From 93ce9ba067eaa09bc5068940a75b56d89412f0f5 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 15 Apr 2025 23:10:41 +0000 Subject: [PATCH 1/2] docs: A comment for field `cooling_threshold_days` in message `.google.cloud.netapp.v1.TieringPolicy` is changed PiperOrigin-RevId: 748001139 Source-Link: https://github.com/googleapis/googleapis/commit/d3ada0de47bd83b613a02570ef944feedb036218 Source-Link: https://github.com/googleapis/googleapis-gen/commit/0f97bc81175ce2d9aebbc49aae9dc5ac6ef7af59 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW5ldGFwcC8uT3dsQm90LnlhbWwiLCJoIjoiMGY5N2JjODExNzVjZTJkOWFlYmJjNDlhYWU5ZGM1YWM2ZWY3YWY1OSJ9 --- .../google-cloud-netapp/v1/.coveragerc | 13 + .../google-cloud-netapp/v1/.flake8 | 34 + .../google-cloud-netapp/v1/LICENSE | 202 + .../google-cloud-netapp/v1/MANIFEST.in | 20 + .../google-cloud-netapp/v1/README.rst | 143 + .../v1/docs/_static/custom.css | 3 + .../google-cloud-netapp/v1/docs/conf.py | 376 + .../google-cloud-netapp/v1/docs/index.rst | 7 + .../v1/docs/netapp_v1/net_app.rst | 10 + .../v1/docs/netapp_v1/services_.rst | 6 + .../v1/docs/netapp_v1/types_.rst | 6 + .../v1/google/cloud/netapp/__init__.py | 241 + .../v1/google/cloud/netapp/gapic_version.py | 16 + .../v1/google/cloud/netapp/py.typed | 2 + .../v1/google/cloud/netapp_v1/__init__.py | 242 + .../cloud/netapp_v1/gapic_metadata.json | 928 + .../google/cloud/netapp_v1/gapic_version.py | 16 + .../v1/google/cloud/netapp_v1/py.typed | 2 + .../cloud/netapp_v1/services/__init__.py | 15 + .../netapp_v1/services/net_app/__init__.py | 22 + .../services/net_app/async_client.py | 8035 +++ .../netapp_v1/services/net_app/client.py | 8448 +++ .../netapp_v1/services/net_app/pagers.py | 1426 + .../services/net_app/transports/README.rst | 9 + .../services/net_app/transports/__init__.py | 38 + .../services/net_app/transports/base.py | 1251 + .../services/net_app/transports/grpc.py | 2052 + .../net_app/transports/grpc_asyncio.py | 2560 + .../services/net_app/transports/rest.py | 11531 ++++ .../services/net_app/transports/rest_base.py | 2786 + .../google/cloud/netapp_v1/types/__init__.py | 256 + .../cloud/netapp_v1/types/active_directory.py | 401 + .../v1/google/cloud/netapp_v1/types/backup.py | 372 + .../cloud/netapp_v1/types/backup_policy.py | 333 + .../cloud/netapp_v1/types/backup_vault.py | 274 + .../netapp_v1/types/cloud_netapp_service.py | 95 + .../v1/google/cloud/netapp_v1/types/common.py | 130 + .../v1/google/cloud/netapp_v1/types/kms.py | 381 + .../cloud/netapp_v1/types/quota_rule.py | 321 + .../cloud/netapp_v1/types/replication.py | 817 + .../google/cloud/netapp_v1/types/snapshot.py | 290 + .../cloud/netapp_v1/types/storage_pool.py | 440 + .../v1/google/cloud/netapp_v1/types/volume.py | 1322 + .../google-cloud-netapp/v1/mypy.ini | 3 + .../google-cloud-netapp/v1/noxfile.py | 591 + ...d_net_app_create_active_directory_async.py | 65 + ...ed_net_app_create_active_directory_sync.py | 65 + ...1_generated_net_app_create_backup_async.py | 57 + ...ated_net_app_create_backup_policy_async.py | 57 + ...rated_net_app_create_backup_policy_sync.py | 57 + ...v1_generated_net_app_create_backup_sync.py | 57 + ...rated_net_app_create_backup_vault_async.py | 57 + ...erated_net_app_create_backup_vault_sync.py | 57 + ...nerated_net_app_create_kms_config_async.py | 61 + ...enerated_net_app_create_kms_config_sync.py | 61 + ...nerated_net_app_create_quota_rule_async.py | 62 + ...enerated_net_app_create_quota_rule_sync.py | 62 + ...erated_net_app_create_replication_async.py | 62 + ...nerated_net_app_create_replication_sync.py | 62 + ...generated_net_app_create_snapshot_async.py | 57 + ..._generated_net_app_create_snapshot_sync.py | 57 + ...rated_net_app_create_storage_pool_async.py | 63 + ...erated_net_app_create_storage_pool_sync.py | 63 + ...1_generated_net_app_create_volume_async.py | 64 + ...v1_generated_net_app_create_volume_sync.py | 64 + ...d_net_app_delete_active_directory_async.py | 56 + ...ed_net_app_delete_active_directory_sync.py | 56 + ...1_generated_net_app_delete_backup_async.py | 56 + ...ated_net_app_delete_backup_policy_async.py | 56 + ...rated_net_app_delete_backup_policy_sync.py | 56 + ...v1_generated_net_app_delete_backup_sync.py | 56 + ...rated_net_app_delete_backup_vault_async.py | 56 + ...erated_net_app_delete_backup_vault_sync.py | 56 + ...nerated_net_app_delete_kms_config_async.py | 56 + ...enerated_net_app_delete_kms_config_sync.py | 56 + ...nerated_net_app_delete_quota_rule_async.py | 56 + ...enerated_net_app_delete_quota_rule_sync.py | 56 + ...erated_net_app_delete_replication_async.py | 56 + ...nerated_net_app_delete_replication_sync.py | 56 + ...generated_net_app_delete_snapshot_async.py | 56 + ..._generated_net_app_delete_snapshot_sync.py | 56 + ...rated_net_app_delete_storage_pool_async.py | 56 + ...erated_net_app_delete_storage_pool_sync.py | 56 + ...1_generated_net_app_delete_volume_async.py | 56 + ...v1_generated_net_app_delete_volume_sync.py | 56 + ...generated_net_app_encrypt_volumes_async.py | 56 + ..._generated_net_app_encrypt_volumes_sync.py | 56 + ...nerated_net_app_establish_peering_async.py | 59 + ...enerated_net_app_establish_peering_sync.py | 59 + ...ated_net_app_get_active_directory_async.py | 52 + ...rated_net_app_get_active_directory_sync.py | 52 + ...p_v1_generated_net_app_get_backup_async.py | 52 + ...nerated_net_app_get_backup_policy_async.py | 52 + ...enerated_net_app_get_backup_policy_sync.py | 52 + ...pp_v1_generated_net_app_get_backup_sync.py | 52 + ...enerated_net_app_get_backup_vault_async.py | 52 + ...generated_net_app_get_backup_vault_sync.py | 52 + ..._generated_net_app_get_kms_config_async.py | 52 + ...1_generated_net_app_get_kms_config_sync.py | 52 + ..._generated_net_app_get_quota_rule_async.py | 52 + ...1_generated_net_app_get_quota_rule_sync.py | 52 + ...generated_net_app_get_replication_async.py | 52 + ..._generated_net_app_get_replication_sync.py | 52 + ...v1_generated_net_app_get_snapshot_async.py | 52 + ..._v1_generated_net_app_get_snapshot_sync.py | 52 + ...enerated_net_app_get_storage_pool_async.py | 52 + ...generated_net_app_get_storage_pool_sync.py | 52 + ...p_v1_generated_net_app_get_volume_async.py | 52 + ...pp_v1_generated_net_app_get_volume_sync.py | 52 + ...d_net_app_list_active_directories_async.py | 53 + ...ed_net_app_list_active_directories_sync.py | 53 + ...ated_net_app_list_backup_policies_async.py | 53 + ...rated_net_app_list_backup_policies_sync.py | 53 + ...erated_net_app_list_backup_vaults_async.py | 53 + ...nerated_net_app_list_backup_vaults_sync.py | 53 + ...v1_generated_net_app_list_backups_async.py | 53 + ..._v1_generated_net_app_list_backups_sync.py | 53 + ...enerated_net_app_list_kms_configs_async.py | 53 + ...generated_net_app_list_kms_configs_sync.py | 53 + ...enerated_net_app_list_quota_rules_async.py | 53 + ...generated_net_app_list_quota_rules_sync.py | 53 + ...nerated_net_app_list_replications_async.py | 53 + ...enerated_net_app_list_replications_sync.py | 53 + ..._generated_net_app_list_snapshots_async.py | 53 + ...1_generated_net_app_list_snapshots_sync.py | 53 + ...erated_net_app_list_storage_pools_async.py | 53 + ...nerated_net_app_list_storage_pools_sync.py | 53 + ...v1_generated_net_app_list_volumes_async.py | 53 + ..._v1_generated_net_app_list_volumes_sync.py | 53 + ...erated_net_app_resume_replication_async.py | 56 + ...nerated_net_app_resume_replication_sync.py | 56 + ...app_reverse_replication_direction_async.py | 56 + ..._app_reverse_replication_direction_sync.py | 56 + ...1_generated_net_app_revert_volume_async.py | 57 + ...v1_generated_net_app_revert_volume_sync.py | 57 + ...enerated_net_app_stop_replication_async.py | 56 + ...generated_net_app_stop_replication_sync.py | 56 + ...et_app_switch_active_replica_zone_async.py | 56 + ...net_app_switch_active_replica_zone_sync.py | 56 + ...enerated_net_app_sync_replication_async.py | 56 + ...generated_net_app_sync_replication_sync.py | 56 + ...d_net_app_update_active_directory_async.py | 63 + ...ed_net_app_update_active_directory_sync.py | 63 + ...1_generated_net_app_update_backup_async.py | 55 + ...ated_net_app_update_backup_policy_async.py | 55 + ...rated_net_app_update_backup_policy_sync.py | 55 + ...v1_generated_net_app_update_backup_sync.py | 55 + ...rated_net_app_update_backup_vault_async.py | 55 + ...erated_net_app_update_backup_vault_sync.py | 55 + ...nerated_net_app_update_kms_config_async.py | 59 + ...enerated_net_app_update_kms_config_sync.py | 59 + ...nerated_net_app_update_quota_rule_async.py | 60 + ...enerated_net_app_update_quota_rule_sync.py | 60 + ...erated_net_app_update_replication_async.py | 60 + ...nerated_net_app_update_replication_sync.py | 60 + ...generated_net_app_update_snapshot_async.py | 55 + ..._generated_net_app_update_snapshot_sync.py | 55 + ...rated_net_app_update_storage_pool_async.py | 61 + ...erated_net_app_update_storage_pool_sync.py | 61 + ...1_generated_net_app_update_volume_async.py | 62 + ...v1_generated_net_app_update_volume_sync.py | 62 + ...et_app_validate_directory_service_async.py | 56 + ...net_app_validate_directory_service_sync.py | 56 + ...nerated_net_app_verify_kms_config_async.py | 52 + ...enerated_net_app_verify_kms_config_sync.py | 52 + ...ippet_metadata_google.cloud.netapp.v1.json | 9835 ++++ .../v1/scripts/fixup_netapp_v1_keywords.py | 235 + .../google-cloud-netapp/v1/setup.py | 98 + .../v1/testing/constraints-3.10.txt | 6 + .../v1/testing/constraints-3.11.txt | 6 + .../v1/testing/constraints-3.12.txt | 6 + .../v1/testing/constraints-3.13.txt | 11 + .../v1/testing/constraints-3.7.txt | 10 + .../v1/testing/constraints-3.8.txt | 6 + .../v1/testing/constraints-3.9.txt | 6 + .../google-cloud-netapp/v1/tests/__init__.py | 16 + .../v1/tests/unit/__init__.py | 16 + .../v1/tests/unit/gapic/__init__.py | 16 + .../v1/tests/unit/gapic/netapp_v1/__init__.py | 16 + .../unit/gapic/netapp_v1/test_net_app.py | 46391 ++++++++++++++++ 180 files changed, 109860 insertions(+) create mode 100644 owl-bot-staging/google-cloud-netapp/v1/.coveragerc create mode 100644 owl-bot-staging/google-cloud-netapp/v1/.flake8 create mode 100644 owl-bot-staging/google-cloud-netapp/v1/LICENSE create mode 100644 owl-bot-staging/google-cloud-netapp/v1/MANIFEST.in create mode 100644 owl-bot-staging/google-cloud-netapp/v1/README.rst create mode 100644 owl-bot-staging/google-cloud-netapp/v1/docs/_static/custom.css create mode 100644 owl-bot-staging/google-cloud-netapp/v1/docs/conf.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/docs/index.rst create mode 100644 owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/net_app.rst create mode 100644 owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/services_.rst create mode 100644 owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/types_.rst create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/__init__.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/gapic_version.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/py.typed create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/__init__.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/gapic_version.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/py.typed create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/__init__.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/__init__.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/async_client.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/client.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/pagers.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/README.rst create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/__init__.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/base.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/grpc.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/rest.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/rest_base.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/__init__.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/active_directory.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup_policy.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup_vault.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/cloud_netapp_service.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/common.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/kms.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/quota_rule.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/replication.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/snapshot.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/storage_pool.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/volume.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/mypy.ini create mode 100644 owl-bot-staging/google-cloud-netapp/v1/noxfile.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_active_directory_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_active_directory_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_policy_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_policy_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_vault_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_vault_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_kms_config_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_kms_config_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_quota_rule_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_quota_rule_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_replication_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_replication_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_snapshot_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_snapshot_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_storage_pool_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_storage_pool_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_volume_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_volume_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_active_directory_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_active_directory_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_policy_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_policy_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_vault_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_vault_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_kms_config_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_kms_config_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_quota_rule_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_quota_rule_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_replication_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_replication_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_snapshot_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_snapshot_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_storage_pool_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_storage_pool_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_volume_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_volume_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_encrypt_volumes_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_encrypt_volumes_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_establish_peering_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_establish_peering_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_active_directory_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_active_directory_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_policy_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_policy_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_vault_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_vault_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_kms_config_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_kms_config_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_quota_rule_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_quota_rule_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_replication_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_replication_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_snapshot_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_snapshot_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_storage_pool_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_storage_pool_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_volume_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_volume_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_active_directories_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_active_directories_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_policies_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_policies_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_vaults_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_vaults_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backups_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backups_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_kms_configs_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_kms_configs_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_quota_rules_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_quota_rules_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_replications_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_replications_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_snapshots_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_snapshots_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_storage_pools_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_storage_pools_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_volumes_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_volumes_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_resume_replication_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_resume_replication_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_reverse_replication_direction_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_reverse_replication_direction_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_revert_volume_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_revert_volume_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_stop_replication_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_stop_replication_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_switch_active_replica_zone_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_switch_active_replica_zone_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_sync_replication_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_sync_replication_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_active_directory_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_active_directory_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_policy_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_policy_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_vault_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_vault_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_kms_config_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_kms_config_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_quota_rule_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_quota_rule_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_replication_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_replication_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_snapshot_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_snapshot_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_storage_pool_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_storage_pool_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_volume_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_volume_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_validate_directory_service_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_validate_directory_service_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_verify_kms_config_async.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_verify_kms_config_sync.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/snippet_metadata_google.cloud.netapp.v1.json create mode 100644 owl-bot-staging/google-cloud-netapp/v1/scripts/fixup_netapp_v1_keywords.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/setup.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.10.txt create mode 100644 owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.11.txt create mode 100644 owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.12.txt create mode 100644 owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.13.txt create mode 100644 owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.7.txt create mode 100644 owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.8.txt create mode 100644 owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.9.txt create mode 100644 owl-bot-staging/google-cloud-netapp/v1/tests/__init__.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/tests/unit/__init__.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/tests/unit/gapic/__init__.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/tests/unit/gapic/netapp_v1/__init__.py create mode 100644 owl-bot-staging/google-cloud-netapp/v1/tests/unit/gapic/netapp_v1/test_net_app.py diff --git a/owl-bot-staging/google-cloud-netapp/v1/.coveragerc b/owl-bot-staging/google-cloud-netapp/v1/.coveragerc new file mode 100644 index 000000000000..b52a142c7e46 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/.coveragerc @@ -0,0 +1,13 @@ +[run] +branch = True + +[report] +show_missing = True +omit = + google/cloud/netapp/__init__.py + google/cloud/netapp/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-netapp/v1/.flake8 b/owl-bot-staging/google-cloud-netapp/v1/.flake8 new file mode 100644 index 000000000000..90316de21489 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/.flake8 @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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. +# +[flake8] +# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): +# Resolve flake8 lint issues +ignore = E203, E231, E266, E501, W503 +exclude = + # TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): + # Ensure that generated code passes flake8 lint + **/gapic/** + **/services/** + **/types/** + # Exclude Protobuf gencode + *_pb2.py + + # Standard linting exemptions. + **/.nox/** + __pycache__, + .git, + *.pyc, + conf.py diff --git a/owl-bot-staging/google-cloud-netapp/v1/LICENSE b/owl-bot-staging/google-cloud-netapp/v1/LICENSE new file mode 100644 index 000000000000..d64569567334 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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-netapp/v1/MANIFEST.in b/owl-bot-staging/google-cloud-netapp/v1/MANIFEST.in new file mode 100644 index 000000000000..dae249ec8976 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/MANIFEST.in @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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. +# +include README.rst LICENSE +recursive-include google *.py *.pyi *.json *.proto py.typed +recursive-include tests * +global-exclude *.py[co] +global-exclude __pycache__ diff --git a/owl-bot-staging/google-cloud-netapp/v1/README.rst b/owl-bot-staging/google-cloud-netapp/v1/README.rst new file mode 100644 index 000000000000..7e519a71c372 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/README.rst @@ -0,0 +1,143 @@ +Python Client for Google Cloud Netapp 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 Netapp 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 + + +Logging +------- + +This library uses the standard Python :code:`logging` functionality to log some RPC events that could be of interest for debugging and monitoring purposes. +Note the following: + +#. Logs may contain sensitive information. Take care to **restrict access to the logs** if they are saved, whether it be on local storage or on Google Cloud Logging. +#. Google may refine the occurrence, level, and content of various log messages in this library without flagging such changes as breaking. **Do not depend on immutability of the logging events**. +#. By default, the logging events from this library are not handled. You must **explicitly configure log handling** using one of the mechanisms below. + + +Simple, environment-based configuration +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To enable logging for this library without any changes in your code, set the :code:`GOOGLE_SDK_PYTHON_LOGGING_SCOPE` environment variable to a valid Google +logging scope. This configures handling of logging events (at level :code:`logging.DEBUG` or higher) from this library in a default manner, emitting the logged +messages in a structured format. It does not currently allow customizing the logging levels captured nor the handlers, formatters, etc. used for any logging +event. + +A logging scope is a period-separated namespace that begins with :code:`google`, identifying the Python module or package to log. + +- Valid logging scopes: :code:`google`, :code:`google.cloud.asset.v1`, :code:`google.api`, :code:`google.auth`, etc. +- Invalid logging scopes: :code:`foo`, :code:`123`, etc. + +**NOTE**: If the logging scope is invalid, the library does not set up any logging handlers. + + +Examples +^^^^^^^^ + +- Enabling the default handler for all Google-based loggers + +.. code-block:: console + + export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google + +- Enabling the default handler for a specific Google module (for a client library called :code:`library_v1`): + +.. code-block:: console + + export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google.cloud.library_v1 + + +Advanced, code-based configuration +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also configure a valid logging scope using Python's standard `logging` mechanism. + + +Examples +^^^^^^^^ + +- Configuring a handler for all Google-based loggers + +.. code-block:: python + + import logging + + from google.cloud.translate_v3 import translate + + base_logger = logging.getLogger("google") + base_logger.addHandler(logging.StreamHandler()) + base_logger.setLevel(logging.DEBUG) + +- Configuring a handler for a specific Google module (for a client library called :code:`library_v1`): + +.. code-block:: python + + import logging + + from google.cloud.translate_v3 import translate + + base_logger = logging.getLogger("google.cloud.library_v1") + base_logger.addHandler(logging.StreamHandler()) + base_logger.setLevel(logging.DEBUG) + + +Logging details +~~~~~~~~~~~~~~~ + +#. Regardless of which of the mechanisms above you use to configure logging for this library, by default logging events are not propagated up to the root + logger from the `google`-level logger. If you need the events to be propagated to the root logger, you must explicitly set + :code:`logging.getLogger("google").propagate = True` in your code. +#. You can mix the different logging configurations above for different Google modules. For example, you may want use a code-based logging configuration for + one library, but decide you need to also set up environment-based logging configuration for another library. + + #. If you attempt to use both code-based and environment-based configuration for the same module, the environment-based configuration will be ineffectual + if the code -based configuration gets applied first. + +#. The Google-specific logging configurations (default handlers for environment-based configuration; not propagating logging events to the root logger) get + executed the first time *any* client library is instantiated in your application, and only if the affected loggers have not been previously configured. + (This is the reason for 2.i. above.) diff --git a/owl-bot-staging/google-cloud-netapp/v1/docs/_static/custom.css b/owl-bot-staging/google-cloud-netapp/v1/docs/_static/custom.css new file mode 100644 index 000000000000..06423be0b592 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/docs/_static/custom.css @@ -0,0 +1,3 @@ +dl.field-list > dt { + min-width: 100px +} diff --git a/owl-bot-staging/google-cloud-netapp/v1/docs/conf.py b/owl-bot-staging/google-cloud-netapp/v1/docs/conf.py new file mode 100644 index 000000000000..a8df6d383101 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/docs/conf.py @@ -0,0 +1,376 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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-netapp 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-netapp" +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-netapp-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-netapp.tex", + u"google-cloud-netapp 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-netapp", + u"Google Cloud Netapp 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-netapp", + u"google-cloud-netapp Documentation", + author, + "google-cloud-netapp", + "GAPIC library for Google Cloud Netapp 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-netapp/v1/docs/index.rst b/owl-bot-staging/google-cloud-netapp/v1/docs/index.rst new file mode 100644 index 000000000000..39a2c8ae820f --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/docs/index.rst @@ -0,0 +1,7 @@ +API Reference +------------- +.. toctree:: + :maxdepth: 2 + + netapp_v1/services_ + netapp_v1/types_ diff --git a/owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/net_app.rst b/owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/net_app.rst new file mode 100644 index 000000000000..03f507188fd9 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/net_app.rst @@ -0,0 +1,10 @@ +NetApp +------------------------ + +.. automodule:: google.cloud.netapp_v1.services.net_app + :members: + :inherited-members: + +.. automodule:: google.cloud.netapp_v1.services.net_app.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/services_.rst b/owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/services_.rst new file mode 100644 index 000000000000..48180d798fdc --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/services_.rst @@ -0,0 +1,6 @@ +Services for Google Cloud Netapp v1 API +======================================= +.. toctree:: + :maxdepth: 2 + + net_app diff --git a/owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/types_.rst b/owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/types_.rst new file mode 100644 index 000000000000..dd42bfd262c5 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/types_.rst @@ -0,0 +1,6 @@ +Types for Google Cloud Netapp v1 API +==================================== + +.. automodule:: google.cloud.netapp_v1.types + :members: + :show-inheritance: diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/__init__.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/__init__.py new file mode 100644 index 000000000000..59b8e3e3a6d2 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/__init__.py @@ -0,0 +1,241 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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.netapp import gapic_version as package_version + +__version__ = package_version.__version__ + + +from google.cloud.netapp_v1.services.net_app.client import NetAppClient +from google.cloud.netapp_v1.services.net_app.async_client import NetAppAsyncClient + +from google.cloud.netapp_v1.types.active_directory import ActiveDirectory +from google.cloud.netapp_v1.types.active_directory import CreateActiveDirectoryRequest +from google.cloud.netapp_v1.types.active_directory import DeleteActiveDirectoryRequest +from google.cloud.netapp_v1.types.active_directory import GetActiveDirectoryRequest +from google.cloud.netapp_v1.types.active_directory import ListActiveDirectoriesRequest +from google.cloud.netapp_v1.types.active_directory import ListActiveDirectoriesResponse +from google.cloud.netapp_v1.types.active_directory import UpdateActiveDirectoryRequest +from google.cloud.netapp_v1.types.backup import Backup +from google.cloud.netapp_v1.types.backup import CreateBackupRequest +from google.cloud.netapp_v1.types.backup import DeleteBackupRequest +from google.cloud.netapp_v1.types.backup import GetBackupRequest +from google.cloud.netapp_v1.types.backup import ListBackupsRequest +from google.cloud.netapp_v1.types.backup import ListBackupsResponse +from google.cloud.netapp_v1.types.backup import UpdateBackupRequest +from google.cloud.netapp_v1.types.backup_policy import BackupPolicy +from google.cloud.netapp_v1.types.backup_policy import CreateBackupPolicyRequest +from google.cloud.netapp_v1.types.backup_policy import DeleteBackupPolicyRequest +from google.cloud.netapp_v1.types.backup_policy import GetBackupPolicyRequest +from google.cloud.netapp_v1.types.backup_policy import ListBackupPoliciesRequest +from google.cloud.netapp_v1.types.backup_policy import ListBackupPoliciesResponse +from google.cloud.netapp_v1.types.backup_policy import UpdateBackupPolicyRequest +from google.cloud.netapp_v1.types.backup_vault import BackupVault +from google.cloud.netapp_v1.types.backup_vault import CreateBackupVaultRequest +from google.cloud.netapp_v1.types.backup_vault import DeleteBackupVaultRequest +from google.cloud.netapp_v1.types.backup_vault import GetBackupVaultRequest +from google.cloud.netapp_v1.types.backup_vault import ListBackupVaultsRequest +from google.cloud.netapp_v1.types.backup_vault import ListBackupVaultsResponse +from google.cloud.netapp_v1.types.backup_vault import UpdateBackupVaultRequest +from google.cloud.netapp_v1.types.cloud_netapp_service import OperationMetadata +from google.cloud.netapp_v1.types.common import LocationMetadata +from google.cloud.netapp_v1.types.common import DirectoryServiceType +from google.cloud.netapp_v1.types.common import EncryptionType +from google.cloud.netapp_v1.types.common import FlexPerformance +from google.cloud.netapp_v1.types.common import ServiceLevel +from google.cloud.netapp_v1.types.kms import CreateKmsConfigRequest +from google.cloud.netapp_v1.types.kms import DeleteKmsConfigRequest +from google.cloud.netapp_v1.types.kms import EncryptVolumesRequest +from google.cloud.netapp_v1.types.kms import GetKmsConfigRequest +from google.cloud.netapp_v1.types.kms import KmsConfig +from google.cloud.netapp_v1.types.kms import ListKmsConfigsRequest +from google.cloud.netapp_v1.types.kms import ListKmsConfigsResponse +from google.cloud.netapp_v1.types.kms import UpdateKmsConfigRequest +from google.cloud.netapp_v1.types.kms import VerifyKmsConfigRequest +from google.cloud.netapp_v1.types.kms import VerifyKmsConfigResponse +from google.cloud.netapp_v1.types.quota_rule import CreateQuotaRuleRequest +from google.cloud.netapp_v1.types.quota_rule import DeleteQuotaRuleRequest +from google.cloud.netapp_v1.types.quota_rule import GetQuotaRuleRequest +from google.cloud.netapp_v1.types.quota_rule import ListQuotaRulesRequest +from google.cloud.netapp_v1.types.quota_rule import ListQuotaRulesResponse +from google.cloud.netapp_v1.types.quota_rule import QuotaRule +from google.cloud.netapp_v1.types.quota_rule import UpdateQuotaRuleRequest +from google.cloud.netapp_v1.types.replication import CreateReplicationRequest +from google.cloud.netapp_v1.types.replication import DeleteReplicationRequest +from google.cloud.netapp_v1.types.replication import DestinationVolumeParameters +from google.cloud.netapp_v1.types.replication import EstablishPeeringRequest +from google.cloud.netapp_v1.types.replication import GetReplicationRequest +from google.cloud.netapp_v1.types.replication import HybridPeeringDetails +from google.cloud.netapp_v1.types.replication import ListReplicationsRequest +from google.cloud.netapp_v1.types.replication import ListReplicationsResponse +from google.cloud.netapp_v1.types.replication import Replication +from google.cloud.netapp_v1.types.replication import ResumeReplicationRequest +from google.cloud.netapp_v1.types.replication import ReverseReplicationDirectionRequest +from google.cloud.netapp_v1.types.replication import StopReplicationRequest +from google.cloud.netapp_v1.types.replication import SyncReplicationRequest +from google.cloud.netapp_v1.types.replication import TransferStats +from google.cloud.netapp_v1.types.replication import UpdateReplicationRequest +from google.cloud.netapp_v1.types.snapshot import CreateSnapshotRequest +from google.cloud.netapp_v1.types.snapshot import DeleteSnapshotRequest +from google.cloud.netapp_v1.types.snapshot import GetSnapshotRequest +from google.cloud.netapp_v1.types.snapshot import ListSnapshotsRequest +from google.cloud.netapp_v1.types.snapshot import ListSnapshotsResponse +from google.cloud.netapp_v1.types.snapshot import Snapshot +from google.cloud.netapp_v1.types.snapshot import UpdateSnapshotRequest +from google.cloud.netapp_v1.types.storage_pool import CreateStoragePoolRequest +from google.cloud.netapp_v1.types.storage_pool import DeleteStoragePoolRequest +from google.cloud.netapp_v1.types.storage_pool import GetStoragePoolRequest +from google.cloud.netapp_v1.types.storage_pool import ListStoragePoolsRequest +from google.cloud.netapp_v1.types.storage_pool import ListStoragePoolsResponse +from google.cloud.netapp_v1.types.storage_pool import StoragePool +from google.cloud.netapp_v1.types.storage_pool import SwitchActiveReplicaZoneRequest +from google.cloud.netapp_v1.types.storage_pool import UpdateStoragePoolRequest +from google.cloud.netapp_v1.types.storage_pool import ValidateDirectoryServiceRequest +from google.cloud.netapp_v1.types.volume import BackupConfig +from google.cloud.netapp_v1.types.volume import CreateVolumeRequest +from google.cloud.netapp_v1.types.volume import DailySchedule +from google.cloud.netapp_v1.types.volume import DeleteVolumeRequest +from google.cloud.netapp_v1.types.volume import ExportPolicy +from google.cloud.netapp_v1.types.volume import GetVolumeRequest +from google.cloud.netapp_v1.types.volume import HourlySchedule +from google.cloud.netapp_v1.types.volume import HybridReplicationParameters +from google.cloud.netapp_v1.types.volume import ListVolumesRequest +from google.cloud.netapp_v1.types.volume import ListVolumesResponse +from google.cloud.netapp_v1.types.volume import MonthlySchedule +from google.cloud.netapp_v1.types.volume import MountOption +from google.cloud.netapp_v1.types.volume import RestoreParameters +from google.cloud.netapp_v1.types.volume import RevertVolumeRequest +from google.cloud.netapp_v1.types.volume import SimpleExportPolicyRule +from google.cloud.netapp_v1.types.volume import SnapshotPolicy +from google.cloud.netapp_v1.types.volume import TieringPolicy +from google.cloud.netapp_v1.types.volume import UpdateVolumeRequest +from google.cloud.netapp_v1.types.volume import Volume +from google.cloud.netapp_v1.types.volume import WeeklySchedule +from google.cloud.netapp_v1.types.volume import AccessType +from google.cloud.netapp_v1.types.volume import Protocols +from google.cloud.netapp_v1.types.volume import RestrictedAction +from google.cloud.netapp_v1.types.volume import SecurityStyle +from google.cloud.netapp_v1.types.volume import SMBSettings + +__all__ = ('NetAppClient', + 'NetAppAsyncClient', + 'ActiveDirectory', + 'CreateActiveDirectoryRequest', + 'DeleteActiveDirectoryRequest', + 'GetActiveDirectoryRequest', + 'ListActiveDirectoriesRequest', + 'ListActiveDirectoriesResponse', + 'UpdateActiveDirectoryRequest', + 'Backup', + 'CreateBackupRequest', + 'DeleteBackupRequest', + 'GetBackupRequest', + 'ListBackupsRequest', + 'ListBackupsResponse', + 'UpdateBackupRequest', + 'BackupPolicy', + 'CreateBackupPolicyRequest', + 'DeleteBackupPolicyRequest', + 'GetBackupPolicyRequest', + 'ListBackupPoliciesRequest', + 'ListBackupPoliciesResponse', + 'UpdateBackupPolicyRequest', + 'BackupVault', + 'CreateBackupVaultRequest', + 'DeleteBackupVaultRequest', + 'GetBackupVaultRequest', + 'ListBackupVaultsRequest', + 'ListBackupVaultsResponse', + 'UpdateBackupVaultRequest', + 'OperationMetadata', + 'LocationMetadata', + 'DirectoryServiceType', + 'EncryptionType', + 'FlexPerformance', + 'ServiceLevel', + 'CreateKmsConfigRequest', + 'DeleteKmsConfigRequest', + 'EncryptVolumesRequest', + 'GetKmsConfigRequest', + 'KmsConfig', + 'ListKmsConfigsRequest', + 'ListKmsConfigsResponse', + 'UpdateKmsConfigRequest', + 'VerifyKmsConfigRequest', + 'VerifyKmsConfigResponse', + 'CreateQuotaRuleRequest', + 'DeleteQuotaRuleRequest', + 'GetQuotaRuleRequest', + 'ListQuotaRulesRequest', + 'ListQuotaRulesResponse', + 'QuotaRule', + 'UpdateQuotaRuleRequest', + 'CreateReplicationRequest', + 'DeleteReplicationRequest', + 'DestinationVolumeParameters', + 'EstablishPeeringRequest', + 'GetReplicationRequest', + 'HybridPeeringDetails', + 'ListReplicationsRequest', + 'ListReplicationsResponse', + 'Replication', + 'ResumeReplicationRequest', + 'ReverseReplicationDirectionRequest', + 'StopReplicationRequest', + 'SyncReplicationRequest', + 'TransferStats', + 'UpdateReplicationRequest', + 'CreateSnapshotRequest', + 'DeleteSnapshotRequest', + 'GetSnapshotRequest', + 'ListSnapshotsRequest', + 'ListSnapshotsResponse', + 'Snapshot', + 'UpdateSnapshotRequest', + 'CreateStoragePoolRequest', + 'DeleteStoragePoolRequest', + 'GetStoragePoolRequest', + 'ListStoragePoolsRequest', + 'ListStoragePoolsResponse', + 'StoragePool', + 'SwitchActiveReplicaZoneRequest', + 'UpdateStoragePoolRequest', + 'ValidateDirectoryServiceRequest', + 'BackupConfig', + 'CreateVolumeRequest', + 'DailySchedule', + 'DeleteVolumeRequest', + 'ExportPolicy', + 'GetVolumeRequest', + 'HourlySchedule', + 'HybridReplicationParameters', + 'ListVolumesRequest', + 'ListVolumesResponse', + 'MonthlySchedule', + 'MountOption', + 'RestoreParameters', + 'RevertVolumeRequest', + 'SimpleExportPolicyRule', + 'SnapshotPolicy', + 'TieringPolicy', + 'UpdateVolumeRequest', + 'Volume', + 'WeeklySchedule', + 'AccessType', + 'Protocols', + 'RestrictedAction', + 'SecurityStyle', + 'SMBSettings', +) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/gapic_version.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/gapic_version.py new file mode 100644 index 000000000000..20a9cd975b02 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/gapic_version.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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-netapp/v1/google/cloud/netapp/py.typed b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/py.typed new file mode 100644 index 000000000000..7d2f4c53406d --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-netapp package uses inline types. diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/__init__.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/__init__.py new file mode 100644 index 000000000000..9fbe7ba71c5b --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/__init__.py @@ -0,0 +1,242 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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.netapp_v1 import gapic_version as package_version + +__version__ = package_version.__version__ + + +from .services.net_app import NetAppClient +from .services.net_app import NetAppAsyncClient + +from .types.active_directory import ActiveDirectory +from .types.active_directory import CreateActiveDirectoryRequest +from .types.active_directory import DeleteActiveDirectoryRequest +from .types.active_directory import GetActiveDirectoryRequest +from .types.active_directory import ListActiveDirectoriesRequest +from .types.active_directory import ListActiveDirectoriesResponse +from .types.active_directory import UpdateActiveDirectoryRequest +from .types.backup import Backup +from .types.backup import CreateBackupRequest +from .types.backup import DeleteBackupRequest +from .types.backup import GetBackupRequest +from .types.backup import ListBackupsRequest +from .types.backup import ListBackupsResponse +from .types.backup import UpdateBackupRequest +from .types.backup_policy import BackupPolicy +from .types.backup_policy import CreateBackupPolicyRequest +from .types.backup_policy import DeleteBackupPolicyRequest +from .types.backup_policy import GetBackupPolicyRequest +from .types.backup_policy import ListBackupPoliciesRequest +from .types.backup_policy import ListBackupPoliciesResponse +from .types.backup_policy import UpdateBackupPolicyRequest +from .types.backup_vault import BackupVault +from .types.backup_vault import CreateBackupVaultRequest +from .types.backup_vault import DeleteBackupVaultRequest +from .types.backup_vault import GetBackupVaultRequest +from .types.backup_vault import ListBackupVaultsRequest +from .types.backup_vault import ListBackupVaultsResponse +from .types.backup_vault import UpdateBackupVaultRequest +from .types.cloud_netapp_service import OperationMetadata +from .types.common import LocationMetadata +from .types.common import DirectoryServiceType +from .types.common import EncryptionType +from .types.common import FlexPerformance +from .types.common import ServiceLevel +from .types.kms import CreateKmsConfigRequest +from .types.kms import DeleteKmsConfigRequest +from .types.kms import EncryptVolumesRequest +from .types.kms import GetKmsConfigRequest +from .types.kms import KmsConfig +from .types.kms import ListKmsConfigsRequest +from .types.kms import ListKmsConfigsResponse +from .types.kms import UpdateKmsConfigRequest +from .types.kms import VerifyKmsConfigRequest +from .types.kms import VerifyKmsConfigResponse +from .types.quota_rule import CreateQuotaRuleRequest +from .types.quota_rule import DeleteQuotaRuleRequest +from .types.quota_rule import GetQuotaRuleRequest +from .types.quota_rule import ListQuotaRulesRequest +from .types.quota_rule import ListQuotaRulesResponse +from .types.quota_rule import QuotaRule +from .types.quota_rule import UpdateQuotaRuleRequest +from .types.replication import CreateReplicationRequest +from .types.replication import DeleteReplicationRequest +from .types.replication import DestinationVolumeParameters +from .types.replication import EstablishPeeringRequest +from .types.replication import GetReplicationRequest +from .types.replication import HybridPeeringDetails +from .types.replication import ListReplicationsRequest +from .types.replication import ListReplicationsResponse +from .types.replication import Replication +from .types.replication import ResumeReplicationRequest +from .types.replication import ReverseReplicationDirectionRequest +from .types.replication import StopReplicationRequest +from .types.replication import SyncReplicationRequest +from .types.replication import TransferStats +from .types.replication import UpdateReplicationRequest +from .types.snapshot import CreateSnapshotRequest +from .types.snapshot import DeleteSnapshotRequest +from .types.snapshot import GetSnapshotRequest +from .types.snapshot import ListSnapshotsRequest +from .types.snapshot import ListSnapshotsResponse +from .types.snapshot import Snapshot +from .types.snapshot import UpdateSnapshotRequest +from .types.storage_pool import CreateStoragePoolRequest +from .types.storage_pool import DeleteStoragePoolRequest +from .types.storage_pool import GetStoragePoolRequest +from .types.storage_pool import ListStoragePoolsRequest +from .types.storage_pool import ListStoragePoolsResponse +from .types.storage_pool import StoragePool +from .types.storage_pool import SwitchActiveReplicaZoneRequest +from .types.storage_pool import UpdateStoragePoolRequest +from .types.storage_pool import ValidateDirectoryServiceRequest +from .types.volume import BackupConfig +from .types.volume import CreateVolumeRequest +from .types.volume import DailySchedule +from .types.volume import DeleteVolumeRequest +from .types.volume import ExportPolicy +from .types.volume import GetVolumeRequest +from .types.volume import HourlySchedule +from .types.volume import HybridReplicationParameters +from .types.volume import ListVolumesRequest +from .types.volume import ListVolumesResponse +from .types.volume import MonthlySchedule +from .types.volume import MountOption +from .types.volume import RestoreParameters +from .types.volume import RevertVolumeRequest +from .types.volume import SimpleExportPolicyRule +from .types.volume import SnapshotPolicy +from .types.volume import TieringPolicy +from .types.volume import UpdateVolumeRequest +from .types.volume import Volume +from .types.volume import WeeklySchedule +from .types.volume import AccessType +from .types.volume import Protocols +from .types.volume import RestrictedAction +from .types.volume import SecurityStyle +from .types.volume import SMBSettings + +__all__ = ( + 'NetAppAsyncClient', +'AccessType', +'ActiveDirectory', +'Backup', +'BackupConfig', +'BackupPolicy', +'BackupVault', +'CreateActiveDirectoryRequest', +'CreateBackupPolicyRequest', +'CreateBackupRequest', +'CreateBackupVaultRequest', +'CreateKmsConfigRequest', +'CreateQuotaRuleRequest', +'CreateReplicationRequest', +'CreateSnapshotRequest', +'CreateStoragePoolRequest', +'CreateVolumeRequest', +'DailySchedule', +'DeleteActiveDirectoryRequest', +'DeleteBackupPolicyRequest', +'DeleteBackupRequest', +'DeleteBackupVaultRequest', +'DeleteKmsConfigRequest', +'DeleteQuotaRuleRequest', +'DeleteReplicationRequest', +'DeleteSnapshotRequest', +'DeleteStoragePoolRequest', +'DeleteVolumeRequest', +'DestinationVolumeParameters', +'DirectoryServiceType', +'EncryptVolumesRequest', +'EncryptionType', +'EstablishPeeringRequest', +'ExportPolicy', +'FlexPerformance', +'GetActiveDirectoryRequest', +'GetBackupPolicyRequest', +'GetBackupRequest', +'GetBackupVaultRequest', +'GetKmsConfigRequest', +'GetQuotaRuleRequest', +'GetReplicationRequest', +'GetSnapshotRequest', +'GetStoragePoolRequest', +'GetVolumeRequest', +'HourlySchedule', +'HybridPeeringDetails', +'HybridReplicationParameters', +'KmsConfig', +'ListActiveDirectoriesRequest', +'ListActiveDirectoriesResponse', +'ListBackupPoliciesRequest', +'ListBackupPoliciesResponse', +'ListBackupVaultsRequest', +'ListBackupVaultsResponse', +'ListBackupsRequest', +'ListBackupsResponse', +'ListKmsConfigsRequest', +'ListKmsConfigsResponse', +'ListQuotaRulesRequest', +'ListQuotaRulesResponse', +'ListReplicationsRequest', +'ListReplicationsResponse', +'ListSnapshotsRequest', +'ListSnapshotsResponse', +'ListStoragePoolsRequest', +'ListStoragePoolsResponse', +'ListVolumesRequest', +'ListVolumesResponse', +'LocationMetadata', +'MonthlySchedule', +'MountOption', +'NetAppClient', +'OperationMetadata', +'Protocols', +'QuotaRule', +'Replication', +'RestoreParameters', +'RestrictedAction', +'ResumeReplicationRequest', +'ReverseReplicationDirectionRequest', +'RevertVolumeRequest', +'SMBSettings', +'SecurityStyle', +'ServiceLevel', +'SimpleExportPolicyRule', +'Snapshot', +'SnapshotPolicy', +'StopReplicationRequest', +'StoragePool', +'SwitchActiveReplicaZoneRequest', +'SyncReplicationRequest', +'TieringPolicy', +'TransferStats', +'UpdateActiveDirectoryRequest', +'UpdateBackupPolicyRequest', +'UpdateBackupRequest', +'UpdateBackupVaultRequest', +'UpdateKmsConfigRequest', +'UpdateQuotaRuleRequest', +'UpdateReplicationRequest', +'UpdateSnapshotRequest', +'UpdateStoragePoolRequest', +'UpdateVolumeRequest', +'ValidateDirectoryServiceRequest', +'VerifyKmsConfigRequest', +'VerifyKmsConfigResponse', +'Volume', +'WeeklySchedule', +) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/gapic_metadata.json b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/gapic_metadata.json new file mode 100644 index 000000000000..c06767c5fa9a --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/gapic_metadata.json @@ -0,0 +1,928 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.netapp_v1", + "protoPackage": "google.cloud.netapp.v1", + "schema": "1.0", + "services": { + "NetApp": { + "clients": { + "grpc": { + "libraryClient": "NetAppClient", + "rpcs": { + "CreateActiveDirectory": { + "methods": [ + "create_active_directory" + ] + }, + "CreateBackup": { + "methods": [ + "create_backup" + ] + }, + "CreateBackupPolicy": { + "methods": [ + "create_backup_policy" + ] + }, + "CreateBackupVault": { + "methods": [ + "create_backup_vault" + ] + }, + "CreateKmsConfig": { + "methods": [ + "create_kms_config" + ] + }, + "CreateQuotaRule": { + "methods": [ + "create_quota_rule" + ] + }, + "CreateReplication": { + "methods": [ + "create_replication" + ] + }, + "CreateSnapshot": { + "methods": [ + "create_snapshot" + ] + }, + "CreateStoragePool": { + "methods": [ + "create_storage_pool" + ] + }, + "CreateVolume": { + "methods": [ + "create_volume" + ] + }, + "DeleteActiveDirectory": { + "methods": [ + "delete_active_directory" + ] + }, + "DeleteBackup": { + "methods": [ + "delete_backup" + ] + }, + "DeleteBackupPolicy": { + "methods": [ + "delete_backup_policy" + ] + }, + "DeleteBackupVault": { + "methods": [ + "delete_backup_vault" + ] + }, + "DeleteKmsConfig": { + "methods": [ + "delete_kms_config" + ] + }, + "DeleteQuotaRule": { + "methods": [ + "delete_quota_rule" + ] + }, + "DeleteReplication": { + "methods": [ + "delete_replication" + ] + }, + "DeleteSnapshot": { + "methods": [ + "delete_snapshot" + ] + }, + "DeleteStoragePool": { + "methods": [ + "delete_storage_pool" + ] + }, + "DeleteVolume": { + "methods": [ + "delete_volume" + ] + }, + "EncryptVolumes": { + "methods": [ + "encrypt_volumes" + ] + }, + "EstablishPeering": { + "methods": [ + "establish_peering" + ] + }, + "GetActiveDirectory": { + "methods": [ + "get_active_directory" + ] + }, + "GetBackup": { + "methods": [ + "get_backup" + ] + }, + "GetBackupPolicy": { + "methods": [ + "get_backup_policy" + ] + }, + "GetBackupVault": { + "methods": [ + "get_backup_vault" + ] + }, + "GetKmsConfig": { + "methods": [ + "get_kms_config" + ] + }, + "GetQuotaRule": { + "methods": [ + "get_quota_rule" + ] + }, + "GetReplication": { + "methods": [ + "get_replication" + ] + }, + "GetSnapshot": { + "methods": [ + "get_snapshot" + ] + }, + "GetStoragePool": { + "methods": [ + "get_storage_pool" + ] + }, + "GetVolume": { + "methods": [ + "get_volume" + ] + }, + "ListActiveDirectories": { + "methods": [ + "list_active_directories" + ] + }, + "ListBackupPolicies": { + "methods": [ + "list_backup_policies" + ] + }, + "ListBackupVaults": { + "methods": [ + "list_backup_vaults" + ] + }, + "ListBackups": { + "methods": [ + "list_backups" + ] + }, + "ListKmsConfigs": { + "methods": [ + "list_kms_configs" + ] + }, + "ListQuotaRules": { + "methods": [ + "list_quota_rules" + ] + }, + "ListReplications": { + "methods": [ + "list_replications" + ] + }, + "ListSnapshots": { + "methods": [ + "list_snapshots" + ] + }, + "ListStoragePools": { + "methods": [ + "list_storage_pools" + ] + }, + "ListVolumes": { + "methods": [ + "list_volumes" + ] + }, + "ResumeReplication": { + "methods": [ + "resume_replication" + ] + }, + "ReverseReplicationDirection": { + "methods": [ + "reverse_replication_direction" + ] + }, + "RevertVolume": { + "methods": [ + "revert_volume" + ] + }, + "StopReplication": { + "methods": [ + "stop_replication" + ] + }, + "SwitchActiveReplicaZone": { + "methods": [ + "switch_active_replica_zone" + ] + }, + "SyncReplication": { + "methods": [ + "sync_replication" + ] + }, + "UpdateActiveDirectory": { + "methods": [ + "update_active_directory" + ] + }, + "UpdateBackup": { + "methods": [ + "update_backup" + ] + }, + "UpdateBackupPolicy": { + "methods": [ + "update_backup_policy" + ] + }, + "UpdateBackupVault": { + "methods": [ + "update_backup_vault" + ] + }, + "UpdateKmsConfig": { + "methods": [ + "update_kms_config" + ] + }, + "UpdateQuotaRule": { + "methods": [ + "update_quota_rule" + ] + }, + "UpdateReplication": { + "methods": [ + "update_replication" + ] + }, + "UpdateSnapshot": { + "methods": [ + "update_snapshot" + ] + }, + "UpdateStoragePool": { + "methods": [ + "update_storage_pool" + ] + }, + "UpdateVolume": { + "methods": [ + "update_volume" + ] + }, + "ValidateDirectoryService": { + "methods": [ + "validate_directory_service" + ] + }, + "VerifyKmsConfig": { + "methods": [ + "verify_kms_config" + ] + } + } + }, + "grpc-async": { + "libraryClient": "NetAppAsyncClient", + "rpcs": { + "CreateActiveDirectory": { + "methods": [ + "create_active_directory" + ] + }, + "CreateBackup": { + "methods": [ + "create_backup" + ] + }, + "CreateBackupPolicy": { + "methods": [ + "create_backup_policy" + ] + }, + "CreateBackupVault": { + "methods": [ + "create_backup_vault" + ] + }, + "CreateKmsConfig": { + "methods": [ + "create_kms_config" + ] + }, + "CreateQuotaRule": { + "methods": [ + "create_quota_rule" + ] + }, + "CreateReplication": { + "methods": [ + "create_replication" + ] + }, + "CreateSnapshot": { + "methods": [ + "create_snapshot" + ] + }, + "CreateStoragePool": { + "methods": [ + "create_storage_pool" + ] + }, + "CreateVolume": { + "methods": [ + "create_volume" + ] + }, + "DeleteActiveDirectory": { + "methods": [ + "delete_active_directory" + ] + }, + "DeleteBackup": { + "methods": [ + "delete_backup" + ] + }, + "DeleteBackupPolicy": { + "methods": [ + "delete_backup_policy" + ] + }, + "DeleteBackupVault": { + "methods": [ + "delete_backup_vault" + ] + }, + "DeleteKmsConfig": { + "methods": [ + "delete_kms_config" + ] + }, + "DeleteQuotaRule": { + "methods": [ + "delete_quota_rule" + ] + }, + "DeleteReplication": { + "methods": [ + "delete_replication" + ] + }, + "DeleteSnapshot": { + "methods": [ + "delete_snapshot" + ] + }, + "DeleteStoragePool": { + "methods": [ + "delete_storage_pool" + ] + }, + "DeleteVolume": { + "methods": [ + "delete_volume" + ] + }, + "EncryptVolumes": { + "methods": [ + "encrypt_volumes" + ] + }, + "EstablishPeering": { + "methods": [ + "establish_peering" + ] + }, + "GetActiveDirectory": { + "methods": [ + "get_active_directory" + ] + }, + "GetBackup": { + "methods": [ + "get_backup" + ] + }, + "GetBackupPolicy": { + "methods": [ + "get_backup_policy" + ] + }, + "GetBackupVault": { + "methods": [ + "get_backup_vault" + ] + }, + "GetKmsConfig": { + "methods": [ + "get_kms_config" + ] + }, + "GetQuotaRule": { + "methods": [ + "get_quota_rule" + ] + }, + "GetReplication": { + "methods": [ + "get_replication" + ] + }, + "GetSnapshot": { + "methods": [ + "get_snapshot" + ] + }, + "GetStoragePool": { + "methods": [ + "get_storage_pool" + ] + }, + "GetVolume": { + "methods": [ + "get_volume" + ] + }, + "ListActiveDirectories": { + "methods": [ + "list_active_directories" + ] + }, + "ListBackupPolicies": { + "methods": [ + "list_backup_policies" + ] + }, + "ListBackupVaults": { + "methods": [ + "list_backup_vaults" + ] + }, + "ListBackups": { + "methods": [ + "list_backups" + ] + }, + "ListKmsConfigs": { + "methods": [ + "list_kms_configs" + ] + }, + "ListQuotaRules": { + "methods": [ + "list_quota_rules" + ] + }, + "ListReplications": { + "methods": [ + "list_replications" + ] + }, + "ListSnapshots": { + "methods": [ + "list_snapshots" + ] + }, + "ListStoragePools": { + "methods": [ + "list_storage_pools" + ] + }, + "ListVolumes": { + "methods": [ + "list_volumes" + ] + }, + "ResumeReplication": { + "methods": [ + "resume_replication" + ] + }, + "ReverseReplicationDirection": { + "methods": [ + "reverse_replication_direction" + ] + }, + "RevertVolume": { + "methods": [ + "revert_volume" + ] + }, + "StopReplication": { + "methods": [ + "stop_replication" + ] + }, + "SwitchActiveReplicaZone": { + "methods": [ + "switch_active_replica_zone" + ] + }, + "SyncReplication": { + "methods": [ + "sync_replication" + ] + }, + "UpdateActiveDirectory": { + "methods": [ + "update_active_directory" + ] + }, + "UpdateBackup": { + "methods": [ + "update_backup" + ] + }, + "UpdateBackupPolicy": { + "methods": [ + "update_backup_policy" + ] + }, + "UpdateBackupVault": { + "methods": [ + "update_backup_vault" + ] + }, + "UpdateKmsConfig": { + "methods": [ + "update_kms_config" + ] + }, + "UpdateQuotaRule": { + "methods": [ + "update_quota_rule" + ] + }, + "UpdateReplication": { + "methods": [ + "update_replication" + ] + }, + "UpdateSnapshot": { + "methods": [ + "update_snapshot" + ] + }, + "UpdateStoragePool": { + "methods": [ + "update_storage_pool" + ] + }, + "UpdateVolume": { + "methods": [ + "update_volume" + ] + }, + "ValidateDirectoryService": { + "methods": [ + "validate_directory_service" + ] + }, + "VerifyKmsConfig": { + "methods": [ + "verify_kms_config" + ] + } + } + }, + "rest": { + "libraryClient": "NetAppClient", + "rpcs": { + "CreateActiveDirectory": { + "methods": [ + "create_active_directory" + ] + }, + "CreateBackup": { + "methods": [ + "create_backup" + ] + }, + "CreateBackupPolicy": { + "methods": [ + "create_backup_policy" + ] + }, + "CreateBackupVault": { + "methods": [ + "create_backup_vault" + ] + }, + "CreateKmsConfig": { + "methods": [ + "create_kms_config" + ] + }, + "CreateQuotaRule": { + "methods": [ + "create_quota_rule" + ] + }, + "CreateReplication": { + "methods": [ + "create_replication" + ] + }, + "CreateSnapshot": { + "methods": [ + "create_snapshot" + ] + }, + "CreateStoragePool": { + "methods": [ + "create_storage_pool" + ] + }, + "CreateVolume": { + "methods": [ + "create_volume" + ] + }, + "DeleteActiveDirectory": { + "methods": [ + "delete_active_directory" + ] + }, + "DeleteBackup": { + "methods": [ + "delete_backup" + ] + }, + "DeleteBackupPolicy": { + "methods": [ + "delete_backup_policy" + ] + }, + "DeleteBackupVault": { + "methods": [ + "delete_backup_vault" + ] + }, + "DeleteKmsConfig": { + "methods": [ + "delete_kms_config" + ] + }, + "DeleteQuotaRule": { + "methods": [ + "delete_quota_rule" + ] + }, + "DeleteReplication": { + "methods": [ + "delete_replication" + ] + }, + "DeleteSnapshot": { + "methods": [ + "delete_snapshot" + ] + }, + "DeleteStoragePool": { + "methods": [ + "delete_storage_pool" + ] + }, + "DeleteVolume": { + "methods": [ + "delete_volume" + ] + }, + "EncryptVolumes": { + "methods": [ + "encrypt_volumes" + ] + }, + "EstablishPeering": { + "methods": [ + "establish_peering" + ] + }, + "GetActiveDirectory": { + "methods": [ + "get_active_directory" + ] + }, + "GetBackup": { + "methods": [ + "get_backup" + ] + }, + "GetBackupPolicy": { + "methods": [ + "get_backup_policy" + ] + }, + "GetBackupVault": { + "methods": [ + "get_backup_vault" + ] + }, + "GetKmsConfig": { + "methods": [ + "get_kms_config" + ] + }, + "GetQuotaRule": { + "methods": [ + "get_quota_rule" + ] + }, + "GetReplication": { + "methods": [ + "get_replication" + ] + }, + "GetSnapshot": { + "methods": [ + "get_snapshot" + ] + }, + "GetStoragePool": { + "methods": [ + "get_storage_pool" + ] + }, + "GetVolume": { + "methods": [ + "get_volume" + ] + }, + "ListActiveDirectories": { + "methods": [ + "list_active_directories" + ] + }, + "ListBackupPolicies": { + "methods": [ + "list_backup_policies" + ] + }, + "ListBackupVaults": { + "methods": [ + "list_backup_vaults" + ] + }, + "ListBackups": { + "methods": [ + "list_backups" + ] + }, + "ListKmsConfigs": { + "methods": [ + "list_kms_configs" + ] + }, + "ListQuotaRules": { + "methods": [ + "list_quota_rules" + ] + }, + "ListReplications": { + "methods": [ + "list_replications" + ] + }, + "ListSnapshots": { + "methods": [ + "list_snapshots" + ] + }, + "ListStoragePools": { + "methods": [ + "list_storage_pools" + ] + }, + "ListVolumes": { + "methods": [ + "list_volumes" + ] + }, + "ResumeReplication": { + "methods": [ + "resume_replication" + ] + }, + "ReverseReplicationDirection": { + "methods": [ + "reverse_replication_direction" + ] + }, + "RevertVolume": { + "methods": [ + "revert_volume" + ] + }, + "StopReplication": { + "methods": [ + "stop_replication" + ] + }, + "SwitchActiveReplicaZone": { + "methods": [ + "switch_active_replica_zone" + ] + }, + "SyncReplication": { + "methods": [ + "sync_replication" + ] + }, + "UpdateActiveDirectory": { + "methods": [ + "update_active_directory" + ] + }, + "UpdateBackup": { + "methods": [ + "update_backup" + ] + }, + "UpdateBackupPolicy": { + "methods": [ + "update_backup_policy" + ] + }, + "UpdateBackupVault": { + "methods": [ + "update_backup_vault" + ] + }, + "UpdateKmsConfig": { + "methods": [ + "update_kms_config" + ] + }, + "UpdateQuotaRule": { + "methods": [ + "update_quota_rule" + ] + }, + "UpdateReplication": { + "methods": [ + "update_replication" + ] + }, + "UpdateSnapshot": { + "methods": [ + "update_snapshot" + ] + }, + "UpdateStoragePool": { + "methods": [ + "update_storage_pool" + ] + }, + "UpdateVolume": { + "methods": [ + "update_volume" + ] + }, + "ValidateDirectoryService": { + "methods": [ + "validate_directory_service" + ] + }, + "VerifyKmsConfig": { + "methods": [ + "verify_kms_config" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/gapic_version.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/gapic_version.py new file mode 100644 index 000000000000..20a9cd975b02 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/gapic_version.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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-netapp/v1/google/cloud/netapp_v1/py.typed b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/py.typed new file mode 100644 index 000000000000..7d2f4c53406d --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-netapp package uses inline types. diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/__init__.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/__init__.py new file mode 100644 index 000000000000..cbf94b283c70 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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-netapp/v1/google/cloud/netapp_v1/services/net_app/__init__.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/__init__.py new file mode 100644 index 000000000000..c2e08c12629f --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 NetAppClient +from .async_client import NetAppAsyncClient + +__all__ = ( + 'NetAppClient', + 'NetAppAsyncClient', +) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/async_client.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/async_client.py new file mode 100644 index 000000000000..b544c5e288de --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/async_client.py @@ -0,0 +1,8035 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 logging as std_logging +from collections import OrderedDict +import re +from typing import Dict, Callable, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union + +from google.cloud.netapp_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.location import locations_pb2 # type: ignore +from google.cloud.netapp_v1.services.net_app import pagers +from google.cloud.netapp_v1.types import active_directory +from google.cloud.netapp_v1.types import active_directory as gcn_active_directory +from google.cloud.netapp_v1.types import backup +from google.cloud.netapp_v1.types import backup as gcn_backup +from google.cloud.netapp_v1.types import backup_policy +from google.cloud.netapp_v1.types import backup_policy as gcn_backup_policy +from google.cloud.netapp_v1.types import backup_vault +from google.cloud.netapp_v1.types import backup_vault as gcn_backup_vault +from google.cloud.netapp_v1.types import cloud_netapp_service +from google.cloud.netapp_v1.types import common +from google.cloud.netapp_v1.types import kms +from google.cloud.netapp_v1.types import quota_rule +from google.cloud.netapp_v1.types import quota_rule as gcn_quota_rule +from google.cloud.netapp_v1.types import replication +from google.cloud.netapp_v1.types import replication as gcn_replication +from google.cloud.netapp_v1.types import snapshot +from google.cloud.netapp_v1.types import snapshot as gcn_snapshot +from google.cloud.netapp_v1.types import storage_pool +from google.cloud.netapp_v1.types import storage_pool as gcn_storage_pool +from google.cloud.netapp_v1.types import volume +from google.cloud.netapp_v1.types import volume as gcn_volume +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 timestamp_pb2 # type: ignore +from .transports.base import NetAppTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import NetAppGrpcAsyncIOTransport +from .client import NetAppClient + +try: + from google.api_core import client_logging # type: ignore + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + +class NetAppAsyncClient: + """NetApp Files Google Cloud Service""" + + _client: NetAppClient + + # Copy defaults from the synchronous client for use here. + # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead. + DEFAULT_ENDPOINT = NetAppClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = NetAppClient.DEFAULT_MTLS_ENDPOINT + _DEFAULT_ENDPOINT_TEMPLATE = NetAppClient._DEFAULT_ENDPOINT_TEMPLATE + _DEFAULT_UNIVERSE = NetAppClient._DEFAULT_UNIVERSE + + active_directory_path = staticmethod(NetAppClient.active_directory_path) + parse_active_directory_path = staticmethod(NetAppClient.parse_active_directory_path) + backup_path = staticmethod(NetAppClient.backup_path) + parse_backup_path = staticmethod(NetAppClient.parse_backup_path) + backup_policy_path = staticmethod(NetAppClient.backup_policy_path) + parse_backup_policy_path = staticmethod(NetAppClient.parse_backup_policy_path) + backup_vault_path = staticmethod(NetAppClient.backup_vault_path) + parse_backup_vault_path = staticmethod(NetAppClient.parse_backup_vault_path) + kms_config_path = staticmethod(NetAppClient.kms_config_path) + parse_kms_config_path = staticmethod(NetAppClient.parse_kms_config_path) + network_path = staticmethod(NetAppClient.network_path) + parse_network_path = staticmethod(NetAppClient.parse_network_path) + quota_rule_path = staticmethod(NetAppClient.quota_rule_path) + parse_quota_rule_path = staticmethod(NetAppClient.parse_quota_rule_path) + replication_path = staticmethod(NetAppClient.replication_path) + parse_replication_path = staticmethod(NetAppClient.parse_replication_path) + snapshot_path = staticmethod(NetAppClient.snapshot_path) + parse_snapshot_path = staticmethod(NetAppClient.parse_snapshot_path) + storage_pool_path = staticmethod(NetAppClient.storage_pool_path) + parse_storage_pool_path = staticmethod(NetAppClient.parse_storage_pool_path) + volume_path = staticmethod(NetAppClient.volume_path) + parse_volume_path = staticmethod(NetAppClient.parse_volume_path) + common_billing_account_path = staticmethod(NetAppClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(NetAppClient.parse_common_billing_account_path) + common_folder_path = staticmethod(NetAppClient.common_folder_path) + parse_common_folder_path = staticmethod(NetAppClient.parse_common_folder_path) + common_organization_path = staticmethod(NetAppClient.common_organization_path) + parse_common_organization_path = staticmethod(NetAppClient.parse_common_organization_path) + common_project_path = staticmethod(NetAppClient.common_project_path) + parse_common_project_path = staticmethod(NetAppClient.parse_common_project_path) + common_location_path = staticmethod(NetAppClient.common_location_path) + parse_common_location_path = staticmethod(NetAppClient.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: + NetAppAsyncClient: The constructed client. + """ + return NetAppClient.from_service_account_info.__func__(NetAppAsyncClient, 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: + NetAppAsyncClient: The constructed client. + """ + return NetAppClient.from_service_account_file.__func__(NetAppAsyncClient, 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 NetAppClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + + @property + def transport(self) -> NetAppTransport: + """Returns the transport used by the client instance. + + Returns: + NetAppTransport: 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 = NetAppClient.get_transport_class + + def __init__(self, *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Optional[Union[str, NetAppTransport, Callable[..., NetAppTransport]]] = "grpc_asyncio", + client_options: Optional[ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the net app 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,NetAppTransport,Callable[..., NetAppTransport]]]): + 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 NetAppTransport 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 = NetAppClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.netapp_v1.NetAppAsyncClient`.", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "universeDomain": getattr(self._client._transport._credentials, "universe_domain", ""), + "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}", + "credentialsInfo": getattr(self.transport._credentials, "get_cred_info", lambda: None)(), + } if hasattr(self._client._transport, "_credentials") else { + "serviceName": "google.cloud.netapp.v1.NetApp", + "credentialsType": None, + } + ) + + async def list_storage_pools(self, + request: Optional[Union[storage_pool.ListStoragePoolsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListStoragePoolsAsyncPager: + r"""Returns descriptions of all storage pools owned by + the caller. + + .. 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 netapp_v1 + + async def sample_list_storage_pools(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ListStoragePoolsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_storage_pools(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.ListStoragePoolsRequest, dict]]): + The request object. ListStoragePoolsRequest lists Storage + Pools. + parent (:class:`str`): + Required. Parent value + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.services.net_app.pagers.ListStoragePoolsAsyncPager: + ListStoragePoolsResponse is the + response to a ListStoragePoolsRequest. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, storage_pool.ListStoragePoolsRequest): + request = storage_pool.ListStoragePoolsRequest(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_storage_pools] + + # 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.ListStoragePoolsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_storage_pool(self, + request: Optional[Union[gcn_storage_pool.CreateStoragePoolRequest, dict]] = None, + *, + parent: Optional[str] = None, + storage_pool: Optional[gcn_storage_pool.StoragePool] = None, + storage_pool_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates a new storage pool. + + .. 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 netapp_v1 + + async def sample_create_storage_pool(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + storage_pool = netapp_v1.StoragePool() + storage_pool.service_level = "FLEX" + storage_pool.capacity_gib = 1247 + storage_pool.network = "network_value" + + request = netapp_v1.CreateStoragePoolRequest( + parent="parent_value", + storage_pool_id="storage_pool_id_value", + storage_pool=storage_pool, + ) + + # Make the request + operation = client.create_storage_pool(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.CreateStoragePoolRequest, dict]]): + The request object. CreateStoragePoolRequest creates a + Storage Pool. + parent (:class:`str`): + Required. Value for parent. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + storage_pool (:class:`google.cloud.netapp_v1.types.StoragePool`): + Required. The required parameters to + create a new storage pool. + + This corresponds to the ``storage_pool`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + storage_pool_id (:class:`str`): + Required. Id of the requesting + storage pool. Must be unique within the + parent resource. Must contain only + letters, numbers and hyphen, with the + first character a letter, the last a + letter or a number, and a 63 character + maximum. + + This corresponds to the ``storage_pool_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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.StoragePool` StoragePool is a container for volumes with a service level and capacity. + Volumes can be created in a pool of sufficient + available capacity. StoragePool capacity is what you + are billed for. + + """ + # 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. + flattened_params = [parent, storage_pool, storage_pool_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_storage_pool.CreateStoragePoolRequest): + request = gcn_storage_pool.CreateStoragePoolRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if storage_pool is not None: + request.storage_pool = storage_pool + if storage_pool_id is not None: + request.storage_pool_id = storage_pool_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_storage_pool] + + # 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, + gcn_storage_pool.StoragePool, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def get_storage_pool(self, + request: Optional[Union[storage_pool.GetStoragePoolRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> storage_pool.StoragePool: + r"""Returns the description of the specified storage pool + by poolId. + + .. 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 netapp_v1 + + async def sample_get_storage_pool(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.GetStoragePoolRequest( + name="name_value", + ) + + # Make the request + response = await client.get_storage_pool(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.GetStoragePoolRequest, dict]]): + The request object. GetStoragePoolRequest gets a Storage + Pool. + name (:class:`str`): + Required. Name of the storage pool + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.StoragePool: + StoragePool is a container for + volumes with a service level and + capacity. Volumes can be created in a + pool of sufficient available capacity. + StoragePool capacity is what you are + billed for. + + """ + # 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, storage_pool.GetStoragePoolRequest): + request = storage_pool.GetStoragePoolRequest(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_storage_pool] + + # 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_storage_pool(self, + request: Optional[Union[gcn_storage_pool.UpdateStoragePoolRequest, dict]] = None, + *, + storage_pool: Optional[gcn_storage_pool.StoragePool] = 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, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates the storage pool properties with the full + spec + + .. 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 netapp_v1 + + async def sample_update_storage_pool(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + storage_pool = netapp_v1.StoragePool() + storage_pool.service_level = "FLEX" + storage_pool.capacity_gib = 1247 + storage_pool.network = "network_value" + + request = netapp_v1.UpdateStoragePoolRequest( + storage_pool=storage_pool, + ) + + # Make the request + operation = client.update_storage_pool(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.UpdateStoragePoolRequest, dict]]): + The request object. UpdateStoragePoolRequest updates a + Storage Pool. + storage_pool (:class:`google.cloud.netapp_v1.types.StoragePool`): + Required. The pool being updated + This corresponds to the ``storage_pool`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. Field mask is used to specify the fields to be + overwritten in the StoragePool resource by the update. + The fields specified in the update_mask are relative to + the resource, not the full request. A field will be + overwritten if it is in the mask. If the user does not + provide a mask then all fields will be overwritten. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.StoragePool` StoragePool is a container for volumes with a service level and capacity. + Volumes can be created in a pool of sufficient + available capacity. StoragePool capacity is what you + are billed for. + + """ + # 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. + flattened_params = [storage_pool, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_storage_pool.UpdateStoragePoolRequest): + request = gcn_storage_pool.UpdateStoragePoolRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if storage_pool is not None: + request.storage_pool = storage_pool + 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_storage_pool] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("storage_pool.name", request.storage_pool.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, + gcn_storage_pool.StoragePool, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_storage_pool(self, + request: Optional[Union[storage_pool.DeleteStoragePoolRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Warning! This operation will permanently delete the + storage pool. + + .. 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 netapp_v1 + + async def sample_delete_storage_pool(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteStoragePoolRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_storage_pool(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.DeleteStoragePoolRequest, dict]]): + The request object. DeleteStoragePoolRequest deletes a + Storage Pool. + name (:class:`str`): + Required. Name of the storage pool + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, storage_pool.DeleteStoragePoolRequest): + request = storage_pool.DeleteStoragePoolRequest(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_storage_pool] + + # 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=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def validate_directory_service(self, + request: Optional[Union[storage_pool.ValidateDirectoryServiceRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""ValidateDirectoryService does a connectivity check + for a directory service policy attached to the storage + pool. + + .. 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 netapp_v1 + + async def sample_validate_directory_service(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ValidateDirectoryServiceRequest( + name="name_value", + ) + + # Make the request + operation = client.validate_directory_service(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.ValidateDirectoryServiceRequest, dict]]): + The request object. ValidateDirectoryServiceRequest + validates the directory service policy + attached to the storage pool. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + # - 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, storage_pool.ValidateDirectoryServiceRequest): + request = storage_pool.ValidateDirectoryServiceRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[self._client._transport.validate_directory_service] + + # 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=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def switch_active_replica_zone(self, + request: Optional[Union[storage_pool.SwitchActiveReplicaZoneRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""This operation will switch the active/replica zone + for a regional storagePool. + + .. 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 netapp_v1 + + async def sample_switch_active_replica_zone(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.SwitchActiveReplicaZoneRequest( + name="name_value", + ) + + # Make the request + operation = client.switch_active_replica_zone(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.SwitchActiveReplicaZoneRequest, dict]]): + The request object. SwitchActiveReplicaZoneRequest switch + the active/replica zone for a regional + storagePool. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.StoragePool` StoragePool is a container for volumes with a service level and capacity. + Volumes can be created in a pool of sufficient + available capacity. StoragePool capacity is what you + are billed for. + + """ + # 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, storage_pool.SwitchActiveReplicaZoneRequest): + request = storage_pool.SwitchActiveReplicaZoneRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[self._client._transport.switch_active_replica_zone] + + # 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, + storage_pool.StoragePool, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def list_volumes(self, + request: Optional[Union[volume.ListVolumesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListVolumesAsyncPager: + r"""Lists Volumes in a given 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 netapp_v1 + + async def sample_list_volumes(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ListVolumesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_volumes(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.ListVolumesRequest, dict]]): + The request object. Message for requesting list of + Volumes + parent (:class:`str`): + Required. Parent value for + ListVolumesRequest + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.services.net_app.pagers.ListVolumesAsyncPager: + Message for response to listing + Volumes + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, volume.ListVolumesRequest): + request = volume.ListVolumesRequest(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_volumes] + + # 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.ListVolumesAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_volume(self, + request: Optional[Union[volume.GetVolumeRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> volume.Volume: + r"""Gets details of a single Volume. + + .. 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 netapp_v1 + + async def sample_get_volume(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.GetVolumeRequest( + name="name_value", + ) + + # Make the request + response = await client.get_volume(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.GetVolumeRequest, dict]]): + The request object. Message for getting a Volume + name (:class:`str`): + Required. Name of the volume + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.Volume: + Volume provides a filesystem that you + can mount. + + """ + # 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, volume.GetVolumeRequest): + request = volume.GetVolumeRequest(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_volume] + + # 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_volume(self, + request: Optional[Union[gcn_volume.CreateVolumeRequest, dict]] = None, + *, + parent: Optional[str] = None, + volume: Optional[gcn_volume.Volume] = None, + volume_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates a new Volume in a given project and location. + + .. 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 netapp_v1 + + async def sample_create_volume(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + volume = netapp_v1.Volume() + volume.share_name = "share_name_value" + volume.storage_pool = "storage_pool_value" + volume.capacity_gib = 1247 + volume.protocols = ['SMB'] + + request = netapp_v1.CreateVolumeRequest( + parent="parent_value", + volume_id="volume_id_value", + volume=volume, + ) + + # Make the request + operation = client.create_volume(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.CreateVolumeRequest, dict]]): + The request object. Message for creating a Volume + parent (:class:`str`): + Required. Value for parent. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + volume (:class:`google.cloud.netapp_v1.types.Volume`): + Required. The volume being created. + This corresponds to the ``volume`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + volume_id (:class:`str`): + Required. Id of the requesting + volume. Must be unique within the parent + resource. Must contain only letters, + numbers and hyphen, with the first + character a letter, the last a letter or + a number, and a 63 character maximum. + + This corresponds to the ``volume_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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.Volume` Volume + provides a filesystem that you can mount. + + """ + # 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. + flattened_params = [parent, volume, volume_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_volume.CreateVolumeRequest): + request = gcn_volume.CreateVolumeRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if volume is not None: + request.volume = volume + if volume_id is not None: + request.volume_id = volume_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_volume] + + # 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, + gcn_volume.Volume, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_volume(self, + request: Optional[Union[gcn_volume.UpdateVolumeRequest, dict]] = None, + *, + volume: Optional[gcn_volume.Volume] = 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, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates the parameters of a single Volume. + + .. 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 netapp_v1 + + async def sample_update_volume(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + volume = netapp_v1.Volume() + volume.share_name = "share_name_value" + volume.storage_pool = "storage_pool_value" + volume.capacity_gib = 1247 + volume.protocols = ['SMB'] + + request = netapp_v1.UpdateVolumeRequest( + volume=volume, + ) + + # Make the request + operation = client.update_volume(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.UpdateVolumeRequest, dict]]): + The request object. Message for updating a Volume + volume (:class:`google.cloud.netapp_v1.types.Volume`): + Required. The volume being updated + This corresponds to the ``volume`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. Field mask is used to specify the fields to be + overwritten in the Volume resource by the update. The + fields specified in the update_mask are relative to the + resource, not the full request. A field will be + overwritten if it is in the mask. If the user does not + provide a mask then all fields will be overwritten. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.Volume` Volume + provides a filesystem that you can mount. + + """ + # 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. + flattened_params = [volume, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_volume.UpdateVolumeRequest): + request = gcn_volume.UpdateVolumeRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if volume is not None: + request.volume = volume + 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_volume] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("volume.name", request.volume.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, + gcn_volume.Volume, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_volume(self, + request: Optional[Union[volume.DeleteVolumeRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Deletes a single Volume. + + .. 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 netapp_v1 + + async def sample_delete_volume(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteVolumeRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_volume(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.DeleteVolumeRequest, dict]]): + The request object. Message for deleting a Volume + name (:class:`str`): + Required. Name of the volume + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, volume.DeleteVolumeRequest): + request = volume.DeleteVolumeRequest(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_volume] + + # 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=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def revert_volume(self, + request: Optional[Union[volume.RevertVolumeRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Revert an existing volume to a specified snapshot. + Warning! This operation will permanently revert all + changes made after the snapshot was created. + + .. 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 netapp_v1 + + async def sample_revert_volume(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.RevertVolumeRequest( + name="name_value", + snapshot_id="snapshot_id_value", + ) + + # Make the request + operation = client.revert_volume(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.RevertVolumeRequest, dict]]): + The request object. RevertVolumeRequest reverts the given + volume to the specified snapshot. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.Volume` Volume + provides a filesystem that you can mount. + + """ + # 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, volume.RevertVolumeRequest): + request = volume.RevertVolumeRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[self._client._transport.revert_volume] + + # 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, + volume.Volume, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def list_snapshots(self, + request: Optional[Union[snapshot.ListSnapshotsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListSnapshotsAsyncPager: + r"""Returns descriptions of all snapshots for a volume. + + .. 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 netapp_v1 + + async def sample_list_snapshots(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ListSnapshotsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_snapshots(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.ListSnapshotsRequest, dict]]): + The request object. ListSnapshotsRequest lists snapshots. + parent (:class:`str`): + Required. The volume for which to retrieve snapshot + information, in the format + ``projects/{project_id}/locations/{location}/volumes/{volume_id}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.services.net_app.pagers.ListSnapshotsAsyncPager: + ListSnapshotsResponse is the result + of ListSnapshotsRequest. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, snapshot.ListSnapshotsRequest): + request = snapshot.ListSnapshotsRequest(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_snapshots] + + # 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.ListSnapshotsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_snapshot(self, + request: Optional[Union[snapshot.GetSnapshotRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> snapshot.Snapshot: + r"""Describe a snapshot for a volume. + + .. 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 netapp_v1 + + async def sample_get_snapshot(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.GetSnapshotRequest( + name="name_value", + ) + + # Make the request + response = await client.get_snapshot(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.GetSnapshotRequest, dict]]): + The request object. GetSnapshotRequest gets the state of + a snapshot. + name (:class:`str`): + Required. The snapshot resource name, in the format + ``projects/{project_id}/locations/{location}/volumes/{volume_id}/snapshots/{snapshot_id}`` + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.Snapshot: + Snapshot is a point-in-time version + of a Volume's content. + + """ + # 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, snapshot.GetSnapshotRequest): + request = snapshot.GetSnapshotRequest(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_snapshot] + + # 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_snapshot(self, + request: Optional[Union[gcn_snapshot.CreateSnapshotRequest, dict]] = None, + *, + parent: Optional[str] = None, + snapshot: Optional[gcn_snapshot.Snapshot] = None, + snapshot_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Create a new snapshot for a volume. + + .. 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 netapp_v1 + + async def sample_create_snapshot(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.CreateSnapshotRequest( + parent="parent_value", + snapshot_id="snapshot_id_value", + ) + + # Make the request + operation = client.create_snapshot(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.CreateSnapshotRequest, dict]]): + The request object. CreateSnapshotRequest creates a + snapshot. + parent (:class:`str`): + Required. The NetApp volume to create the snapshots of, + in the format + ``projects/{project_id}/locations/{location}/volumes/{volume_id}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + snapshot (:class:`google.cloud.netapp_v1.types.Snapshot`): + Required. A snapshot resource + This corresponds to the ``snapshot`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + snapshot_id (:class:`str`): + Required. ID of the snapshot to + create. Must be unique within the parent + resource. Must contain only letters, + numbers and hyphen, with the first + character a letter, the last a letter or + a number, and a 63 character maximum. + + This corresponds to the ``snapshot_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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.Snapshot` Snapshot + is a point-in-time version of a Volume's content. + + """ + # 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. + flattened_params = [parent, snapshot, snapshot_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_snapshot.CreateSnapshotRequest): + request = gcn_snapshot.CreateSnapshotRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if snapshot is not None: + request.snapshot = snapshot + if snapshot_id is not None: + request.snapshot_id = snapshot_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_snapshot] + + # 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, + gcn_snapshot.Snapshot, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_snapshot(self, + request: Optional[Union[snapshot.DeleteSnapshotRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Deletes a snapshot. + + .. 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 netapp_v1 + + async def sample_delete_snapshot(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteSnapshotRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_snapshot(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.DeleteSnapshotRequest, dict]]): + The request object. DeleteSnapshotRequest deletes a + snapshot. + name (:class:`str`): + Required. The snapshot resource name, in the format + ``projects/*/locations/*/volumes/*/snapshots/{snapshot_id}`` + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, snapshot.DeleteSnapshotRequest): + request = snapshot.DeleteSnapshotRequest(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_snapshot] + + # 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=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_snapshot(self, + request: Optional[Union[gcn_snapshot.UpdateSnapshotRequest, dict]] = None, + *, + snapshot: Optional[gcn_snapshot.Snapshot] = 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, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates the settings of a specific snapshot. + + .. 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 netapp_v1 + + async def sample_update_snapshot(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.UpdateSnapshotRequest( + ) + + # Make the request + operation = client.update_snapshot(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.UpdateSnapshotRequest, dict]]): + The request object. UpdateSnapshotRequest updates + description and/or labels for a + snapshot. + snapshot (:class:`google.cloud.netapp_v1.types.Snapshot`): + Required. A snapshot resource + This corresponds to the ``snapshot`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. Mask of fields to update. + At least one path must be supplied in + this field. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.Snapshot` Snapshot + is a point-in-time version of a Volume's content. + + """ + # 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. + flattened_params = [snapshot, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_snapshot.UpdateSnapshotRequest): + request = gcn_snapshot.UpdateSnapshotRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if snapshot is not None: + request.snapshot = snapshot + 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_snapshot] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("snapshot.name", request.snapshot.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, + gcn_snapshot.Snapshot, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def list_active_directories(self, + request: Optional[Union[active_directory.ListActiveDirectoriesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListActiveDirectoriesAsyncPager: + r"""Lists active directories. + + .. 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 netapp_v1 + + async def sample_list_active_directories(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ListActiveDirectoriesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_active_directories(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.ListActiveDirectoriesRequest, dict]]): + The request object. ListActiveDirectoriesRequest for + requesting multiple active directories. + parent (:class:`str`): + Required. Parent value for + ListActiveDirectoriesRequest + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.services.net_app.pagers.ListActiveDirectoriesAsyncPager: + ListActiveDirectoriesResponse + contains all the active directories + requested. 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, active_directory.ListActiveDirectoriesRequest): + request = active_directory.ListActiveDirectoriesRequest(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_active_directories] + + # 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.ListActiveDirectoriesAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_active_directory(self, + request: Optional[Union[active_directory.GetActiveDirectoryRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> active_directory.ActiveDirectory: + r"""Describes a specified active directory. + + .. 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 netapp_v1 + + async def sample_get_active_directory(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.GetActiveDirectoryRequest( + name="name_value", + ) + + # Make the request + response = await client.get_active_directory(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.GetActiveDirectoryRequest, dict]]): + The request object. GetActiveDirectory for getting a + single active directory. + name (:class:`str`): + Required. Name of the active + directory. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.ActiveDirectory: + ActiveDirectory is the public + representation of the active directory + config. + + """ + # 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, active_directory.GetActiveDirectoryRequest): + request = active_directory.GetActiveDirectoryRequest(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_active_directory] + + # 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_active_directory(self, + request: Optional[Union[gcn_active_directory.CreateActiveDirectoryRequest, dict]] = None, + *, + parent: Optional[str] = None, + active_directory: Optional[gcn_active_directory.ActiveDirectory] = None, + active_directory_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""CreateActiveDirectory + Creates the active directory specified in the request. + + .. 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 netapp_v1 + + async def sample_create_active_directory(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + active_directory = netapp_v1.ActiveDirectory() + active_directory.domain = "domain_value" + active_directory.dns = "dns_value" + active_directory.net_bios_prefix = "net_bios_prefix_value" + active_directory.username = "username_value" + active_directory.password = "password_value" + + request = netapp_v1.CreateActiveDirectoryRequest( + parent="parent_value", + active_directory=active_directory, + active_directory_id="active_directory_id_value", + ) + + # Make the request + operation = client.create_active_directory(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.CreateActiveDirectoryRequest, dict]]): + The request object. CreateActiveDirectoryRequest for + creating an active directory. + parent (:class:`str`): + Required. Value for parent. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + active_directory (:class:`google.cloud.netapp_v1.types.ActiveDirectory`): + Required. Fields of the to be created + active directory. + + This corresponds to the ``active_directory`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + active_directory_id (:class:`str`): + Required. ID of the active directory + to create. Must be unique within the + parent resource. Must contain only + letters, numbers and hyphen, with the + first character a letter , the last a + letter or a number, and a 63 character + maximum. + + This corresponds to the ``active_directory_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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.ActiveDirectory` + ActiveDirectory is the public representation of the + active directory config. + + """ + # 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. + flattened_params = [parent, active_directory, active_directory_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_active_directory.CreateActiveDirectoryRequest): + request = gcn_active_directory.CreateActiveDirectoryRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if active_directory is not None: + request.active_directory = active_directory + if active_directory_id is not None: + request.active_directory_id = active_directory_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_active_directory] + + # 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, + gcn_active_directory.ActiveDirectory, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_active_directory(self, + request: Optional[Union[gcn_active_directory.UpdateActiveDirectoryRequest, dict]] = None, + *, + active_directory: Optional[gcn_active_directory.ActiveDirectory] = 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, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Update the parameters of an active directories. + + .. 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 netapp_v1 + + async def sample_update_active_directory(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + active_directory = netapp_v1.ActiveDirectory() + active_directory.domain = "domain_value" + active_directory.dns = "dns_value" + active_directory.net_bios_prefix = "net_bios_prefix_value" + active_directory.username = "username_value" + active_directory.password = "password_value" + + request = netapp_v1.UpdateActiveDirectoryRequest( + active_directory=active_directory, + ) + + # Make the request + operation = client.update_active_directory(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.UpdateActiveDirectoryRequest, dict]]): + The request object. UpdateActiveDirectoryRequest for + updating an active directory. + active_directory (:class:`google.cloud.netapp_v1.types.ActiveDirectory`): + Required. The volume being updated + This corresponds to the ``active_directory`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. Field mask is used to specify the fields to be + overwritten in the Active Directory resource by the + update. The fields specified in the update_mask are + relative to the resource, not the full request. A field + will be overwritten if it is in the mask. If the user + does not provide a mask then all fields will be + overwritten. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.ActiveDirectory` + ActiveDirectory is the public representation of the + active directory config. + + """ + # 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. + flattened_params = [active_directory, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_active_directory.UpdateActiveDirectoryRequest): + request = gcn_active_directory.UpdateActiveDirectoryRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if active_directory is not None: + request.active_directory = active_directory + 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_active_directory] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("active_directory.name", request.active_directory.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, + gcn_active_directory.ActiveDirectory, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_active_directory(self, + request: Optional[Union[active_directory.DeleteActiveDirectoryRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Delete the active directory specified in the request. + + .. 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 netapp_v1 + + async def sample_delete_active_directory(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteActiveDirectoryRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_active_directory(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.DeleteActiveDirectoryRequest, dict]]): + The request object. DeleteActiveDirectoryRequest for + deleting a single active directory. + name (:class:`str`): + Required. Name of the active + directory. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, active_directory.DeleteActiveDirectoryRequest): + request = active_directory.DeleteActiveDirectoryRequest(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_active_directory] + + # 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=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def list_kms_configs(self, + request: Optional[Union[kms.ListKmsConfigsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListKmsConfigsAsyncPager: + r"""Returns descriptions of all KMS configs owned by the + caller. + + .. 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 netapp_v1 + + async def sample_list_kms_configs(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ListKmsConfigsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_kms_configs(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.ListKmsConfigsRequest, dict]]): + The request object. ListKmsConfigsRequest lists KMS + Configs. + parent (:class:`str`): + Required. Parent value + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.services.net_app.pagers.ListKmsConfigsAsyncPager: + ListKmsConfigsResponse is the + response to a ListKmsConfigsRequest. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, kms.ListKmsConfigsRequest): + request = kms.ListKmsConfigsRequest(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_kms_configs] + + # 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.ListKmsConfigsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_kms_config(self, + request: Optional[Union[kms.CreateKmsConfigRequest, dict]] = None, + *, + parent: Optional[str] = None, + kms_config: Optional[kms.KmsConfig] = None, + kms_config_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates a new KMS config. + + .. 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 netapp_v1 + + async def sample_create_kms_config(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + kms_config = netapp_v1.KmsConfig() + kms_config.crypto_key_name = "crypto_key_name_value" + + request = netapp_v1.CreateKmsConfigRequest( + parent="parent_value", + kms_config_id="kms_config_id_value", + kms_config=kms_config, + ) + + # Make the request + operation = client.create_kms_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.CreateKmsConfigRequest, dict]]): + The request object. CreateKmsConfigRequest creates a KMS + Config. + parent (:class:`str`): + Required. Value for parent. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + kms_config (:class:`google.cloud.netapp_v1.types.KmsConfig`): + Required. The required parameters to + create a new KmsConfig. + + This corresponds to the ``kms_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + kms_config_id (:class:`str`): + Required. Id of the requesting + KmsConfig. Must be unique within the + parent resource. Must contain only + letters, numbers and hyphen, with the + first character a letter, the last a + letter or a number, and a 63 character + maximum. + + This corresponds to the ``kms_config_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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.KmsConfig` + KmsConfig is the customer managed encryption key(CMEK) + configuration. + + """ + # 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. + flattened_params = [parent, kms_config, kms_config_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, kms.CreateKmsConfigRequest): + request = kms.CreateKmsConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if kms_config is not None: + request.kms_config = kms_config + if kms_config_id is not None: + request.kms_config_id = kms_config_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_kms_config] + + # 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, + kms.KmsConfig, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def get_kms_config(self, + request: Optional[Union[kms.GetKmsConfigRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> kms.KmsConfig: + r"""Returns the description of the specified KMS config by + kms_config_id. + + .. 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 netapp_v1 + + async def sample_get_kms_config(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.GetKmsConfigRequest( + name="name_value", + ) + + # Make the request + response = await client.get_kms_config(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.GetKmsConfigRequest, dict]]): + The request object. GetKmsConfigRequest gets a KMS + Config. + name (:class:`str`): + Required. Name of the KmsConfig + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.KmsConfig: + KmsConfig is the customer managed + encryption key(CMEK) configuration. + + """ + # 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, kms.GetKmsConfigRequest): + request = kms.GetKmsConfigRequest(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_kms_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_kms_config(self, + request: Optional[Union[kms.UpdateKmsConfigRequest, dict]] = None, + *, + kms_config: Optional[kms.KmsConfig] = 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, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates the Kms config properties with the full spec + + .. 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 netapp_v1 + + async def sample_update_kms_config(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + kms_config = netapp_v1.KmsConfig() + kms_config.crypto_key_name = "crypto_key_name_value" + + request = netapp_v1.UpdateKmsConfigRequest( + kms_config=kms_config, + ) + + # Make the request + operation = client.update_kms_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.UpdateKmsConfigRequest, dict]]): + The request object. UpdateKmsConfigRequest updates a KMS + Config. + kms_config (:class:`google.cloud.netapp_v1.types.KmsConfig`): + Required. The KmsConfig being updated + This corresponds to the ``kms_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. Field mask is used to specify the fields to be + overwritten in the KmsConfig resource by the update. The + fields specified in the update_mask are relative to the + resource, not the full request. A field will be + overwritten if it is in the mask. If the user does not + provide a mask then all fields will be overwritten. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.KmsConfig` + KmsConfig is the customer managed encryption key(CMEK) + configuration. + + """ + # 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. + flattened_params = [kms_config, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, kms.UpdateKmsConfigRequest): + request = kms.UpdateKmsConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if kms_config is not None: + request.kms_config = kms_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_kms_config] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("kms_config.name", request.kms_config.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, + kms.KmsConfig, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def encrypt_volumes(self, + request: Optional[Union[kms.EncryptVolumesRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Encrypt the existing volumes without CMEK encryption + with the desired the KMS config for the whole region. + + .. 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 netapp_v1 + + async def sample_encrypt_volumes(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.EncryptVolumesRequest( + name="name_value", + ) + + # Make the request + operation = client.encrypt_volumes(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.EncryptVolumesRequest, dict]]): + The request object. EncryptVolumesRequest specifies the + KMS config to encrypt existing volumes. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.KmsConfig` + KmsConfig is the customer managed encryption key(CMEK) + configuration. + + """ + # 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, kms.EncryptVolumesRequest): + request = kms.EncryptVolumesRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[self._client._transport.encrypt_volumes] + + # 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, + kms.KmsConfig, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def verify_kms_config(self, + request: Optional[Union[kms.VerifyKmsConfigRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> kms.VerifyKmsConfigResponse: + r"""Verifies KMS config reachability. + + .. 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 netapp_v1 + + async def sample_verify_kms_config(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.VerifyKmsConfigRequest( + name="name_value", + ) + + # Make the request + response = await client.verify_kms_config(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.VerifyKmsConfigRequest, dict]]): + The request object. VerifyKmsConfigRequest specifies the + KMS config to be validated. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.VerifyKmsConfigResponse: + VerifyKmsConfigResponse contains the + information if the config is correctly + and error message. + + """ + # 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, kms.VerifyKmsConfigRequest): + request = kms.VerifyKmsConfigRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[self._client._transport.verify_kms_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 delete_kms_config(self, + request: Optional[Union[kms.DeleteKmsConfigRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Warning! This operation will permanently delete the + Kms config. + + .. 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 netapp_v1 + + async def sample_delete_kms_config(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteKmsConfigRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_kms_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.DeleteKmsConfigRequest, dict]]): + The request object. DeleteKmsConfigRequest deletes a KMS + Config. + name (:class:`str`): + Required. Name of the KmsConfig. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, kms.DeleteKmsConfigRequest): + request = kms.DeleteKmsConfigRequest(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_kms_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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def list_replications(self, + request: Optional[Union[replication.ListReplicationsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListReplicationsAsyncPager: + r"""Returns descriptions of all replications for a + volume. + + .. 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 netapp_v1 + + async def sample_list_replications(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ListReplicationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_replications(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.ListReplicationsRequest, dict]]): + The request object. ListReplications lists replications. + parent (:class:`str`): + Required. The volume for which to retrieve replication + information, in the format + ``projects/{project_id}/locations/{location}/volumes/{volume_id}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.services.net_app.pagers.ListReplicationsAsyncPager: + ListReplicationsResponse is the + result of ListReplicationsRequest. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, replication.ListReplicationsRequest): + request = replication.ListReplicationsRequest(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_replications] + + # 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.ListReplicationsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_replication(self, + request: Optional[Union[replication.GetReplicationRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> replication.Replication: + r"""Describe a replication for a volume. + + .. 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 netapp_v1 + + async def sample_get_replication(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.GetReplicationRequest( + name="name_value", + ) + + # Make the request + response = await client.get_replication(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.GetReplicationRequest, dict]]): + The request object. GetReplicationRequest gets the state + of a replication. + name (:class:`str`): + Required. The replication resource name, in the format + ``projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}`` + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.Replication: + Replication is a nested resource + under Volume, that describes a + cross-region replication relationship + between 2 volumes in different regions. + + """ + # 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, replication.GetReplicationRequest): + request = replication.GetReplicationRequest(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_replication] + + # 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_replication(self, + request: Optional[Union[gcn_replication.CreateReplicationRequest, dict]] = None, + *, + parent: Optional[str] = None, + replication: Optional[gcn_replication.Replication] = None, + replication_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Create a new replication for a volume. + + .. 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 netapp_v1 + + async def sample_create_replication(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + replication = netapp_v1.Replication() + replication.replication_schedule = "DAILY" + replication.destination_volume_parameters.storage_pool = "storage_pool_value" + + request = netapp_v1.CreateReplicationRequest( + parent="parent_value", + replication=replication, + replication_id="replication_id_value", + ) + + # Make the request + operation = client.create_replication(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.CreateReplicationRequest, dict]]): + The request object. CreateReplicationRequest creates a + replication. + parent (:class:`str`): + Required. The NetApp volume to create the replications + of, in the format + ``projects/{project_id}/locations/{location}/volumes/{volume_id}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + replication (:class:`google.cloud.netapp_v1.types.Replication`): + Required. A replication resource + This corresponds to the ``replication`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + replication_id (:class:`str`): + Required. ID of the replication to + create. Must be unique within the parent + resource. Must contain only letters, + numbers and hyphen, with the first + character a letter, the last a letter or + a number, and a 63 character maximum. + + This corresponds to the ``replication_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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a + cross-region replication relationship between 2 + volumes in different regions. + + """ + # 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. + flattened_params = [parent, replication, replication_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_replication.CreateReplicationRequest): + request = gcn_replication.CreateReplicationRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if replication is not None: + request.replication = replication + if replication_id is not None: + request.replication_id = replication_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_replication] + + # 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, + gcn_replication.Replication, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_replication(self, + request: Optional[Union[replication.DeleteReplicationRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Deletes a replication. + + .. 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 netapp_v1 + + async def sample_delete_replication(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteReplicationRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_replication(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.DeleteReplicationRequest, dict]]): + The request object. DeleteReplicationRequest deletes a + replication. + name (:class:`str`): + Required. The replication resource name, in the format + ``projects/*/locations/*/volumes/*/replications/{replication_id}`` + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, replication.DeleteReplicationRequest): + request = replication.DeleteReplicationRequest(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_replication] + + # 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=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_replication(self, + request: Optional[Union[gcn_replication.UpdateReplicationRequest, dict]] = None, + *, + replication: Optional[gcn_replication.Replication] = 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, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates the settings of a specific replication. + + .. 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 netapp_v1 + + async def sample_update_replication(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + replication = netapp_v1.Replication() + replication.replication_schedule = "DAILY" + replication.destination_volume_parameters.storage_pool = "storage_pool_value" + + request = netapp_v1.UpdateReplicationRequest( + replication=replication, + ) + + # Make the request + operation = client.update_replication(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.UpdateReplicationRequest, dict]]): + The request object. UpdateReplicationRequest updates + description and/or labels for a + replication. + replication (:class:`google.cloud.netapp_v1.types.Replication`): + Required. A replication resource + This corresponds to the ``replication`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. Mask of fields to update. + At least one path must be supplied in + this field. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a + cross-region replication relationship between 2 + volumes in different regions. + + """ + # 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. + flattened_params = [replication, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_replication.UpdateReplicationRequest): + request = gcn_replication.UpdateReplicationRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if replication is not None: + request.replication = replication + 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_replication] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("replication.name", request.replication.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, + gcn_replication.Replication, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def stop_replication(self, + request: Optional[Union[replication.StopReplicationRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Stop Cross Region Replication. + + .. 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 netapp_v1 + + async def sample_stop_replication(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.StopReplicationRequest( + name="name_value", + ) + + # Make the request + operation = client.stop_replication(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.StopReplicationRequest, dict]]): + The request object. StopReplicationRequest stops a + replication until resumed. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a + cross-region replication relationship between 2 + volumes in different regions. + + """ + # 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, replication.StopReplicationRequest): + request = replication.StopReplicationRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[self._client._transport.stop_replication] + + # 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, + replication.Replication, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def resume_replication(self, + request: Optional[Union[replication.ResumeReplicationRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Resume Cross Region Replication. + + .. 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 netapp_v1 + + async def sample_resume_replication(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ResumeReplicationRequest( + name="name_value", + ) + + # Make the request + operation = client.resume_replication(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.ResumeReplicationRequest, dict]]): + The request object. ResumeReplicationRequest resumes a + stopped replication. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a + cross-region replication relationship between 2 + volumes in different regions. + + """ + # 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, replication.ResumeReplicationRequest): + request = replication.ResumeReplicationRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[self._client._transport.resume_replication] + + # 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, + replication.Replication, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def reverse_replication_direction(self, + request: Optional[Union[replication.ReverseReplicationDirectionRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Reverses direction of replication. Source becomes + destination and destination becomes source. + + .. 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 netapp_v1 + + async def sample_reverse_replication_direction(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ReverseReplicationDirectionRequest( + name="name_value", + ) + + # Make the request + operation = client.reverse_replication_direction(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.ReverseReplicationDirectionRequest, dict]]): + The request object. ReverseReplicationDirectionRequest + reverses direction of replication. + Source becomes destination and + destination becomes source. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a + cross-region replication relationship between 2 + volumes in different regions. + + """ + # 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, replication.ReverseReplicationDirectionRequest): + request = replication.ReverseReplicationDirectionRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[self._client._transport.reverse_replication_direction] + + # 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, + replication.Replication, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def establish_peering(self, + request: Optional[Union[replication.EstablishPeeringRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Establish replication peering. + + .. 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 netapp_v1 + + async def sample_establish_peering(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.EstablishPeeringRequest( + name="name_value", + peer_cluster_name="peer_cluster_name_value", + peer_svm_name="peer_svm_name_value", + peer_volume_name="peer_volume_name_value", + ) + + # Make the request + operation = client.establish_peering(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.EstablishPeeringRequest, dict]]): + The request object. EstablishPeeringRequest establishes + cluster and svm peerings between the + source and the destination replications. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a + cross-region replication relationship between 2 + volumes in different regions. + + """ + # 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, replication.EstablishPeeringRequest): + request = replication.EstablishPeeringRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[self._client._transport.establish_peering] + + # 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, + replication.Replication, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def sync_replication(self, + request: Optional[Union[replication.SyncReplicationRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Syncs the replication. This will invoke one time + volume data transfer from source to destination. + + .. 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 netapp_v1 + + async def sample_sync_replication(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.SyncReplicationRequest( + name="name_value", + ) + + # Make the request + operation = client.sync_replication(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.SyncReplicationRequest, dict]]): + The request object. SyncReplicationRequest syncs the + replication from source to destination. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a + cross-region replication relationship between 2 + volumes in different regions. + + """ + # 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, replication.SyncReplicationRequest): + request = replication.SyncReplicationRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[self._client._transport.sync_replication] + + # 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, + replication.Replication, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def create_backup_vault(self, + request: Optional[Union[gcn_backup_vault.CreateBackupVaultRequest, dict]] = None, + *, + parent: Optional[str] = None, + backup_vault: Optional[gcn_backup_vault.BackupVault] = None, + backup_vault_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates new backup vault + + .. 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 netapp_v1 + + async def sample_create_backup_vault(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.CreateBackupVaultRequest( + parent="parent_value", + backup_vault_id="backup_vault_id_value", + ) + + # Make the request + operation = client.create_backup_vault(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.CreateBackupVaultRequest, dict]]): + The request object. CreateBackupVaultRequest creates a + backup vault. + parent (:class:`str`): + Required. The location to create the backup vaults, in + the format + ``projects/{project_id}/locations/{location}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + backup_vault (:class:`google.cloud.netapp_v1.types.BackupVault`): + Required. A backupVault resource + This corresponds to the ``backup_vault`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + backup_vault_id (:class:`str`): + Required. The ID to use for the + backupVault. The ID must be unique + within the specified location. Must + contain only letters, numbers and + hyphen, with the first character a + letter, the last a letter or a number, + and a 63 character maximum. + + This corresponds to the ``backup_vault_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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.BackupVault` A + NetApp BackupVault. + + """ + # 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. + flattened_params = [parent, backup_vault, backup_vault_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_backup_vault.CreateBackupVaultRequest): + request = gcn_backup_vault.CreateBackupVaultRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if backup_vault is not None: + request.backup_vault = backup_vault + if backup_vault_id is not None: + request.backup_vault_id = backup_vault_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_backup_vault] + + # 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, + gcn_backup_vault.BackupVault, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def get_backup_vault(self, + request: Optional[Union[backup_vault.GetBackupVaultRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> backup_vault.BackupVault: + r"""Returns the description of the specified backup vault + + .. 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 netapp_v1 + + async def sample_get_backup_vault(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.GetBackupVaultRequest( + name="name_value", + ) + + # Make the request + response = await client.get_backup_vault(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.GetBackupVaultRequest, dict]]): + The request object. GetBackupVaultRequest gets the state + of a backupVault. + name (:class:`str`): + Required. The backupVault resource name, in the format + ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}`` + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.BackupVault: + A NetApp BackupVault. + """ + # 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, backup_vault.GetBackupVaultRequest): + request = backup_vault.GetBackupVaultRequest(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_backup_vault] + + # 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_backup_vaults(self, + request: Optional[Union[backup_vault.ListBackupVaultsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListBackupVaultsAsyncPager: + r"""Returns list of all available backup vaults. + + .. 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 netapp_v1 + + async def sample_list_backup_vaults(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ListBackupVaultsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_backup_vaults(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.ListBackupVaultsRequest, dict]]): + The request object. ListBackupVaultsRequest lists + backupVaults. + parent (:class:`str`): + Required. The location for which to retrieve backupVault + information, in the format + ``projects/{project_id}/locations/{location}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.services.net_app.pagers.ListBackupVaultsAsyncPager: + ListBackupVaultsResponse is the + result of ListBackupVaultsRequest. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, backup_vault.ListBackupVaultsRequest): + request = backup_vault.ListBackupVaultsRequest(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_backup_vaults] + + # 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.ListBackupVaultsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_backup_vault(self, + request: Optional[Union[gcn_backup_vault.UpdateBackupVaultRequest, dict]] = None, + *, + backup_vault: Optional[gcn_backup_vault.BackupVault] = 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, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates the settings of a specific backup vault. + + .. 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 netapp_v1 + + async def sample_update_backup_vault(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.UpdateBackupVaultRequest( + ) + + # Make the request + operation = client.update_backup_vault(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.UpdateBackupVaultRequest, dict]]): + The request object. UpdateBackupVaultRequest updates + description and/or labels for a + backupVault. + backup_vault (:class:`google.cloud.netapp_v1.types.BackupVault`): + Required. The backupVault being + updated + + This corresponds to the ``backup_vault`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. Field mask is used to specify the fields to be + overwritten in the Backup resource to be updated. The + fields specified in the update_mask are relative to the + resource, not the full request. A field will be + overwritten if it is in the mask. If the user does not + provide a mask then all fields will be overwritten. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.BackupVault` A + NetApp BackupVault. + + """ + # 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. + flattened_params = [backup_vault, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_backup_vault.UpdateBackupVaultRequest): + request = gcn_backup_vault.UpdateBackupVaultRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if backup_vault is not None: + request.backup_vault = backup_vault + 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_backup_vault] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("backup_vault.name", request.backup_vault.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, + gcn_backup_vault.BackupVault, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_backup_vault(self, + request: Optional[Union[backup_vault.DeleteBackupVaultRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Warning! This operation will permanently delete the + backup vault. + + .. 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 netapp_v1 + + async def sample_delete_backup_vault(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteBackupVaultRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_backup_vault(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.DeleteBackupVaultRequest, dict]]): + The request object. DeleteBackupVaultRequest deletes a + backupVault. + name (:class:`str`): + Required. The backupVault resource name, in the format + ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}`` + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, backup_vault.DeleteBackupVaultRequest): + request = backup_vault.DeleteBackupVaultRequest(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_backup_vault] + + # 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=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def create_backup(self, + request: Optional[Union[gcn_backup.CreateBackupRequest, dict]] = None, + *, + parent: Optional[str] = None, + backup: Optional[gcn_backup.Backup] = None, + backup_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates a backup from the volume specified in the + request The backup can be created from the given + snapshot if specified in the request. If no snapshot + specified, there'll be a new snapshot taken to initiate + the backup creation. + + .. 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 netapp_v1 + + async def sample_create_backup(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.CreateBackupRequest( + parent="parent_value", + backup_id="backup_id_value", + ) + + # Make the request + operation = client.create_backup(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.CreateBackupRequest, dict]]): + The request object. CreateBackupRequest creates a backup. + parent (:class:`str`): + Required. The NetApp backupVault to create the backups + of, in the format + ``projects/*/locations/*/backupVaults/{backup_vault_id}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + backup (:class:`google.cloud.netapp_v1.types.Backup`): + Required. A backup resource + This corresponds to the ``backup`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + backup_id (:class:`str`): + Required. The ID to use for the + backup. The ID must be unique within the + specified backupVault. Must contain only + letters, numbers and hyphen, with the + first character a letter, the last a + letter or a number, and a 63 character + maximum. + + This corresponds to the ``backup_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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.Backup` A NetApp + Backup. + + """ + # 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. + flattened_params = [parent, backup, backup_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_backup.CreateBackupRequest): + request = gcn_backup.CreateBackupRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if backup is not None: + request.backup = backup + if backup_id is not None: + request.backup_id = backup_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_backup] + + # 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, + gcn_backup.Backup, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def get_backup(self, + request: Optional[Union[backup.GetBackupRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> backup.Backup: + r"""Returns the description of the specified backup + + .. 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 netapp_v1 + + async def sample_get_backup(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.GetBackupRequest( + name="name_value", + ) + + # Make the request + response = await client.get_backup(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.GetBackupRequest, dict]]): + The request object. GetBackupRequest gets the state of a + backup. + name (:class:`str`): + Required. The backup resource name, in the format + ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id}`` + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.Backup: + A NetApp Backup. + """ + # 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, backup.GetBackupRequest): + request = backup.GetBackupRequest(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_backup] + + # 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_backups(self, + request: Optional[Union[backup.ListBackupsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListBackupsAsyncPager: + r"""Returns descriptions of all backups for a + backupVault. + + .. 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 netapp_v1 + + async def sample_list_backups(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ListBackupsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_backups(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.ListBackupsRequest, dict]]): + The request object. ListBackupsRequest lists backups. + parent (:class:`str`): + Required. The backupVault for which to retrieve backup + information, in the format + ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}``. + To retrieve backup information for all locations, use + "-" for the ``{location}`` value. To retrieve backup + information for all backupVaults, use "-" for the + ``{backup_vault_id}`` value. To retrieve backup + information for a volume, use "-" for the + ``{backup_vault_id}`` value and specify volume full name + with the filter. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.services.net_app.pagers.ListBackupsAsyncPager: + ListBackupsResponse is the result of + ListBackupsRequest. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, backup.ListBackupsRequest): + request = backup.ListBackupsRequest(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_backups] + + # 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.ListBackupsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_backup(self, + request: Optional[Union[backup.DeleteBackupRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Warning! This operation will permanently delete the + backup. + + .. 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 netapp_v1 + + async def sample_delete_backup(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteBackupRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_backup(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.DeleteBackupRequest, dict]]): + The request object. DeleteBackupRequest deletes a backup. + name (:class:`str`): + Required. The backup resource name, in the format + ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id}`` + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, backup.DeleteBackupRequest): + request = backup.DeleteBackupRequest(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_backup] + + # 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=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_backup(self, + request: Optional[Union[gcn_backup.UpdateBackupRequest, dict]] = None, + *, + backup: Optional[gcn_backup.Backup] = 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, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Update backup with full spec. + + .. 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 netapp_v1 + + async def sample_update_backup(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.UpdateBackupRequest( + ) + + # Make the request + operation = client.update_backup(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.UpdateBackupRequest, dict]]): + The request object. UpdateBackupRequest updates + description and/or labels for a backup. + backup (:class:`google.cloud.netapp_v1.types.Backup`): + Required. The backup being updated + This corresponds to the ``backup`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. Field mask is used to specify the fields to be + overwritten in the Backup resource to be updated. The + fields specified in the update_mask are relative to the + resource, not the full request. A field will be + overwritten if it is in the mask. If the user does not + provide a mask then all fields will be overwritten. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.Backup` A NetApp + Backup. + + """ + # 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. + flattened_params = [backup, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_backup.UpdateBackupRequest): + request = gcn_backup.UpdateBackupRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if backup is not None: + request.backup = backup + 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_backup] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("backup.name", request.backup.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, + gcn_backup.Backup, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def create_backup_policy(self, + request: Optional[Union[gcn_backup_policy.CreateBackupPolicyRequest, dict]] = None, + *, + parent: Optional[str] = None, + backup_policy: Optional[gcn_backup_policy.BackupPolicy] = None, + backup_policy_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates new backup policy + + .. 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 netapp_v1 + + async def sample_create_backup_policy(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.CreateBackupPolicyRequest( + parent="parent_value", + backup_policy_id="backup_policy_id_value", + ) + + # Make the request + operation = client.create_backup_policy(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.CreateBackupPolicyRequest, dict]]): + The request object. CreateBackupPolicyRequest creates a + backupPolicy. + parent (:class:`str`): + Required. The location to create the backup policies of, + in the format + ``projects/{project_id}/locations/{location}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + backup_policy (:class:`google.cloud.netapp_v1.types.BackupPolicy`): + Required. A backupPolicy resource + This corresponds to the ``backup_policy`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + backup_policy_id (:class:`str`): + Required. The ID to use for the + backup policy. The ID must be unique + within the specified location. Must + contain only letters, numbers and + hyphen, with the first character a + letter, the last a letter or a number, + and a 63 character maximum. + + This corresponds to the ``backup_policy_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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.BackupPolicy` + Backup Policy. + + """ + # 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. + flattened_params = [parent, backup_policy, backup_policy_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_backup_policy.CreateBackupPolicyRequest): + request = gcn_backup_policy.CreateBackupPolicyRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if backup_policy is not None: + request.backup_policy = backup_policy + if backup_policy_id is not None: + request.backup_policy_id = backup_policy_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_backup_policy] + + # 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, + gcn_backup_policy.BackupPolicy, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def get_backup_policy(self, + request: Optional[Union[backup_policy.GetBackupPolicyRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> backup_policy.BackupPolicy: + r"""Returns the description of the specified backup policy by + backup_policy_id. + + .. 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 netapp_v1 + + async def sample_get_backup_policy(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.GetBackupPolicyRequest( + name="name_value", + ) + + # Make the request + response = await client.get_backup_policy(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.GetBackupPolicyRequest, dict]]): + The request object. GetBackupPolicyRequest gets the state + of a backupPolicy. + name (:class:`str`): + Required. The backupPolicy resource name, in the format + ``projects/{project_id}/locations/{location}/backupPolicies/{backup_policy_id}`` + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.BackupPolicy: + Backup Policy. + """ + # 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, backup_policy.GetBackupPolicyRequest): + request = backup_policy.GetBackupPolicyRequest(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_backup_policy] + + # 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_backup_policies(self, + request: Optional[Union[backup_policy.ListBackupPoliciesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListBackupPoliciesAsyncPager: + r"""Returns list of all available backup policies. + + .. 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 netapp_v1 + + async def sample_list_backup_policies(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ListBackupPoliciesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_backup_policies(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.ListBackupPoliciesRequest, dict]]): + The request object. ListBackupPoliciesRequest for + requesting multiple backup policies. + parent (:class:`str`): + Required. Parent value for + ListBackupPoliciesRequest + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.services.net_app.pagers.ListBackupPoliciesAsyncPager: + ListBackupPoliciesResponse contains + all the backup policies requested. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, backup_policy.ListBackupPoliciesRequest): + request = backup_policy.ListBackupPoliciesRequest(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_backup_policies] + + # 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.ListBackupPoliciesAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_backup_policy(self, + request: Optional[Union[gcn_backup_policy.UpdateBackupPolicyRequest, dict]] = None, + *, + backup_policy: Optional[gcn_backup_policy.BackupPolicy] = 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, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates settings of a specific backup policy. + + .. 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 netapp_v1 + + async def sample_update_backup_policy(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.UpdateBackupPolicyRequest( + ) + + # Make the request + operation = client.update_backup_policy(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.UpdateBackupPolicyRequest, dict]]): + The request object. UpdateBackupPolicyRequest for + updating a backup policy. + backup_policy (:class:`google.cloud.netapp_v1.types.BackupPolicy`): + Required. The backup policy being + updated + + This corresponds to the ``backup_policy`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. Field mask is used to specify the fields to be + overwritten in the Backup Policy resource by the update. + The fields specified in the update_mask are relative to + the resource, not the full request. A field will be + overwritten if it is in the mask. If the user does not + provide a mask then all fields will be overwritten. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.BackupPolicy` + Backup Policy. + + """ + # 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. + flattened_params = [backup_policy, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_backup_policy.UpdateBackupPolicyRequest): + request = gcn_backup_policy.UpdateBackupPolicyRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if backup_policy is not None: + request.backup_policy = backup_policy + 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_backup_policy] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("backup_policy.name", request.backup_policy.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, + gcn_backup_policy.BackupPolicy, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_backup_policy(self, + request: Optional[Union[backup_policy.DeleteBackupPolicyRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Warning! This operation will permanently delete the + backup policy. + + .. 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 netapp_v1 + + async def sample_delete_backup_policy(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteBackupPolicyRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_backup_policy(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.DeleteBackupPolicyRequest, dict]]): + The request object. DeleteBackupPolicyRequest deletes a + backup policy. + name (:class:`str`): + Required. The backup policy resource name, in the format + ``projects/{project_id}/locations/{location}/backupPolicies/{backup_policy_id}`` + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, backup_policy.DeleteBackupPolicyRequest): + request = backup_policy.DeleteBackupPolicyRequest(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_backup_policy] + + # 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=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def list_quota_rules(self, + request: Optional[Union[quota_rule.ListQuotaRulesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListQuotaRulesAsyncPager: + r"""Returns list of all quota rules in a location. + + .. 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 netapp_v1 + + async def sample_list_quota_rules(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ListQuotaRulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_quota_rules(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.ListQuotaRulesRequest, dict]]): + The request object. ListQuotaRulesRequest for listing + quota rules. + parent (:class:`str`): + Required. Parent value for + ListQuotaRulesRequest + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.services.net_app.pagers.ListQuotaRulesAsyncPager: + ListQuotaRulesResponse is the + response to a ListQuotaRulesRequest. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, quota_rule.ListQuotaRulesRequest): + request = quota_rule.ListQuotaRulesRequest(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_quota_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.ListQuotaRulesAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_quota_rule(self, + request: Optional[Union[quota_rule.GetQuotaRuleRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> quota_rule.QuotaRule: + r"""Returns details of the specified quota 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 netapp_v1 + + async def sample_get_quota_rule(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.GetQuotaRuleRequest( + name="name_value", + ) + + # Make the request + response = await client.get_quota_rule(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.GetQuotaRuleRequest, dict]]): + The request object. GetQuotaRuleRequest for getting a + quota rule. + name (:class:`str`): + Required. Name of the quota rule + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.QuotaRule: + QuotaRule specifies the maximum disk + space a user or group can use within a + volume. They can be used for creating + default and individual quota rules. + + """ + # 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, quota_rule.GetQuotaRuleRequest): + request = quota_rule.GetQuotaRuleRequest(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_quota_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 create_quota_rule(self, + request: Optional[Union[gcn_quota_rule.CreateQuotaRuleRequest, dict]] = None, + *, + parent: Optional[str] = None, + quota_rule: Optional[gcn_quota_rule.QuotaRule] = None, + quota_rule_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates a new quota 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 netapp_v1 + + async def sample_create_quota_rule(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + quota_rule = netapp_v1.QuotaRule() + quota_rule.type_ = "DEFAULT_GROUP_QUOTA" + quota_rule.disk_limit_mib = 1472 + + request = netapp_v1.CreateQuotaRuleRequest( + parent="parent_value", + quota_rule=quota_rule, + quota_rule_id="quota_rule_id_value", + ) + + # Make the request + operation = client.create_quota_rule(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.CreateQuotaRuleRequest, dict]]): + The request object. CreateQuotaRuleRequest for creating a + quota rule. + parent (:class:`str`): + Required. Parent value for + CreateQuotaRuleRequest + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + quota_rule (:class:`google.cloud.netapp_v1.types.QuotaRule`): + Required. Fields of the to be created + quota rule. + + This corresponds to the ``quota_rule`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + quota_rule_id (:class:`str`): + Required. ID of the quota rule to + create. Must be unique within the parent + resource. Must contain only letters, + numbers, underscore and hyphen, with the + first character a letter or underscore, + the last a letter or underscore or a + number, and a 63 character maximum. + + This corresponds to the ``quota_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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.QuotaRule` QuotaRule specifies the maximum disk space a user or group can use within a + volume. They can be used for creating default and + individual quota rules. + + """ + # 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. + flattened_params = [parent, quota_rule, quota_rule_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_quota_rule.CreateQuotaRuleRequest): + request = gcn_quota_rule.CreateQuotaRuleRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if quota_rule is not None: + request.quota_rule = quota_rule + if quota_rule_id is not None: + request.quota_rule_id = quota_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_quota_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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + gcn_quota_rule.QuotaRule, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_quota_rule(self, + request: Optional[Union[gcn_quota_rule.UpdateQuotaRuleRequest, dict]] = None, + *, + quota_rule: Optional[gcn_quota_rule.QuotaRule] = 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, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates a quota 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 netapp_v1 + + async def sample_update_quota_rule(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + quota_rule = netapp_v1.QuotaRule() + quota_rule.type_ = "DEFAULT_GROUP_QUOTA" + quota_rule.disk_limit_mib = 1472 + + request = netapp_v1.UpdateQuotaRuleRequest( + quota_rule=quota_rule, + ) + + # Make the request + operation = client.update_quota_rule(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.UpdateQuotaRuleRequest, dict]]): + The request object. UpdateQuotaRuleRequest for updating a + quota rule. + quota_rule (:class:`google.cloud.netapp_v1.types.QuotaRule`): + Required. The quota rule being + updated + + This corresponds to the ``quota_rule`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Optional. Field mask is used to specify the fields to be + overwritten in the Quota Rule resource by the update. + The fields specified in the update_mask are relative to + the resource, not the full request. A field will be + overwritten if it is in the mask. If the user does not + provide a mask then all fields will be overwritten. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.netapp_v1.types.QuotaRule` QuotaRule specifies the maximum disk space a user or group can use within a + volume. They can be used for creating default and + individual quota rules. + + """ + # 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. + flattened_params = [quota_rule, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_quota_rule.UpdateQuotaRuleRequest): + request = gcn_quota_rule.UpdateQuotaRuleRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if quota_rule is not None: + request.quota_rule = quota_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_quota_rule] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("quota_rule.name", request.quota_rule.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, + gcn_quota_rule.QuotaRule, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_quota_rule(self, + request: Optional[Union[quota_rule.DeleteQuotaRuleRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Deletes a quota 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 netapp_v1 + + async def sample_delete_quota_rule(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteQuotaRuleRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_quota_rule(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.netapp_v1.types.DeleteQuotaRuleRequest, dict]]): + The request object. DeleteQuotaRuleRequest for deleting a + single quota rule. + name (:class:`str`): + Required. Name of the quota rule. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, quota_rule.DeleteQuotaRuleRequest): + request = quota_rule.DeleteQuotaRuleRequest(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_quota_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, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def list_operations( + self, + request: Optional[operations_pb2.ListOperationsRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.ListOperationsResponse: + r"""Lists operations that match the specified filter in the request. + + Args: + request (:class:`~.operations_pb2.ListOperationsRequest`): + The request object. Request message for + `ListOperations` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + Returns: + ~.operations_pb2.ListOperationsResponse: + Response message for ``ListOperations`` 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 = operations_pb2.ListOperationsRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self.transport._wrapped_methods[self._client._transport.list_operations] + + # 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_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, Union[str, bytes]]] = (), + ) -> 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + 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 delete_operation( + self, + request: Optional[operations_pb2.DeleteOperationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> None: + r"""Deletes a long-running operation. + + This method indicates that the client is no longer interested + in the operation result. It does not cancel the operation. + If the server doesn't support this method, it returns + `google.rpc.Code.UNIMPLEMENTED`. + + Args: + request (:class:`~.operations_pb2.DeleteOperationRequest`): + The request object. Request message for + `DeleteOperation` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + Returns: + None + """ + # 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.DeleteOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self.transport._wrapped_methods[self._client._transport.delete_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. + await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + async def cancel_operation( + self, + request: Optional[operations_pb2.CancelOperationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> None: + r"""Starts asynchronous cancellation on a long-running operation. + + The server makes a best effort to cancel the operation, but success + is not guaranteed. If the server doesn't support this method, it returns + `google.rpc.Code.UNIMPLEMENTED`. + + Args: + request (:class:`~.operations_pb2.CancelOperationRequest`): + The request object. Request message for + `CancelOperation` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + Returns: + None + """ + # 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.CancelOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self.transport._wrapped_methods[self._client._transport.cancel_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. + await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + 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, Union[str, bytes]]] = (), + ) -> 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + 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, Union[str, bytes]]] = (), + ) -> 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + 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) -> "NetAppAsyncClient": + 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__ = ( + "NetAppAsyncClient", +) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/client.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/client.py new file mode 100644 index 000000000000..22fe61682ad4 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/client.py @@ -0,0 +1,8448 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 http import HTTPStatus +import json +import logging as std_logging +import os +import re +from typing import Dict, Callable, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union, cast +import warnings + +from google.cloud.netapp_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 + +try: + from google.api_core import client_logging # type: ignore + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.location import locations_pb2 # type: ignore +from google.cloud.netapp_v1.services.net_app import pagers +from google.cloud.netapp_v1.types import active_directory +from google.cloud.netapp_v1.types import active_directory as gcn_active_directory +from google.cloud.netapp_v1.types import backup +from google.cloud.netapp_v1.types import backup as gcn_backup +from google.cloud.netapp_v1.types import backup_policy +from google.cloud.netapp_v1.types import backup_policy as gcn_backup_policy +from google.cloud.netapp_v1.types import backup_vault +from google.cloud.netapp_v1.types import backup_vault as gcn_backup_vault +from google.cloud.netapp_v1.types import cloud_netapp_service +from google.cloud.netapp_v1.types import common +from google.cloud.netapp_v1.types import kms +from google.cloud.netapp_v1.types import quota_rule +from google.cloud.netapp_v1.types import quota_rule as gcn_quota_rule +from google.cloud.netapp_v1.types import replication +from google.cloud.netapp_v1.types import replication as gcn_replication +from google.cloud.netapp_v1.types import snapshot +from google.cloud.netapp_v1.types import snapshot as gcn_snapshot +from google.cloud.netapp_v1.types import storage_pool +from google.cloud.netapp_v1.types import storage_pool as gcn_storage_pool +from google.cloud.netapp_v1.types import volume +from google.cloud.netapp_v1.types import volume as gcn_volume +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 timestamp_pb2 # type: ignore +from .transports.base import NetAppTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import NetAppGrpcTransport +from .transports.grpc_asyncio import NetAppGrpcAsyncIOTransport +from .transports.rest import NetAppRestTransport + + +class NetAppClientMeta(type): + """Metaclass for the NetApp 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[NetAppTransport]] + _transport_registry["grpc"] = NetAppGrpcTransport + _transport_registry["grpc_asyncio"] = NetAppGrpcAsyncIOTransport + _transport_registry["rest"] = NetAppRestTransport + + def get_transport_class(cls, + label: Optional[str] = None, + ) -> Type[NetAppTransport]: + """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 NetAppClient(metaclass=NetAppClientMeta): + """NetApp Files Google Cloud Service""" + + @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 = "netapp.googleapis.com" + DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore + DEFAULT_ENDPOINT + ) + + _DEFAULT_ENDPOINT_TEMPLATE = "netapp.{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: + NetAppClient: 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: + NetAppClient: 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) -> NetAppTransport: + """Returns the transport used by the client instance. + + Returns: + NetAppTransport: The transport used by the client + instance. + """ + return self._transport + + @staticmethod + def active_directory_path(project: str,location: str,active_directory: str,) -> str: + """Returns a fully-qualified active_directory string.""" + return "projects/{project}/locations/{location}/activeDirectories/{active_directory}".format(project=project, location=location, active_directory=active_directory, ) + + @staticmethod + def parse_active_directory_path(path: str) -> Dict[str,str]: + """Parses a active_directory path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/activeDirectories/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def backup_path(project: str,location: str,backup_vault: str,backup: str,) -> str: + """Returns a fully-qualified backup string.""" + return "projects/{project}/locations/{location}/backupVaults/{backup_vault}/backups/{backup}".format(project=project, location=location, backup_vault=backup_vault, backup=backup, ) + + @staticmethod + def parse_backup_path(path: str) -> Dict[str,str]: + """Parses a backup path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/backupVaults/(?P.+?)/backups/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def backup_policy_path(project: str,location: str,backup_policy: str,) -> str: + """Returns a fully-qualified backup_policy string.""" + return "projects/{project}/locations/{location}/backupPolicies/{backup_policy}".format(project=project, location=location, backup_policy=backup_policy, ) + + @staticmethod + def parse_backup_policy_path(path: str) -> Dict[str,str]: + """Parses a backup_policy path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/backupPolicies/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def backup_vault_path(project: str,location: str,backup_vault: str,) -> str: + """Returns a fully-qualified backup_vault string.""" + return "projects/{project}/locations/{location}/backupVaults/{backup_vault}".format(project=project, location=location, backup_vault=backup_vault, ) + + @staticmethod + def parse_backup_vault_path(path: str) -> Dict[str,str]: + """Parses a backup_vault path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/backupVaults/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def kms_config_path(project: str,location: str,kms_config: str,) -> str: + """Returns a fully-qualified kms_config string.""" + return "projects/{project}/locations/{location}/kmsConfigs/{kms_config}".format(project=project, location=location, kms_config=kms_config, ) + + @staticmethod + def parse_kms_config_path(path: str) -> Dict[str,str]: + """Parses a kms_config path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/kmsConfigs/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def network_path(project: str,network: str,) -> str: + """Returns a fully-qualified network string.""" + return "projects/{project}/global/networks/{network}".format(project=project, network=network, ) + + @staticmethod + def parse_network_path(path: str) -> Dict[str,str]: + """Parses a network path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/global/networks/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def quota_rule_path(project: str,location: str,volume: str,quota_rule: str,) -> str: + """Returns a fully-qualified quota_rule string.""" + return "projects/{project}/locations/{location}/volumes/{volume}/quotaRules/{quota_rule}".format(project=project, location=location, volume=volume, quota_rule=quota_rule, ) + + @staticmethod + def parse_quota_rule_path(path: str) -> Dict[str,str]: + """Parses a quota_rule path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/volumes/(?P.+?)/quotaRules/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def replication_path(project: str,location: str,volume: str,replication: str,) -> str: + """Returns a fully-qualified replication string.""" + return "projects/{project}/locations/{location}/volumes/{volume}/replications/{replication}".format(project=project, location=location, volume=volume, replication=replication, ) + + @staticmethod + def parse_replication_path(path: str) -> Dict[str,str]: + """Parses a replication path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/volumes/(?P.+?)/replications/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def snapshot_path(project: str,location: str,volume: str,snapshot: str,) -> str: + """Returns a fully-qualified snapshot string.""" + return "projects/{project}/locations/{location}/volumes/{volume}/snapshots/{snapshot}".format(project=project, location=location, volume=volume, snapshot=snapshot, ) + + @staticmethod + def parse_snapshot_path(path: str) -> Dict[str,str]: + """Parses a snapshot path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/volumes/(?P.+?)/snapshots/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def storage_pool_path(project: str,location: str,storage_pool: str,) -> str: + """Returns a fully-qualified storage_pool string.""" + return "projects/{project}/locations/{location}/storagePools/{storage_pool}".format(project=project, location=location, storage_pool=storage_pool, ) + + @staticmethod + def parse_storage_pool_path(path: str) -> Dict[str,str]: + """Parses a storage_pool path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/storagePools/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def volume_path(project: str,location: str,volume: str,) -> str: + """Returns a fully-qualified volume string.""" + return "projects/{project}/locations/{location}/volumes/{volume}".format(project=project, location=location, volume=volume, ) + + @staticmethod + def parse_volume_path(path: str) -> Dict[str,str]: + """Parses a volume path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/volumes/(?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 = NetAppClient._DEFAULT_UNIVERSE + if universe_domain != _default_universe: + raise MutualTLSChannelError(f"mTLS is not supported in any universe other than {_default_universe}.") + api_endpoint = NetAppClient.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = NetAppClient._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 = NetAppClient._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 + + 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. + """ + + # NOTE (b/349488459): universe validation is disabled until further notice. + return True + + def _add_cred_info_for_auth_errors( + self, + error: core_exceptions.GoogleAPICallError + ) -> None: + """Adds credential info string to error details for 401/403/404 errors. + + Args: + error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info. + """ + if error.code not in [HTTPStatus.UNAUTHORIZED, HTTPStatus.FORBIDDEN, HTTPStatus.NOT_FOUND]: + return + + cred = self._transport._credentials + + # get_cred_info is only available in google-auth>=2.35.0 + if not hasattr(cred, "get_cred_info"): + return + + # ignore the type check since pypy test fails when get_cred_info + # is not available + cred_info = cred.get_cred_info() # type: ignore + if cred_info and hasattr(error._details, "append"): + error._details.append(json.dumps(cred_info)) + + @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, NetAppTransport, Callable[..., NetAppTransport]]] = None, + client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the net app 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,NetAppTransport,Callable[..., NetAppTransport]]]): + 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 NetAppTransport 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 = NetAppClient._read_environment_variables() + self._client_cert_source = NetAppClient._get_client_cert_source(self._client_options.client_cert_source, self._use_client_cert) + self._universe_domain = NetAppClient._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 + + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + + 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, NetAppTransport) + if transport_provided: + # transport is a NetAppTransport 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(NetAppTransport, transport) + self._api_endpoint = self._transport.host + + self._api_endpoint = (self._api_endpoint or + NetAppClient._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[NetAppTransport], Callable[..., NetAppTransport]] = ( + NetAppClient.get_transport_class(transport) + if isinstance(transport, str) or transport is None + else cast(Callable[..., NetAppTransport], 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, + ) + + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.netapp_v1.NetAppClient`.", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "universeDomain": getattr(self._transport._credentials, "universe_domain", ""), + "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}", + "credentialsInfo": getattr(self.transport._credentials, "get_cred_info", lambda: None)(), + } if hasattr(self._transport, "_credentials") else { + "serviceName": "google.cloud.netapp.v1.NetApp", + "credentialsType": None, + } + ) + + def list_storage_pools(self, + request: Optional[Union[storage_pool.ListStoragePoolsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListStoragePoolsPager: + r"""Returns descriptions of all storage pools owned by + the caller. + + .. 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 netapp_v1 + + def sample_list_storage_pools(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ListStoragePoolsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_storage_pools(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.ListStoragePoolsRequest, dict]): + The request object. ListStoragePoolsRequest lists Storage + Pools. + parent (str): + Required. Parent value + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.services.net_app.pagers.ListStoragePoolsPager: + ListStoragePoolsResponse is the + response to a ListStoragePoolsRequest. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, storage_pool.ListStoragePoolsRequest): + request = storage_pool.ListStoragePoolsRequest(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_storage_pools] + + # 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.ListStoragePoolsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_storage_pool(self, + request: Optional[Union[gcn_storage_pool.CreateStoragePoolRequest, dict]] = None, + *, + parent: Optional[str] = None, + storage_pool: Optional[gcn_storage_pool.StoragePool] = None, + storage_pool_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Creates a new storage pool. + + .. 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 netapp_v1 + + def sample_create_storage_pool(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + storage_pool = netapp_v1.StoragePool() + storage_pool.service_level = "FLEX" + storage_pool.capacity_gib = 1247 + storage_pool.network = "network_value" + + request = netapp_v1.CreateStoragePoolRequest( + parent="parent_value", + storage_pool_id="storage_pool_id_value", + storage_pool=storage_pool, + ) + + # Make the request + operation = client.create_storage_pool(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.CreateStoragePoolRequest, dict]): + The request object. CreateStoragePoolRequest creates a + Storage Pool. + parent (str): + Required. Value for parent. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + storage_pool (google.cloud.netapp_v1.types.StoragePool): + Required. The required parameters to + create a new storage pool. + + This corresponds to the ``storage_pool`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + storage_pool_id (str): + Required. Id of the requesting + storage pool. Must be unique within the + parent resource. Must contain only + letters, numbers and hyphen, with the + first character a letter, the last a + letter or a number, and a 63 character + maximum. + + This corresponds to the ``storage_pool_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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.netapp_v1.types.StoragePool` StoragePool is a container for volumes with a service level and capacity. + Volumes can be created in a pool of sufficient + available capacity. StoragePool capacity is what you + are billed for. + + """ + # 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. + flattened_params = [parent, storage_pool, storage_pool_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_storage_pool.CreateStoragePoolRequest): + request = gcn_storage_pool.CreateStoragePoolRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if storage_pool is not None: + request.storage_pool = storage_pool + if storage_pool_id is not None: + request.storage_pool_id = storage_pool_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_storage_pool] + + # 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, + gcn_storage_pool.StoragePool, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def get_storage_pool(self, + request: Optional[Union[storage_pool.GetStoragePoolRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> storage_pool.StoragePool: + r"""Returns the description of the specified storage pool + by poolId. + + .. 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 netapp_v1 + + def sample_get_storage_pool(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.GetStoragePoolRequest( + name="name_value", + ) + + # Make the request + response = client.get_storage_pool(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.GetStoragePoolRequest, dict]): + The request object. GetStoragePoolRequest gets a Storage + Pool. + name (str): + Required. Name of the storage pool + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.StoragePool: + StoragePool is a container for + volumes with a service level and + capacity. Volumes can be created in a + pool of sufficient available capacity. + StoragePool capacity is what you are + billed for. + + """ + # 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, storage_pool.GetStoragePoolRequest): + request = storage_pool.GetStoragePoolRequest(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_storage_pool] + + # 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_storage_pool(self, + request: Optional[Union[gcn_storage_pool.UpdateStoragePoolRequest, dict]] = None, + *, + storage_pool: Optional[gcn_storage_pool.StoragePool] = 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, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Updates the storage pool properties with the full + spec + + .. 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 netapp_v1 + + def sample_update_storage_pool(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + storage_pool = netapp_v1.StoragePool() + storage_pool.service_level = "FLEX" + storage_pool.capacity_gib = 1247 + storage_pool.network = "network_value" + + request = netapp_v1.UpdateStoragePoolRequest( + storage_pool=storage_pool, + ) + + # Make the request + operation = client.update_storage_pool(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.UpdateStoragePoolRequest, dict]): + The request object. UpdateStoragePoolRequest updates a + Storage Pool. + storage_pool (google.cloud.netapp_v1.types.StoragePool): + Required. The pool being updated + This corresponds to the ``storage_pool`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Field mask is used to specify the fields to be + overwritten in the StoragePool resource by the update. + The fields specified in the update_mask are relative to + the resource, not the full request. A field will be + overwritten if it is in the mask. If the user does not + provide a mask then all fields will be overwritten. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.netapp_v1.types.StoragePool` StoragePool is a container for volumes with a service level and capacity. + Volumes can be created in a pool of sufficient + available capacity. StoragePool capacity is what you + are billed for. + + """ + # 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. + flattened_params = [storage_pool, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_storage_pool.UpdateStoragePoolRequest): + request = gcn_storage_pool.UpdateStoragePoolRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if storage_pool is not None: + request.storage_pool = storage_pool + 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_storage_pool] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("storage_pool.name", request.storage_pool.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, + gcn_storage_pool.StoragePool, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_storage_pool(self, + request: Optional[Union[storage_pool.DeleteStoragePoolRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Warning! This operation will permanently delete the + storage pool. + + .. 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 netapp_v1 + + def sample_delete_storage_pool(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteStoragePoolRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_storage_pool(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.DeleteStoragePoolRequest, dict]): + The request object. DeleteStoragePoolRequest deletes a + Storage Pool. + name (str): + Required. Name of the storage pool + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, storage_pool.DeleteStoragePoolRequest): + request = storage_pool.DeleteStoragePoolRequest(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_storage_pool] + + # 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=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def validate_directory_service(self, + request: Optional[Union[storage_pool.ValidateDirectoryServiceRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""ValidateDirectoryService does a connectivity check + for a directory service policy attached to the storage + pool. + + .. 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 netapp_v1 + + def sample_validate_directory_service(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ValidateDirectoryServiceRequest( + name="name_value", + ) + + # Make the request + operation = client.validate_directory_service(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.ValidateDirectoryServiceRequest, dict]): + The request object. ValidateDirectoryServiceRequest + validates the directory service policy + attached to the storage pool. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + # - 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, storage_pool.ValidateDirectoryServiceRequest): + request = storage_pool.ValidateDirectoryServiceRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.validate_directory_service] + + # 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=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def switch_active_replica_zone(self, + request: Optional[Union[storage_pool.SwitchActiveReplicaZoneRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""This operation will switch the active/replica zone + for a regional storagePool. + + .. 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 netapp_v1 + + def sample_switch_active_replica_zone(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.SwitchActiveReplicaZoneRequest( + name="name_value", + ) + + # Make the request + operation = client.switch_active_replica_zone(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.SwitchActiveReplicaZoneRequest, dict]): + The request object. SwitchActiveReplicaZoneRequest switch + the active/replica zone for a regional + storagePool. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.netapp_v1.types.StoragePool` StoragePool is a container for volumes with a service level and capacity. + Volumes can be created in a pool of sufficient + available capacity. StoragePool capacity is what you + are billed for. + + """ + # 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, storage_pool.SwitchActiveReplicaZoneRequest): + request = storage_pool.SwitchActiveReplicaZoneRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.switch_active_replica_zone] + + # 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, + storage_pool.StoragePool, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def list_volumes(self, + request: Optional[Union[volume.ListVolumesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListVolumesPager: + r"""Lists Volumes in a given 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 netapp_v1 + + def sample_list_volumes(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ListVolumesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_volumes(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.ListVolumesRequest, dict]): + The request object. Message for requesting list of + Volumes + parent (str): + Required. Parent value for + ListVolumesRequest + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.services.net_app.pagers.ListVolumesPager: + Message for response to listing + Volumes + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, volume.ListVolumesRequest): + request = volume.ListVolumesRequest(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_volumes] + + # 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.ListVolumesPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_volume(self, + request: Optional[Union[volume.GetVolumeRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> volume.Volume: + r"""Gets details of a single Volume. + + .. 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 netapp_v1 + + def sample_get_volume(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.GetVolumeRequest( + name="name_value", + ) + + # Make the request + response = client.get_volume(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.GetVolumeRequest, dict]): + The request object. Message for getting a Volume + name (str): + Required. Name of the volume + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.Volume: + Volume provides a filesystem that you + can mount. + + """ + # 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, volume.GetVolumeRequest): + request = volume.GetVolumeRequest(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_volume] + + # 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_volume(self, + request: Optional[Union[gcn_volume.CreateVolumeRequest, dict]] = None, + *, + parent: Optional[str] = None, + volume: Optional[gcn_volume.Volume] = None, + volume_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Creates a new Volume in a given project and location. + + .. 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 netapp_v1 + + def sample_create_volume(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + volume = netapp_v1.Volume() + volume.share_name = "share_name_value" + volume.storage_pool = "storage_pool_value" + volume.capacity_gib = 1247 + volume.protocols = ['SMB'] + + request = netapp_v1.CreateVolumeRequest( + parent="parent_value", + volume_id="volume_id_value", + volume=volume, + ) + + # Make the request + operation = client.create_volume(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.CreateVolumeRequest, dict]): + The request object. Message for creating a Volume + parent (str): + Required. Value for parent. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + volume (google.cloud.netapp_v1.types.Volume): + Required. The volume being created. + This corresponds to the ``volume`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + volume_id (str): + Required. Id of the requesting + volume. Must be unique within the parent + resource. Must contain only letters, + numbers and hyphen, with the first + character a letter, the last a letter or + a number, and a 63 character maximum. + + This corresponds to the ``volume_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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.netapp_v1.types.Volume` Volume + provides a filesystem that you can mount. + + """ + # 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. + flattened_params = [parent, volume, volume_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_volume.CreateVolumeRequest): + request = gcn_volume.CreateVolumeRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if volume is not None: + request.volume = volume + if volume_id is not None: + request.volume_id = volume_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_volume] + + # 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, + gcn_volume.Volume, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_volume(self, + request: Optional[Union[gcn_volume.UpdateVolumeRequest, dict]] = None, + *, + volume: Optional[gcn_volume.Volume] = 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, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Updates the parameters of a single Volume. + + .. 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 netapp_v1 + + def sample_update_volume(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + volume = netapp_v1.Volume() + volume.share_name = "share_name_value" + volume.storage_pool = "storage_pool_value" + volume.capacity_gib = 1247 + volume.protocols = ['SMB'] + + request = netapp_v1.UpdateVolumeRequest( + volume=volume, + ) + + # Make the request + operation = client.update_volume(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.UpdateVolumeRequest, dict]): + The request object. Message for updating a Volume + volume (google.cloud.netapp_v1.types.Volume): + Required. The volume being updated + This corresponds to the ``volume`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Field mask is used to specify the fields to be + overwritten in the Volume resource by the update. The + fields specified in the update_mask are relative to the + resource, not the full request. A field will be + overwritten if it is in the mask. If the user does not + provide a mask then all fields will be overwritten. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.netapp_v1.types.Volume` Volume + provides a filesystem that you can mount. + + """ + # 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. + flattened_params = [volume, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_volume.UpdateVolumeRequest): + request = gcn_volume.UpdateVolumeRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if volume is not None: + request.volume = volume + 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_volume] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("volume.name", request.volume.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, + gcn_volume.Volume, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_volume(self, + request: Optional[Union[volume.DeleteVolumeRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Deletes a single Volume. + + .. 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 netapp_v1 + + def sample_delete_volume(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteVolumeRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_volume(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.DeleteVolumeRequest, dict]): + The request object. Message for deleting a Volume + name (str): + Required. Name of the volume + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, volume.DeleteVolumeRequest): + request = volume.DeleteVolumeRequest(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_volume] + + # 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=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def revert_volume(self, + request: Optional[Union[volume.RevertVolumeRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Revert an existing volume to a specified snapshot. + Warning! This operation will permanently revert all + changes made after the snapshot was created. + + .. 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 netapp_v1 + + def sample_revert_volume(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.RevertVolumeRequest( + name="name_value", + snapshot_id="snapshot_id_value", + ) + + # Make the request + operation = client.revert_volume(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.RevertVolumeRequest, dict]): + The request object. RevertVolumeRequest reverts the given + volume to the specified snapshot. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.netapp_v1.types.Volume` Volume + provides a filesystem that you can mount. + + """ + # 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, volume.RevertVolumeRequest): + request = volume.RevertVolumeRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.revert_volume] + + # 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, + volume.Volume, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def list_snapshots(self, + request: Optional[Union[snapshot.ListSnapshotsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListSnapshotsPager: + r"""Returns descriptions of all snapshots for a volume. + + .. 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 netapp_v1 + + def sample_list_snapshots(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ListSnapshotsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_snapshots(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.ListSnapshotsRequest, dict]): + The request object. ListSnapshotsRequest lists snapshots. + parent (str): + Required. The volume for which to retrieve snapshot + information, in the format + ``projects/{project_id}/locations/{location}/volumes/{volume_id}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.services.net_app.pagers.ListSnapshotsPager: + ListSnapshotsResponse is the result + of ListSnapshotsRequest. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, snapshot.ListSnapshotsRequest): + request = snapshot.ListSnapshotsRequest(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_snapshots] + + # 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.ListSnapshotsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_snapshot(self, + request: Optional[Union[snapshot.GetSnapshotRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> snapshot.Snapshot: + r"""Describe a snapshot for a volume. + + .. 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 netapp_v1 + + def sample_get_snapshot(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.GetSnapshotRequest( + name="name_value", + ) + + # Make the request + response = client.get_snapshot(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.GetSnapshotRequest, dict]): + The request object. GetSnapshotRequest gets the state of + a snapshot. + name (str): + Required. The snapshot resource name, in the format + ``projects/{project_id}/locations/{location}/volumes/{volume_id}/snapshots/{snapshot_id}`` + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.Snapshot: + Snapshot is a point-in-time version + of a Volume's content. + + """ + # 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, snapshot.GetSnapshotRequest): + request = snapshot.GetSnapshotRequest(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_snapshot] + + # 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_snapshot(self, + request: Optional[Union[gcn_snapshot.CreateSnapshotRequest, dict]] = None, + *, + parent: Optional[str] = None, + snapshot: Optional[gcn_snapshot.Snapshot] = None, + snapshot_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Create a new snapshot for a volume. + + .. 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 netapp_v1 + + def sample_create_snapshot(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.CreateSnapshotRequest( + parent="parent_value", + snapshot_id="snapshot_id_value", + ) + + # Make the request + operation = client.create_snapshot(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.CreateSnapshotRequest, dict]): + The request object. CreateSnapshotRequest creates a + snapshot. + parent (str): + Required. The NetApp volume to create the snapshots of, + in the format + ``projects/{project_id}/locations/{location}/volumes/{volume_id}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + snapshot (google.cloud.netapp_v1.types.Snapshot): + Required. A snapshot resource + This corresponds to the ``snapshot`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + snapshot_id (str): + Required. ID of the snapshot to + create. Must be unique within the parent + resource. Must contain only letters, + numbers and hyphen, with the first + character a letter, the last a letter or + a number, and a 63 character maximum. + + This corresponds to the ``snapshot_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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.netapp_v1.types.Snapshot` Snapshot + is a point-in-time version of a Volume's content. + + """ + # 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. + flattened_params = [parent, snapshot, snapshot_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_snapshot.CreateSnapshotRequest): + request = gcn_snapshot.CreateSnapshotRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if snapshot is not None: + request.snapshot = snapshot + if snapshot_id is not None: + request.snapshot_id = snapshot_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_snapshot] + + # 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, + gcn_snapshot.Snapshot, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_snapshot(self, + request: Optional[Union[snapshot.DeleteSnapshotRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Deletes a snapshot. + + .. 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 netapp_v1 + + def sample_delete_snapshot(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteSnapshotRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_snapshot(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.DeleteSnapshotRequest, dict]): + The request object. DeleteSnapshotRequest deletes a + snapshot. + name (str): + Required. The snapshot resource name, in the format + ``projects/*/locations/*/volumes/*/snapshots/{snapshot_id}`` + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, snapshot.DeleteSnapshotRequest): + request = snapshot.DeleteSnapshotRequest(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_snapshot] + + # 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=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_snapshot(self, + request: Optional[Union[gcn_snapshot.UpdateSnapshotRequest, dict]] = None, + *, + snapshot: Optional[gcn_snapshot.Snapshot] = 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, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Updates the settings of a specific snapshot. + + .. 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 netapp_v1 + + def sample_update_snapshot(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.UpdateSnapshotRequest( + ) + + # Make the request + operation = client.update_snapshot(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.UpdateSnapshotRequest, dict]): + The request object. UpdateSnapshotRequest updates + description and/or labels for a + snapshot. + snapshot (google.cloud.netapp_v1.types.Snapshot): + Required. A snapshot resource + This corresponds to the ``snapshot`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Mask of fields to update. + At least one path must be supplied in + this field. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.netapp_v1.types.Snapshot` Snapshot + is a point-in-time version of a Volume's content. + + """ + # 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. + flattened_params = [snapshot, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_snapshot.UpdateSnapshotRequest): + request = gcn_snapshot.UpdateSnapshotRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if snapshot is not None: + request.snapshot = snapshot + 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_snapshot] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("snapshot.name", request.snapshot.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, + gcn_snapshot.Snapshot, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def list_active_directories(self, + request: Optional[Union[active_directory.ListActiveDirectoriesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListActiveDirectoriesPager: + r"""Lists active directories. + + .. 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 netapp_v1 + + def sample_list_active_directories(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ListActiveDirectoriesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_active_directories(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.ListActiveDirectoriesRequest, dict]): + The request object. ListActiveDirectoriesRequest for + requesting multiple active directories. + parent (str): + Required. Parent value for + ListActiveDirectoriesRequest + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.services.net_app.pagers.ListActiveDirectoriesPager: + ListActiveDirectoriesResponse + contains all the active directories + requested. 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, active_directory.ListActiveDirectoriesRequest): + request = active_directory.ListActiveDirectoriesRequest(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_active_directories] + + # 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.ListActiveDirectoriesPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_active_directory(self, + request: Optional[Union[active_directory.GetActiveDirectoryRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> active_directory.ActiveDirectory: + r"""Describes a specified active directory. + + .. 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 netapp_v1 + + def sample_get_active_directory(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.GetActiveDirectoryRequest( + name="name_value", + ) + + # Make the request + response = client.get_active_directory(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.GetActiveDirectoryRequest, dict]): + The request object. GetActiveDirectory for getting a + single active directory. + name (str): + Required. Name of the active + directory. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.ActiveDirectory: + ActiveDirectory is the public + representation of the active directory + config. + + """ + # 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, active_directory.GetActiveDirectoryRequest): + request = active_directory.GetActiveDirectoryRequest(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_active_directory] + + # 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_active_directory(self, + request: Optional[Union[gcn_active_directory.CreateActiveDirectoryRequest, dict]] = None, + *, + parent: Optional[str] = None, + active_directory: Optional[gcn_active_directory.ActiveDirectory] = None, + active_directory_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""CreateActiveDirectory + Creates the active directory specified in the request. + + .. 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 netapp_v1 + + def sample_create_active_directory(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + active_directory = netapp_v1.ActiveDirectory() + active_directory.domain = "domain_value" + active_directory.dns = "dns_value" + active_directory.net_bios_prefix = "net_bios_prefix_value" + active_directory.username = "username_value" + active_directory.password = "password_value" + + request = netapp_v1.CreateActiveDirectoryRequest( + parent="parent_value", + active_directory=active_directory, + active_directory_id="active_directory_id_value", + ) + + # Make the request + operation = client.create_active_directory(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.CreateActiveDirectoryRequest, dict]): + The request object. CreateActiveDirectoryRequest for + creating an active directory. + parent (str): + Required. Value for parent. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + active_directory (google.cloud.netapp_v1.types.ActiveDirectory): + Required. Fields of the to be created + active directory. + + This corresponds to the ``active_directory`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + active_directory_id (str): + Required. ID of the active directory + to create. Must be unique within the + parent resource. Must contain only + letters, numbers and hyphen, with the + first character a letter , the last a + letter or a number, and a 63 character + maximum. + + This corresponds to the ``active_directory_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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.netapp_v1.types.ActiveDirectory` + ActiveDirectory is the public representation of the + active directory config. + + """ + # 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. + flattened_params = [parent, active_directory, active_directory_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_active_directory.CreateActiveDirectoryRequest): + request = gcn_active_directory.CreateActiveDirectoryRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if active_directory is not None: + request.active_directory = active_directory + if active_directory_id is not None: + request.active_directory_id = active_directory_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_active_directory] + + # 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, + gcn_active_directory.ActiveDirectory, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_active_directory(self, + request: Optional[Union[gcn_active_directory.UpdateActiveDirectoryRequest, dict]] = None, + *, + active_directory: Optional[gcn_active_directory.ActiveDirectory] = 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, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Update the parameters of an active directories. + + .. 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 netapp_v1 + + def sample_update_active_directory(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + active_directory = netapp_v1.ActiveDirectory() + active_directory.domain = "domain_value" + active_directory.dns = "dns_value" + active_directory.net_bios_prefix = "net_bios_prefix_value" + active_directory.username = "username_value" + active_directory.password = "password_value" + + request = netapp_v1.UpdateActiveDirectoryRequest( + active_directory=active_directory, + ) + + # Make the request + operation = client.update_active_directory(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.UpdateActiveDirectoryRequest, dict]): + The request object. UpdateActiveDirectoryRequest for + updating an active directory. + active_directory (google.cloud.netapp_v1.types.ActiveDirectory): + Required. The volume being updated + This corresponds to the ``active_directory`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Field mask is used to specify the fields to be + overwritten in the Active Directory resource by the + update. The fields specified in the update_mask are + relative to the resource, not the full request. A field + will be overwritten if it is in the mask. If the user + does not provide a mask then all fields will be + overwritten. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.netapp_v1.types.ActiveDirectory` + ActiveDirectory is the public representation of the + active directory config. + + """ + # 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. + flattened_params = [active_directory, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_active_directory.UpdateActiveDirectoryRequest): + request = gcn_active_directory.UpdateActiveDirectoryRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if active_directory is not None: + request.active_directory = active_directory + 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_active_directory] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("active_directory.name", request.active_directory.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, + gcn_active_directory.ActiveDirectory, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_active_directory(self, + request: Optional[Union[active_directory.DeleteActiveDirectoryRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Delete the active directory specified in the request. + + .. 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 netapp_v1 + + def sample_delete_active_directory(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteActiveDirectoryRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_active_directory(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.DeleteActiveDirectoryRequest, dict]): + The request object. DeleteActiveDirectoryRequest for + deleting a single active directory. + name (str): + Required. Name of the active + directory. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, active_directory.DeleteActiveDirectoryRequest): + request = active_directory.DeleteActiveDirectoryRequest(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_active_directory] + + # 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=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def list_kms_configs(self, + request: Optional[Union[kms.ListKmsConfigsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListKmsConfigsPager: + r"""Returns descriptions of all KMS configs owned by the + caller. + + .. 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 netapp_v1 + + def sample_list_kms_configs(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ListKmsConfigsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_kms_configs(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.ListKmsConfigsRequest, dict]): + The request object. ListKmsConfigsRequest lists KMS + Configs. + parent (str): + Required. Parent value + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.services.net_app.pagers.ListKmsConfigsPager: + ListKmsConfigsResponse is the + response to a ListKmsConfigsRequest. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, kms.ListKmsConfigsRequest): + request = kms.ListKmsConfigsRequest(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_kms_configs] + + # 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.ListKmsConfigsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_kms_config(self, + request: Optional[Union[kms.CreateKmsConfigRequest, dict]] = None, + *, + parent: Optional[str] = None, + kms_config: Optional[kms.KmsConfig] = None, + kms_config_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Creates a new KMS config. + + .. 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 netapp_v1 + + def sample_create_kms_config(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + kms_config = netapp_v1.KmsConfig() + kms_config.crypto_key_name = "crypto_key_name_value" + + request = netapp_v1.CreateKmsConfigRequest( + parent="parent_value", + kms_config_id="kms_config_id_value", + kms_config=kms_config, + ) + + # Make the request + operation = client.create_kms_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.CreateKmsConfigRequest, dict]): + The request object. CreateKmsConfigRequest creates a KMS + Config. + parent (str): + Required. Value for parent. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + kms_config (google.cloud.netapp_v1.types.KmsConfig): + Required. The required parameters to + create a new KmsConfig. + + This corresponds to the ``kms_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + kms_config_id (str): + Required. Id of the requesting + KmsConfig. Must be unique within the + parent resource. Must contain only + letters, numbers and hyphen, with the + first character a letter, the last a + letter or a number, and a 63 character + maximum. + + This corresponds to the ``kms_config_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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.netapp_v1.types.KmsConfig` + KmsConfig is the customer managed encryption key(CMEK) + configuration. + + """ + # 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. + flattened_params = [parent, kms_config, kms_config_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, kms.CreateKmsConfigRequest): + request = kms.CreateKmsConfigRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if kms_config is not None: + request.kms_config = kms_config + if kms_config_id is not None: + request.kms_config_id = kms_config_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_kms_config] + + # 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, + kms.KmsConfig, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def get_kms_config(self, + request: Optional[Union[kms.GetKmsConfigRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> kms.KmsConfig: + r"""Returns the description of the specified KMS config by + kms_config_id. + + .. 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 netapp_v1 + + def sample_get_kms_config(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.GetKmsConfigRequest( + name="name_value", + ) + + # Make the request + response = client.get_kms_config(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.GetKmsConfigRequest, dict]): + The request object. GetKmsConfigRequest gets a KMS + Config. + name (str): + Required. Name of the KmsConfig + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.KmsConfig: + KmsConfig is the customer managed + encryption key(CMEK) configuration. + + """ + # 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, kms.GetKmsConfigRequest): + request = kms.GetKmsConfigRequest(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_kms_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_kms_config(self, + request: Optional[Union[kms.UpdateKmsConfigRequest, dict]] = None, + *, + kms_config: Optional[kms.KmsConfig] = 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, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Updates the Kms config properties with the full spec + + .. 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 netapp_v1 + + def sample_update_kms_config(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + kms_config = netapp_v1.KmsConfig() + kms_config.crypto_key_name = "crypto_key_name_value" + + request = netapp_v1.UpdateKmsConfigRequest( + kms_config=kms_config, + ) + + # Make the request + operation = client.update_kms_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.UpdateKmsConfigRequest, dict]): + The request object. UpdateKmsConfigRequest updates a KMS + Config. + kms_config (google.cloud.netapp_v1.types.KmsConfig): + Required. The KmsConfig being updated + This corresponds to the ``kms_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Field mask is used to specify the fields to be + overwritten in the KmsConfig resource by the update. The + fields specified in the update_mask are relative to the + resource, not the full request. A field will be + overwritten if it is in the mask. If the user does not + provide a mask then all fields will be overwritten. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.netapp_v1.types.KmsConfig` + KmsConfig is the customer managed encryption key(CMEK) + configuration. + + """ + # 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. + flattened_params = [kms_config, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, kms.UpdateKmsConfigRequest): + request = kms.UpdateKmsConfigRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if kms_config is not None: + request.kms_config = kms_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_kms_config] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("kms_config.name", request.kms_config.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, + kms.KmsConfig, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def encrypt_volumes(self, + request: Optional[Union[kms.EncryptVolumesRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Encrypt the existing volumes without CMEK encryption + with the desired the KMS config for the whole region. + + .. 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 netapp_v1 + + def sample_encrypt_volumes(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.EncryptVolumesRequest( + name="name_value", + ) + + # Make the request + operation = client.encrypt_volumes(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.EncryptVolumesRequest, dict]): + The request object. EncryptVolumesRequest specifies the + KMS config to encrypt existing volumes. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.netapp_v1.types.KmsConfig` + KmsConfig is the customer managed encryption key(CMEK) + configuration. + + """ + # 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, kms.EncryptVolumesRequest): + request = kms.EncryptVolumesRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.encrypt_volumes] + + # 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, + kms.KmsConfig, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def verify_kms_config(self, + request: Optional[Union[kms.VerifyKmsConfigRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> kms.VerifyKmsConfigResponse: + r"""Verifies KMS config reachability. + + .. 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 netapp_v1 + + def sample_verify_kms_config(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.VerifyKmsConfigRequest( + name="name_value", + ) + + # Make the request + response = client.verify_kms_config(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.VerifyKmsConfigRequest, dict]): + The request object. VerifyKmsConfigRequest specifies the + KMS config to be validated. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.VerifyKmsConfigResponse: + VerifyKmsConfigResponse contains the + information if the config is correctly + and error message. + + """ + # 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, kms.VerifyKmsConfigRequest): + request = kms.VerifyKmsConfigRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.verify_kms_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 delete_kms_config(self, + request: Optional[Union[kms.DeleteKmsConfigRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Warning! This operation will permanently delete the + Kms config. + + .. 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 netapp_v1 + + def sample_delete_kms_config(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteKmsConfigRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_kms_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.DeleteKmsConfigRequest, dict]): + The request object. DeleteKmsConfigRequest deletes a KMS + Config. + name (str): + Required. Name of the KmsConfig. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, kms.DeleteKmsConfigRequest): + request = kms.DeleteKmsConfigRequest(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_kms_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, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + empty_pb2.Empty, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def list_replications(self, + request: Optional[Union[replication.ListReplicationsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListReplicationsPager: + r"""Returns descriptions of all replications for a + volume. + + .. 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 netapp_v1 + + def sample_list_replications(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ListReplicationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_replications(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.ListReplicationsRequest, dict]): + The request object. ListReplications lists replications. + parent (str): + Required. The volume for which to retrieve replication + information, in the format + ``projects/{project_id}/locations/{location}/volumes/{volume_id}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.services.net_app.pagers.ListReplicationsPager: + ListReplicationsResponse is the + result of ListReplicationsRequest. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, replication.ListReplicationsRequest): + request = replication.ListReplicationsRequest(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_replications] + + # 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.ListReplicationsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_replication(self, + request: Optional[Union[replication.GetReplicationRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> replication.Replication: + r"""Describe a replication for a volume. + + .. 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 netapp_v1 + + def sample_get_replication(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.GetReplicationRequest( + name="name_value", + ) + + # Make the request + response = client.get_replication(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.GetReplicationRequest, dict]): + The request object. GetReplicationRequest gets the state + of a replication. + name (str): + Required. The replication resource name, in the format + ``projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}`` + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.Replication: + Replication is a nested resource + under Volume, that describes a + cross-region replication relationship + between 2 volumes in different regions. + + """ + # 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, replication.GetReplicationRequest): + request = replication.GetReplicationRequest(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_replication] + + # 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_replication(self, + request: Optional[Union[gcn_replication.CreateReplicationRequest, dict]] = None, + *, + parent: Optional[str] = None, + replication: Optional[gcn_replication.Replication] = None, + replication_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Create a new replication for a volume. + + .. 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 netapp_v1 + + def sample_create_replication(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + replication = netapp_v1.Replication() + replication.replication_schedule = "DAILY" + replication.destination_volume_parameters.storage_pool = "storage_pool_value" + + request = netapp_v1.CreateReplicationRequest( + parent="parent_value", + replication=replication, + replication_id="replication_id_value", + ) + + # Make the request + operation = client.create_replication(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.CreateReplicationRequest, dict]): + The request object. CreateReplicationRequest creates a + replication. + parent (str): + Required. The NetApp volume to create the replications + of, in the format + ``projects/{project_id}/locations/{location}/volumes/{volume_id}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + replication (google.cloud.netapp_v1.types.Replication): + Required. A replication resource + This corresponds to the ``replication`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + replication_id (str): + Required. ID of the replication to + create. Must be unique within the parent + resource. Must contain only letters, + numbers and hyphen, with the first + character a letter, the last a letter or + a number, and a 63 character maximum. + + This corresponds to the ``replication_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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a + cross-region replication relationship between 2 + volumes in different regions. + + """ + # 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. + flattened_params = [parent, replication, replication_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_replication.CreateReplicationRequest): + request = gcn_replication.CreateReplicationRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if replication is not None: + request.replication = replication + if replication_id is not None: + request.replication_id = replication_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_replication] + + # 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, + gcn_replication.Replication, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_replication(self, + request: Optional[Union[replication.DeleteReplicationRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Deletes a replication. + + .. 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 netapp_v1 + + def sample_delete_replication(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteReplicationRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_replication(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.DeleteReplicationRequest, dict]): + The request object. DeleteReplicationRequest deletes a + replication. + name (str): + Required. The replication resource name, in the format + ``projects/*/locations/*/volumes/*/replications/{replication_id}`` + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, replication.DeleteReplicationRequest): + request = replication.DeleteReplicationRequest(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_replication] + + # 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=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_replication(self, + request: Optional[Union[gcn_replication.UpdateReplicationRequest, dict]] = None, + *, + replication: Optional[gcn_replication.Replication] = 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, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Updates the settings of a specific replication. + + .. 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 netapp_v1 + + def sample_update_replication(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + replication = netapp_v1.Replication() + replication.replication_schedule = "DAILY" + replication.destination_volume_parameters.storage_pool = "storage_pool_value" + + request = netapp_v1.UpdateReplicationRequest( + replication=replication, + ) + + # Make the request + operation = client.update_replication(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.UpdateReplicationRequest, dict]): + The request object. UpdateReplicationRequest updates + description and/or labels for a + replication. + replication (google.cloud.netapp_v1.types.Replication): + Required. A replication resource + This corresponds to the ``replication`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Mask of fields to update. + At least one path must be supplied in + this field. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a + cross-region replication relationship between 2 + volumes in different regions. + + """ + # 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. + flattened_params = [replication, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_replication.UpdateReplicationRequest): + request = gcn_replication.UpdateReplicationRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if replication is not None: + request.replication = replication + 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_replication] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("replication.name", request.replication.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, + gcn_replication.Replication, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def stop_replication(self, + request: Optional[Union[replication.StopReplicationRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Stop Cross Region Replication. + + .. 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 netapp_v1 + + def sample_stop_replication(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.StopReplicationRequest( + name="name_value", + ) + + # Make the request + operation = client.stop_replication(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.StopReplicationRequest, dict]): + The request object. StopReplicationRequest stops a + replication until resumed. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a + cross-region replication relationship between 2 + volumes in different regions. + + """ + # 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, replication.StopReplicationRequest): + request = replication.StopReplicationRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.stop_replication] + + # 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, + replication.Replication, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def resume_replication(self, + request: Optional[Union[replication.ResumeReplicationRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Resume Cross Region Replication. + + .. 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 netapp_v1 + + def sample_resume_replication(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ResumeReplicationRequest( + name="name_value", + ) + + # Make the request + operation = client.resume_replication(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.ResumeReplicationRequest, dict]): + The request object. ResumeReplicationRequest resumes a + stopped replication. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a + cross-region replication relationship between 2 + volumes in different regions. + + """ + # 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, replication.ResumeReplicationRequest): + request = replication.ResumeReplicationRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.resume_replication] + + # 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, + replication.Replication, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def reverse_replication_direction(self, + request: Optional[Union[replication.ReverseReplicationDirectionRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Reverses direction of replication. Source becomes + destination and destination becomes source. + + .. 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 netapp_v1 + + def sample_reverse_replication_direction(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ReverseReplicationDirectionRequest( + name="name_value", + ) + + # Make the request + operation = client.reverse_replication_direction(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.ReverseReplicationDirectionRequest, dict]): + The request object. ReverseReplicationDirectionRequest + reverses direction of replication. + Source becomes destination and + destination becomes source. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a + cross-region replication relationship between 2 + volumes in different regions. + + """ + # 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, replication.ReverseReplicationDirectionRequest): + request = replication.ReverseReplicationDirectionRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.reverse_replication_direction] + + # 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, + replication.Replication, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def establish_peering(self, + request: Optional[Union[replication.EstablishPeeringRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Establish replication peering. + + .. 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 netapp_v1 + + def sample_establish_peering(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.EstablishPeeringRequest( + name="name_value", + peer_cluster_name="peer_cluster_name_value", + peer_svm_name="peer_svm_name_value", + peer_volume_name="peer_volume_name_value", + ) + + # Make the request + operation = client.establish_peering(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.EstablishPeeringRequest, dict]): + The request object. EstablishPeeringRequest establishes + cluster and svm peerings between the + source and the destination replications. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a + cross-region replication relationship between 2 + volumes in different regions. + + """ + # 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, replication.EstablishPeeringRequest): + request = replication.EstablishPeeringRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.establish_peering] + + # 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, + replication.Replication, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def sync_replication(self, + request: Optional[Union[replication.SyncReplicationRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Syncs the replication. This will invoke one time + volume data transfer from source to destination. + + .. 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 netapp_v1 + + def sample_sync_replication(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.SyncReplicationRequest( + name="name_value", + ) + + # Make the request + operation = client.sync_replication(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.SyncReplicationRequest, dict]): + The request object. SyncReplicationRequest syncs the + replication from source to destination. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a + cross-region replication relationship between 2 + volumes in different regions. + + """ + # 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, replication.SyncReplicationRequest): + request = replication.SyncReplicationRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.sync_replication] + + # 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, + replication.Replication, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def create_backup_vault(self, + request: Optional[Union[gcn_backup_vault.CreateBackupVaultRequest, dict]] = None, + *, + parent: Optional[str] = None, + backup_vault: Optional[gcn_backup_vault.BackupVault] = None, + backup_vault_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Creates new backup vault + + .. 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 netapp_v1 + + def sample_create_backup_vault(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.CreateBackupVaultRequest( + parent="parent_value", + backup_vault_id="backup_vault_id_value", + ) + + # Make the request + operation = client.create_backup_vault(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.CreateBackupVaultRequest, dict]): + The request object. CreateBackupVaultRequest creates a + backup vault. + parent (str): + Required. The location to create the backup vaults, in + the format + ``projects/{project_id}/locations/{location}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + backup_vault (google.cloud.netapp_v1.types.BackupVault): + Required. A backupVault resource + This corresponds to the ``backup_vault`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + backup_vault_id (str): + Required. The ID to use for the + backupVault. The ID must be unique + within the specified location. Must + contain only letters, numbers and + hyphen, with the first character a + letter, the last a letter or a number, + and a 63 character maximum. + + This corresponds to the ``backup_vault_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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.netapp_v1.types.BackupVault` A + NetApp BackupVault. + + """ + # 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. + flattened_params = [parent, backup_vault, backup_vault_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_backup_vault.CreateBackupVaultRequest): + request = gcn_backup_vault.CreateBackupVaultRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if backup_vault is not None: + request.backup_vault = backup_vault + if backup_vault_id is not None: + request.backup_vault_id = backup_vault_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_backup_vault] + + # 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, + gcn_backup_vault.BackupVault, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def get_backup_vault(self, + request: Optional[Union[backup_vault.GetBackupVaultRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> backup_vault.BackupVault: + r"""Returns the description of the specified backup vault + + .. 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 netapp_v1 + + def sample_get_backup_vault(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.GetBackupVaultRequest( + name="name_value", + ) + + # Make the request + response = client.get_backup_vault(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.GetBackupVaultRequest, dict]): + The request object. GetBackupVaultRequest gets the state + of a backupVault. + name (str): + Required. The backupVault resource name, in the format + ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}`` + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.BackupVault: + A NetApp BackupVault. + """ + # 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, backup_vault.GetBackupVaultRequest): + request = backup_vault.GetBackupVaultRequest(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_backup_vault] + + # 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_backup_vaults(self, + request: Optional[Union[backup_vault.ListBackupVaultsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListBackupVaultsPager: + r"""Returns list of all available backup vaults. + + .. 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 netapp_v1 + + def sample_list_backup_vaults(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ListBackupVaultsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_backup_vaults(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.ListBackupVaultsRequest, dict]): + The request object. ListBackupVaultsRequest lists + backupVaults. + parent (str): + Required. The location for which to retrieve backupVault + information, in the format + ``projects/{project_id}/locations/{location}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.services.net_app.pagers.ListBackupVaultsPager: + ListBackupVaultsResponse is the + result of ListBackupVaultsRequest. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, backup_vault.ListBackupVaultsRequest): + request = backup_vault.ListBackupVaultsRequest(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_backup_vaults] + + # 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.ListBackupVaultsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_backup_vault(self, + request: Optional[Union[gcn_backup_vault.UpdateBackupVaultRequest, dict]] = None, + *, + backup_vault: Optional[gcn_backup_vault.BackupVault] = 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, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Updates the settings of a specific backup vault. + + .. 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 netapp_v1 + + def sample_update_backup_vault(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.UpdateBackupVaultRequest( + ) + + # Make the request + operation = client.update_backup_vault(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.UpdateBackupVaultRequest, dict]): + The request object. UpdateBackupVaultRequest updates + description and/or labels for a + backupVault. + backup_vault (google.cloud.netapp_v1.types.BackupVault): + Required. The backupVault being + updated + + This corresponds to the ``backup_vault`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Field mask is used to specify the fields to be + overwritten in the Backup resource to be updated. The + fields specified in the update_mask are relative to the + resource, not the full request. A field will be + overwritten if it is in the mask. If the user does not + provide a mask then all fields will be overwritten. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.netapp_v1.types.BackupVault` A + NetApp BackupVault. + + """ + # 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. + flattened_params = [backup_vault, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_backup_vault.UpdateBackupVaultRequest): + request = gcn_backup_vault.UpdateBackupVaultRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if backup_vault is not None: + request.backup_vault = backup_vault + 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_backup_vault] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("backup_vault.name", request.backup_vault.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, + gcn_backup_vault.BackupVault, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_backup_vault(self, + request: Optional[Union[backup_vault.DeleteBackupVaultRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Warning! This operation will permanently delete the + backup vault. + + .. 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 netapp_v1 + + def sample_delete_backup_vault(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteBackupVaultRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_backup_vault(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.DeleteBackupVaultRequest, dict]): + The request object. DeleteBackupVaultRequest deletes a + backupVault. + name (str): + Required. The backupVault resource name, in the format + ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}`` + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, backup_vault.DeleteBackupVaultRequest): + request = backup_vault.DeleteBackupVaultRequest(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_backup_vault] + + # 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=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def create_backup(self, + request: Optional[Union[gcn_backup.CreateBackupRequest, dict]] = None, + *, + parent: Optional[str] = None, + backup: Optional[gcn_backup.Backup] = None, + backup_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Creates a backup from the volume specified in the + request The backup can be created from the given + snapshot if specified in the request. If no snapshot + specified, there'll be a new snapshot taken to initiate + the backup creation. + + .. 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 netapp_v1 + + def sample_create_backup(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.CreateBackupRequest( + parent="parent_value", + backup_id="backup_id_value", + ) + + # Make the request + operation = client.create_backup(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.CreateBackupRequest, dict]): + The request object. CreateBackupRequest creates a backup. + parent (str): + Required. The NetApp backupVault to create the backups + of, in the format + ``projects/*/locations/*/backupVaults/{backup_vault_id}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + backup (google.cloud.netapp_v1.types.Backup): + Required. A backup resource + This corresponds to the ``backup`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + backup_id (str): + Required. The ID to use for the + backup. The ID must be unique within the + specified backupVault. Must contain only + letters, numbers and hyphen, with the + first character a letter, the last a + letter or a number, and a 63 character + maximum. + + This corresponds to the ``backup_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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.netapp_v1.types.Backup` A NetApp + Backup. + + """ + # 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. + flattened_params = [parent, backup, backup_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_backup.CreateBackupRequest): + request = gcn_backup.CreateBackupRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if backup is not None: + request.backup = backup + if backup_id is not None: + request.backup_id = backup_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_backup] + + # 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, + gcn_backup.Backup, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def get_backup(self, + request: Optional[Union[backup.GetBackupRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> backup.Backup: + r"""Returns the description of the specified backup + + .. 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 netapp_v1 + + def sample_get_backup(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.GetBackupRequest( + name="name_value", + ) + + # Make the request + response = client.get_backup(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.GetBackupRequest, dict]): + The request object. GetBackupRequest gets the state of a + backup. + name (str): + Required. The backup resource name, in the format + ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id}`` + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.Backup: + A NetApp Backup. + """ + # 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, backup.GetBackupRequest): + request = backup.GetBackupRequest(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_backup] + + # 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_backups(self, + request: Optional[Union[backup.ListBackupsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListBackupsPager: + r"""Returns descriptions of all backups for a + backupVault. + + .. 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 netapp_v1 + + def sample_list_backups(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ListBackupsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_backups(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.ListBackupsRequest, dict]): + The request object. ListBackupsRequest lists backups. + parent (str): + Required. The backupVault for which to retrieve backup + information, in the format + ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}``. + To retrieve backup information for all locations, use + "-" for the ``{location}`` value. To retrieve backup + information for all backupVaults, use "-" for the + ``{backup_vault_id}`` value. To retrieve backup + information for a volume, use "-" for the + ``{backup_vault_id}`` value and specify volume full name + with the filter. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.services.net_app.pagers.ListBackupsPager: + ListBackupsResponse is the result of + ListBackupsRequest. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, backup.ListBackupsRequest): + request = backup.ListBackupsRequest(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_backups] + + # 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.ListBackupsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_backup(self, + request: Optional[Union[backup.DeleteBackupRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Warning! This operation will permanently delete the + backup. + + .. 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 netapp_v1 + + def sample_delete_backup(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteBackupRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_backup(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.DeleteBackupRequest, dict]): + The request object. DeleteBackupRequest deletes a backup. + name (str): + Required. The backup resource name, in the format + ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id}`` + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, backup.DeleteBackupRequest): + request = backup.DeleteBackupRequest(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_backup] + + # 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=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_backup(self, + request: Optional[Union[gcn_backup.UpdateBackupRequest, dict]] = None, + *, + backup: Optional[gcn_backup.Backup] = 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, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Update backup with full spec. + + .. 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 netapp_v1 + + def sample_update_backup(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.UpdateBackupRequest( + ) + + # Make the request + operation = client.update_backup(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.UpdateBackupRequest, dict]): + The request object. UpdateBackupRequest updates + description and/or labels for a backup. + backup (google.cloud.netapp_v1.types.Backup): + Required. The backup being updated + This corresponds to the ``backup`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Field mask is used to specify the fields to be + overwritten in the Backup resource to be updated. The + fields specified in the update_mask are relative to the + resource, not the full request. A field will be + overwritten if it is in the mask. If the user does not + provide a mask then all fields will be overwritten. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.netapp_v1.types.Backup` A NetApp + Backup. + + """ + # 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. + flattened_params = [backup, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_backup.UpdateBackupRequest): + request = gcn_backup.UpdateBackupRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if backup is not None: + request.backup = backup + 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_backup] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("backup.name", request.backup.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, + gcn_backup.Backup, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def create_backup_policy(self, + request: Optional[Union[gcn_backup_policy.CreateBackupPolicyRequest, dict]] = None, + *, + parent: Optional[str] = None, + backup_policy: Optional[gcn_backup_policy.BackupPolicy] = None, + backup_policy_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Creates new backup policy + + .. 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 netapp_v1 + + def sample_create_backup_policy(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.CreateBackupPolicyRequest( + parent="parent_value", + backup_policy_id="backup_policy_id_value", + ) + + # Make the request + operation = client.create_backup_policy(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.CreateBackupPolicyRequest, dict]): + The request object. CreateBackupPolicyRequest creates a + backupPolicy. + parent (str): + Required. The location to create the backup policies of, + in the format + ``projects/{project_id}/locations/{location}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + backup_policy (google.cloud.netapp_v1.types.BackupPolicy): + Required. A backupPolicy resource + This corresponds to the ``backup_policy`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + backup_policy_id (str): + Required. The ID to use for the + backup policy. The ID must be unique + within the specified location. Must + contain only letters, numbers and + hyphen, with the first character a + letter, the last a letter or a number, + and a 63 character maximum. + + This corresponds to the ``backup_policy_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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.netapp_v1.types.BackupPolicy` + Backup Policy. + + """ + # 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. + flattened_params = [parent, backup_policy, backup_policy_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_backup_policy.CreateBackupPolicyRequest): + request = gcn_backup_policy.CreateBackupPolicyRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if backup_policy is not None: + request.backup_policy = backup_policy + if backup_policy_id is not None: + request.backup_policy_id = backup_policy_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_backup_policy] + + # 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, + gcn_backup_policy.BackupPolicy, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def get_backup_policy(self, + request: Optional[Union[backup_policy.GetBackupPolicyRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> backup_policy.BackupPolicy: + r"""Returns the description of the specified backup policy by + backup_policy_id. + + .. 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 netapp_v1 + + def sample_get_backup_policy(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.GetBackupPolicyRequest( + name="name_value", + ) + + # Make the request + response = client.get_backup_policy(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.GetBackupPolicyRequest, dict]): + The request object. GetBackupPolicyRequest gets the state + of a backupPolicy. + name (str): + Required. The backupPolicy resource name, in the format + ``projects/{project_id}/locations/{location}/backupPolicies/{backup_policy_id}`` + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.BackupPolicy: + Backup Policy. + """ + # 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, backup_policy.GetBackupPolicyRequest): + request = backup_policy.GetBackupPolicyRequest(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_backup_policy] + + # 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_backup_policies(self, + request: Optional[Union[backup_policy.ListBackupPoliciesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListBackupPoliciesPager: + r"""Returns list of all available backup policies. + + .. 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 netapp_v1 + + def sample_list_backup_policies(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ListBackupPoliciesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_backup_policies(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.ListBackupPoliciesRequest, dict]): + The request object. ListBackupPoliciesRequest for + requesting multiple backup policies. + parent (str): + Required. Parent value for + ListBackupPoliciesRequest + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.services.net_app.pagers.ListBackupPoliciesPager: + ListBackupPoliciesResponse contains + all the backup policies requested. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, backup_policy.ListBackupPoliciesRequest): + request = backup_policy.ListBackupPoliciesRequest(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_backup_policies] + + # 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.ListBackupPoliciesPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_backup_policy(self, + request: Optional[Union[gcn_backup_policy.UpdateBackupPolicyRequest, dict]] = None, + *, + backup_policy: Optional[gcn_backup_policy.BackupPolicy] = 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, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Updates settings of a specific backup policy. + + .. 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 netapp_v1 + + def sample_update_backup_policy(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.UpdateBackupPolicyRequest( + ) + + # Make the request + operation = client.update_backup_policy(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.UpdateBackupPolicyRequest, dict]): + The request object. UpdateBackupPolicyRequest for + updating a backup policy. + backup_policy (google.cloud.netapp_v1.types.BackupPolicy): + Required. The backup policy being + updated + + This corresponds to the ``backup_policy`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Field mask is used to specify the fields to be + overwritten in the Backup Policy resource by the update. + The fields specified in the update_mask are relative to + the resource, not the full request. A field will be + overwritten if it is in the mask. If the user does not + provide a mask then all fields will be overwritten. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.netapp_v1.types.BackupPolicy` + Backup Policy. + + """ + # 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. + flattened_params = [backup_policy, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_backup_policy.UpdateBackupPolicyRequest): + request = gcn_backup_policy.UpdateBackupPolicyRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if backup_policy is not None: + request.backup_policy = backup_policy + 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_backup_policy] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("backup_policy.name", request.backup_policy.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, + gcn_backup_policy.BackupPolicy, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_backup_policy(self, + request: Optional[Union[backup_policy.DeleteBackupPolicyRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Warning! This operation will permanently delete the + backup policy. + + .. 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 netapp_v1 + + def sample_delete_backup_policy(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteBackupPolicyRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_backup_policy(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.DeleteBackupPolicyRequest, dict]): + The request object. DeleteBackupPolicyRequest deletes a + backup policy. + name (str): + Required. The backup policy resource name, in the format + ``projects/{project_id}/locations/{location}/backupPolicies/{backup_policy_id}`` + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, backup_policy.DeleteBackupPolicyRequest): + request = backup_policy.DeleteBackupPolicyRequest(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_backup_policy] + + # 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=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def list_quota_rules(self, + request: Optional[Union[quota_rule.ListQuotaRulesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListQuotaRulesPager: + r"""Returns list of all quota rules in a location. + + .. 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 netapp_v1 + + def sample_list_quota_rules(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ListQuotaRulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_quota_rules(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.ListQuotaRulesRequest, dict]): + The request object. ListQuotaRulesRequest for listing + quota rules. + parent (str): + Required. Parent value for + ListQuotaRulesRequest + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.services.net_app.pagers.ListQuotaRulesPager: + ListQuotaRulesResponse is the + response to a ListQuotaRulesRequest. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, quota_rule.ListQuotaRulesRequest): + request = quota_rule.ListQuotaRulesRequest(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_quota_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.ListQuotaRulesPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_quota_rule(self, + request: Optional[Union[quota_rule.GetQuotaRuleRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> quota_rule.QuotaRule: + r"""Returns details of the specified quota 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 netapp_v1 + + def sample_get_quota_rule(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.GetQuotaRuleRequest( + name="name_value", + ) + + # Make the request + response = client.get_quota_rule(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.GetQuotaRuleRequest, dict]): + The request object. GetQuotaRuleRequest for getting a + quota rule. + name (str): + Required. Name of the quota rule + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.netapp_v1.types.QuotaRule: + QuotaRule specifies the maximum disk + space a user or group can use within a + volume. They can be used for creating + default and individual quota rules. + + """ + # 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, quota_rule.GetQuotaRuleRequest): + request = quota_rule.GetQuotaRuleRequest(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_quota_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 create_quota_rule(self, + request: Optional[Union[gcn_quota_rule.CreateQuotaRuleRequest, dict]] = None, + *, + parent: Optional[str] = None, + quota_rule: Optional[gcn_quota_rule.QuotaRule] = None, + quota_rule_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Creates a new quota 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 netapp_v1 + + def sample_create_quota_rule(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + quota_rule = netapp_v1.QuotaRule() + quota_rule.type_ = "DEFAULT_GROUP_QUOTA" + quota_rule.disk_limit_mib = 1472 + + request = netapp_v1.CreateQuotaRuleRequest( + parent="parent_value", + quota_rule=quota_rule, + quota_rule_id="quota_rule_id_value", + ) + + # Make the request + operation = client.create_quota_rule(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.CreateQuotaRuleRequest, dict]): + The request object. CreateQuotaRuleRequest for creating a + quota rule. + parent (str): + Required. Parent value for + CreateQuotaRuleRequest + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + quota_rule (google.cloud.netapp_v1.types.QuotaRule): + Required. Fields of the to be created + quota rule. + + This corresponds to the ``quota_rule`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + quota_rule_id (str): + Required. ID of the quota rule to + create. Must be unique within the parent + resource. Must contain only letters, + numbers, underscore and hyphen, with the + first character a letter or underscore, + the last a letter or underscore or a + number, and a 63 character maximum. + + This corresponds to the ``quota_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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.netapp_v1.types.QuotaRule` QuotaRule specifies the maximum disk space a user or group can use within a + volume. They can be used for creating default and + individual quota rules. + + """ + # 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. + flattened_params = [parent, quota_rule, quota_rule_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_quota_rule.CreateQuotaRuleRequest): + request = gcn_quota_rule.CreateQuotaRuleRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if quota_rule is not None: + request.quota_rule = quota_rule + if quota_rule_id is not None: + request.quota_rule_id = quota_rule_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_quota_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, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + gcn_quota_rule.QuotaRule, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_quota_rule(self, + request: Optional[Union[gcn_quota_rule.UpdateQuotaRuleRequest, dict]] = None, + *, + quota_rule: Optional[gcn_quota_rule.QuotaRule] = 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, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Updates a quota 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 netapp_v1 + + def sample_update_quota_rule(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + quota_rule = netapp_v1.QuotaRule() + quota_rule.type_ = "DEFAULT_GROUP_QUOTA" + quota_rule.disk_limit_mib = 1472 + + request = netapp_v1.UpdateQuotaRuleRequest( + quota_rule=quota_rule, + ) + + # Make the request + operation = client.update_quota_rule(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.UpdateQuotaRuleRequest, dict]): + The request object. UpdateQuotaRuleRequest for updating a + quota rule. + quota_rule (google.cloud.netapp_v1.types.QuotaRule): + Required. The quota rule being + updated + + This corresponds to the ``quota_rule`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. Field mask is used to specify the fields to be + overwritten in the Quota Rule resource by the update. + The fields specified in the update_mask are relative to + the resource, not the full request. A field will be + overwritten if it is in the mask. If the user does not + provide a mask then all fields will be overwritten. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.netapp_v1.types.QuotaRule` QuotaRule specifies the maximum disk space a user or group can use within a + volume. They can be used for creating default and + individual quota rules. + + """ + # 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. + flattened_params = [quota_rule, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, gcn_quota_rule.UpdateQuotaRuleRequest): + request = gcn_quota_rule.UpdateQuotaRuleRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if quota_rule is not None: + request.quota_rule = quota_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_quota_rule] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("quota_rule.name", request.quota_rule.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, + gcn_quota_rule.QuotaRule, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_quota_rule(self, + request: Optional[Union[quota_rule.DeleteQuotaRuleRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Deletes a quota 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 netapp_v1 + + def sample_delete_quota_rule(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteQuotaRuleRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_quota_rule(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.netapp_v1.types.DeleteQuotaRuleRequest, dict]): + The request object. DeleteQuotaRuleRequest for deleting a + single quota rule. + name (str): + Required. Name of the quota rule. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + 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, quota_rule.DeleteQuotaRuleRequest): + request = quota_rule.DeleteQuotaRuleRequest(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_quota_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, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + empty_pb2.Empty, + metadata_type=cloud_netapp_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def __enter__(self) -> "NetAppClient": + 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 list_operations( + self, + request: Optional[operations_pb2.ListOperationsRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.ListOperationsResponse: + r"""Lists operations that match the specified filter in the request. + + Args: + request (:class:`~.operations_pb2.ListOperationsRequest`): + The request object. Request message for + `ListOperations` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + Returns: + ~.operations_pb2.ListOperationsResponse: + Response message for ``ListOperations`` 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 = operations_pb2.ListOperationsRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_operations] + + # 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() + + try: + # Send the request. + response = rpc( + request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + except core_exceptions.GoogleAPICallError as e: + self._add_cred_info_for_auth_errors(e) + raise e + + 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, Union[str, bytes]]] = (), + ) -> 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + 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() + + try: + # Send the request. + response = rpc( + request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + except core_exceptions.GoogleAPICallError as e: + self._add_cred_info_for_auth_errors(e) + raise e + + def delete_operation( + self, + request: Optional[operations_pb2.DeleteOperationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> None: + r"""Deletes a long-running operation. + + This method indicates that the client is no longer interested + in the operation result. It does not cancel the operation. + If the server doesn't support this method, it returns + `google.rpc.Code.UNIMPLEMENTED`. + + Args: + request (:class:`~.operations_pb2.DeleteOperationRequest`): + The request object. Request message for + `DeleteOperation` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + Returns: + None + """ + # 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.DeleteOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_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. + rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + def cancel_operation( + self, + request: Optional[operations_pb2.CancelOperationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> None: + r"""Starts asynchronous cancellation on a long-running operation. + + The server makes a best effort to cancel the operation, but success + is not guaranteed. If the server doesn't support this method, it returns + `google.rpc.Code.UNIMPLEMENTED`. + + Args: + request (:class:`~.operations_pb2.CancelOperationRequest`): + The request object. Request message for + `CancelOperation` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + Returns: + None + """ + # 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.CancelOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.cancel_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. + rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + 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, Union[str, bytes]]] = (), + ) -> 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + 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() + + try: + # Send the request. + response = rpc( + request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + except core_exceptions.GoogleAPICallError as e: + self._add_cred_info_for_auth_errors(e) + raise e + + 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, Union[str, bytes]]] = (), + ) -> 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + 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() + + try: + # Send the request. + response = rpc( + request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + except core_exceptions.GoogleAPICallError as e: + self._add_cred_info_for_auth_errors(e) + raise e + + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) + + +__all__ = ( + "NetAppClient", +) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/pagers.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/pagers.py new file mode 100644 index 000000000000..adbdb24c09a4 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/pagers.py @@ -0,0 +1,1426 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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.netapp_v1.types import active_directory +from google.cloud.netapp_v1.types import backup +from google.cloud.netapp_v1.types import backup_policy +from google.cloud.netapp_v1.types import backup_vault +from google.cloud.netapp_v1.types import kms +from google.cloud.netapp_v1.types import quota_rule +from google.cloud.netapp_v1.types import replication +from google.cloud.netapp_v1.types import snapshot +from google.cloud.netapp_v1.types import storage_pool +from google.cloud.netapp_v1.types import volume + + +class ListStoragePoolsPager: + """A pager for iterating through ``list_storage_pools`` requests. + + This class thinly wraps an initial + :class:`google.cloud.netapp_v1.types.ListStoragePoolsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``storage_pools`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListStoragePools`` requests and continue to iterate + through the ``storage_pools`` field on the + corresponding responses. + + All the usual :class:`google.cloud.netapp_v1.types.ListStoragePoolsResponse` + 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[..., storage_pool.ListStoragePoolsResponse], + request: storage_pool.ListStoragePoolsRequest, + response: storage_pool.ListStoragePoolsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.netapp_v1.types.ListStoragePoolsRequest): + The initial request object. + response (google.cloud.netapp_v1.types.ListStoragePoolsResponse): + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = storage_pool.ListStoragePoolsRequest(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[storage_pool.ListStoragePoolsResponse]: + 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[storage_pool.StoragePool]: + for page in self.pages: + yield from page.storage_pools + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListStoragePoolsAsyncPager: + """A pager for iterating through ``list_storage_pools`` requests. + + This class thinly wraps an initial + :class:`google.cloud.netapp_v1.types.ListStoragePoolsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``storage_pools`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListStoragePools`` requests and continue to iterate + through the ``storage_pools`` field on the + corresponding responses. + + All the usual :class:`google.cloud.netapp_v1.types.ListStoragePoolsResponse` + 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[storage_pool.ListStoragePoolsResponse]], + request: storage_pool.ListStoragePoolsRequest, + response: storage_pool.ListStoragePoolsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.netapp_v1.types.ListStoragePoolsRequest): + The initial request object. + response (google.cloud.netapp_v1.types.ListStoragePoolsResponse): + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = storage_pool.ListStoragePoolsRequest(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[storage_pool.ListStoragePoolsResponse]: + 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[storage_pool.StoragePool]: + async def async_generator(): + async for page in self.pages: + for response in page.storage_pools: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListVolumesPager: + """A pager for iterating through ``list_volumes`` requests. + + This class thinly wraps an initial + :class:`google.cloud.netapp_v1.types.ListVolumesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``volumes`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListVolumes`` requests and continue to iterate + through the ``volumes`` field on the + corresponding responses. + + All the usual :class:`google.cloud.netapp_v1.types.ListVolumesResponse` + 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[..., volume.ListVolumesResponse], + request: volume.ListVolumesRequest, + response: volume.ListVolumesResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.netapp_v1.types.ListVolumesRequest): + The initial request object. + response (google.cloud.netapp_v1.types.ListVolumesResponse): + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = volume.ListVolumesRequest(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[volume.ListVolumesResponse]: + 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[volume.Volume]: + for page in self.pages: + yield from page.volumes + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListVolumesAsyncPager: + """A pager for iterating through ``list_volumes`` requests. + + This class thinly wraps an initial + :class:`google.cloud.netapp_v1.types.ListVolumesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``volumes`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListVolumes`` requests and continue to iterate + through the ``volumes`` field on the + corresponding responses. + + All the usual :class:`google.cloud.netapp_v1.types.ListVolumesResponse` + 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[volume.ListVolumesResponse]], + request: volume.ListVolumesRequest, + response: volume.ListVolumesResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.netapp_v1.types.ListVolumesRequest): + The initial request object. + response (google.cloud.netapp_v1.types.ListVolumesResponse): + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = volume.ListVolumesRequest(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[volume.ListVolumesResponse]: + 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[volume.Volume]: + async def async_generator(): + async for page in self.pages: + for response in page.volumes: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListSnapshotsPager: + """A pager for iterating through ``list_snapshots`` requests. + + This class thinly wraps an initial + :class:`google.cloud.netapp_v1.types.ListSnapshotsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``snapshots`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListSnapshots`` requests and continue to iterate + through the ``snapshots`` field on the + corresponding responses. + + All the usual :class:`google.cloud.netapp_v1.types.ListSnapshotsResponse` + 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[..., snapshot.ListSnapshotsResponse], + request: snapshot.ListSnapshotsRequest, + response: snapshot.ListSnapshotsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.netapp_v1.types.ListSnapshotsRequest): + The initial request object. + response (google.cloud.netapp_v1.types.ListSnapshotsResponse): + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = snapshot.ListSnapshotsRequest(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[snapshot.ListSnapshotsResponse]: + 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[snapshot.Snapshot]: + for page in self.pages: + yield from page.snapshots + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListSnapshotsAsyncPager: + """A pager for iterating through ``list_snapshots`` requests. + + This class thinly wraps an initial + :class:`google.cloud.netapp_v1.types.ListSnapshotsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``snapshots`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListSnapshots`` requests and continue to iterate + through the ``snapshots`` field on the + corresponding responses. + + All the usual :class:`google.cloud.netapp_v1.types.ListSnapshotsResponse` + 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[snapshot.ListSnapshotsResponse]], + request: snapshot.ListSnapshotsRequest, + response: snapshot.ListSnapshotsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.netapp_v1.types.ListSnapshotsRequest): + The initial request object. + response (google.cloud.netapp_v1.types.ListSnapshotsResponse): + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = snapshot.ListSnapshotsRequest(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[snapshot.ListSnapshotsResponse]: + 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[snapshot.Snapshot]: + async def async_generator(): + async for page in self.pages: + for response in page.snapshots: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListActiveDirectoriesPager: + """A pager for iterating through ``list_active_directories`` requests. + + This class thinly wraps an initial + :class:`google.cloud.netapp_v1.types.ListActiveDirectoriesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``active_directories`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListActiveDirectories`` requests and continue to iterate + through the ``active_directories`` field on the + corresponding responses. + + All the usual :class:`google.cloud.netapp_v1.types.ListActiveDirectoriesResponse` + 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[..., active_directory.ListActiveDirectoriesResponse], + request: active_directory.ListActiveDirectoriesRequest, + response: active_directory.ListActiveDirectoriesResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.netapp_v1.types.ListActiveDirectoriesRequest): + The initial request object. + response (google.cloud.netapp_v1.types.ListActiveDirectoriesResponse): + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = active_directory.ListActiveDirectoriesRequest(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[active_directory.ListActiveDirectoriesResponse]: + 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[active_directory.ActiveDirectory]: + for page in self.pages: + yield from page.active_directories + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListActiveDirectoriesAsyncPager: + """A pager for iterating through ``list_active_directories`` requests. + + This class thinly wraps an initial + :class:`google.cloud.netapp_v1.types.ListActiveDirectoriesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``active_directories`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListActiveDirectories`` requests and continue to iterate + through the ``active_directories`` field on the + corresponding responses. + + All the usual :class:`google.cloud.netapp_v1.types.ListActiveDirectoriesResponse` + 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[active_directory.ListActiveDirectoriesResponse]], + request: active_directory.ListActiveDirectoriesRequest, + response: active_directory.ListActiveDirectoriesResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.netapp_v1.types.ListActiveDirectoriesRequest): + The initial request object. + response (google.cloud.netapp_v1.types.ListActiveDirectoriesResponse): + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = active_directory.ListActiveDirectoriesRequest(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[active_directory.ListActiveDirectoriesResponse]: + 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[active_directory.ActiveDirectory]: + async def async_generator(): + async for page in self.pages: + for response in page.active_directories: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListKmsConfigsPager: + """A pager for iterating through ``list_kms_configs`` requests. + + This class thinly wraps an initial + :class:`google.cloud.netapp_v1.types.ListKmsConfigsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``kms_configs`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListKmsConfigs`` requests and continue to iterate + through the ``kms_configs`` field on the + corresponding responses. + + All the usual :class:`google.cloud.netapp_v1.types.ListKmsConfigsResponse` + 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[..., kms.ListKmsConfigsResponse], + request: kms.ListKmsConfigsRequest, + response: kms.ListKmsConfigsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.netapp_v1.types.ListKmsConfigsRequest): + The initial request object. + response (google.cloud.netapp_v1.types.ListKmsConfigsResponse): + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = kms.ListKmsConfigsRequest(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[kms.ListKmsConfigsResponse]: + 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[kms.KmsConfig]: + for page in self.pages: + yield from page.kms_configs + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListKmsConfigsAsyncPager: + """A pager for iterating through ``list_kms_configs`` requests. + + This class thinly wraps an initial + :class:`google.cloud.netapp_v1.types.ListKmsConfigsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``kms_configs`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListKmsConfigs`` requests and continue to iterate + through the ``kms_configs`` field on the + corresponding responses. + + All the usual :class:`google.cloud.netapp_v1.types.ListKmsConfigsResponse` + 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[kms.ListKmsConfigsResponse]], + request: kms.ListKmsConfigsRequest, + response: kms.ListKmsConfigsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.netapp_v1.types.ListKmsConfigsRequest): + The initial request object. + response (google.cloud.netapp_v1.types.ListKmsConfigsResponse): + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = kms.ListKmsConfigsRequest(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[kms.ListKmsConfigsResponse]: + 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[kms.KmsConfig]: + async def async_generator(): + async for page in self.pages: + for response in page.kms_configs: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListReplicationsPager: + """A pager for iterating through ``list_replications`` requests. + + This class thinly wraps an initial + :class:`google.cloud.netapp_v1.types.ListReplicationsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``replications`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListReplications`` requests and continue to iterate + through the ``replications`` field on the + corresponding responses. + + All the usual :class:`google.cloud.netapp_v1.types.ListReplicationsResponse` + 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[..., replication.ListReplicationsResponse], + request: replication.ListReplicationsRequest, + response: replication.ListReplicationsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.netapp_v1.types.ListReplicationsRequest): + The initial request object. + response (google.cloud.netapp_v1.types.ListReplicationsResponse): + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = replication.ListReplicationsRequest(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[replication.ListReplicationsResponse]: + 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[replication.Replication]: + for page in self.pages: + yield from page.replications + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListReplicationsAsyncPager: + """A pager for iterating through ``list_replications`` requests. + + This class thinly wraps an initial + :class:`google.cloud.netapp_v1.types.ListReplicationsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``replications`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListReplications`` requests and continue to iterate + through the ``replications`` field on the + corresponding responses. + + All the usual :class:`google.cloud.netapp_v1.types.ListReplicationsResponse` + 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[replication.ListReplicationsResponse]], + request: replication.ListReplicationsRequest, + response: replication.ListReplicationsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.netapp_v1.types.ListReplicationsRequest): + The initial request object. + response (google.cloud.netapp_v1.types.ListReplicationsResponse): + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = replication.ListReplicationsRequest(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[replication.ListReplicationsResponse]: + 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[replication.Replication]: + async def async_generator(): + async for page in self.pages: + for response in page.replications: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListBackupVaultsPager: + """A pager for iterating through ``list_backup_vaults`` requests. + + This class thinly wraps an initial + :class:`google.cloud.netapp_v1.types.ListBackupVaultsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``backup_vaults`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListBackupVaults`` requests and continue to iterate + through the ``backup_vaults`` field on the + corresponding responses. + + All the usual :class:`google.cloud.netapp_v1.types.ListBackupVaultsResponse` + 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[..., backup_vault.ListBackupVaultsResponse], + request: backup_vault.ListBackupVaultsRequest, + response: backup_vault.ListBackupVaultsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.netapp_v1.types.ListBackupVaultsRequest): + The initial request object. + response (google.cloud.netapp_v1.types.ListBackupVaultsResponse): + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = backup_vault.ListBackupVaultsRequest(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[backup_vault.ListBackupVaultsResponse]: + 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[backup_vault.BackupVault]: + for page in self.pages: + yield from page.backup_vaults + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListBackupVaultsAsyncPager: + """A pager for iterating through ``list_backup_vaults`` requests. + + This class thinly wraps an initial + :class:`google.cloud.netapp_v1.types.ListBackupVaultsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``backup_vaults`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListBackupVaults`` requests and continue to iterate + through the ``backup_vaults`` field on the + corresponding responses. + + All the usual :class:`google.cloud.netapp_v1.types.ListBackupVaultsResponse` + 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[backup_vault.ListBackupVaultsResponse]], + request: backup_vault.ListBackupVaultsRequest, + response: backup_vault.ListBackupVaultsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.netapp_v1.types.ListBackupVaultsRequest): + The initial request object. + response (google.cloud.netapp_v1.types.ListBackupVaultsResponse): + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = backup_vault.ListBackupVaultsRequest(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[backup_vault.ListBackupVaultsResponse]: + 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[backup_vault.BackupVault]: + async def async_generator(): + async for page in self.pages: + for response in page.backup_vaults: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListBackupsPager: + """A pager for iterating through ``list_backups`` requests. + + This class thinly wraps an initial + :class:`google.cloud.netapp_v1.types.ListBackupsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``backups`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListBackups`` requests and continue to iterate + through the ``backups`` field on the + corresponding responses. + + All the usual :class:`google.cloud.netapp_v1.types.ListBackupsResponse` + 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[..., backup.ListBackupsResponse], + request: backup.ListBackupsRequest, + response: backup.ListBackupsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.netapp_v1.types.ListBackupsRequest): + The initial request object. + response (google.cloud.netapp_v1.types.ListBackupsResponse): + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = backup.ListBackupsRequest(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[backup.ListBackupsResponse]: + 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[backup.Backup]: + for page in self.pages: + yield from page.backups + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListBackupsAsyncPager: + """A pager for iterating through ``list_backups`` requests. + + This class thinly wraps an initial + :class:`google.cloud.netapp_v1.types.ListBackupsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``backups`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListBackups`` requests and continue to iterate + through the ``backups`` field on the + corresponding responses. + + All the usual :class:`google.cloud.netapp_v1.types.ListBackupsResponse` + 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[backup.ListBackupsResponse]], + request: backup.ListBackupsRequest, + response: backup.ListBackupsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.netapp_v1.types.ListBackupsRequest): + The initial request object. + response (google.cloud.netapp_v1.types.ListBackupsResponse): + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = backup.ListBackupsRequest(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[backup.ListBackupsResponse]: + 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[backup.Backup]: + async def async_generator(): + async for page in self.pages: + for response in page.backups: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListBackupPoliciesPager: + """A pager for iterating through ``list_backup_policies`` requests. + + This class thinly wraps an initial + :class:`google.cloud.netapp_v1.types.ListBackupPoliciesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``backup_policies`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListBackupPolicies`` requests and continue to iterate + through the ``backup_policies`` field on the + corresponding responses. + + All the usual :class:`google.cloud.netapp_v1.types.ListBackupPoliciesResponse` + 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[..., backup_policy.ListBackupPoliciesResponse], + request: backup_policy.ListBackupPoliciesRequest, + response: backup_policy.ListBackupPoliciesResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.netapp_v1.types.ListBackupPoliciesRequest): + The initial request object. + response (google.cloud.netapp_v1.types.ListBackupPoliciesResponse): + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = backup_policy.ListBackupPoliciesRequest(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[backup_policy.ListBackupPoliciesResponse]: + 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[backup_policy.BackupPolicy]: + for page in self.pages: + yield from page.backup_policies + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListBackupPoliciesAsyncPager: + """A pager for iterating through ``list_backup_policies`` requests. + + This class thinly wraps an initial + :class:`google.cloud.netapp_v1.types.ListBackupPoliciesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``backup_policies`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListBackupPolicies`` requests and continue to iterate + through the ``backup_policies`` field on the + corresponding responses. + + All the usual :class:`google.cloud.netapp_v1.types.ListBackupPoliciesResponse` + 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[backup_policy.ListBackupPoliciesResponse]], + request: backup_policy.ListBackupPoliciesRequest, + response: backup_policy.ListBackupPoliciesResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.netapp_v1.types.ListBackupPoliciesRequest): + The initial request object. + response (google.cloud.netapp_v1.types.ListBackupPoliciesResponse): + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = backup_policy.ListBackupPoliciesRequest(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[backup_policy.ListBackupPoliciesResponse]: + 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[backup_policy.BackupPolicy]: + async def async_generator(): + async for page in self.pages: + for response in page.backup_policies: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListQuotaRulesPager: + """A pager for iterating through ``list_quota_rules`` requests. + + This class thinly wraps an initial + :class:`google.cloud.netapp_v1.types.ListQuotaRulesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``quota_rules`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListQuotaRules`` requests and continue to iterate + through the ``quota_rules`` field on the + corresponding responses. + + All the usual :class:`google.cloud.netapp_v1.types.ListQuotaRulesResponse` + 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[..., quota_rule.ListQuotaRulesResponse], + request: quota_rule.ListQuotaRulesRequest, + response: quota_rule.ListQuotaRulesResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.netapp_v1.types.ListQuotaRulesRequest): + The initial request object. + response (google.cloud.netapp_v1.types.ListQuotaRulesResponse): + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = quota_rule.ListQuotaRulesRequest(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[quota_rule.ListQuotaRulesResponse]: + 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[quota_rule.QuotaRule]: + for page in self.pages: + yield from page.quota_rules + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListQuotaRulesAsyncPager: + """A pager for iterating through ``list_quota_rules`` requests. + + This class thinly wraps an initial + :class:`google.cloud.netapp_v1.types.ListQuotaRulesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``quota_rules`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListQuotaRules`` requests and continue to iterate + through the ``quota_rules`` field on the + corresponding responses. + + All the usual :class:`google.cloud.netapp_v1.types.ListQuotaRulesResponse` + 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[quota_rule.ListQuotaRulesResponse]], + request: quota_rule.ListQuotaRulesRequest, + response: quota_rule.ListQuotaRulesResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.netapp_v1.types.ListQuotaRulesRequest): + The initial request object. + response (google.cloud.netapp_v1.types.ListQuotaRulesResponse): + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = quota_rule.ListQuotaRulesRequest(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[quota_rule.ListQuotaRulesResponse]: + 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[quota_rule.QuotaRule]: + async def async_generator(): + async for page in self.pages: + for response in page.quota_rules: + 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-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/README.rst b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/README.rst new file mode 100644 index 000000000000..16bd00900281 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/README.rst @@ -0,0 +1,9 @@ + +transport inheritance structure +_______________________________ + +`NetAppTransport` is the ABC for all transports. +- public child `NetAppGrpcTransport` for sync gRPC transport (defined in `grpc.py`). +- public child `NetAppGrpcAsyncIOTransport` for async gRPC transport (defined in `grpc_asyncio.py`). +- private child `_BaseNetAppRestTransport` for base REST transport with inner classes `_BaseMETHOD` (defined in `rest_base.py`). +- public child `NetAppRestTransport` 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-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/__init__.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/__init__.py new file mode 100644 index 000000000000..4e551ab78d20 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/__init__.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 NetAppTransport +from .grpc import NetAppGrpcTransport +from .grpc_asyncio import NetAppGrpcAsyncIOTransport +from .rest import NetAppRestTransport +from .rest import NetAppRestInterceptor + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[NetAppTransport]] +_transport_registry['grpc'] = NetAppGrpcTransport +_transport_registry['grpc_asyncio'] = NetAppGrpcAsyncIOTransport +_transport_registry['rest'] = NetAppRestTransport + +__all__ = ( + 'NetAppTransport', + 'NetAppGrpcTransport', + 'NetAppGrpcAsyncIOTransport', + 'NetAppRestTransport', + 'NetAppRestInterceptor', +) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/base.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/base.py new file mode 100644 index 000000000000..bd582c4a0b82 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/base.py @@ -0,0 +1,1251 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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.netapp_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.location import locations_pb2 # type: ignore +from google.cloud.netapp_v1.types import active_directory +from google.cloud.netapp_v1.types import active_directory as gcn_active_directory +from google.cloud.netapp_v1.types import backup +from google.cloud.netapp_v1.types import backup as gcn_backup +from google.cloud.netapp_v1.types import backup_policy +from google.cloud.netapp_v1.types import backup_policy as gcn_backup_policy +from google.cloud.netapp_v1.types import backup_vault +from google.cloud.netapp_v1.types import backup_vault as gcn_backup_vault +from google.cloud.netapp_v1.types import kms +from google.cloud.netapp_v1.types import quota_rule +from google.cloud.netapp_v1.types import quota_rule as gcn_quota_rule +from google.cloud.netapp_v1.types import replication +from google.cloud.netapp_v1.types import replication as gcn_replication +from google.cloud.netapp_v1.types import snapshot +from google.cloud.netapp_v1.types import snapshot as gcn_snapshot +from google.cloud.netapp_v1.types import storage_pool +from google.cloud.netapp_v1.types import storage_pool as gcn_storage_pool +from google.cloud.netapp_v1.types import volume +from google.cloud.netapp_v1.types import volume as gcn_volume +from google.longrunning import operations_pb2 # type: ignore + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) + + +class NetAppTransport(abc.ABC): + """Abstract transport class for NetApp.""" + + AUTH_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + ) + + DEFAULT_HOST: str = 'netapp.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: 'netapp.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_storage_pools: gapic_v1.method.wrap_method( + self.list_storage_pools, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.create_storage_pool: gapic_v1.method.wrap_method( + self.create_storage_pool, + default_timeout=60.0, + client_info=client_info, + ), + self.get_storage_pool: gapic_v1.method.wrap_method( + self.get_storage_pool, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.update_storage_pool: gapic_v1.method.wrap_method( + self.update_storage_pool, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_storage_pool: gapic_v1.method.wrap_method( + self.delete_storage_pool, + default_timeout=60.0, + client_info=client_info, + ), + self.validate_directory_service: gapic_v1.method.wrap_method( + self.validate_directory_service, + default_timeout=None, + client_info=client_info, + ), + self.switch_active_replica_zone: gapic_v1.method.wrap_method( + self.switch_active_replica_zone, + default_timeout=None, + client_info=client_info, + ), + self.list_volumes: gapic_v1.method.wrap_method( + self.list_volumes, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.get_volume: gapic_v1.method.wrap_method( + self.get_volume, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.create_volume: gapic_v1.method.wrap_method( + self.create_volume, + default_timeout=60.0, + client_info=client_info, + ), + self.update_volume: gapic_v1.method.wrap_method( + self.update_volume, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_volume: gapic_v1.method.wrap_method( + self.delete_volume, + default_timeout=60.0, + client_info=client_info, + ), + self.revert_volume: gapic_v1.method.wrap_method( + self.revert_volume, + default_timeout=60.0, + client_info=client_info, + ), + self.list_snapshots: gapic_v1.method.wrap_method( + self.list_snapshots, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.get_snapshot: gapic_v1.method.wrap_method( + self.get_snapshot, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.create_snapshot: gapic_v1.method.wrap_method( + self.create_snapshot, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_snapshot: gapic_v1.method.wrap_method( + self.delete_snapshot, + default_timeout=60.0, + client_info=client_info, + ), + self.update_snapshot: gapic_v1.method.wrap_method( + self.update_snapshot, + default_timeout=60.0, + client_info=client_info, + ), + self.list_active_directories: gapic_v1.method.wrap_method( + self.list_active_directories, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.get_active_directory: gapic_v1.method.wrap_method( + self.get_active_directory, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.create_active_directory: gapic_v1.method.wrap_method( + self.create_active_directory, + default_timeout=60.0, + client_info=client_info, + ), + self.update_active_directory: gapic_v1.method.wrap_method( + self.update_active_directory, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_active_directory: gapic_v1.method.wrap_method( + self.delete_active_directory, + default_timeout=60.0, + client_info=client_info, + ), + self.list_kms_configs: gapic_v1.method.wrap_method( + self.list_kms_configs, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.create_kms_config: gapic_v1.method.wrap_method( + self.create_kms_config, + default_timeout=60.0, + client_info=client_info, + ), + self.get_kms_config: gapic_v1.method.wrap_method( + self.get_kms_config, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.update_kms_config: gapic_v1.method.wrap_method( + self.update_kms_config, + default_timeout=60.0, + client_info=client_info, + ), + self.encrypt_volumes: gapic_v1.method.wrap_method( + self.encrypt_volumes, + default_timeout=60.0, + client_info=client_info, + ), + self.verify_kms_config: gapic_v1.method.wrap_method( + self.verify_kms_config, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_kms_config: gapic_v1.method.wrap_method( + self.delete_kms_config, + default_timeout=60.0, + client_info=client_info, + ), + self.list_replications: gapic_v1.method.wrap_method( + self.list_replications, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.get_replication: gapic_v1.method.wrap_method( + self.get_replication, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.create_replication: gapic_v1.method.wrap_method( + self.create_replication, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_replication: gapic_v1.method.wrap_method( + self.delete_replication, + default_timeout=60.0, + client_info=client_info, + ), + self.update_replication: gapic_v1.method.wrap_method( + self.update_replication, + default_timeout=60.0, + client_info=client_info, + ), + self.stop_replication: gapic_v1.method.wrap_method( + self.stop_replication, + default_timeout=60.0, + client_info=client_info, + ), + self.resume_replication: gapic_v1.method.wrap_method( + self.resume_replication, + default_timeout=60.0, + client_info=client_info, + ), + self.reverse_replication_direction: gapic_v1.method.wrap_method( + self.reverse_replication_direction, + default_timeout=60.0, + client_info=client_info, + ), + self.establish_peering: gapic_v1.method.wrap_method( + self.establish_peering, + default_timeout=None, + client_info=client_info, + ), + self.sync_replication: gapic_v1.method.wrap_method( + self.sync_replication, + default_timeout=None, + client_info=client_info, + ), + self.create_backup_vault: gapic_v1.method.wrap_method( + self.create_backup_vault, + default_timeout=60.0, + client_info=client_info, + ), + self.get_backup_vault: gapic_v1.method.wrap_method( + self.get_backup_vault, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.list_backup_vaults: gapic_v1.method.wrap_method( + self.list_backup_vaults, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.update_backup_vault: gapic_v1.method.wrap_method( + self.update_backup_vault, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_backup_vault: gapic_v1.method.wrap_method( + self.delete_backup_vault, + default_timeout=60.0, + client_info=client_info, + ), + self.create_backup: gapic_v1.method.wrap_method( + self.create_backup, + default_timeout=60.0, + client_info=client_info, + ), + self.get_backup: gapic_v1.method.wrap_method( + self.get_backup, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.list_backups: gapic_v1.method.wrap_method( + self.list_backups, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.delete_backup: gapic_v1.method.wrap_method( + self.delete_backup, + default_timeout=60.0, + client_info=client_info, + ), + self.update_backup: gapic_v1.method.wrap_method( + self.update_backup, + default_timeout=60.0, + client_info=client_info, + ), + self.create_backup_policy: gapic_v1.method.wrap_method( + self.create_backup_policy, + default_timeout=60.0, + client_info=client_info, + ), + self.get_backup_policy: gapic_v1.method.wrap_method( + self.get_backup_policy, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.list_backup_policies: gapic_v1.method.wrap_method( + self.list_backup_policies, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.update_backup_policy: gapic_v1.method.wrap_method( + self.update_backup_policy, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_backup_policy: gapic_v1.method.wrap_method( + self.delete_backup_policy, + default_timeout=60.0, + client_info=client_info, + ), + self.list_quota_rules: gapic_v1.method.wrap_method( + self.list_quota_rules, + default_timeout=None, + client_info=client_info, + ), + self.get_quota_rule: gapic_v1.method.wrap_method( + self.get_quota_rule, + default_timeout=None, + client_info=client_info, + ), + self.create_quota_rule: gapic_v1.method.wrap_method( + self.create_quota_rule, + default_timeout=None, + client_info=client_info, + ), + self.update_quota_rule: gapic_v1.method.wrap_method( + self.update_quota_rule, + default_timeout=None, + client_info=client_info, + ), + self.delete_quota_rule: gapic_v1.method.wrap_method( + self.delete_quota_rule, + 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.cancel_operation: gapic_v1.method.wrap_method( + self.cancel_operation, + default_timeout=None, + client_info=client_info, + ), + self.delete_operation: gapic_v1.method.wrap_method( + self.delete_operation, + 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, + ), + self.list_operations: gapic_v1.method.wrap_method( + self.list_operations, + 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_storage_pools(self) -> Callable[ + [storage_pool.ListStoragePoolsRequest], + Union[ + storage_pool.ListStoragePoolsResponse, + Awaitable[storage_pool.ListStoragePoolsResponse] + ]]: + raise NotImplementedError() + + @property + def create_storage_pool(self) -> Callable[ + [gcn_storage_pool.CreateStoragePoolRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def get_storage_pool(self) -> Callable[ + [storage_pool.GetStoragePoolRequest], + Union[ + storage_pool.StoragePool, + Awaitable[storage_pool.StoragePool] + ]]: + raise NotImplementedError() + + @property + def update_storage_pool(self) -> Callable[ + [gcn_storage_pool.UpdateStoragePoolRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_storage_pool(self) -> Callable[ + [storage_pool.DeleteStoragePoolRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def validate_directory_service(self) -> Callable[ + [storage_pool.ValidateDirectoryServiceRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def switch_active_replica_zone(self) -> Callable[ + [storage_pool.SwitchActiveReplicaZoneRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def list_volumes(self) -> Callable[ + [volume.ListVolumesRequest], + Union[ + volume.ListVolumesResponse, + Awaitable[volume.ListVolumesResponse] + ]]: + raise NotImplementedError() + + @property + def get_volume(self) -> Callable[ + [volume.GetVolumeRequest], + Union[ + volume.Volume, + Awaitable[volume.Volume] + ]]: + raise NotImplementedError() + + @property + def create_volume(self) -> Callable[ + [gcn_volume.CreateVolumeRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_volume(self) -> Callable[ + [gcn_volume.UpdateVolumeRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_volume(self) -> Callable[ + [volume.DeleteVolumeRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def revert_volume(self) -> Callable[ + [volume.RevertVolumeRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def list_snapshots(self) -> Callable[ + [snapshot.ListSnapshotsRequest], + Union[ + snapshot.ListSnapshotsResponse, + Awaitable[snapshot.ListSnapshotsResponse] + ]]: + raise NotImplementedError() + + @property + def get_snapshot(self) -> Callable[ + [snapshot.GetSnapshotRequest], + Union[ + snapshot.Snapshot, + Awaitable[snapshot.Snapshot] + ]]: + raise NotImplementedError() + + @property + def create_snapshot(self) -> Callable[ + [gcn_snapshot.CreateSnapshotRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_snapshot(self) -> Callable[ + [snapshot.DeleteSnapshotRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_snapshot(self) -> Callable[ + [gcn_snapshot.UpdateSnapshotRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def list_active_directories(self) -> Callable[ + [active_directory.ListActiveDirectoriesRequest], + Union[ + active_directory.ListActiveDirectoriesResponse, + Awaitable[active_directory.ListActiveDirectoriesResponse] + ]]: + raise NotImplementedError() + + @property + def get_active_directory(self) -> Callable[ + [active_directory.GetActiveDirectoryRequest], + Union[ + active_directory.ActiveDirectory, + Awaitable[active_directory.ActiveDirectory] + ]]: + raise NotImplementedError() + + @property + def create_active_directory(self) -> Callable[ + [gcn_active_directory.CreateActiveDirectoryRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_active_directory(self) -> Callable[ + [gcn_active_directory.UpdateActiveDirectoryRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_active_directory(self) -> Callable[ + [active_directory.DeleteActiveDirectoryRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def list_kms_configs(self) -> Callable[ + [kms.ListKmsConfigsRequest], + Union[ + kms.ListKmsConfigsResponse, + Awaitable[kms.ListKmsConfigsResponse] + ]]: + raise NotImplementedError() + + @property + def create_kms_config(self) -> Callable[ + [kms.CreateKmsConfigRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def get_kms_config(self) -> Callable[ + [kms.GetKmsConfigRequest], + Union[ + kms.KmsConfig, + Awaitable[kms.KmsConfig] + ]]: + raise NotImplementedError() + + @property + def update_kms_config(self) -> Callable[ + [kms.UpdateKmsConfigRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def encrypt_volumes(self) -> Callable[ + [kms.EncryptVolumesRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def verify_kms_config(self) -> Callable[ + [kms.VerifyKmsConfigRequest], + Union[ + kms.VerifyKmsConfigResponse, + Awaitable[kms.VerifyKmsConfigResponse] + ]]: + raise NotImplementedError() + + @property + def delete_kms_config(self) -> Callable[ + [kms.DeleteKmsConfigRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def list_replications(self) -> Callable[ + [replication.ListReplicationsRequest], + Union[ + replication.ListReplicationsResponse, + Awaitable[replication.ListReplicationsResponse] + ]]: + raise NotImplementedError() + + @property + def get_replication(self) -> Callable[ + [replication.GetReplicationRequest], + Union[ + replication.Replication, + Awaitable[replication.Replication] + ]]: + raise NotImplementedError() + + @property + def create_replication(self) -> Callable[ + [gcn_replication.CreateReplicationRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_replication(self) -> Callable[ + [replication.DeleteReplicationRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_replication(self) -> Callable[ + [gcn_replication.UpdateReplicationRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def stop_replication(self) -> Callable[ + [replication.StopReplicationRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def resume_replication(self) -> Callable[ + [replication.ResumeReplicationRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def reverse_replication_direction(self) -> Callable[ + [replication.ReverseReplicationDirectionRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def establish_peering(self) -> Callable[ + [replication.EstablishPeeringRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def sync_replication(self) -> Callable[ + [replication.SyncReplicationRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def create_backup_vault(self) -> Callable[ + [gcn_backup_vault.CreateBackupVaultRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def get_backup_vault(self) -> Callable[ + [backup_vault.GetBackupVaultRequest], + Union[ + backup_vault.BackupVault, + Awaitable[backup_vault.BackupVault] + ]]: + raise NotImplementedError() + + @property + def list_backup_vaults(self) -> Callable[ + [backup_vault.ListBackupVaultsRequest], + Union[ + backup_vault.ListBackupVaultsResponse, + Awaitable[backup_vault.ListBackupVaultsResponse] + ]]: + raise NotImplementedError() + + @property + def update_backup_vault(self) -> Callable[ + [gcn_backup_vault.UpdateBackupVaultRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_backup_vault(self) -> Callable[ + [backup_vault.DeleteBackupVaultRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def create_backup(self) -> Callable[ + [gcn_backup.CreateBackupRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def get_backup(self) -> Callable[ + [backup.GetBackupRequest], + Union[ + backup.Backup, + Awaitable[backup.Backup] + ]]: + raise NotImplementedError() + + @property + def list_backups(self) -> Callable[ + [backup.ListBackupsRequest], + Union[ + backup.ListBackupsResponse, + Awaitable[backup.ListBackupsResponse] + ]]: + raise NotImplementedError() + + @property + def delete_backup(self) -> Callable[ + [backup.DeleteBackupRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_backup(self) -> Callable[ + [gcn_backup.UpdateBackupRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def create_backup_policy(self) -> Callable[ + [gcn_backup_policy.CreateBackupPolicyRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def get_backup_policy(self) -> Callable[ + [backup_policy.GetBackupPolicyRequest], + Union[ + backup_policy.BackupPolicy, + Awaitable[backup_policy.BackupPolicy] + ]]: + raise NotImplementedError() + + @property + def list_backup_policies(self) -> Callable[ + [backup_policy.ListBackupPoliciesRequest], + Union[ + backup_policy.ListBackupPoliciesResponse, + Awaitable[backup_policy.ListBackupPoliciesResponse] + ]]: + raise NotImplementedError() + + @property + def update_backup_policy(self) -> Callable[ + [gcn_backup_policy.UpdateBackupPolicyRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_backup_policy(self) -> Callable[ + [backup_policy.DeleteBackupPolicyRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def list_quota_rules(self) -> Callable[ + [quota_rule.ListQuotaRulesRequest], + Union[ + quota_rule.ListQuotaRulesResponse, + Awaitable[quota_rule.ListQuotaRulesResponse] + ]]: + raise NotImplementedError() + + @property + def get_quota_rule(self) -> Callable[ + [quota_rule.GetQuotaRuleRequest], + Union[ + quota_rule.QuotaRule, + Awaitable[quota_rule.QuotaRule] + ]]: + raise NotImplementedError() + + @property + def create_quota_rule(self) -> Callable[ + [gcn_quota_rule.CreateQuotaRuleRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_quota_rule(self) -> Callable[ + [gcn_quota_rule.UpdateQuotaRuleRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_quota_rule(self) -> Callable[ + [quota_rule.DeleteQuotaRuleRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def list_operations( + self, + ) -> Callable[ + [operations_pb2.ListOperationsRequest], + Union[operations_pb2.ListOperationsResponse, Awaitable[operations_pb2.ListOperationsResponse]], + ]: + raise NotImplementedError() + + @property + def get_operation( + self, + ) -> Callable[ + [operations_pb2.GetOperationRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def cancel_operation( + self, + ) -> Callable[ + [operations_pb2.CancelOperationRequest], + None, + ]: + raise NotImplementedError() + + @property + def delete_operation( + self, + ) -> Callable[ + [operations_pb2.DeleteOperationRequest], + None, + ]: + 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__ = ( + 'NetAppTransport', +) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/grpc.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/grpc.py new file mode 100644 index 000000000000..0030b7b37801 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/grpc.py @@ -0,0 +1,2052 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 +import logging as std_logging +import pickle +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 +from google.protobuf.json_format import MessageToJson +import google.protobuf.message + +import grpc # type: ignore +import proto # type: ignore + +from google.cloud.location import locations_pb2 # type: ignore +from google.cloud.netapp_v1.types import active_directory +from google.cloud.netapp_v1.types import active_directory as gcn_active_directory +from google.cloud.netapp_v1.types import backup +from google.cloud.netapp_v1.types import backup as gcn_backup +from google.cloud.netapp_v1.types import backup_policy +from google.cloud.netapp_v1.types import backup_policy as gcn_backup_policy +from google.cloud.netapp_v1.types import backup_vault +from google.cloud.netapp_v1.types import backup_vault as gcn_backup_vault +from google.cloud.netapp_v1.types import kms +from google.cloud.netapp_v1.types import quota_rule +from google.cloud.netapp_v1.types import quota_rule as gcn_quota_rule +from google.cloud.netapp_v1.types import replication +from google.cloud.netapp_v1.types import replication as gcn_replication +from google.cloud.netapp_v1.types import snapshot +from google.cloud.netapp_v1.types import snapshot as gcn_snapshot +from google.cloud.netapp_v1.types import storage_pool +from google.cloud.netapp_v1.types import storage_pool as gcn_storage_pool +from google.cloud.netapp_v1.types import volume +from google.cloud.netapp_v1.types import volume as gcn_volume +from google.longrunning import operations_pb2 # type: ignore +from .base import NetAppTransport, DEFAULT_CLIENT_INFO + +try: + from google.api_core import client_logging # type: ignore + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER + def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": str(client_call_details.method), + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + response = continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = dict([(k, str(v)) for k, v in response_metadata]) if response_metadata else None + result = response.result() + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response for {client_call_details.method}.", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + + +class NetAppGrpcTransport(NetAppTransport): + """gRPC backend transport for NetApp. + + NetApp Files Google Cloud Service + + 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 = 'netapp.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: 'netapp.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), + ], + ) + + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel(self._grpc_channel, self._interceptor) + + # Wrap messages. This must be done after self._logged_channel exists + self._prep_wrapped_messages(client_info) + + @classmethod + def create_channel(cls, + host: str = 'netapp.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._logged_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def list_storage_pools(self) -> Callable[ + [storage_pool.ListStoragePoolsRequest], + storage_pool.ListStoragePoolsResponse]: + r"""Return a callable for the list storage pools method over gRPC. + + Returns descriptions of all storage pools owned by + the caller. + + Returns: + Callable[[~.ListStoragePoolsRequest], + ~.ListStoragePoolsResponse]: + 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_storage_pools' not in self._stubs: + self._stubs['list_storage_pools'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ListStoragePools', + request_serializer=storage_pool.ListStoragePoolsRequest.serialize, + response_deserializer=storage_pool.ListStoragePoolsResponse.deserialize, + ) + return self._stubs['list_storage_pools'] + + @property + def create_storage_pool(self) -> Callable[ + [gcn_storage_pool.CreateStoragePoolRequest], + operations_pb2.Operation]: + r"""Return a callable for the create storage pool method over gRPC. + + Creates a new storage pool. + + Returns: + Callable[[~.CreateStoragePoolRequest], + ~.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_storage_pool' not in self._stubs: + self._stubs['create_storage_pool'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/CreateStoragePool', + request_serializer=gcn_storage_pool.CreateStoragePoolRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_storage_pool'] + + @property + def get_storage_pool(self) -> Callable[ + [storage_pool.GetStoragePoolRequest], + storage_pool.StoragePool]: + r"""Return a callable for the get storage pool method over gRPC. + + Returns the description of the specified storage pool + by poolId. + + Returns: + Callable[[~.GetStoragePoolRequest], + ~.StoragePool]: + 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_storage_pool' not in self._stubs: + self._stubs['get_storage_pool'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/GetStoragePool', + request_serializer=storage_pool.GetStoragePoolRequest.serialize, + response_deserializer=storage_pool.StoragePool.deserialize, + ) + return self._stubs['get_storage_pool'] + + @property + def update_storage_pool(self) -> Callable[ + [gcn_storage_pool.UpdateStoragePoolRequest], + operations_pb2.Operation]: + r"""Return a callable for the update storage pool method over gRPC. + + Updates the storage pool properties with the full + spec + + Returns: + Callable[[~.UpdateStoragePoolRequest], + ~.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 'update_storage_pool' not in self._stubs: + self._stubs['update_storage_pool'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/UpdateStoragePool', + request_serializer=gcn_storage_pool.UpdateStoragePoolRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_storage_pool'] + + @property + def delete_storage_pool(self) -> Callable[ + [storage_pool.DeleteStoragePoolRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete storage pool method over gRPC. + + Warning! This operation will permanently delete the + storage pool. + + Returns: + Callable[[~.DeleteStoragePoolRequest], + ~.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_storage_pool' not in self._stubs: + self._stubs['delete_storage_pool'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/DeleteStoragePool', + request_serializer=storage_pool.DeleteStoragePoolRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_storage_pool'] + + @property + def validate_directory_service(self) -> Callable[ + [storage_pool.ValidateDirectoryServiceRequest], + operations_pb2.Operation]: + r"""Return a callable for the validate directory service method over gRPC. + + ValidateDirectoryService does a connectivity check + for a directory service policy attached to the storage + pool. + + Returns: + Callable[[~.ValidateDirectoryServiceRequest], + ~.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 'validate_directory_service' not in self._stubs: + self._stubs['validate_directory_service'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ValidateDirectoryService', + request_serializer=storage_pool.ValidateDirectoryServiceRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['validate_directory_service'] + + @property + def switch_active_replica_zone(self) -> Callable[ + [storage_pool.SwitchActiveReplicaZoneRequest], + operations_pb2.Operation]: + r"""Return a callable for the switch active replica zone method over gRPC. + + This operation will switch the active/replica zone + for a regional storagePool. + + Returns: + Callable[[~.SwitchActiveReplicaZoneRequest], + ~.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 'switch_active_replica_zone' not in self._stubs: + self._stubs['switch_active_replica_zone'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/SwitchActiveReplicaZone', + request_serializer=storage_pool.SwitchActiveReplicaZoneRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['switch_active_replica_zone'] + + @property + def list_volumes(self) -> Callable[ + [volume.ListVolumesRequest], + volume.ListVolumesResponse]: + r"""Return a callable for the list volumes method over gRPC. + + Lists Volumes in a given project. + + Returns: + Callable[[~.ListVolumesRequest], + ~.ListVolumesResponse]: + 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_volumes' not in self._stubs: + self._stubs['list_volumes'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ListVolumes', + request_serializer=volume.ListVolumesRequest.serialize, + response_deserializer=volume.ListVolumesResponse.deserialize, + ) + return self._stubs['list_volumes'] + + @property + def get_volume(self) -> Callable[ + [volume.GetVolumeRequest], + volume.Volume]: + r"""Return a callable for the get volume method over gRPC. + + Gets details of a single Volume. + + Returns: + Callable[[~.GetVolumeRequest], + ~.Volume]: + 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_volume' not in self._stubs: + self._stubs['get_volume'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/GetVolume', + request_serializer=volume.GetVolumeRequest.serialize, + response_deserializer=volume.Volume.deserialize, + ) + return self._stubs['get_volume'] + + @property + def create_volume(self) -> Callable[ + [gcn_volume.CreateVolumeRequest], + operations_pb2.Operation]: + r"""Return a callable for the create volume method over gRPC. + + Creates a new Volume in a given project and location. + + Returns: + Callable[[~.CreateVolumeRequest], + ~.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_volume' not in self._stubs: + self._stubs['create_volume'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/CreateVolume', + request_serializer=gcn_volume.CreateVolumeRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_volume'] + + @property + def update_volume(self) -> Callable[ + [gcn_volume.UpdateVolumeRequest], + operations_pb2.Operation]: + r"""Return a callable for the update volume method over gRPC. + + Updates the parameters of a single Volume. + + Returns: + Callable[[~.UpdateVolumeRequest], + ~.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 'update_volume' not in self._stubs: + self._stubs['update_volume'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/UpdateVolume', + request_serializer=gcn_volume.UpdateVolumeRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_volume'] + + @property + def delete_volume(self) -> Callable[ + [volume.DeleteVolumeRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete volume method over gRPC. + + Deletes a single Volume. + + Returns: + Callable[[~.DeleteVolumeRequest], + ~.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_volume' not in self._stubs: + self._stubs['delete_volume'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/DeleteVolume', + request_serializer=volume.DeleteVolumeRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_volume'] + + @property + def revert_volume(self) -> Callable[ + [volume.RevertVolumeRequest], + operations_pb2.Operation]: + r"""Return a callable for the revert volume method over gRPC. + + Revert an existing volume to a specified snapshot. + Warning! This operation will permanently revert all + changes made after the snapshot was created. + + Returns: + Callable[[~.RevertVolumeRequest], + ~.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 'revert_volume' not in self._stubs: + self._stubs['revert_volume'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/RevertVolume', + request_serializer=volume.RevertVolumeRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['revert_volume'] + + @property + def list_snapshots(self) -> Callable[ + [snapshot.ListSnapshotsRequest], + snapshot.ListSnapshotsResponse]: + r"""Return a callable for the list snapshots method over gRPC. + + Returns descriptions of all snapshots for a volume. + + Returns: + Callable[[~.ListSnapshotsRequest], + ~.ListSnapshotsResponse]: + 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_snapshots' not in self._stubs: + self._stubs['list_snapshots'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ListSnapshots', + request_serializer=snapshot.ListSnapshotsRequest.serialize, + response_deserializer=snapshot.ListSnapshotsResponse.deserialize, + ) + return self._stubs['list_snapshots'] + + @property + def get_snapshot(self) -> Callable[ + [snapshot.GetSnapshotRequest], + snapshot.Snapshot]: + r"""Return a callable for the get snapshot method over gRPC. + + Describe a snapshot for a volume. + + Returns: + Callable[[~.GetSnapshotRequest], + ~.Snapshot]: + 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_snapshot' not in self._stubs: + self._stubs['get_snapshot'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/GetSnapshot', + request_serializer=snapshot.GetSnapshotRequest.serialize, + response_deserializer=snapshot.Snapshot.deserialize, + ) + return self._stubs['get_snapshot'] + + @property + def create_snapshot(self) -> Callable[ + [gcn_snapshot.CreateSnapshotRequest], + operations_pb2.Operation]: + r"""Return a callable for the create snapshot method over gRPC. + + Create a new snapshot for a volume. + + Returns: + Callable[[~.CreateSnapshotRequest], + ~.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_snapshot' not in self._stubs: + self._stubs['create_snapshot'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/CreateSnapshot', + request_serializer=gcn_snapshot.CreateSnapshotRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_snapshot'] + + @property + def delete_snapshot(self) -> Callable[ + [snapshot.DeleteSnapshotRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete snapshot method over gRPC. + + Deletes a snapshot. + + Returns: + Callable[[~.DeleteSnapshotRequest], + ~.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_snapshot' not in self._stubs: + self._stubs['delete_snapshot'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/DeleteSnapshot', + request_serializer=snapshot.DeleteSnapshotRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_snapshot'] + + @property + def update_snapshot(self) -> Callable[ + [gcn_snapshot.UpdateSnapshotRequest], + operations_pb2.Operation]: + r"""Return a callable for the update snapshot method over gRPC. + + Updates the settings of a specific snapshot. + + Returns: + Callable[[~.UpdateSnapshotRequest], + ~.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 'update_snapshot' not in self._stubs: + self._stubs['update_snapshot'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/UpdateSnapshot', + request_serializer=gcn_snapshot.UpdateSnapshotRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_snapshot'] + + @property + def list_active_directories(self) -> Callable[ + [active_directory.ListActiveDirectoriesRequest], + active_directory.ListActiveDirectoriesResponse]: + r"""Return a callable for the list active directories method over gRPC. + + Lists active directories. + + Returns: + Callable[[~.ListActiveDirectoriesRequest], + ~.ListActiveDirectoriesResponse]: + 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_active_directories' not in self._stubs: + self._stubs['list_active_directories'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ListActiveDirectories', + request_serializer=active_directory.ListActiveDirectoriesRequest.serialize, + response_deserializer=active_directory.ListActiveDirectoriesResponse.deserialize, + ) + return self._stubs['list_active_directories'] + + @property + def get_active_directory(self) -> Callable[ + [active_directory.GetActiveDirectoryRequest], + active_directory.ActiveDirectory]: + r"""Return a callable for the get active directory method over gRPC. + + Describes a specified active directory. + + Returns: + Callable[[~.GetActiveDirectoryRequest], + ~.ActiveDirectory]: + 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_active_directory' not in self._stubs: + self._stubs['get_active_directory'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/GetActiveDirectory', + request_serializer=active_directory.GetActiveDirectoryRequest.serialize, + response_deserializer=active_directory.ActiveDirectory.deserialize, + ) + return self._stubs['get_active_directory'] + + @property + def create_active_directory(self) -> Callable[ + [gcn_active_directory.CreateActiveDirectoryRequest], + operations_pb2.Operation]: + r"""Return a callable for the create active directory method over gRPC. + + CreateActiveDirectory + Creates the active directory specified in the request. + + Returns: + Callable[[~.CreateActiveDirectoryRequest], + ~.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_active_directory' not in self._stubs: + self._stubs['create_active_directory'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/CreateActiveDirectory', + request_serializer=gcn_active_directory.CreateActiveDirectoryRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_active_directory'] + + @property + def update_active_directory(self) -> Callable[ + [gcn_active_directory.UpdateActiveDirectoryRequest], + operations_pb2.Operation]: + r"""Return a callable for the update active directory method over gRPC. + + Update the parameters of an active directories. + + Returns: + Callable[[~.UpdateActiveDirectoryRequest], + ~.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 'update_active_directory' not in self._stubs: + self._stubs['update_active_directory'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/UpdateActiveDirectory', + request_serializer=gcn_active_directory.UpdateActiveDirectoryRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_active_directory'] + + @property + def delete_active_directory(self) -> Callable[ + [active_directory.DeleteActiveDirectoryRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete active directory method over gRPC. + + Delete the active directory specified in the request. + + Returns: + Callable[[~.DeleteActiveDirectoryRequest], + ~.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_active_directory' not in self._stubs: + self._stubs['delete_active_directory'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/DeleteActiveDirectory', + request_serializer=active_directory.DeleteActiveDirectoryRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_active_directory'] + + @property + def list_kms_configs(self) -> Callable[ + [kms.ListKmsConfigsRequest], + kms.ListKmsConfigsResponse]: + r"""Return a callable for the list kms configs method over gRPC. + + Returns descriptions of all KMS configs owned by the + caller. + + Returns: + Callable[[~.ListKmsConfigsRequest], + ~.ListKmsConfigsResponse]: + 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_kms_configs' not in self._stubs: + self._stubs['list_kms_configs'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ListKmsConfigs', + request_serializer=kms.ListKmsConfigsRequest.serialize, + response_deserializer=kms.ListKmsConfigsResponse.deserialize, + ) + return self._stubs['list_kms_configs'] + + @property + def create_kms_config(self) -> Callable[ + [kms.CreateKmsConfigRequest], + operations_pb2.Operation]: + r"""Return a callable for the create kms config method over gRPC. + + Creates a new KMS config. + + Returns: + Callable[[~.CreateKmsConfigRequest], + ~.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_kms_config' not in self._stubs: + self._stubs['create_kms_config'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/CreateKmsConfig', + request_serializer=kms.CreateKmsConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_kms_config'] + + @property + def get_kms_config(self) -> Callable[ + [kms.GetKmsConfigRequest], + kms.KmsConfig]: + r"""Return a callable for the get kms config method over gRPC. + + Returns the description of the specified KMS config by + kms_config_id. + + Returns: + Callable[[~.GetKmsConfigRequest], + ~.KmsConfig]: + 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_kms_config' not in self._stubs: + self._stubs['get_kms_config'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/GetKmsConfig', + request_serializer=kms.GetKmsConfigRequest.serialize, + response_deserializer=kms.KmsConfig.deserialize, + ) + return self._stubs['get_kms_config'] + + @property + def update_kms_config(self) -> Callable[ + [kms.UpdateKmsConfigRequest], + operations_pb2.Operation]: + r"""Return a callable for the update kms config method over gRPC. + + Updates the Kms config properties with the full spec + + Returns: + Callable[[~.UpdateKmsConfigRequest], + ~.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 'update_kms_config' not in self._stubs: + self._stubs['update_kms_config'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/UpdateKmsConfig', + request_serializer=kms.UpdateKmsConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_kms_config'] + + @property + def encrypt_volumes(self) -> Callable[ + [kms.EncryptVolumesRequest], + operations_pb2.Operation]: + r"""Return a callable for the encrypt volumes method over gRPC. + + Encrypt the existing volumes without CMEK encryption + with the desired the KMS config for the whole region. + + Returns: + Callable[[~.EncryptVolumesRequest], + ~.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 'encrypt_volumes' not in self._stubs: + self._stubs['encrypt_volumes'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/EncryptVolumes', + request_serializer=kms.EncryptVolumesRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['encrypt_volumes'] + + @property + def verify_kms_config(self) -> Callable[ + [kms.VerifyKmsConfigRequest], + kms.VerifyKmsConfigResponse]: + r"""Return a callable for the verify kms config method over gRPC. + + Verifies KMS config reachability. + + Returns: + Callable[[~.VerifyKmsConfigRequest], + ~.VerifyKmsConfigResponse]: + 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 'verify_kms_config' not in self._stubs: + self._stubs['verify_kms_config'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/VerifyKmsConfig', + request_serializer=kms.VerifyKmsConfigRequest.serialize, + response_deserializer=kms.VerifyKmsConfigResponse.deserialize, + ) + return self._stubs['verify_kms_config'] + + @property + def delete_kms_config(self) -> Callable[ + [kms.DeleteKmsConfigRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete kms config method over gRPC. + + Warning! This operation will permanently delete the + Kms config. + + Returns: + Callable[[~.DeleteKmsConfigRequest], + ~.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_kms_config' not in self._stubs: + self._stubs['delete_kms_config'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/DeleteKmsConfig', + request_serializer=kms.DeleteKmsConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_kms_config'] + + @property + def list_replications(self) -> Callable[ + [replication.ListReplicationsRequest], + replication.ListReplicationsResponse]: + r"""Return a callable for the list replications method over gRPC. + + Returns descriptions of all replications for a + volume. + + Returns: + Callable[[~.ListReplicationsRequest], + ~.ListReplicationsResponse]: + 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_replications' not in self._stubs: + self._stubs['list_replications'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ListReplications', + request_serializer=replication.ListReplicationsRequest.serialize, + response_deserializer=replication.ListReplicationsResponse.deserialize, + ) + return self._stubs['list_replications'] + + @property + def get_replication(self) -> Callable[ + [replication.GetReplicationRequest], + replication.Replication]: + r"""Return a callable for the get replication method over gRPC. + + Describe a replication for a volume. + + Returns: + Callable[[~.GetReplicationRequest], + ~.Replication]: + 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_replication' not in self._stubs: + self._stubs['get_replication'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/GetReplication', + request_serializer=replication.GetReplicationRequest.serialize, + response_deserializer=replication.Replication.deserialize, + ) + return self._stubs['get_replication'] + + @property + def create_replication(self) -> Callable[ + [gcn_replication.CreateReplicationRequest], + operations_pb2.Operation]: + r"""Return a callable for the create replication method over gRPC. + + Create a new replication for a volume. + + Returns: + Callable[[~.CreateReplicationRequest], + ~.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_replication' not in self._stubs: + self._stubs['create_replication'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/CreateReplication', + request_serializer=gcn_replication.CreateReplicationRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_replication'] + + @property + def delete_replication(self) -> Callable[ + [replication.DeleteReplicationRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete replication method over gRPC. + + Deletes a replication. + + Returns: + Callable[[~.DeleteReplicationRequest], + ~.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_replication' not in self._stubs: + self._stubs['delete_replication'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/DeleteReplication', + request_serializer=replication.DeleteReplicationRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_replication'] + + @property + def update_replication(self) -> Callable[ + [gcn_replication.UpdateReplicationRequest], + operations_pb2.Operation]: + r"""Return a callable for the update replication method over gRPC. + + Updates the settings of a specific replication. + + Returns: + Callable[[~.UpdateReplicationRequest], + ~.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 'update_replication' not in self._stubs: + self._stubs['update_replication'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/UpdateReplication', + request_serializer=gcn_replication.UpdateReplicationRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_replication'] + + @property + def stop_replication(self) -> Callable[ + [replication.StopReplicationRequest], + operations_pb2.Operation]: + r"""Return a callable for the stop replication method over gRPC. + + Stop Cross Region Replication. + + Returns: + Callable[[~.StopReplicationRequest], + ~.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 'stop_replication' not in self._stubs: + self._stubs['stop_replication'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/StopReplication', + request_serializer=replication.StopReplicationRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['stop_replication'] + + @property + def resume_replication(self) -> Callable[ + [replication.ResumeReplicationRequest], + operations_pb2.Operation]: + r"""Return a callable for the resume replication method over gRPC. + + Resume Cross Region Replication. + + Returns: + Callable[[~.ResumeReplicationRequest], + ~.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 'resume_replication' not in self._stubs: + self._stubs['resume_replication'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ResumeReplication', + request_serializer=replication.ResumeReplicationRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['resume_replication'] + + @property + def reverse_replication_direction(self) -> Callable[ + [replication.ReverseReplicationDirectionRequest], + operations_pb2.Operation]: + r"""Return a callable for the reverse replication direction method over gRPC. + + Reverses direction of replication. Source becomes + destination and destination becomes source. + + Returns: + Callable[[~.ReverseReplicationDirectionRequest], + ~.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 'reverse_replication_direction' not in self._stubs: + self._stubs['reverse_replication_direction'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ReverseReplicationDirection', + request_serializer=replication.ReverseReplicationDirectionRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['reverse_replication_direction'] + + @property + def establish_peering(self) -> Callable[ + [replication.EstablishPeeringRequest], + operations_pb2.Operation]: + r"""Return a callable for the establish peering method over gRPC. + + Establish replication peering. + + Returns: + Callable[[~.EstablishPeeringRequest], + ~.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 'establish_peering' not in self._stubs: + self._stubs['establish_peering'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/EstablishPeering', + request_serializer=replication.EstablishPeeringRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['establish_peering'] + + @property + def sync_replication(self) -> Callable[ + [replication.SyncReplicationRequest], + operations_pb2.Operation]: + r"""Return a callable for the sync replication method over gRPC. + + Syncs the replication. This will invoke one time + volume data transfer from source to destination. + + Returns: + Callable[[~.SyncReplicationRequest], + ~.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 'sync_replication' not in self._stubs: + self._stubs['sync_replication'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/SyncReplication', + request_serializer=replication.SyncReplicationRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['sync_replication'] + + @property + def create_backup_vault(self) -> Callable[ + [gcn_backup_vault.CreateBackupVaultRequest], + operations_pb2.Operation]: + r"""Return a callable for the create backup vault method over gRPC. + + Creates new backup vault + + Returns: + Callable[[~.CreateBackupVaultRequest], + ~.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_backup_vault' not in self._stubs: + self._stubs['create_backup_vault'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/CreateBackupVault', + request_serializer=gcn_backup_vault.CreateBackupVaultRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_backup_vault'] + + @property + def get_backup_vault(self) -> Callable[ + [backup_vault.GetBackupVaultRequest], + backup_vault.BackupVault]: + r"""Return a callable for the get backup vault method over gRPC. + + Returns the description of the specified backup vault + + Returns: + Callable[[~.GetBackupVaultRequest], + ~.BackupVault]: + 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_backup_vault' not in self._stubs: + self._stubs['get_backup_vault'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/GetBackupVault', + request_serializer=backup_vault.GetBackupVaultRequest.serialize, + response_deserializer=backup_vault.BackupVault.deserialize, + ) + return self._stubs['get_backup_vault'] + + @property + def list_backup_vaults(self) -> Callable[ + [backup_vault.ListBackupVaultsRequest], + backup_vault.ListBackupVaultsResponse]: + r"""Return a callable for the list backup vaults method over gRPC. + + Returns list of all available backup vaults. + + Returns: + Callable[[~.ListBackupVaultsRequest], + ~.ListBackupVaultsResponse]: + 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_backup_vaults' not in self._stubs: + self._stubs['list_backup_vaults'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ListBackupVaults', + request_serializer=backup_vault.ListBackupVaultsRequest.serialize, + response_deserializer=backup_vault.ListBackupVaultsResponse.deserialize, + ) + return self._stubs['list_backup_vaults'] + + @property + def update_backup_vault(self) -> Callable[ + [gcn_backup_vault.UpdateBackupVaultRequest], + operations_pb2.Operation]: + r"""Return a callable for the update backup vault method over gRPC. + + Updates the settings of a specific backup vault. + + Returns: + Callable[[~.UpdateBackupVaultRequest], + ~.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 'update_backup_vault' not in self._stubs: + self._stubs['update_backup_vault'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/UpdateBackupVault', + request_serializer=gcn_backup_vault.UpdateBackupVaultRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_backup_vault'] + + @property + def delete_backup_vault(self) -> Callable[ + [backup_vault.DeleteBackupVaultRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete backup vault method over gRPC. + + Warning! This operation will permanently delete the + backup vault. + + Returns: + Callable[[~.DeleteBackupVaultRequest], + ~.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_backup_vault' not in self._stubs: + self._stubs['delete_backup_vault'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/DeleteBackupVault', + request_serializer=backup_vault.DeleteBackupVaultRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_backup_vault'] + + @property + def create_backup(self) -> Callable[ + [gcn_backup.CreateBackupRequest], + operations_pb2.Operation]: + r"""Return a callable for the create backup method over gRPC. + + Creates a backup from the volume specified in the + request The backup can be created from the given + snapshot if specified in the request. If no snapshot + specified, there'll be a new snapshot taken to initiate + the backup creation. + + Returns: + Callable[[~.CreateBackupRequest], + ~.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_backup' not in self._stubs: + self._stubs['create_backup'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/CreateBackup', + request_serializer=gcn_backup.CreateBackupRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_backup'] + + @property + def get_backup(self) -> Callable[ + [backup.GetBackupRequest], + backup.Backup]: + r"""Return a callable for the get backup method over gRPC. + + Returns the description of the specified backup + + Returns: + Callable[[~.GetBackupRequest], + ~.Backup]: + 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_backup' not in self._stubs: + self._stubs['get_backup'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/GetBackup', + request_serializer=backup.GetBackupRequest.serialize, + response_deserializer=backup.Backup.deserialize, + ) + return self._stubs['get_backup'] + + @property + def list_backups(self) -> Callable[ + [backup.ListBackupsRequest], + backup.ListBackupsResponse]: + r"""Return a callable for the list backups method over gRPC. + + Returns descriptions of all backups for a + backupVault. + + Returns: + Callable[[~.ListBackupsRequest], + ~.ListBackupsResponse]: + 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_backups' not in self._stubs: + self._stubs['list_backups'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ListBackups', + request_serializer=backup.ListBackupsRequest.serialize, + response_deserializer=backup.ListBackupsResponse.deserialize, + ) + return self._stubs['list_backups'] + + @property + def delete_backup(self) -> Callable[ + [backup.DeleteBackupRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete backup method over gRPC. + + Warning! This operation will permanently delete the + backup. + + Returns: + Callable[[~.DeleteBackupRequest], + ~.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_backup' not in self._stubs: + self._stubs['delete_backup'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/DeleteBackup', + request_serializer=backup.DeleteBackupRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_backup'] + + @property + def update_backup(self) -> Callable[ + [gcn_backup.UpdateBackupRequest], + operations_pb2.Operation]: + r"""Return a callable for the update backup method over gRPC. + + Update backup with full spec. + + Returns: + Callable[[~.UpdateBackupRequest], + ~.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 'update_backup' not in self._stubs: + self._stubs['update_backup'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/UpdateBackup', + request_serializer=gcn_backup.UpdateBackupRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_backup'] + + @property + def create_backup_policy(self) -> Callable[ + [gcn_backup_policy.CreateBackupPolicyRequest], + operations_pb2.Operation]: + r"""Return a callable for the create backup policy method over gRPC. + + Creates new backup policy + + Returns: + Callable[[~.CreateBackupPolicyRequest], + ~.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_backup_policy' not in self._stubs: + self._stubs['create_backup_policy'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/CreateBackupPolicy', + request_serializer=gcn_backup_policy.CreateBackupPolicyRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_backup_policy'] + + @property + def get_backup_policy(self) -> Callable[ + [backup_policy.GetBackupPolicyRequest], + backup_policy.BackupPolicy]: + r"""Return a callable for the get backup policy method over gRPC. + + Returns the description of the specified backup policy by + backup_policy_id. + + Returns: + Callable[[~.GetBackupPolicyRequest], + ~.BackupPolicy]: + 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_backup_policy' not in self._stubs: + self._stubs['get_backup_policy'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/GetBackupPolicy', + request_serializer=backup_policy.GetBackupPolicyRequest.serialize, + response_deserializer=backup_policy.BackupPolicy.deserialize, + ) + return self._stubs['get_backup_policy'] + + @property + def list_backup_policies(self) -> Callable[ + [backup_policy.ListBackupPoliciesRequest], + backup_policy.ListBackupPoliciesResponse]: + r"""Return a callable for the list backup policies method over gRPC. + + Returns list of all available backup policies. + + Returns: + Callable[[~.ListBackupPoliciesRequest], + ~.ListBackupPoliciesResponse]: + 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_backup_policies' not in self._stubs: + self._stubs['list_backup_policies'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ListBackupPolicies', + request_serializer=backup_policy.ListBackupPoliciesRequest.serialize, + response_deserializer=backup_policy.ListBackupPoliciesResponse.deserialize, + ) + return self._stubs['list_backup_policies'] + + @property + def update_backup_policy(self) -> Callable[ + [gcn_backup_policy.UpdateBackupPolicyRequest], + operations_pb2.Operation]: + r"""Return a callable for the update backup policy method over gRPC. + + Updates settings of a specific backup policy. + + Returns: + Callable[[~.UpdateBackupPolicyRequest], + ~.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 'update_backup_policy' not in self._stubs: + self._stubs['update_backup_policy'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/UpdateBackupPolicy', + request_serializer=gcn_backup_policy.UpdateBackupPolicyRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_backup_policy'] + + @property + def delete_backup_policy(self) -> Callable[ + [backup_policy.DeleteBackupPolicyRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete backup policy method over gRPC. + + Warning! This operation will permanently delete the + backup policy. + + Returns: + Callable[[~.DeleteBackupPolicyRequest], + ~.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_backup_policy' not in self._stubs: + self._stubs['delete_backup_policy'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/DeleteBackupPolicy', + request_serializer=backup_policy.DeleteBackupPolicyRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_backup_policy'] + + @property + def list_quota_rules(self) -> Callable[ + [quota_rule.ListQuotaRulesRequest], + quota_rule.ListQuotaRulesResponse]: + r"""Return a callable for the list quota rules method over gRPC. + + Returns list of all quota rules in a location. + + Returns: + Callable[[~.ListQuotaRulesRequest], + ~.ListQuotaRulesResponse]: + 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_quota_rules' not in self._stubs: + self._stubs['list_quota_rules'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ListQuotaRules', + request_serializer=quota_rule.ListQuotaRulesRequest.serialize, + response_deserializer=quota_rule.ListQuotaRulesResponse.deserialize, + ) + return self._stubs['list_quota_rules'] + + @property + def get_quota_rule(self) -> Callable[ + [quota_rule.GetQuotaRuleRequest], + quota_rule.QuotaRule]: + r"""Return a callable for the get quota rule method over gRPC. + + Returns details of the specified quota rule. + + Returns: + Callable[[~.GetQuotaRuleRequest], + ~.QuotaRule]: + 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_quota_rule' not in self._stubs: + self._stubs['get_quota_rule'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/GetQuotaRule', + request_serializer=quota_rule.GetQuotaRuleRequest.serialize, + response_deserializer=quota_rule.QuotaRule.deserialize, + ) + return self._stubs['get_quota_rule'] + + @property + def create_quota_rule(self) -> Callable[ + [gcn_quota_rule.CreateQuotaRuleRequest], + operations_pb2.Operation]: + r"""Return a callable for the create quota rule method over gRPC. + + Creates a new quota rule. + + Returns: + Callable[[~.CreateQuotaRuleRequest], + ~.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_quota_rule' not in self._stubs: + self._stubs['create_quota_rule'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/CreateQuotaRule', + request_serializer=gcn_quota_rule.CreateQuotaRuleRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_quota_rule'] + + @property + def update_quota_rule(self) -> Callable[ + [gcn_quota_rule.UpdateQuotaRuleRequest], + operations_pb2.Operation]: + r"""Return a callable for the update quota rule method over gRPC. + + Updates a quota rule. + + Returns: + Callable[[~.UpdateQuotaRuleRequest], + ~.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 'update_quota_rule' not in self._stubs: + self._stubs['update_quota_rule'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/UpdateQuotaRule', + request_serializer=gcn_quota_rule.UpdateQuotaRuleRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_quota_rule'] + + @property + def delete_quota_rule(self) -> Callable[ + [quota_rule.DeleteQuotaRuleRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete quota rule method over gRPC. + + Deletes a quota rule. + + Returns: + Callable[[~.DeleteQuotaRuleRequest], + ~.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_quota_rule' not in self._stubs: + self._stubs['delete_quota_rule'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/DeleteQuotaRule', + request_serializer=quota_rule.DeleteQuotaRuleRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_quota_rule'] + + def close(self): + self._logged_channel.close() + + @property + def delete_operation( + self, + ) -> Callable[[operations_pb2.DeleteOperationRequest], None]: + r"""Return a callable for the delete_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 "delete_operation" not in self._stubs: + self._stubs["delete_operation"] = self._logged_channel.unary_unary( + "/google.longrunning.Operations/DeleteOperation", + request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, + response_deserializer=None, + ) + return self._stubs["delete_operation"] + + @property + def cancel_operation( + self, + ) -> Callable[[operations_pb2.CancelOperationRequest], None]: + r"""Return a callable for the cancel_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 "cancel_operation" not in self._stubs: + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( + "/google.longrunning.Operations/CancelOperation", + request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, + response_deserializer=None, + ) + return self._stubs["cancel_operation"] + + @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._logged_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_operations( + self, + ) -> Callable[[operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse]: + r"""Return a callable for the list_operations 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_operations" not in self._stubs: + self._stubs["list_operations"] = self._logged_channel.unary_unary( + "/google.longrunning.Operations/ListOperations", + request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, + response_deserializer=operations_pb2.ListOperationsResponse.FromString, + ) + return self._stubs["list_operations"] + + @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._logged_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._logged_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__ = ( + 'NetAppGrpcTransport', +) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/grpc_asyncio.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/grpc_asyncio.py new file mode 100644 index 000000000000..9669115ac22a --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/grpc_asyncio.py @@ -0,0 +1,2560 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 json +import pickle +import logging as std_logging +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 +from google.protobuf.json_format import MessageToJson +import google.protobuf.message + +import grpc # type: ignore +import proto # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.location import locations_pb2 # type: ignore +from google.cloud.netapp_v1.types import active_directory +from google.cloud.netapp_v1.types import active_directory as gcn_active_directory +from google.cloud.netapp_v1.types import backup +from google.cloud.netapp_v1.types import backup as gcn_backup +from google.cloud.netapp_v1.types import backup_policy +from google.cloud.netapp_v1.types import backup_policy as gcn_backup_policy +from google.cloud.netapp_v1.types import backup_vault +from google.cloud.netapp_v1.types import backup_vault as gcn_backup_vault +from google.cloud.netapp_v1.types import kms +from google.cloud.netapp_v1.types import quota_rule +from google.cloud.netapp_v1.types import quota_rule as gcn_quota_rule +from google.cloud.netapp_v1.types import replication +from google.cloud.netapp_v1.types import replication as gcn_replication +from google.cloud.netapp_v1.types import snapshot +from google.cloud.netapp_v1.types import snapshot as gcn_snapshot +from google.cloud.netapp_v1.types import storage_pool +from google.cloud.netapp_v1.types import storage_pool as gcn_storage_pool +from google.cloud.netapp_v1.types import volume +from google.cloud.netapp_v1.types import volume as gcn_volume +from google.longrunning import operations_pb2 # type: ignore +from .base import NetAppTransport, DEFAULT_CLIENT_INFO +from .grpc import NetAppGrpcTransport + +try: + from google.api_core import client_logging # type: ignore + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientAIOInterceptor(grpc.aio.UnaryUnaryClientInterceptor): # pragma: NO COVER + async def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": str(client_call_details.method), + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + response = await continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = await response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = dict([(k, str(v)) for k, v in response_metadata]) if response_metadata else None + result = await response + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response to rpc {client_call_details.method}.", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + + +class NetAppGrpcAsyncIOTransport(NetAppTransport): + """gRPC AsyncIO backend transport for NetApp. + + NetApp Files Google Cloud Service + + 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 = 'netapp.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 = 'netapp.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: 'netapp.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), + ], + ) + + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel + self._wrap_with_kind = "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters + # Wrap messages. This must be done after self._logged_channel exists + 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._logged_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def list_storage_pools(self) -> Callable[ + [storage_pool.ListStoragePoolsRequest], + Awaitable[storage_pool.ListStoragePoolsResponse]]: + r"""Return a callable for the list storage pools method over gRPC. + + Returns descriptions of all storage pools owned by + the caller. + + Returns: + Callable[[~.ListStoragePoolsRequest], + Awaitable[~.ListStoragePoolsResponse]]: + 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_storage_pools' not in self._stubs: + self._stubs['list_storage_pools'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ListStoragePools', + request_serializer=storage_pool.ListStoragePoolsRequest.serialize, + response_deserializer=storage_pool.ListStoragePoolsResponse.deserialize, + ) + return self._stubs['list_storage_pools'] + + @property + def create_storage_pool(self) -> Callable[ + [gcn_storage_pool.CreateStoragePoolRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create storage pool method over gRPC. + + Creates a new storage pool. + + Returns: + Callable[[~.CreateStoragePoolRequest], + 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_storage_pool' not in self._stubs: + self._stubs['create_storage_pool'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/CreateStoragePool', + request_serializer=gcn_storage_pool.CreateStoragePoolRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_storage_pool'] + + @property + def get_storage_pool(self) -> Callable[ + [storage_pool.GetStoragePoolRequest], + Awaitable[storage_pool.StoragePool]]: + r"""Return a callable for the get storage pool method over gRPC. + + Returns the description of the specified storage pool + by poolId. + + Returns: + Callable[[~.GetStoragePoolRequest], + Awaitable[~.StoragePool]]: + 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_storage_pool' not in self._stubs: + self._stubs['get_storage_pool'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/GetStoragePool', + request_serializer=storage_pool.GetStoragePoolRequest.serialize, + response_deserializer=storage_pool.StoragePool.deserialize, + ) + return self._stubs['get_storage_pool'] + + @property + def update_storage_pool(self) -> Callable[ + [gcn_storage_pool.UpdateStoragePoolRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update storage pool method over gRPC. + + Updates the storage pool properties with the full + spec + + Returns: + Callable[[~.UpdateStoragePoolRequest], + 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 'update_storage_pool' not in self._stubs: + self._stubs['update_storage_pool'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/UpdateStoragePool', + request_serializer=gcn_storage_pool.UpdateStoragePoolRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_storage_pool'] + + @property + def delete_storage_pool(self) -> Callable[ + [storage_pool.DeleteStoragePoolRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete storage pool method over gRPC. + + Warning! This operation will permanently delete the + storage pool. + + Returns: + Callable[[~.DeleteStoragePoolRequest], + 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_storage_pool' not in self._stubs: + self._stubs['delete_storage_pool'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/DeleteStoragePool', + request_serializer=storage_pool.DeleteStoragePoolRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_storage_pool'] + + @property + def validate_directory_service(self) -> Callable[ + [storage_pool.ValidateDirectoryServiceRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the validate directory service method over gRPC. + + ValidateDirectoryService does a connectivity check + for a directory service policy attached to the storage + pool. + + Returns: + Callable[[~.ValidateDirectoryServiceRequest], + 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 'validate_directory_service' not in self._stubs: + self._stubs['validate_directory_service'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ValidateDirectoryService', + request_serializer=storage_pool.ValidateDirectoryServiceRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['validate_directory_service'] + + @property + def switch_active_replica_zone(self) -> Callable[ + [storage_pool.SwitchActiveReplicaZoneRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the switch active replica zone method over gRPC. + + This operation will switch the active/replica zone + for a regional storagePool. + + Returns: + Callable[[~.SwitchActiveReplicaZoneRequest], + 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 'switch_active_replica_zone' not in self._stubs: + self._stubs['switch_active_replica_zone'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/SwitchActiveReplicaZone', + request_serializer=storage_pool.SwitchActiveReplicaZoneRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['switch_active_replica_zone'] + + @property + def list_volumes(self) -> Callable[ + [volume.ListVolumesRequest], + Awaitable[volume.ListVolumesResponse]]: + r"""Return a callable for the list volumes method over gRPC. + + Lists Volumes in a given project. + + Returns: + Callable[[~.ListVolumesRequest], + Awaitable[~.ListVolumesResponse]]: + 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_volumes' not in self._stubs: + self._stubs['list_volumes'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ListVolumes', + request_serializer=volume.ListVolumesRequest.serialize, + response_deserializer=volume.ListVolumesResponse.deserialize, + ) + return self._stubs['list_volumes'] + + @property + def get_volume(self) -> Callable[ + [volume.GetVolumeRequest], + Awaitable[volume.Volume]]: + r"""Return a callable for the get volume method over gRPC. + + Gets details of a single Volume. + + Returns: + Callable[[~.GetVolumeRequest], + Awaitable[~.Volume]]: + 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_volume' not in self._stubs: + self._stubs['get_volume'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/GetVolume', + request_serializer=volume.GetVolumeRequest.serialize, + response_deserializer=volume.Volume.deserialize, + ) + return self._stubs['get_volume'] + + @property + def create_volume(self) -> Callable[ + [gcn_volume.CreateVolumeRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create volume method over gRPC. + + Creates a new Volume in a given project and location. + + Returns: + Callable[[~.CreateVolumeRequest], + 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_volume' not in self._stubs: + self._stubs['create_volume'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/CreateVolume', + request_serializer=gcn_volume.CreateVolumeRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_volume'] + + @property + def update_volume(self) -> Callable[ + [gcn_volume.UpdateVolumeRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update volume method over gRPC. + + Updates the parameters of a single Volume. + + Returns: + Callable[[~.UpdateVolumeRequest], + 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 'update_volume' not in self._stubs: + self._stubs['update_volume'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/UpdateVolume', + request_serializer=gcn_volume.UpdateVolumeRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_volume'] + + @property + def delete_volume(self) -> Callable[ + [volume.DeleteVolumeRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete volume method over gRPC. + + Deletes a single Volume. + + Returns: + Callable[[~.DeleteVolumeRequest], + 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_volume' not in self._stubs: + self._stubs['delete_volume'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/DeleteVolume', + request_serializer=volume.DeleteVolumeRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_volume'] + + @property + def revert_volume(self) -> Callable[ + [volume.RevertVolumeRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the revert volume method over gRPC. + + Revert an existing volume to a specified snapshot. + Warning! This operation will permanently revert all + changes made after the snapshot was created. + + Returns: + Callable[[~.RevertVolumeRequest], + 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 'revert_volume' not in self._stubs: + self._stubs['revert_volume'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/RevertVolume', + request_serializer=volume.RevertVolumeRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['revert_volume'] + + @property + def list_snapshots(self) -> Callable[ + [snapshot.ListSnapshotsRequest], + Awaitable[snapshot.ListSnapshotsResponse]]: + r"""Return a callable for the list snapshots method over gRPC. + + Returns descriptions of all snapshots for a volume. + + Returns: + Callable[[~.ListSnapshotsRequest], + Awaitable[~.ListSnapshotsResponse]]: + 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_snapshots' not in self._stubs: + self._stubs['list_snapshots'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ListSnapshots', + request_serializer=snapshot.ListSnapshotsRequest.serialize, + response_deserializer=snapshot.ListSnapshotsResponse.deserialize, + ) + return self._stubs['list_snapshots'] + + @property + def get_snapshot(self) -> Callable[ + [snapshot.GetSnapshotRequest], + Awaitable[snapshot.Snapshot]]: + r"""Return a callable for the get snapshot method over gRPC. + + Describe a snapshot for a volume. + + Returns: + Callable[[~.GetSnapshotRequest], + Awaitable[~.Snapshot]]: + 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_snapshot' not in self._stubs: + self._stubs['get_snapshot'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/GetSnapshot', + request_serializer=snapshot.GetSnapshotRequest.serialize, + response_deserializer=snapshot.Snapshot.deserialize, + ) + return self._stubs['get_snapshot'] + + @property + def create_snapshot(self) -> Callable[ + [gcn_snapshot.CreateSnapshotRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create snapshot method over gRPC. + + Create a new snapshot for a volume. + + Returns: + Callable[[~.CreateSnapshotRequest], + 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_snapshot' not in self._stubs: + self._stubs['create_snapshot'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/CreateSnapshot', + request_serializer=gcn_snapshot.CreateSnapshotRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_snapshot'] + + @property + def delete_snapshot(self) -> Callable[ + [snapshot.DeleteSnapshotRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete snapshot method over gRPC. + + Deletes a snapshot. + + Returns: + Callable[[~.DeleteSnapshotRequest], + 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_snapshot' not in self._stubs: + self._stubs['delete_snapshot'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/DeleteSnapshot', + request_serializer=snapshot.DeleteSnapshotRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_snapshot'] + + @property + def update_snapshot(self) -> Callable[ + [gcn_snapshot.UpdateSnapshotRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update snapshot method over gRPC. + + Updates the settings of a specific snapshot. + + Returns: + Callable[[~.UpdateSnapshotRequest], + 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 'update_snapshot' not in self._stubs: + self._stubs['update_snapshot'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/UpdateSnapshot', + request_serializer=gcn_snapshot.UpdateSnapshotRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_snapshot'] + + @property + def list_active_directories(self) -> Callable[ + [active_directory.ListActiveDirectoriesRequest], + Awaitable[active_directory.ListActiveDirectoriesResponse]]: + r"""Return a callable for the list active directories method over gRPC. + + Lists active directories. + + Returns: + Callable[[~.ListActiveDirectoriesRequest], + Awaitable[~.ListActiveDirectoriesResponse]]: + 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_active_directories' not in self._stubs: + self._stubs['list_active_directories'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ListActiveDirectories', + request_serializer=active_directory.ListActiveDirectoriesRequest.serialize, + response_deserializer=active_directory.ListActiveDirectoriesResponse.deserialize, + ) + return self._stubs['list_active_directories'] + + @property + def get_active_directory(self) -> Callable[ + [active_directory.GetActiveDirectoryRequest], + Awaitable[active_directory.ActiveDirectory]]: + r"""Return a callable for the get active directory method over gRPC. + + Describes a specified active directory. + + Returns: + Callable[[~.GetActiveDirectoryRequest], + Awaitable[~.ActiveDirectory]]: + 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_active_directory' not in self._stubs: + self._stubs['get_active_directory'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/GetActiveDirectory', + request_serializer=active_directory.GetActiveDirectoryRequest.serialize, + response_deserializer=active_directory.ActiveDirectory.deserialize, + ) + return self._stubs['get_active_directory'] + + @property + def create_active_directory(self) -> Callable[ + [gcn_active_directory.CreateActiveDirectoryRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create active directory method over gRPC. + + CreateActiveDirectory + Creates the active directory specified in the request. + + Returns: + Callable[[~.CreateActiveDirectoryRequest], + 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_active_directory' not in self._stubs: + self._stubs['create_active_directory'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/CreateActiveDirectory', + request_serializer=gcn_active_directory.CreateActiveDirectoryRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_active_directory'] + + @property + def update_active_directory(self) -> Callable[ + [gcn_active_directory.UpdateActiveDirectoryRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update active directory method over gRPC. + + Update the parameters of an active directories. + + Returns: + Callable[[~.UpdateActiveDirectoryRequest], + 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 'update_active_directory' not in self._stubs: + self._stubs['update_active_directory'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/UpdateActiveDirectory', + request_serializer=gcn_active_directory.UpdateActiveDirectoryRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_active_directory'] + + @property + def delete_active_directory(self) -> Callable[ + [active_directory.DeleteActiveDirectoryRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete active directory method over gRPC. + + Delete the active directory specified in the request. + + Returns: + Callable[[~.DeleteActiveDirectoryRequest], + 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_active_directory' not in self._stubs: + self._stubs['delete_active_directory'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/DeleteActiveDirectory', + request_serializer=active_directory.DeleteActiveDirectoryRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_active_directory'] + + @property + def list_kms_configs(self) -> Callable[ + [kms.ListKmsConfigsRequest], + Awaitable[kms.ListKmsConfigsResponse]]: + r"""Return a callable for the list kms configs method over gRPC. + + Returns descriptions of all KMS configs owned by the + caller. + + Returns: + Callable[[~.ListKmsConfigsRequest], + Awaitable[~.ListKmsConfigsResponse]]: + 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_kms_configs' not in self._stubs: + self._stubs['list_kms_configs'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ListKmsConfigs', + request_serializer=kms.ListKmsConfigsRequest.serialize, + response_deserializer=kms.ListKmsConfigsResponse.deserialize, + ) + return self._stubs['list_kms_configs'] + + @property + def create_kms_config(self) -> Callable[ + [kms.CreateKmsConfigRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create kms config method over gRPC. + + Creates a new KMS config. + + Returns: + Callable[[~.CreateKmsConfigRequest], + 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_kms_config' not in self._stubs: + self._stubs['create_kms_config'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/CreateKmsConfig', + request_serializer=kms.CreateKmsConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_kms_config'] + + @property + def get_kms_config(self) -> Callable[ + [kms.GetKmsConfigRequest], + Awaitable[kms.KmsConfig]]: + r"""Return a callable for the get kms config method over gRPC. + + Returns the description of the specified KMS config by + kms_config_id. + + Returns: + Callable[[~.GetKmsConfigRequest], + Awaitable[~.KmsConfig]]: + 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_kms_config' not in self._stubs: + self._stubs['get_kms_config'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/GetKmsConfig', + request_serializer=kms.GetKmsConfigRequest.serialize, + response_deserializer=kms.KmsConfig.deserialize, + ) + return self._stubs['get_kms_config'] + + @property + def update_kms_config(self) -> Callable[ + [kms.UpdateKmsConfigRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update kms config method over gRPC. + + Updates the Kms config properties with the full spec + + Returns: + Callable[[~.UpdateKmsConfigRequest], + 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 'update_kms_config' not in self._stubs: + self._stubs['update_kms_config'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/UpdateKmsConfig', + request_serializer=kms.UpdateKmsConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_kms_config'] + + @property + def encrypt_volumes(self) -> Callable[ + [kms.EncryptVolumesRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the encrypt volumes method over gRPC. + + Encrypt the existing volumes without CMEK encryption + with the desired the KMS config for the whole region. + + Returns: + Callable[[~.EncryptVolumesRequest], + 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 'encrypt_volumes' not in self._stubs: + self._stubs['encrypt_volumes'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/EncryptVolumes', + request_serializer=kms.EncryptVolumesRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['encrypt_volumes'] + + @property + def verify_kms_config(self) -> Callable[ + [kms.VerifyKmsConfigRequest], + Awaitable[kms.VerifyKmsConfigResponse]]: + r"""Return a callable for the verify kms config method over gRPC. + + Verifies KMS config reachability. + + Returns: + Callable[[~.VerifyKmsConfigRequest], + Awaitable[~.VerifyKmsConfigResponse]]: + 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 'verify_kms_config' not in self._stubs: + self._stubs['verify_kms_config'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/VerifyKmsConfig', + request_serializer=kms.VerifyKmsConfigRequest.serialize, + response_deserializer=kms.VerifyKmsConfigResponse.deserialize, + ) + return self._stubs['verify_kms_config'] + + @property + def delete_kms_config(self) -> Callable[ + [kms.DeleteKmsConfigRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete kms config method over gRPC. + + Warning! This operation will permanently delete the + Kms config. + + Returns: + Callable[[~.DeleteKmsConfigRequest], + 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_kms_config' not in self._stubs: + self._stubs['delete_kms_config'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/DeleteKmsConfig', + request_serializer=kms.DeleteKmsConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_kms_config'] + + @property + def list_replications(self) -> Callable[ + [replication.ListReplicationsRequest], + Awaitable[replication.ListReplicationsResponse]]: + r"""Return a callable for the list replications method over gRPC. + + Returns descriptions of all replications for a + volume. + + Returns: + Callable[[~.ListReplicationsRequest], + Awaitable[~.ListReplicationsResponse]]: + 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_replications' not in self._stubs: + self._stubs['list_replications'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ListReplications', + request_serializer=replication.ListReplicationsRequest.serialize, + response_deserializer=replication.ListReplicationsResponse.deserialize, + ) + return self._stubs['list_replications'] + + @property + def get_replication(self) -> Callable[ + [replication.GetReplicationRequest], + Awaitable[replication.Replication]]: + r"""Return a callable for the get replication method over gRPC. + + Describe a replication for a volume. + + Returns: + Callable[[~.GetReplicationRequest], + Awaitable[~.Replication]]: + 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_replication' not in self._stubs: + self._stubs['get_replication'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/GetReplication', + request_serializer=replication.GetReplicationRequest.serialize, + response_deserializer=replication.Replication.deserialize, + ) + return self._stubs['get_replication'] + + @property + def create_replication(self) -> Callable[ + [gcn_replication.CreateReplicationRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create replication method over gRPC. + + Create a new replication for a volume. + + Returns: + Callable[[~.CreateReplicationRequest], + 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_replication' not in self._stubs: + self._stubs['create_replication'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/CreateReplication', + request_serializer=gcn_replication.CreateReplicationRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_replication'] + + @property + def delete_replication(self) -> Callable[ + [replication.DeleteReplicationRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete replication method over gRPC. + + Deletes a replication. + + Returns: + Callable[[~.DeleteReplicationRequest], + 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_replication' not in self._stubs: + self._stubs['delete_replication'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/DeleteReplication', + request_serializer=replication.DeleteReplicationRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_replication'] + + @property + def update_replication(self) -> Callable[ + [gcn_replication.UpdateReplicationRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update replication method over gRPC. + + Updates the settings of a specific replication. + + Returns: + Callable[[~.UpdateReplicationRequest], + 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 'update_replication' not in self._stubs: + self._stubs['update_replication'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/UpdateReplication', + request_serializer=gcn_replication.UpdateReplicationRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_replication'] + + @property + def stop_replication(self) -> Callable[ + [replication.StopReplicationRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the stop replication method over gRPC. + + Stop Cross Region Replication. + + Returns: + Callable[[~.StopReplicationRequest], + 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 'stop_replication' not in self._stubs: + self._stubs['stop_replication'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/StopReplication', + request_serializer=replication.StopReplicationRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['stop_replication'] + + @property + def resume_replication(self) -> Callable[ + [replication.ResumeReplicationRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the resume replication method over gRPC. + + Resume Cross Region Replication. + + Returns: + Callable[[~.ResumeReplicationRequest], + 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 'resume_replication' not in self._stubs: + self._stubs['resume_replication'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ResumeReplication', + request_serializer=replication.ResumeReplicationRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['resume_replication'] + + @property + def reverse_replication_direction(self) -> Callable[ + [replication.ReverseReplicationDirectionRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the reverse replication direction method over gRPC. + + Reverses direction of replication. Source becomes + destination and destination becomes source. + + Returns: + Callable[[~.ReverseReplicationDirectionRequest], + 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 'reverse_replication_direction' not in self._stubs: + self._stubs['reverse_replication_direction'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ReverseReplicationDirection', + request_serializer=replication.ReverseReplicationDirectionRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['reverse_replication_direction'] + + @property + def establish_peering(self) -> Callable[ + [replication.EstablishPeeringRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the establish peering method over gRPC. + + Establish replication peering. + + Returns: + Callable[[~.EstablishPeeringRequest], + 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 'establish_peering' not in self._stubs: + self._stubs['establish_peering'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/EstablishPeering', + request_serializer=replication.EstablishPeeringRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['establish_peering'] + + @property + def sync_replication(self) -> Callable[ + [replication.SyncReplicationRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the sync replication method over gRPC. + + Syncs the replication. This will invoke one time + volume data transfer from source to destination. + + Returns: + Callable[[~.SyncReplicationRequest], + 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 'sync_replication' not in self._stubs: + self._stubs['sync_replication'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/SyncReplication', + request_serializer=replication.SyncReplicationRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['sync_replication'] + + @property + def create_backup_vault(self) -> Callable[ + [gcn_backup_vault.CreateBackupVaultRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create backup vault method over gRPC. + + Creates new backup vault + + Returns: + Callable[[~.CreateBackupVaultRequest], + 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_backup_vault' not in self._stubs: + self._stubs['create_backup_vault'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/CreateBackupVault', + request_serializer=gcn_backup_vault.CreateBackupVaultRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_backup_vault'] + + @property + def get_backup_vault(self) -> Callable[ + [backup_vault.GetBackupVaultRequest], + Awaitable[backup_vault.BackupVault]]: + r"""Return a callable for the get backup vault method over gRPC. + + Returns the description of the specified backup vault + + Returns: + Callable[[~.GetBackupVaultRequest], + Awaitable[~.BackupVault]]: + 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_backup_vault' not in self._stubs: + self._stubs['get_backup_vault'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/GetBackupVault', + request_serializer=backup_vault.GetBackupVaultRequest.serialize, + response_deserializer=backup_vault.BackupVault.deserialize, + ) + return self._stubs['get_backup_vault'] + + @property + def list_backup_vaults(self) -> Callable[ + [backup_vault.ListBackupVaultsRequest], + Awaitable[backup_vault.ListBackupVaultsResponse]]: + r"""Return a callable for the list backup vaults method over gRPC. + + Returns list of all available backup vaults. + + Returns: + Callable[[~.ListBackupVaultsRequest], + Awaitable[~.ListBackupVaultsResponse]]: + 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_backup_vaults' not in self._stubs: + self._stubs['list_backup_vaults'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ListBackupVaults', + request_serializer=backup_vault.ListBackupVaultsRequest.serialize, + response_deserializer=backup_vault.ListBackupVaultsResponse.deserialize, + ) + return self._stubs['list_backup_vaults'] + + @property + def update_backup_vault(self) -> Callable[ + [gcn_backup_vault.UpdateBackupVaultRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update backup vault method over gRPC. + + Updates the settings of a specific backup vault. + + Returns: + Callable[[~.UpdateBackupVaultRequest], + 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 'update_backup_vault' not in self._stubs: + self._stubs['update_backup_vault'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/UpdateBackupVault', + request_serializer=gcn_backup_vault.UpdateBackupVaultRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_backup_vault'] + + @property + def delete_backup_vault(self) -> Callable[ + [backup_vault.DeleteBackupVaultRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete backup vault method over gRPC. + + Warning! This operation will permanently delete the + backup vault. + + Returns: + Callable[[~.DeleteBackupVaultRequest], + 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_backup_vault' not in self._stubs: + self._stubs['delete_backup_vault'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/DeleteBackupVault', + request_serializer=backup_vault.DeleteBackupVaultRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_backup_vault'] + + @property + def create_backup(self) -> Callable[ + [gcn_backup.CreateBackupRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create backup method over gRPC. + + Creates a backup from the volume specified in the + request The backup can be created from the given + snapshot if specified in the request. If no snapshot + specified, there'll be a new snapshot taken to initiate + the backup creation. + + Returns: + Callable[[~.CreateBackupRequest], + 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_backup' not in self._stubs: + self._stubs['create_backup'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/CreateBackup', + request_serializer=gcn_backup.CreateBackupRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_backup'] + + @property + def get_backup(self) -> Callable[ + [backup.GetBackupRequest], + Awaitable[backup.Backup]]: + r"""Return a callable for the get backup method over gRPC. + + Returns the description of the specified backup + + Returns: + Callable[[~.GetBackupRequest], + Awaitable[~.Backup]]: + 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_backup' not in self._stubs: + self._stubs['get_backup'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/GetBackup', + request_serializer=backup.GetBackupRequest.serialize, + response_deserializer=backup.Backup.deserialize, + ) + return self._stubs['get_backup'] + + @property + def list_backups(self) -> Callable[ + [backup.ListBackupsRequest], + Awaitable[backup.ListBackupsResponse]]: + r"""Return a callable for the list backups method over gRPC. + + Returns descriptions of all backups for a + backupVault. + + Returns: + Callable[[~.ListBackupsRequest], + Awaitable[~.ListBackupsResponse]]: + 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_backups' not in self._stubs: + self._stubs['list_backups'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ListBackups', + request_serializer=backup.ListBackupsRequest.serialize, + response_deserializer=backup.ListBackupsResponse.deserialize, + ) + return self._stubs['list_backups'] + + @property + def delete_backup(self) -> Callable[ + [backup.DeleteBackupRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete backup method over gRPC. + + Warning! This operation will permanently delete the + backup. + + Returns: + Callable[[~.DeleteBackupRequest], + 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_backup' not in self._stubs: + self._stubs['delete_backup'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/DeleteBackup', + request_serializer=backup.DeleteBackupRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_backup'] + + @property + def update_backup(self) -> Callable[ + [gcn_backup.UpdateBackupRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update backup method over gRPC. + + Update backup with full spec. + + Returns: + Callable[[~.UpdateBackupRequest], + 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 'update_backup' not in self._stubs: + self._stubs['update_backup'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/UpdateBackup', + request_serializer=gcn_backup.UpdateBackupRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_backup'] + + @property + def create_backup_policy(self) -> Callable[ + [gcn_backup_policy.CreateBackupPolicyRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create backup policy method over gRPC. + + Creates new backup policy + + Returns: + Callable[[~.CreateBackupPolicyRequest], + 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_backup_policy' not in self._stubs: + self._stubs['create_backup_policy'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/CreateBackupPolicy', + request_serializer=gcn_backup_policy.CreateBackupPolicyRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_backup_policy'] + + @property + def get_backup_policy(self) -> Callable[ + [backup_policy.GetBackupPolicyRequest], + Awaitable[backup_policy.BackupPolicy]]: + r"""Return a callable for the get backup policy method over gRPC. + + Returns the description of the specified backup policy by + backup_policy_id. + + Returns: + Callable[[~.GetBackupPolicyRequest], + Awaitable[~.BackupPolicy]]: + 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_backup_policy' not in self._stubs: + self._stubs['get_backup_policy'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/GetBackupPolicy', + request_serializer=backup_policy.GetBackupPolicyRequest.serialize, + response_deserializer=backup_policy.BackupPolicy.deserialize, + ) + return self._stubs['get_backup_policy'] + + @property + def list_backup_policies(self) -> Callable[ + [backup_policy.ListBackupPoliciesRequest], + Awaitable[backup_policy.ListBackupPoliciesResponse]]: + r"""Return a callable for the list backup policies method over gRPC. + + Returns list of all available backup policies. + + Returns: + Callable[[~.ListBackupPoliciesRequest], + Awaitable[~.ListBackupPoliciesResponse]]: + 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_backup_policies' not in self._stubs: + self._stubs['list_backup_policies'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ListBackupPolicies', + request_serializer=backup_policy.ListBackupPoliciesRequest.serialize, + response_deserializer=backup_policy.ListBackupPoliciesResponse.deserialize, + ) + return self._stubs['list_backup_policies'] + + @property + def update_backup_policy(self) -> Callable[ + [gcn_backup_policy.UpdateBackupPolicyRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update backup policy method over gRPC. + + Updates settings of a specific backup policy. + + Returns: + Callable[[~.UpdateBackupPolicyRequest], + 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 'update_backup_policy' not in self._stubs: + self._stubs['update_backup_policy'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/UpdateBackupPolicy', + request_serializer=gcn_backup_policy.UpdateBackupPolicyRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_backup_policy'] + + @property + def delete_backup_policy(self) -> Callable[ + [backup_policy.DeleteBackupPolicyRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete backup policy method over gRPC. + + Warning! This operation will permanently delete the + backup policy. + + Returns: + Callable[[~.DeleteBackupPolicyRequest], + 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_backup_policy' not in self._stubs: + self._stubs['delete_backup_policy'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/DeleteBackupPolicy', + request_serializer=backup_policy.DeleteBackupPolicyRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_backup_policy'] + + @property + def list_quota_rules(self) -> Callable[ + [quota_rule.ListQuotaRulesRequest], + Awaitable[quota_rule.ListQuotaRulesResponse]]: + r"""Return a callable for the list quota rules method over gRPC. + + Returns list of all quota rules in a location. + + Returns: + Callable[[~.ListQuotaRulesRequest], + Awaitable[~.ListQuotaRulesResponse]]: + 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_quota_rules' not in self._stubs: + self._stubs['list_quota_rules'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/ListQuotaRules', + request_serializer=quota_rule.ListQuotaRulesRequest.serialize, + response_deserializer=quota_rule.ListQuotaRulesResponse.deserialize, + ) + return self._stubs['list_quota_rules'] + + @property + def get_quota_rule(self) -> Callable[ + [quota_rule.GetQuotaRuleRequest], + Awaitable[quota_rule.QuotaRule]]: + r"""Return a callable for the get quota rule method over gRPC. + + Returns details of the specified quota rule. + + Returns: + Callable[[~.GetQuotaRuleRequest], + Awaitable[~.QuotaRule]]: + 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_quota_rule' not in self._stubs: + self._stubs['get_quota_rule'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/GetQuotaRule', + request_serializer=quota_rule.GetQuotaRuleRequest.serialize, + response_deserializer=quota_rule.QuotaRule.deserialize, + ) + return self._stubs['get_quota_rule'] + + @property + def create_quota_rule(self) -> Callable[ + [gcn_quota_rule.CreateQuotaRuleRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create quota rule method over gRPC. + + Creates a new quota rule. + + Returns: + Callable[[~.CreateQuotaRuleRequest], + 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_quota_rule' not in self._stubs: + self._stubs['create_quota_rule'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/CreateQuotaRule', + request_serializer=gcn_quota_rule.CreateQuotaRuleRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_quota_rule'] + + @property + def update_quota_rule(self) -> Callable[ + [gcn_quota_rule.UpdateQuotaRuleRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update quota rule method over gRPC. + + Updates a quota rule. + + Returns: + Callable[[~.UpdateQuotaRuleRequest], + 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 'update_quota_rule' not in self._stubs: + self._stubs['update_quota_rule'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/UpdateQuotaRule', + request_serializer=gcn_quota_rule.UpdateQuotaRuleRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_quota_rule'] + + @property + def delete_quota_rule(self) -> Callable[ + [quota_rule.DeleteQuotaRuleRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete quota rule method over gRPC. + + Deletes a quota rule. + + Returns: + Callable[[~.DeleteQuotaRuleRequest], + 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_quota_rule' not in self._stubs: + self._stubs['delete_quota_rule'] = self._logged_channel.unary_unary( + '/google.cloud.netapp.v1.NetApp/DeleteQuotaRule', + request_serializer=quota_rule.DeleteQuotaRuleRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_quota_rule'] + + 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_storage_pools: self._wrap_method( + self.list_storage_pools, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.create_storage_pool: self._wrap_method( + self.create_storage_pool, + default_timeout=60.0, + client_info=client_info, + ), + self.get_storage_pool: self._wrap_method( + self.get_storage_pool, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.update_storage_pool: self._wrap_method( + self.update_storage_pool, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_storage_pool: self._wrap_method( + self.delete_storage_pool, + default_timeout=60.0, + client_info=client_info, + ), + self.validate_directory_service: self._wrap_method( + self.validate_directory_service, + default_timeout=None, + client_info=client_info, + ), + self.switch_active_replica_zone: self._wrap_method( + self.switch_active_replica_zone, + default_timeout=None, + client_info=client_info, + ), + self.list_volumes: self._wrap_method( + self.list_volumes, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.get_volume: self._wrap_method( + self.get_volume, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.create_volume: self._wrap_method( + self.create_volume, + default_timeout=60.0, + client_info=client_info, + ), + self.update_volume: self._wrap_method( + self.update_volume, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_volume: self._wrap_method( + self.delete_volume, + default_timeout=60.0, + client_info=client_info, + ), + self.revert_volume: self._wrap_method( + self.revert_volume, + default_timeout=60.0, + client_info=client_info, + ), + self.list_snapshots: self._wrap_method( + self.list_snapshots, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.get_snapshot: self._wrap_method( + self.get_snapshot, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.create_snapshot: self._wrap_method( + self.create_snapshot, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_snapshot: self._wrap_method( + self.delete_snapshot, + default_timeout=60.0, + client_info=client_info, + ), + self.update_snapshot: self._wrap_method( + self.update_snapshot, + default_timeout=60.0, + client_info=client_info, + ), + self.list_active_directories: self._wrap_method( + self.list_active_directories, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.get_active_directory: self._wrap_method( + self.get_active_directory, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.create_active_directory: self._wrap_method( + self.create_active_directory, + default_timeout=60.0, + client_info=client_info, + ), + self.update_active_directory: self._wrap_method( + self.update_active_directory, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_active_directory: self._wrap_method( + self.delete_active_directory, + default_timeout=60.0, + client_info=client_info, + ), + self.list_kms_configs: self._wrap_method( + self.list_kms_configs, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.create_kms_config: self._wrap_method( + self.create_kms_config, + default_timeout=60.0, + client_info=client_info, + ), + self.get_kms_config: self._wrap_method( + self.get_kms_config, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.update_kms_config: self._wrap_method( + self.update_kms_config, + default_timeout=60.0, + client_info=client_info, + ), + self.encrypt_volumes: self._wrap_method( + self.encrypt_volumes, + default_timeout=60.0, + client_info=client_info, + ), + self.verify_kms_config: self._wrap_method( + self.verify_kms_config, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_kms_config: self._wrap_method( + self.delete_kms_config, + default_timeout=60.0, + client_info=client_info, + ), + self.list_replications: self._wrap_method( + self.list_replications, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.get_replication: self._wrap_method( + self.get_replication, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.create_replication: self._wrap_method( + self.create_replication, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_replication: self._wrap_method( + self.delete_replication, + default_timeout=60.0, + client_info=client_info, + ), + self.update_replication: self._wrap_method( + self.update_replication, + default_timeout=60.0, + client_info=client_info, + ), + self.stop_replication: self._wrap_method( + self.stop_replication, + default_timeout=60.0, + client_info=client_info, + ), + self.resume_replication: self._wrap_method( + self.resume_replication, + default_timeout=60.0, + client_info=client_info, + ), + self.reverse_replication_direction: self._wrap_method( + self.reverse_replication_direction, + default_timeout=60.0, + client_info=client_info, + ), + self.establish_peering: self._wrap_method( + self.establish_peering, + default_timeout=None, + client_info=client_info, + ), + self.sync_replication: self._wrap_method( + self.sync_replication, + default_timeout=None, + client_info=client_info, + ), + self.create_backup_vault: self._wrap_method( + self.create_backup_vault, + default_timeout=60.0, + client_info=client_info, + ), + self.get_backup_vault: self._wrap_method( + self.get_backup_vault, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.list_backup_vaults: self._wrap_method( + self.list_backup_vaults, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.update_backup_vault: self._wrap_method( + self.update_backup_vault, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_backup_vault: self._wrap_method( + self.delete_backup_vault, + default_timeout=60.0, + client_info=client_info, + ), + self.create_backup: self._wrap_method( + self.create_backup, + default_timeout=60.0, + client_info=client_info, + ), + self.get_backup: self._wrap_method( + self.get_backup, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.list_backups: self._wrap_method( + self.list_backups, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.delete_backup: self._wrap_method( + self.delete_backup, + default_timeout=60.0, + client_info=client_info, + ), + self.update_backup: self._wrap_method( + self.update_backup, + default_timeout=60.0, + client_info=client_info, + ), + self.create_backup_policy: self._wrap_method( + self.create_backup_policy, + default_timeout=60.0, + client_info=client_info, + ), + self.get_backup_policy: self._wrap_method( + self.get_backup_policy, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.list_backup_policies: self._wrap_method( + self.list_backup_policies, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.update_backup_policy: self._wrap_method( + self.update_backup_policy, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_backup_policy: self._wrap_method( + self.delete_backup_policy, + default_timeout=60.0, + client_info=client_info, + ), + self.list_quota_rules: self._wrap_method( + self.list_quota_rules, + default_timeout=None, + client_info=client_info, + ), + self.get_quota_rule: self._wrap_method( + self.get_quota_rule, + default_timeout=None, + client_info=client_info, + ), + self.create_quota_rule: self._wrap_method( + self.create_quota_rule, + default_timeout=None, + client_info=client_info, + ), + self.update_quota_rule: self._wrap_method( + self.update_quota_rule, + default_timeout=None, + client_info=client_info, + ), + self.delete_quota_rule: self._wrap_method( + self.delete_quota_rule, + 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.cancel_operation: self._wrap_method( + self.cancel_operation, + default_timeout=None, + client_info=client_info, + ), + self.delete_operation: self._wrap_method( + self.delete_operation, + default_timeout=None, + client_info=client_info, + ), + self.get_operation: self._wrap_method( + self.get_operation, + default_timeout=None, + client_info=client_info, + ), + self.list_operations: self._wrap_method( + self.list_operations, + 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._logged_channel.close() + + @property + def kind(self) -> str: + return "grpc_asyncio" + + @property + def delete_operation( + self, + ) -> Callable[[operations_pb2.DeleteOperationRequest], None]: + r"""Return a callable for the delete_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 "delete_operation" not in self._stubs: + self._stubs["delete_operation"] = self._logged_channel.unary_unary( + "/google.longrunning.Operations/DeleteOperation", + request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, + response_deserializer=None, + ) + return self._stubs["delete_operation"] + + @property + def cancel_operation( + self, + ) -> Callable[[operations_pb2.CancelOperationRequest], None]: + r"""Return a callable for the cancel_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 "cancel_operation" not in self._stubs: + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( + "/google.longrunning.Operations/CancelOperation", + request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, + response_deserializer=None, + ) + return self._stubs["cancel_operation"] + + @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._logged_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_operations( + self, + ) -> Callable[[operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse]: + r"""Return a callable for the list_operations 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_operations" not in self._stubs: + self._stubs["list_operations"] = self._logged_channel.unary_unary( + "/google.longrunning.Operations/ListOperations", + request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, + response_deserializer=operations_pb2.ListOperationsResponse.FromString, + ) + return self._stubs["list_operations"] + + @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._logged_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._logged_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__ = ( + 'NetAppGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/rest.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/rest.py new file mode 100644 index 000000000000..977f3b2803ad --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/rest.py @@ -0,0 +1,11531 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 logging +import json # type: ignore + +from google.auth.transport.requests import AuthorizedSession # 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.netapp_v1.types import active_directory +from google.cloud.netapp_v1.types import active_directory as gcn_active_directory +from google.cloud.netapp_v1.types import backup +from google.cloud.netapp_v1.types import backup as gcn_backup +from google.cloud.netapp_v1.types import backup_policy +from google.cloud.netapp_v1.types import backup_policy as gcn_backup_policy +from google.cloud.netapp_v1.types import backup_vault +from google.cloud.netapp_v1.types import backup_vault as gcn_backup_vault +from google.cloud.netapp_v1.types import kms +from google.cloud.netapp_v1.types import quota_rule +from google.cloud.netapp_v1.types import quota_rule as gcn_quota_rule +from google.cloud.netapp_v1.types import replication +from google.cloud.netapp_v1.types import replication as gcn_replication +from google.cloud.netapp_v1.types import snapshot +from google.cloud.netapp_v1.types import snapshot as gcn_snapshot +from google.cloud.netapp_v1.types import storage_pool +from google.cloud.netapp_v1.types import storage_pool as gcn_storage_pool +from google.cloud.netapp_v1.types import volume +from google.cloud.netapp_v1.types import volume as gcn_volume +from google.longrunning import operations_pb2 # type: ignore + + +from .rest_base import _BaseNetAppRestTransport +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 + +try: + from google.api_core import client_logging # type: ignore + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) + +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 NetAppRestInterceptor: + """Interceptor for NetApp. + + 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 NetAppRestTransport. + + .. code-block:: python + class MyCustomNetAppInterceptor(NetAppRestInterceptor): + def pre_create_active_directory(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_active_directory(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_backup(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_backup(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_backup_policy(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_backup_policy(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_backup_vault(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_backup_vault(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_kms_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_kms_config(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_quota_rule(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_quota_rule(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_replication(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_replication(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_snapshot(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_snapshot(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_storage_pool(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_storage_pool(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_volume(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_volume(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_active_directory(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_active_directory(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_backup(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_backup(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_backup_policy(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_backup_policy(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_backup_vault(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_backup_vault(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_kms_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_kms_config(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_quota_rule(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_quota_rule(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_replication(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_replication(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_snapshot(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_snapshot(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_storage_pool(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_storage_pool(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_volume(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_volume(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_encrypt_volumes(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_encrypt_volumes(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_establish_peering(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_establish_peering(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_active_directory(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_active_directory(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_backup(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_backup(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_backup_policy(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_backup_policy(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_backup_vault(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_backup_vault(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_kms_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_kms_config(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_quota_rule(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_quota_rule(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_replication(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_replication(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_snapshot(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_snapshot(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_storage_pool(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_storage_pool(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_volume(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_volume(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_active_directories(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_active_directories(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_backup_policies(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_backup_policies(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_backups(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_backups(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_backup_vaults(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_backup_vaults(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_kms_configs(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_kms_configs(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_quota_rules(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_quota_rules(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_replications(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_replications(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_snapshots(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_snapshots(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_storage_pools(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_storage_pools(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_volumes(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_volumes(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_resume_replication(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_resume_replication(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_reverse_replication_direction(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_reverse_replication_direction(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_revert_volume(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_revert_volume(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_stop_replication(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_stop_replication(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_switch_active_replica_zone(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_switch_active_replica_zone(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_sync_replication(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_sync_replication(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_active_directory(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_active_directory(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_backup(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_backup(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_backup_policy(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_backup_policy(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_backup_vault(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_backup_vault(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_kms_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_kms_config(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_quota_rule(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_quota_rule(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_replication(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_replication(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_snapshot(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_snapshot(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_storage_pool(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_storage_pool(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_volume(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_volume(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_validate_directory_service(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_validate_directory_service(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_verify_kms_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_verify_kms_config(self, response): + logging.log(f"Received response: {response}") + return response + + transport = NetAppRestTransport(interceptor=MyCustomNetAppInterceptor()) + client = NetAppClient(transport=transport) + + + """ + def pre_create_active_directory(self, request: gcn_active_directory.CreateActiveDirectoryRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_active_directory.CreateActiveDirectoryRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for create_active_directory + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_create_active_directory(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for create_active_directory + + DEPRECATED. Please use the `post_create_active_directory_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_create_active_directory` interceptor runs + before the `post_create_active_directory_with_metadata` interceptor. + """ + return response + + def post_create_active_directory_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_active_directory + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_create_active_directory_with_metadata` + interceptor in new development instead of the `post_create_active_directory` interceptor. + When both interceptors are used, this `post_create_active_directory_with_metadata` interceptor runs after the + `post_create_active_directory` interceptor. The (possibly modified) response returned by + `post_create_active_directory` will be passed to + `post_create_active_directory_with_metadata`. + """ + return response, metadata + + def pre_create_backup(self, request: gcn_backup.CreateBackupRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_backup.CreateBackupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for create_backup + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_create_backup(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for create_backup + + DEPRECATED. Please use the `post_create_backup_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_create_backup` interceptor runs + before the `post_create_backup_with_metadata` interceptor. + """ + return response + + def post_create_backup_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_backup + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_create_backup_with_metadata` + interceptor in new development instead of the `post_create_backup` interceptor. + When both interceptors are used, this `post_create_backup_with_metadata` interceptor runs after the + `post_create_backup` interceptor. The (possibly modified) response returned by + `post_create_backup` will be passed to + `post_create_backup_with_metadata`. + """ + return response, metadata + + def pre_create_backup_policy(self, request: gcn_backup_policy.CreateBackupPolicyRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_backup_policy.CreateBackupPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for create_backup_policy + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_create_backup_policy(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for create_backup_policy + + DEPRECATED. Please use the `post_create_backup_policy_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_create_backup_policy` interceptor runs + before the `post_create_backup_policy_with_metadata` interceptor. + """ + return response + + def post_create_backup_policy_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_backup_policy + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_create_backup_policy_with_metadata` + interceptor in new development instead of the `post_create_backup_policy` interceptor. + When both interceptors are used, this `post_create_backup_policy_with_metadata` interceptor runs after the + `post_create_backup_policy` interceptor. The (possibly modified) response returned by + `post_create_backup_policy` will be passed to + `post_create_backup_policy_with_metadata`. + """ + return response, metadata + + def pre_create_backup_vault(self, request: gcn_backup_vault.CreateBackupVaultRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_backup_vault.CreateBackupVaultRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for create_backup_vault + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_create_backup_vault(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for create_backup_vault + + DEPRECATED. Please use the `post_create_backup_vault_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_create_backup_vault` interceptor runs + before the `post_create_backup_vault_with_metadata` interceptor. + """ + return response + + def post_create_backup_vault_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_backup_vault + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_create_backup_vault_with_metadata` + interceptor in new development instead of the `post_create_backup_vault` interceptor. + When both interceptors are used, this `post_create_backup_vault_with_metadata` interceptor runs after the + `post_create_backup_vault` interceptor. The (possibly modified) response returned by + `post_create_backup_vault` will be passed to + `post_create_backup_vault_with_metadata`. + """ + return response, metadata + + def pre_create_kms_config(self, request: kms.CreateKmsConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[kms.CreateKmsConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for create_kms_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_create_kms_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for create_kms_config + + DEPRECATED. Please use the `post_create_kms_config_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_create_kms_config` interceptor runs + before the `post_create_kms_config_with_metadata` interceptor. + """ + return response + + def post_create_kms_config_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_kms_config + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_create_kms_config_with_metadata` + interceptor in new development instead of the `post_create_kms_config` interceptor. + When both interceptors are used, this `post_create_kms_config_with_metadata` interceptor runs after the + `post_create_kms_config` interceptor. The (possibly modified) response returned by + `post_create_kms_config` will be passed to + `post_create_kms_config_with_metadata`. + """ + return response, metadata + + def pre_create_quota_rule(self, request: gcn_quota_rule.CreateQuotaRuleRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_quota_rule.CreateQuotaRuleRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for create_quota_rule + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_create_quota_rule(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for create_quota_rule + + DEPRECATED. Please use the `post_create_quota_rule_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_create_quota_rule` interceptor runs + before the `post_create_quota_rule_with_metadata` interceptor. + """ + return response + + def post_create_quota_rule_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_quota_rule + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_create_quota_rule_with_metadata` + interceptor in new development instead of the `post_create_quota_rule` interceptor. + When both interceptors are used, this `post_create_quota_rule_with_metadata` interceptor runs after the + `post_create_quota_rule` interceptor. The (possibly modified) response returned by + `post_create_quota_rule` will be passed to + `post_create_quota_rule_with_metadata`. + """ + return response, metadata + + def pre_create_replication(self, request: gcn_replication.CreateReplicationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_replication.CreateReplicationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for create_replication + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_create_replication(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for create_replication + + DEPRECATED. Please use the `post_create_replication_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_create_replication` interceptor runs + before the `post_create_replication_with_metadata` interceptor. + """ + return response + + def post_create_replication_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_replication + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_create_replication_with_metadata` + interceptor in new development instead of the `post_create_replication` interceptor. + When both interceptors are used, this `post_create_replication_with_metadata` interceptor runs after the + `post_create_replication` interceptor. The (possibly modified) response returned by + `post_create_replication` will be passed to + `post_create_replication_with_metadata`. + """ + return response, metadata + + def pre_create_snapshot(self, request: gcn_snapshot.CreateSnapshotRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_snapshot.CreateSnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for create_snapshot + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_create_snapshot(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for create_snapshot + + DEPRECATED. Please use the `post_create_snapshot_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_create_snapshot` interceptor runs + before the `post_create_snapshot_with_metadata` interceptor. + """ + return response + + def post_create_snapshot_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_snapshot + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_create_snapshot_with_metadata` + interceptor in new development instead of the `post_create_snapshot` interceptor. + When both interceptors are used, this `post_create_snapshot_with_metadata` interceptor runs after the + `post_create_snapshot` interceptor. The (possibly modified) response returned by + `post_create_snapshot` will be passed to + `post_create_snapshot_with_metadata`. + """ + return response, metadata + + def pre_create_storage_pool(self, request: gcn_storage_pool.CreateStoragePoolRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_storage_pool.CreateStoragePoolRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for create_storage_pool + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_create_storage_pool(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for create_storage_pool + + DEPRECATED. Please use the `post_create_storage_pool_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_create_storage_pool` interceptor runs + before the `post_create_storage_pool_with_metadata` interceptor. + """ + return response + + def post_create_storage_pool_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_storage_pool + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_create_storage_pool_with_metadata` + interceptor in new development instead of the `post_create_storage_pool` interceptor. + When both interceptors are used, this `post_create_storage_pool_with_metadata` interceptor runs after the + `post_create_storage_pool` interceptor. The (possibly modified) response returned by + `post_create_storage_pool` will be passed to + `post_create_storage_pool_with_metadata`. + """ + return response, metadata + + def pre_create_volume(self, request: gcn_volume.CreateVolumeRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_volume.CreateVolumeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for create_volume + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_create_volume(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for create_volume + + DEPRECATED. Please use the `post_create_volume_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_create_volume` interceptor runs + before the `post_create_volume_with_metadata` interceptor. + """ + return response + + def post_create_volume_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_volume + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_create_volume_with_metadata` + interceptor in new development instead of the `post_create_volume` interceptor. + When both interceptors are used, this `post_create_volume_with_metadata` interceptor runs after the + `post_create_volume` interceptor. The (possibly modified) response returned by + `post_create_volume` will be passed to + `post_create_volume_with_metadata`. + """ + return response, metadata + + def pre_delete_active_directory(self, request: active_directory.DeleteActiveDirectoryRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[active_directory.DeleteActiveDirectoryRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for delete_active_directory + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_delete_active_directory(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_active_directory + + DEPRECATED. Please use the `post_delete_active_directory_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_delete_active_directory` interceptor runs + before the `post_delete_active_directory_with_metadata` interceptor. + """ + return response + + def post_delete_active_directory_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_active_directory + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_delete_active_directory_with_metadata` + interceptor in new development instead of the `post_delete_active_directory` interceptor. + When both interceptors are used, this `post_delete_active_directory_with_metadata` interceptor runs after the + `post_delete_active_directory` interceptor. The (possibly modified) response returned by + `post_delete_active_directory` will be passed to + `post_delete_active_directory_with_metadata`. + """ + return response, metadata + + def pre_delete_backup(self, request: backup.DeleteBackupRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup.DeleteBackupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for delete_backup + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_delete_backup(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_backup + + DEPRECATED. Please use the `post_delete_backup_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_delete_backup` interceptor runs + before the `post_delete_backup_with_metadata` interceptor. + """ + return response + + def post_delete_backup_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_backup + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_delete_backup_with_metadata` + interceptor in new development instead of the `post_delete_backup` interceptor. + When both interceptors are used, this `post_delete_backup_with_metadata` interceptor runs after the + `post_delete_backup` interceptor. The (possibly modified) response returned by + `post_delete_backup` will be passed to + `post_delete_backup_with_metadata`. + """ + return response, metadata + + def pre_delete_backup_policy(self, request: backup_policy.DeleteBackupPolicyRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup_policy.DeleteBackupPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for delete_backup_policy + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_delete_backup_policy(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_backup_policy + + DEPRECATED. Please use the `post_delete_backup_policy_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_delete_backup_policy` interceptor runs + before the `post_delete_backup_policy_with_metadata` interceptor. + """ + return response + + def post_delete_backup_policy_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_backup_policy + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_delete_backup_policy_with_metadata` + interceptor in new development instead of the `post_delete_backup_policy` interceptor. + When both interceptors are used, this `post_delete_backup_policy_with_metadata` interceptor runs after the + `post_delete_backup_policy` interceptor. The (possibly modified) response returned by + `post_delete_backup_policy` will be passed to + `post_delete_backup_policy_with_metadata`. + """ + return response, metadata + + def pre_delete_backup_vault(self, request: backup_vault.DeleteBackupVaultRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup_vault.DeleteBackupVaultRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for delete_backup_vault + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_delete_backup_vault(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_backup_vault + + DEPRECATED. Please use the `post_delete_backup_vault_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_delete_backup_vault` interceptor runs + before the `post_delete_backup_vault_with_metadata` interceptor. + """ + return response + + def post_delete_backup_vault_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_backup_vault + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_delete_backup_vault_with_metadata` + interceptor in new development instead of the `post_delete_backup_vault` interceptor. + When both interceptors are used, this `post_delete_backup_vault_with_metadata` interceptor runs after the + `post_delete_backup_vault` interceptor. The (possibly modified) response returned by + `post_delete_backup_vault` will be passed to + `post_delete_backup_vault_with_metadata`. + """ + return response, metadata + + def pre_delete_kms_config(self, request: kms.DeleteKmsConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[kms.DeleteKmsConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for delete_kms_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_delete_kms_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_kms_config + + DEPRECATED. Please use the `post_delete_kms_config_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_delete_kms_config` interceptor runs + before the `post_delete_kms_config_with_metadata` interceptor. + """ + return response + + def post_delete_kms_config_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_kms_config + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_delete_kms_config_with_metadata` + interceptor in new development instead of the `post_delete_kms_config` interceptor. + When both interceptors are used, this `post_delete_kms_config_with_metadata` interceptor runs after the + `post_delete_kms_config` interceptor. The (possibly modified) response returned by + `post_delete_kms_config` will be passed to + `post_delete_kms_config_with_metadata`. + """ + return response, metadata + + def pre_delete_quota_rule(self, request: quota_rule.DeleteQuotaRuleRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[quota_rule.DeleteQuotaRuleRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for delete_quota_rule + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_delete_quota_rule(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_quota_rule + + DEPRECATED. Please use the `post_delete_quota_rule_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_delete_quota_rule` interceptor runs + before the `post_delete_quota_rule_with_metadata` interceptor. + """ + return response + + def post_delete_quota_rule_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_quota_rule + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_delete_quota_rule_with_metadata` + interceptor in new development instead of the `post_delete_quota_rule` interceptor. + When both interceptors are used, this `post_delete_quota_rule_with_metadata` interceptor runs after the + `post_delete_quota_rule` interceptor. The (possibly modified) response returned by + `post_delete_quota_rule` will be passed to + `post_delete_quota_rule_with_metadata`. + """ + return response, metadata + + def pre_delete_replication(self, request: replication.DeleteReplicationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[replication.DeleteReplicationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for delete_replication + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_delete_replication(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_replication + + DEPRECATED. Please use the `post_delete_replication_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_delete_replication` interceptor runs + before the `post_delete_replication_with_metadata` interceptor. + """ + return response + + def post_delete_replication_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_replication + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_delete_replication_with_metadata` + interceptor in new development instead of the `post_delete_replication` interceptor. + When both interceptors are used, this `post_delete_replication_with_metadata` interceptor runs after the + `post_delete_replication` interceptor. The (possibly modified) response returned by + `post_delete_replication` will be passed to + `post_delete_replication_with_metadata`. + """ + return response, metadata + + def pre_delete_snapshot(self, request: snapshot.DeleteSnapshotRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[snapshot.DeleteSnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for delete_snapshot + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_delete_snapshot(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_snapshot + + DEPRECATED. Please use the `post_delete_snapshot_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_delete_snapshot` interceptor runs + before the `post_delete_snapshot_with_metadata` interceptor. + """ + return response + + def post_delete_snapshot_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_snapshot + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_delete_snapshot_with_metadata` + interceptor in new development instead of the `post_delete_snapshot` interceptor. + When both interceptors are used, this `post_delete_snapshot_with_metadata` interceptor runs after the + `post_delete_snapshot` interceptor. The (possibly modified) response returned by + `post_delete_snapshot` will be passed to + `post_delete_snapshot_with_metadata`. + """ + return response, metadata + + def pre_delete_storage_pool(self, request: storage_pool.DeleteStoragePoolRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[storage_pool.DeleteStoragePoolRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for delete_storage_pool + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_delete_storage_pool(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_storage_pool + + DEPRECATED. Please use the `post_delete_storage_pool_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_delete_storage_pool` interceptor runs + before the `post_delete_storage_pool_with_metadata` interceptor. + """ + return response + + def post_delete_storage_pool_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_storage_pool + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_delete_storage_pool_with_metadata` + interceptor in new development instead of the `post_delete_storage_pool` interceptor. + When both interceptors are used, this `post_delete_storage_pool_with_metadata` interceptor runs after the + `post_delete_storage_pool` interceptor. The (possibly modified) response returned by + `post_delete_storage_pool` will be passed to + `post_delete_storage_pool_with_metadata`. + """ + return response, metadata + + def pre_delete_volume(self, request: volume.DeleteVolumeRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[volume.DeleteVolumeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for delete_volume + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_delete_volume(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_volume + + DEPRECATED. Please use the `post_delete_volume_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_delete_volume` interceptor runs + before the `post_delete_volume_with_metadata` interceptor. + """ + return response + + def post_delete_volume_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_volume + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_delete_volume_with_metadata` + interceptor in new development instead of the `post_delete_volume` interceptor. + When both interceptors are used, this `post_delete_volume_with_metadata` interceptor runs after the + `post_delete_volume` interceptor. The (possibly modified) response returned by + `post_delete_volume` will be passed to + `post_delete_volume_with_metadata`. + """ + return response, metadata + + def pre_encrypt_volumes(self, request: kms.EncryptVolumesRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[kms.EncryptVolumesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for encrypt_volumes + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_encrypt_volumes(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for encrypt_volumes + + DEPRECATED. Please use the `post_encrypt_volumes_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_encrypt_volumes` interceptor runs + before the `post_encrypt_volumes_with_metadata` interceptor. + """ + return response + + def post_encrypt_volumes_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for encrypt_volumes + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_encrypt_volumes_with_metadata` + interceptor in new development instead of the `post_encrypt_volumes` interceptor. + When both interceptors are used, this `post_encrypt_volumes_with_metadata` interceptor runs after the + `post_encrypt_volumes` interceptor. The (possibly modified) response returned by + `post_encrypt_volumes` will be passed to + `post_encrypt_volumes_with_metadata`. + """ + return response, metadata + + def pre_establish_peering(self, request: replication.EstablishPeeringRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[replication.EstablishPeeringRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for establish_peering + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_establish_peering(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for establish_peering + + DEPRECATED. Please use the `post_establish_peering_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_establish_peering` interceptor runs + before the `post_establish_peering_with_metadata` interceptor. + """ + return response + + def post_establish_peering_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for establish_peering + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_establish_peering_with_metadata` + interceptor in new development instead of the `post_establish_peering` interceptor. + When both interceptors are used, this `post_establish_peering_with_metadata` interceptor runs after the + `post_establish_peering` interceptor. The (possibly modified) response returned by + `post_establish_peering` will be passed to + `post_establish_peering_with_metadata`. + """ + return response, metadata + + def pre_get_active_directory(self, request: active_directory.GetActiveDirectoryRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[active_directory.GetActiveDirectoryRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_active_directory + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_get_active_directory(self, response: active_directory.ActiveDirectory) -> active_directory.ActiveDirectory: + """Post-rpc interceptor for get_active_directory + + DEPRECATED. Please use the `post_get_active_directory_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_get_active_directory` interceptor runs + before the `post_get_active_directory_with_metadata` interceptor. + """ + return response + + def post_get_active_directory_with_metadata(self, response: active_directory.ActiveDirectory, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[active_directory.ActiveDirectory, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_active_directory + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_get_active_directory_with_metadata` + interceptor in new development instead of the `post_get_active_directory` interceptor. + When both interceptors are used, this `post_get_active_directory_with_metadata` interceptor runs after the + `post_get_active_directory` interceptor. The (possibly modified) response returned by + `post_get_active_directory` will be passed to + `post_get_active_directory_with_metadata`. + """ + return response, metadata + + def pre_get_backup(self, request: backup.GetBackupRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup.GetBackupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_backup + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_get_backup(self, response: backup.Backup) -> backup.Backup: + """Post-rpc interceptor for get_backup + + DEPRECATED. Please use the `post_get_backup_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_get_backup` interceptor runs + before the `post_get_backup_with_metadata` interceptor. + """ + return response + + def post_get_backup_with_metadata(self, response: backup.Backup, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup.Backup, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_backup + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_get_backup_with_metadata` + interceptor in new development instead of the `post_get_backup` interceptor. + When both interceptors are used, this `post_get_backup_with_metadata` interceptor runs after the + `post_get_backup` interceptor. The (possibly modified) response returned by + `post_get_backup` will be passed to + `post_get_backup_with_metadata`. + """ + return response, metadata + + def pre_get_backup_policy(self, request: backup_policy.GetBackupPolicyRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup_policy.GetBackupPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_backup_policy + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_get_backup_policy(self, response: backup_policy.BackupPolicy) -> backup_policy.BackupPolicy: + """Post-rpc interceptor for get_backup_policy + + DEPRECATED. Please use the `post_get_backup_policy_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_get_backup_policy` interceptor runs + before the `post_get_backup_policy_with_metadata` interceptor. + """ + return response + + def post_get_backup_policy_with_metadata(self, response: backup_policy.BackupPolicy, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup_policy.BackupPolicy, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_backup_policy + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_get_backup_policy_with_metadata` + interceptor in new development instead of the `post_get_backup_policy` interceptor. + When both interceptors are used, this `post_get_backup_policy_with_metadata` interceptor runs after the + `post_get_backup_policy` interceptor. The (possibly modified) response returned by + `post_get_backup_policy` will be passed to + `post_get_backup_policy_with_metadata`. + """ + return response, metadata + + def pre_get_backup_vault(self, request: backup_vault.GetBackupVaultRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup_vault.GetBackupVaultRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_backup_vault + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_get_backup_vault(self, response: backup_vault.BackupVault) -> backup_vault.BackupVault: + """Post-rpc interceptor for get_backup_vault + + DEPRECATED. Please use the `post_get_backup_vault_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_get_backup_vault` interceptor runs + before the `post_get_backup_vault_with_metadata` interceptor. + """ + return response + + def post_get_backup_vault_with_metadata(self, response: backup_vault.BackupVault, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup_vault.BackupVault, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_backup_vault + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_get_backup_vault_with_metadata` + interceptor in new development instead of the `post_get_backup_vault` interceptor. + When both interceptors are used, this `post_get_backup_vault_with_metadata` interceptor runs after the + `post_get_backup_vault` interceptor. The (possibly modified) response returned by + `post_get_backup_vault` will be passed to + `post_get_backup_vault_with_metadata`. + """ + return response, metadata + + def pre_get_kms_config(self, request: kms.GetKmsConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[kms.GetKmsConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_kms_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_get_kms_config(self, response: kms.KmsConfig) -> kms.KmsConfig: + """Post-rpc interceptor for get_kms_config + + DEPRECATED. Please use the `post_get_kms_config_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_get_kms_config` interceptor runs + before the `post_get_kms_config_with_metadata` interceptor. + """ + return response + + def post_get_kms_config_with_metadata(self, response: kms.KmsConfig, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[kms.KmsConfig, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_kms_config + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_get_kms_config_with_metadata` + interceptor in new development instead of the `post_get_kms_config` interceptor. + When both interceptors are used, this `post_get_kms_config_with_metadata` interceptor runs after the + `post_get_kms_config` interceptor. The (possibly modified) response returned by + `post_get_kms_config` will be passed to + `post_get_kms_config_with_metadata`. + """ + return response, metadata + + def pre_get_quota_rule(self, request: quota_rule.GetQuotaRuleRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[quota_rule.GetQuotaRuleRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_quota_rule + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_get_quota_rule(self, response: quota_rule.QuotaRule) -> quota_rule.QuotaRule: + """Post-rpc interceptor for get_quota_rule + + DEPRECATED. Please use the `post_get_quota_rule_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_get_quota_rule` interceptor runs + before the `post_get_quota_rule_with_metadata` interceptor. + """ + return response + + def post_get_quota_rule_with_metadata(self, response: quota_rule.QuotaRule, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[quota_rule.QuotaRule, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_quota_rule + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_get_quota_rule_with_metadata` + interceptor in new development instead of the `post_get_quota_rule` interceptor. + When both interceptors are used, this `post_get_quota_rule_with_metadata` interceptor runs after the + `post_get_quota_rule` interceptor. The (possibly modified) response returned by + `post_get_quota_rule` will be passed to + `post_get_quota_rule_with_metadata`. + """ + return response, metadata + + def pre_get_replication(self, request: replication.GetReplicationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[replication.GetReplicationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_replication + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_get_replication(self, response: replication.Replication) -> replication.Replication: + """Post-rpc interceptor for get_replication + + DEPRECATED. Please use the `post_get_replication_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_get_replication` interceptor runs + before the `post_get_replication_with_metadata` interceptor. + """ + return response + + def post_get_replication_with_metadata(self, response: replication.Replication, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[replication.Replication, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_replication + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_get_replication_with_metadata` + interceptor in new development instead of the `post_get_replication` interceptor. + When both interceptors are used, this `post_get_replication_with_metadata` interceptor runs after the + `post_get_replication` interceptor. The (possibly modified) response returned by + `post_get_replication` will be passed to + `post_get_replication_with_metadata`. + """ + return response, metadata + + def pre_get_snapshot(self, request: snapshot.GetSnapshotRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[snapshot.GetSnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_snapshot + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_get_snapshot(self, response: snapshot.Snapshot) -> snapshot.Snapshot: + """Post-rpc interceptor for get_snapshot + + DEPRECATED. Please use the `post_get_snapshot_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_get_snapshot` interceptor runs + before the `post_get_snapshot_with_metadata` interceptor. + """ + return response + + def post_get_snapshot_with_metadata(self, response: snapshot.Snapshot, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[snapshot.Snapshot, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_snapshot + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_get_snapshot_with_metadata` + interceptor in new development instead of the `post_get_snapshot` interceptor. + When both interceptors are used, this `post_get_snapshot_with_metadata` interceptor runs after the + `post_get_snapshot` interceptor. The (possibly modified) response returned by + `post_get_snapshot` will be passed to + `post_get_snapshot_with_metadata`. + """ + return response, metadata + + def pre_get_storage_pool(self, request: storage_pool.GetStoragePoolRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[storage_pool.GetStoragePoolRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_storage_pool + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_get_storage_pool(self, response: storage_pool.StoragePool) -> storage_pool.StoragePool: + """Post-rpc interceptor for get_storage_pool + + DEPRECATED. Please use the `post_get_storage_pool_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_get_storage_pool` interceptor runs + before the `post_get_storage_pool_with_metadata` interceptor. + """ + return response + + def post_get_storage_pool_with_metadata(self, response: storage_pool.StoragePool, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[storage_pool.StoragePool, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_storage_pool + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_get_storage_pool_with_metadata` + interceptor in new development instead of the `post_get_storage_pool` interceptor. + When both interceptors are used, this `post_get_storage_pool_with_metadata` interceptor runs after the + `post_get_storage_pool` interceptor. The (possibly modified) response returned by + `post_get_storage_pool` will be passed to + `post_get_storage_pool_with_metadata`. + """ + return response, metadata + + def pre_get_volume(self, request: volume.GetVolumeRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[volume.GetVolumeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_volume + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_get_volume(self, response: volume.Volume) -> volume.Volume: + """Post-rpc interceptor for get_volume + + DEPRECATED. Please use the `post_get_volume_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_get_volume` interceptor runs + before the `post_get_volume_with_metadata` interceptor. + """ + return response + + def post_get_volume_with_metadata(self, response: volume.Volume, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[volume.Volume, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_volume + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_get_volume_with_metadata` + interceptor in new development instead of the `post_get_volume` interceptor. + When both interceptors are used, this `post_get_volume_with_metadata` interceptor runs after the + `post_get_volume` interceptor. The (possibly modified) response returned by + `post_get_volume` will be passed to + `post_get_volume_with_metadata`. + """ + return response, metadata + + def pre_list_active_directories(self, request: active_directory.ListActiveDirectoriesRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[active_directory.ListActiveDirectoriesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_active_directories + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_list_active_directories(self, response: active_directory.ListActiveDirectoriesResponse) -> active_directory.ListActiveDirectoriesResponse: + """Post-rpc interceptor for list_active_directories + + DEPRECATED. Please use the `post_list_active_directories_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_list_active_directories` interceptor runs + before the `post_list_active_directories_with_metadata` interceptor. + """ + return response + + def post_list_active_directories_with_metadata(self, response: active_directory.ListActiveDirectoriesResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[active_directory.ListActiveDirectoriesResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for list_active_directories + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_list_active_directories_with_metadata` + interceptor in new development instead of the `post_list_active_directories` interceptor. + When both interceptors are used, this `post_list_active_directories_with_metadata` interceptor runs after the + `post_list_active_directories` interceptor. The (possibly modified) response returned by + `post_list_active_directories` will be passed to + `post_list_active_directories_with_metadata`. + """ + return response, metadata + + def pre_list_backup_policies(self, request: backup_policy.ListBackupPoliciesRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup_policy.ListBackupPoliciesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_backup_policies + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_list_backup_policies(self, response: backup_policy.ListBackupPoliciesResponse) -> backup_policy.ListBackupPoliciesResponse: + """Post-rpc interceptor for list_backup_policies + + DEPRECATED. Please use the `post_list_backup_policies_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_list_backup_policies` interceptor runs + before the `post_list_backup_policies_with_metadata` interceptor. + """ + return response + + def post_list_backup_policies_with_metadata(self, response: backup_policy.ListBackupPoliciesResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup_policy.ListBackupPoliciesResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for list_backup_policies + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_list_backup_policies_with_metadata` + interceptor in new development instead of the `post_list_backup_policies` interceptor. + When both interceptors are used, this `post_list_backup_policies_with_metadata` interceptor runs after the + `post_list_backup_policies` interceptor. The (possibly modified) response returned by + `post_list_backup_policies` will be passed to + `post_list_backup_policies_with_metadata`. + """ + return response, metadata + + def pre_list_backups(self, request: backup.ListBackupsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup.ListBackupsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_backups + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_list_backups(self, response: backup.ListBackupsResponse) -> backup.ListBackupsResponse: + """Post-rpc interceptor for list_backups + + DEPRECATED. Please use the `post_list_backups_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_list_backups` interceptor runs + before the `post_list_backups_with_metadata` interceptor. + """ + return response + + def post_list_backups_with_metadata(self, response: backup.ListBackupsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup.ListBackupsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for list_backups + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_list_backups_with_metadata` + interceptor in new development instead of the `post_list_backups` interceptor. + When both interceptors are used, this `post_list_backups_with_metadata` interceptor runs after the + `post_list_backups` interceptor. The (possibly modified) response returned by + `post_list_backups` will be passed to + `post_list_backups_with_metadata`. + """ + return response, metadata + + def pre_list_backup_vaults(self, request: backup_vault.ListBackupVaultsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup_vault.ListBackupVaultsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_backup_vaults + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_list_backup_vaults(self, response: backup_vault.ListBackupVaultsResponse) -> backup_vault.ListBackupVaultsResponse: + """Post-rpc interceptor for list_backup_vaults + + DEPRECATED. Please use the `post_list_backup_vaults_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_list_backup_vaults` interceptor runs + before the `post_list_backup_vaults_with_metadata` interceptor. + """ + return response + + def post_list_backup_vaults_with_metadata(self, response: backup_vault.ListBackupVaultsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup_vault.ListBackupVaultsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for list_backup_vaults + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_list_backup_vaults_with_metadata` + interceptor in new development instead of the `post_list_backup_vaults` interceptor. + When both interceptors are used, this `post_list_backup_vaults_with_metadata` interceptor runs after the + `post_list_backup_vaults` interceptor. The (possibly modified) response returned by + `post_list_backup_vaults` will be passed to + `post_list_backup_vaults_with_metadata`. + """ + return response, metadata + + def pre_list_kms_configs(self, request: kms.ListKmsConfigsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[kms.ListKmsConfigsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_kms_configs + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_list_kms_configs(self, response: kms.ListKmsConfigsResponse) -> kms.ListKmsConfigsResponse: + """Post-rpc interceptor for list_kms_configs + + DEPRECATED. Please use the `post_list_kms_configs_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_list_kms_configs` interceptor runs + before the `post_list_kms_configs_with_metadata` interceptor. + """ + return response + + def post_list_kms_configs_with_metadata(self, response: kms.ListKmsConfigsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[kms.ListKmsConfigsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for list_kms_configs + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_list_kms_configs_with_metadata` + interceptor in new development instead of the `post_list_kms_configs` interceptor. + When both interceptors are used, this `post_list_kms_configs_with_metadata` interceptor runs after the + `post_list_kms_configs` interceptor. The (possibly modified) response returned by + `post_list_kms_configs` will be passed to + `post_list_kms_configs_with_metadata`. + """ + return response, metadata + + def pre_list_quota_rules(self, request: quota_rule.ListQuotaRulesRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[quota_rule.ListQuotaRulesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_quota_rules + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_list_quota_rules(self, response: quota_rule.ListQuotaRulesResponse) -> quota_rule.ListQuotaRulesResponse: + """Post-rpc interceptor for list_quota_rules + + DEPRECATED. Please use the `post_list_quota_rules_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_list_quota_rules` interceptor runs + before the `post_list_quota_rules_with_metadata` interceptor. + """ + return response + + def post_list_quota_rules_with_metadata(self, response: quota_rule.ListQuotaRulesResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[quota_rule.ListQuotaRulesResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for list_quota_rules + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_list_quota_rules_with_metadata` + interceptor in new development instead of the `post_list_quota_rules` interceptor. + When both interceptors are used, this `post_list_quota_rules_with_metadata` interceptor runs after the + `post_list_quota_rules` interceptor. The (possibly modified) response returned by + `post_list_quota_rules` will be passed to + `post_list_quota_rules_with_metadata`. + """ + return response, metadata + + def pre_list_replications(self, request: replication.ListReplicationsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[replication.ListReplicationsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_replications + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_list_replications(self, response: replication.ListReplicationsResponse) -> replication.ListReplicationsResponse: + """Post-rpc interceptor for list_replications + + DEPRECATED. Please use the `post_list_replications_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_list_replications` interceptor runs + before the `post_list_replications_with_metadata` interceptor. + """ + return response + + def post_list_replications_with_metadata(self, response: replication.ListReplicationsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[replication.ListReplicationsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for list_replications + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_list_replications_with_metadata` + interceptor in new development instead of the `post_list_replications` interceptor. + When both interceptors are used, this `post_list_replications_with_metadata` interceptor runs after the + `post_list_replications` interceptor. The (possibly modified) response returned by + `post_list_replications` will be passed to + `post_list_replications_with_metadata`. + """ + return response, metadata + + def pre_list_snapshots(self, request: snapshot.ListSnapshotsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[snapshot.ListSnapshotsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_snapshots + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_list_snapshots(self, response: snapshot.ListSnapshotsResponse) -> snapshot.ListSnapshotsResponse: + """Post-rpc interceptor for list_snapshots + + DEPRECATED. Please use the `post_list_snapshots_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_list_snapshots` interceptor runs + before the `post_list_snapshots_with_metadata` interceptor. + """ + return response + + def post_list_snapshots_with_metadata(self, response: snapshot.ListSnapshotsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[snapshot.ListSnapshotsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for list_snapshots + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_list_snapshots_with_metadata` + interceptor in new development instead of the `post_list_snapshots` interceptor. + When both interceptors are used, this `post_list_snapshots_with_metadata` interceptor runs after the + `post_list_snapshots` interceptor. The (possibly modified) response returned by + `post_list_snapshots` will be passed to + `post_list_snapshots_with_metadata`. + """ + return response, metadata + + def pre_list_storage_pools(self, request: storage_pool.ListStoragePoolsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[storage_pool.ListStoragePoolsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_storage_pools + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_list_storage_pools(self, response: storage_pool.ListStoragePoolsResponse) -> storage_pool.ListStoragePoolsResponse: + """Post-rpc interceptor for list_storage_pools + + DEPRECATED. Please use the `post_list_storage_pools_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_list_storage_pools` interceptor runs + before the `post_list_storage_pools_with_metadata` interceptor. + """ + return response + + def post_list_storage_pools_with_metadata(self, response: storage_pool.ListStoragePoolsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[storage_pool.ListStoragePoolsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for list_storage_pools + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_list_storage_pools_with_metadata` + interceptor in new development instead of the `post_list_storage_pools` interceptor. + When both interceptors are used, this `post_list_storage_pools_with_metadata` interceptor runs after the + `post_list_storage_pools` interceptor. The (possibly modified) response returned by + `post_list_storage_pools` will be passed to + `post_list_storage_pools_with_metadata`. + """ + return response, metadata + + def pre_list_volumes(self, request: volume.ListVolumesRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[volume.ListVolumesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_volumes + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_list_volumes(self, response: volume.ListVolumesResponse) -> volume.ListVolumesResponse: + """Post-rpc interceptor for list_volumes + + DEPRECATED. Please use the `post_list_volumes_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_list_volumes` interceptor runs + before the `post_list_volumes_with_metadata` interceptor. + """ + return response + + def post_list_volumes_with_metadata(self, response: volume.ListVolumesResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[volume.ListVolumesResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for list_volumes + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_list_volumes_with_metadata` + interceptor in new development instead of the `post_list_volumes` interceptor. + When both interceptors are used, this `post_list_volumes_with_metadata` interceptor runs after the + `post_list_volumes` interceptor. The (possibly modified) response returned by + `post_list_volumes` will be passed to + `post_list_volumes_with_metadata`. + """ + return response, metadata + + def pre_resume_replication(self, request: replication.ResumeReplicationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[replication.ResumeReplicationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for resume_replication + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_resume_replication(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for resume_replication + + DEPRECATED. Please use the `post_resume_replication_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_resume_replication` interceptor runs + before the `post_resume_replication_with_metadata` interceptor. + """ + return response + + def post_resume_replication_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for resume_replication + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_resume_replication_with_metadata` + interceptor in new development instead of the `post_resume_replication` interceptor. + When both interceptors are used, this `post_resume_replication_with_metadata` interceptor runs after the + `post_resume_replication` interceptor. The (possibly modified) response returned by + `post_resume_replication` will be passed to + `post_resume_replication_with_metadata`. + """ + return response, metadata + + def pre_reverse_replication_direction(self, request: replication.ReverseReplicationDirectionRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[replication.ReverseReplicationDirectionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for reverse_replication_direction + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_reverse_replication_direction(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for reverse_replication_direction + + DEPRECATED. Please use the `post_reverse_replication_direction_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_reverse_replication_direction` interceptor runs + before the `post_reverse_replication_direction_with_metadata` interceptor. + """ + return response + + def post_reverse_replication_direction_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for reverse_replication_direction + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_reverse_replication_direction_with_metadata` + interceptor in new development instead of the `post_reverse_replication_direction` interceptor. + When both interceptors are used, this `post_reverse_replication_direction_with_metadata` interceptor runs after the + `post_reverse_replication_direction` interceptor. The (possibly modified) response returned by + `post_reverse_replication_direction` will be passed to + `post_reverse_replication_direction_with_metadata`. + """ + return response, metadata + + def pre_revert_volume(self, request: volume.RevertVolumeRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[volume.RevertVolumeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for revert_volume + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_revert_volume(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for revert_volume + + DEPRECATED. Please use the `post_revert_volume_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_revert_volume` interceptor runs + before the `post_revert_volume_with_metadata` interceptor. + """ + return response + + def post_revert_volume_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for revert_volume + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_revert_volume_with_metadata` + interceptor in new development instead of the `post_revert_volume` interceptor. + When both interceptors are used, this `post_revert_volume_with_metadata` interceptor runs after the + `post_revert_volume` interceptor. The (possibly modified) response returned by + `post_revert_volume` will be passed to + `post_revert_volume_with_metadata`. + """ + return response, metadata + + def pre_stop_replication(self, request: replication.StopReplicationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[replication.StopReplicationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for stop_replication + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_stop_replication(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for stop_replication + + DEPRECATED. Please use the `post_stop_replication_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_stop_replication` interceptor runs + before the `post_stop_replication_with_metadata` interceptor. + """ + return response + + def post_stop_replication_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for stop_replication + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_stop_replication_with_metadata` + interceptor in new development instead of the `post_stop_replication` interceptor. + When both interceptors are used, this `post_stop_replication_with_metadata` interceptor runs after the + `post_stop_replication` interceptor. The (possibly modified) response returned by + `post_stop_replication` will be passed to + `post_stop_replication_with_metadata`. + """ + return response, metadata + + def pre_switch_active_replica_zone(self, request: storage_pool.SwitchActiveReplicaZoneRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[storage_pool.SwitchActiveReplicaZoneRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for switch_active_replica_zone + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_switch_active_replica_zone(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for switch_active_replica_zone + + DEPRECATED. Please use the `post_switch_active_replica_zone_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_switch_active_replica_zone` interceptor runs + before the `post_switch_active_replica_zone_with_metadata` interceptor. + """ + return response + + def post_switch_active_replica_zone_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for switch_active_replica_zone + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_switch_active_replica_zone_with_metadata` + interceptor in new development instead of the `post_switch_active_replica_zone` interceptor. + When both interceptors are used, this `post_switch_active_replica_zone_with_metadata` interceptor runs after the + `post_switch_active_replica_zone` interceptor. The (possibly modified) response returned by + `post_switch_active_replica_zone` will be passed to + `post_switch_active_replica_zone_with_metadata`. + """ + return response, metadata + + def pre_sync_replication(self, request: replication.SyncReplicationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[replication.SyncReplicationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for sync_replication + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_sync_replication(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for sync_replication + + DEPRECATED. Please use the `post_sync_replication_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_sync_replication` interceptor runs + before the `post_sync_replication_with_metadata` interceptor. + """ + return response + + def post_sync_replication_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for sync_replication + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_sync_replication_with_metadata` + interceptor in new development instead of the `post_sync_replication` interceptor. + When both interceptors are used, this `post_sync_replication_with_metadata` interceptor runs after the + `post_sync_replication` interceptor. The (possibly modified) response returned by + `post_sync_replication` will be passed to + `post_sync_replication_with_metadata`. + """ + return response, metadata + + def pre_update_active_directory(self, request: gcn_active_directory.UpdateActiveDirectoryRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_active_directory.UpdateActiveDirectoryRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for update_active_directory + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_update_active_directory(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for update_active_directory + + DEPRECATED. Please use the `post_update_active_directory_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_update_active_directory` interceptor runs + before the `post_update_active_directory_with_metadata` interceptor. + """ + return response + + def post_update_active_directory_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_active_directory + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_update_active_directory_with_metadata` + interceptor in new development instead of the `post_update_active_directory` interceptor. + When both interceptors are used, this `post_update_active_directory_with_metadata` interceptor runs after the + `post_update_active_directory` interceptor. The (possibly modified) response returned by + `post_update_active_directory` will be passed to + `post_update_active_directory_with_metadata`. + """ + return response, metadata + + def pre_update_backup(self, request: gcn_backup.UpdateBackupRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_backup.UpdateBackupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for update_backup + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_update_backup(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for update_backup + + DEPRECATED. Please use the `post_update_backup_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_update_backup` interceptor runs + before the `post_update_backup_with_metadata` interceptor. + """ + return response + + def post_update_backup_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_backup + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_update_backup_with_metadata` + interceptor in new development instead of the `post_update_backup` interceptor. + When both interceptors are used, this `post_update_backup_with_metadata` interceptor runs after the + `post_update_backup` interceptor. The (possibly modified) response returned by + `post_update_backup` will be passed to + `post_update_backup_with_metadata`. + """ + return response, metadata + + def pre_update_backup_policy(self, request: gcn_backup_policy.UpdateBackupPolicyRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_backup_policy.UpdateBackupPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for update_backup_policy + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_update_backup_policy(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for update_backup_policy + + DEPRECATED. Please use the `post_update_backup_policy_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_update_backup_policy` interceptor runs + before the `post_update_backup_policy_with_metadata` interceptor. + """ + return response + + def post_update_backup_policy_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_backup_policy + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_update_backup_policy_with_metadata` + interceptor in new development instead of the `post_update_backup_policy` interceptor. + When both interceptors are used, this `post_update_backup_policy_with_metadata` interceptor runs after the + `post_update_backup_policy` interceptor. The (possibly modified) response returned by + `post_update_backup_policy` will be passed to + `post_update_backup_policy_with_metadata`. + """ + return response, metadata + + def pre_update_backup_vault(self, request: gcn_backup_vault.UpdateBackupVaultRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_backup_vault.UpdateBackupVaultRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for update_backup_vault + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_update_backup_vault(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for update_backup_vault + + DEPRECATED. Please use the `post_update_backup_vault_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_update_backup_vault` interceptor runs + before the `post_update_backup_vault_with_metadata` interceptor. + """ + return response + + def post_update_backup_vault_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_backup_vault + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_update_backup_vault_with_metadata` + interceptor in new development instead of the `post_update_backup_vault` interceptor. + When both interceptors are used, this `post_update_backup_vault_with_metadata` interceptor runs after the + `post_update_backup_vault` interceptor. The (possibly modified) response returned by + `post_update_backup_vault` will be passed to + `post_update_backup_vault_with_metadata`. + """ + return response, metadata + + def pre_update_kms_config(self, request: kms.UpdateKmsConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[kms.UpdateKmsConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for update_kms_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_update_kms_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for update_kms_config + + DEPRECATED. Please use the `post_update_kms_config_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_update_kms_config` interceptor runs + before the `post_update_kms_config_with_metadata` interceptor. + """ + return response + + def post_update_kms_config_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_kms_config + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_update_kms_config_with_metadata` + interceptor in new development instead of the `post_update_kms_config` interceptor. + When both interceptors are used, this `post_update_kms_config_with_metadata` interceptor runs after the + `post_update_kms_config` interceptor. The (possibly modified) response returned by + `post_update_kms_config` will be passed to + `post_update_kms_config_with_metadata`. + """ + return response, metadata + + def pre_update_quota_rule(self, request: gcn_quota_rule.UpdateQuotaRuleRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_quota_rule.UpdateQuotaRuleRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for update_quota_rule + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_update_quota_rule(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for update_quota_rule + + DEPRECATED. Please use the `post_update_quota_rule_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_update_quota_rule` interceptor runs + before the `post_update_quota_rule_with_metadata` interceptor. + """ + return response + + def post_update_quota_rule_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_quota_rule + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_update_quota_rule_with_metadata` + interceptor in new development instead of the `post_update_quota_rule` interceptor. + When both interceptors are used, this `post_update_quota_rule_with_metadata` interceptor runs after the + `post_update_quota_rule` interceptor. The (possibly modified) response returned by + `post_update_quota_rule` will be passed to + `post_update_quota_rule_with_metadata`. + """ + return response, metadata + + def pre_update_replication(self, request: gcn_replication.UpdateReplicationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_replication.UpdateReplicationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for update_replication + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_update_replication(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for update_replication + + DEPRECATED. Please use the `post_update_replication_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_update_replication` interceptor runs + before the `post_update_replication_with_metadata` interceptor. + """ + return response + + def post_update_replication_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_replication + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_update_replication_with_metadata` + interceptor in new development instead of the `post_update_replication` interceptor. + When both interceptors are used, this `post_update_replication_with_metadata` interceptor runs after the + `post_update_replication` interceptor. The (possibly modified) response returned by + `post_update_replication` will be passed to + `post_update_replication_with_metadata`. + """ + return response, metadata + + def pre_update_snapshot(self, request: gcn_snapshot.UpdateSnapshotRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_snapshot.UpdateSnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for update_snapshot + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_update_snapshot(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for update_snapshot + + DEPRECATED. Please use the `post_update_snapshot_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_update_snapshot` interceptor runs + before the `post_update_snapshot_with_metadata` interceptor. + """ + return response + + def post_update_snapshot_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_snapshot + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_update_snapshot_with_metadata` + interceptor in new development instead of the `post_update_snapshot` interceptor. + When both interceptors are used, this `post_update_snapshot_with_metadata` interceptor runs after the + `post_update_snapshot` interceptor. The (possibly modified) response returned by + `post_update_snapshot` will be passed to + `post_update_snapshot_with_metadata`. + """ + return response, metadata + + def pre_update_storage_pool(self, request: gcn_storage_pool.UpdateStoragePoolRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_storage_pool.UpdateStoragePoolRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for update_storage_pool + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_update_storage_pool(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for update_storage_pool + + DEPRECATED. Please use the `post_update_storage_pool_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_update_storage_pool` interceptor runs + before the `post_update_storage_pool_with_metadata` interceptor. + """ + return response + + def post_update_storage_pool_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_storage_pool + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_update_storage_pool_with_metadata` + interceptor in new development instead of the `post_update_storage_pool` interceptor. + When both interceptors are used, this `post_update_storage_pool_with_metadata` interceptor runs after the + `post_update_storage_pool` interceptor. The (possibly modified) response returned by + `post_update_storage_pool` will be passed to + `post_update_storage_pool_with_metadata`. + """ + return response, metadata + + def pre_update_volume(self, request: gcn_volume.UpdateVolumeRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_volume.UpdateVolumeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for update_volume + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_update_volume(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for update_volume + + DEPRECATED. Please use the `post_update_volume_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_update_volume` interceptor runs + before the `post_update_volume_with_metadata` interceptor. + """ + return response + + def post_update_volume_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_volume + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_update_volume_with_metadata` + interceptor in new development instead of the `post_update_volume` interceptor. + When both interceptors are used, this `post_update_volume_with_metadata` interceptor runs after the + `post_update_volume` interceptor. The (possibly modified) response returned by + `post_update_volume` will be passed to + `post_update_volume_with_metadata`. + """ + return response, metadata + + def pre_validate_directory_service(self, request: storage_pool.ValidateDirectoryServiceRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[storage_pool.ValidateDirectoryServiceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for validate_directory_service + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_validate_directory_service(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for validate_directory_service + + DEPRECATED. Please use the `post_validate_directory_service_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_validate_directory_service` interceptor runs + before the `post_validate_directory_service_with_metadata` interceptor. + """ + return response + + def post_validate_directory_service_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for validate_directory_service + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_validate_directory_service_with_metadata` + interceptor in new development instead of the `post_validate_directory_service` interceptor. + When both interceptors are used, this `post_validate_directory_service_with_metadata` interceptor runs after the + `post_validate_directory_service` interceptor. The (possibly modified) response returned by + `post_validate_directory_service` will be passed to + `post_validate_directory_service_with_metadata`. + """ + return response, metadata + + def pre_verify_kms_config(self, request: kms.VerifyKmsConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[kms.VerifyKmsConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for verify_kms_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_verify_kms_config(self, response: kms.VerifyKmsConfigResponse) -> kms.VerifyKmsConfigResponse: + """Post-rpc interceptor for verify_kms_config + + DEPRECATED. Please use the `post_verify_kms_config_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. This `post_verify_kms_config` interceptor runs + before the `post_verify_kms_config_with_metadata` interceptor. + """ + return response + + def post_verify_kms_config_with_metadata(self, response: kms.VerifyKmsConfigResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[kms.VerifyKmsConfigResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for verify_kms_config + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the NetApp server but before it is returned to user code. + + We recommend only using this `post_verify_kms_config_with_metadata` + interceptor in new development instead of the `post_verify_kms_config` interceptor. + When both interceptors are used, this `post_verify_kms_config_with_metadata` interceptor runs after the + `post_verify_kms_config` interceptor. The (possibly modified) response returned by + `post_verify_kms_config` will be passed to + `post_verify_kms_config_with_metadata`. + """ + return response, metadata + + def pre_get_location( + self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] + ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_location + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp 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 NetApp server but before + it is returned to user code. + """ + return response + + def pre_list_locations( + self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] + ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_locations + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp 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 NetApp server but before + it is returned to user code. + """ + return response + + def pre_cancel_operation( + self, request: operations_pb2.CancelOperationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] + ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for cancel_operation + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_cancel_operation( + self, response: None + ) -> None: + """Post-rpc interceptor for cancel_operation + + Override in a subclass to manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. + """ + return response + + def pre_delete_operation( + self, request: operations_pb2.DeleteOperationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] + ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for delete_operation + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_delete_operation( + self, response: None + ) -> None: + """Post-rpc interceptor for delete_operation + + Override in a subclass to manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. + """ + return response + + def pre_get_operation( + self, request: operations_pb2.GetOperationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] + ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_operation + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp 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 NetApp server but before + it is returned to user code. + """ + return response + + def pre_list_operations( + self, request: operations_pb2.ListOperationsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] + ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_operations + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetApp server. + """ + return request, metadata + + def post_list_operations( + self, response: operations_pb2.ListOperationsResponse + ) -> operations_pb2.ListOperationsResponse: + """Post-rpc interceptor for list_operations + + Override in a subclass to manipulate the response + after it is returned by the NetApp server but before + it is returned to user code. + """ + return response + + +@dataclasses.dataclass +class NetAppRestStub: + _session: AuthorizedSession + _host: str + _interceptor: NetAppRestInterceptor + + +class NetAppRestTransport(_BaseNetAppRestTransport): + """REST backend synchronous transport for NetApp. + + NetApp Files Google Cloud Service + + 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 = 'netapp.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[NetAppRestInterceptor] = None, + api_audience: Optional[str] = None, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to (default: 'netapp.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 NetAppRestInterceptor() + 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.CancelOperation': [ + { + 'method': 'post', + 'uri': '/v1/{name=projects/*/locations/*/operations/*}:cancel', + 'body': '*', + }, + ], + 'google.longrunning.Operations.DeleteOperation': [ + { + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/operations/*}', + }, + ], + 'google.longrunning.Operations.GetOperation': [ + { + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/operations/*}', + }, + ], + 'google.longrunning.Operations.ListOperations': [ + { + '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 _CreateActiveDirectory(_BaseNetAppRestTransport._BaseCreateActiveDirectory, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.CreateActiveDirectory") + + @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: gcn_active_directory.CreateActiveDirectoryRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the create active directory method over HTTP. + + Args: + request (~.gcn_active_directory.CreateActiveDirectoryRequest): + The request object. CreateActiveDirectoryRequest for + creating an active directory. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseCreateActiveDirectory._get_http_options() + + request, metadata = self._interceptor.pre_create_active_directory(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseCreateActiveDirectory._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseCreateActiveDirectory._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseCreateActiveDirectory._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.CreateActiveDirectory", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "CreateActiveDirectory", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._CreateActiveDirectory._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_active_directory(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_active_directory_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.create_active_directory", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "CreateActiveDirectory", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateBackup(_BaseNetAppRestTransport._BaseCreateBackup, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.CreateBackup") + + @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: gcn_backup.CreateBackupRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the create backup method over HTTP. + + Args: + request (~.gcn_backup.CreateBackupRequest): + The request object. CreateBackupRequest creates a backup. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseCreateBackup._get_http_options() + + request, metadata = self._interceptor.pre_create_backup(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseCreateBackup._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseCreateBackup._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseCreateBackup._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.CreateBackup", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "CreateBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._CreateBackup._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_backup(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_backup_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.create_backup", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "CreateBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateBackupPolicy(_BaseNetAppRestTransport._BaseCreateBackupPolicy, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.CreateBackupPolicy") + + @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: gcn_backup_policy.CreateBackupPolicyRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the create backup policy method over HTTP. + + Args: + request (~.gcn_backup_policy.CreateBackupPolicyRequest): + The request object. CreateBackupPolicyRequest creates a + backupPolicy. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseCreateBackupPolicy._get_http_options() + + request, metadata = self._interceptor.pre_create_backup_policy(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseCreateBackupPolicy._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseCreateBackupPolicy._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseCreateBackupPolicy._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.CreateBackupPolicy", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "CreateBackupPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._CreateBackupPolicy._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_backup_policy(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_backup_policy_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.create_backup_policy", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "CreateBackupPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateBackupVault(_BaseNetAppRestTransport._BaseCreateBackupVault, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.CreateBackupVault") + + @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: gcn_backup_vault.CreateBackupVaultRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the create backup vault method over HTTP. + + Args: + request (~.gcn_backup_vault.CreateBackupVaultRequest): + The request object. CreateBackupVaultRequest creates a + backup vault. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseCreateBackupVault._get_http_options() + + request, metadata = self._interceptor.pre_create_backup_vault(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseCreateBackupVault._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseCreateBackupVault._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseCreateBackupVault._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.CreateBackupVault", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "CreateBackupVault", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._CreateBackupVault._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_backup_vault(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_backup_vault_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.create_backup_vault", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "CreateBackupVault", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateKmsConfig(_BaseNetAppRestTransport._BaseCreateKmsConfig, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.CreateKmsConfig") + + @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: kms.CreateKmsConfigRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the create kms config method over HTTP. + + Args: + request (~.kms.CreateKmsConfigRequest): + The request object. CreateKmsConfigRequest creates a KMS + Config. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseCreateKmsConfig._get_http_options() + + request, metadata = self._interceptor.pre_create_kms_config(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseCreateKmsConfig._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseCreateKmsConfig._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseCreateKmsConfig._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.CreateKmsConfig", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "CreateKmsConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._CreateKmsConfig._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_kms_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_kms_config_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.create_kms_config", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "CreateKmsConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateQuotaRule(_BaseNetAppRestTransport._BaseCreateQuotaRule, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.CreateQuotaRule") + + @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: gcn_quota_rule.CreateQuotaRuleRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the create quota rule method over HTTP. + + Args: + request (~.gcn_quota_rule.CreateQuotaRuleRequest): + The request object. CreateQuotaRuleRequest for creating a + quota 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseCreateQuotaRule._get_http_options() + + request, metadata = self._interceptor.pre_create_quota_rule(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseCreateQuotaRule._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseCreateQuotaRule._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseCreateQuotaRule._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.CreateQuotaRule", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "CreateQuotaRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._CreateQuotaRule._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_quota_rule(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_quota_rule_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.create_quota_rule", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "CreateQuotaRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateReplication(_BaseNetAppRestTransport._BaseCreateReplication, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.CreateReplication") + + @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: gcn_replication.CreateReplicationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the create replication method over HTTP. + + Args: + request (~.gcn_replication.CreateReplicationRequest): + The request object. CreateReplicationRequest creates a + replication. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseCreateReplication._get_http_options() + + request, metadata = self._interceptor.pre_create_replication(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseCreateReplication._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseCreateReplication._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseCreateReplication._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.CreateReplication", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "CreateReplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._CreateReplication._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_replication(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_replication_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.create_replication", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "CreateReplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateSnapshot(_BaseNetAppRestTransport._BaseCreateSnapshot, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.CreateSnapshot") + + @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: gcn_snapshot.CreateSnapshotRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the create snapshot method over HTTP. + + Args: + request (~.gcn_snapshot.CreateSnapshotRequest): + The request object. CreateSnapshotRequest creates a + snapshot. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseCreateSnapshot._get_http_options() + + request, metadata = self._interceptor.pre_create_snapshot(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseCreateSnapshot._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseCreateSnapshot._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseCreateSnapshot._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.CreateSnapshot", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "CreateSnapshot", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._CreateSnapshot._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_snapshot(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_snapshot_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.create_snapshot", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "CreateSnapshot", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateStoragePool(_BaseNetAppRestTransport._BaseCreateStoragePool, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.CreateStoragePool") + + @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: gcn_storage_pool.CreateStoragePoolRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the create storage pool method over HTTP. + + Args: + request (~.gcn_storage_pool.CreateStoragePoolRequest): + The request object. CreateStoragePoolRequest creates a + Storage Pool. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseCreateStoragePool._get_http_options() + + request, metadata = self._interceptor.pre_create_storage_pool(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseCreateStoragePool._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseCreateStoragePool._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseCreateStoragePool._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.CreateStoragePool", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "CreateStoragePool", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._CreateStoragePool._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_storage_pool(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_storage_pool_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.create_storage_pool", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "CreateStoragePool", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateVolume(_BaseNetAppRestTransport._BaseCreateVolume, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.CreateVolume") + + @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: gcn_volume.CreateVolumeRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the create volume method over HTTP. + + Args: + request (~.gcn_volume.CreateVolumeRequest): + The request object. Message for creating a Volume + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseCreateVolume._get_http_options() + + request, metadata = self._interceptor.pre_create_volume(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseCreateVolume._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseCreateVolume._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseCreateVolume._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.CreateVolume", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "CreateVolume", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._CreateVolume._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_volume(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_volume_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.create_volume", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "CreateVolume", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteActiveDirectory(_BaseNetAppRestTransport._BaseDeleteActiveDirectory, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.DeleteActiveDirectory") + + @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: active_directory.DeleteActiveDirectoryRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the delete active directory method over HTTP. + + Args: + request (~.active_directory.DeleteActiveDirectoryRequest): + The request object. DeleteActiveDirectoryRequest for + deleting a single active directory. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseDeleteActiveDirectory._get_http_options() + + request, metadata = self._interceptor.pre_delete_active_directory(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseDeleteActiveDirectory._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseDeleteActiveDirectory._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteActiveDirectory", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "DeleteActiveDirectory", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._DeleteActiveDirectory._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_active_directory(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_active_directory_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.delete_active_directory", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "DeleteActiveDirectory", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteBackup(_BaseNetAppRestTransport._BaseDeleteBackup, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.DeleteBackup") + + @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: backup.DeleteBackupRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the delete backup method over HTTP. + + Args: + request (~.backup.DeleteBackupRequest): + The request object. DeleteBackupRequest deletes a backup. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseDeleteBackup._get_http_options() + + request, metadata = self._interceptor.pre_delete_backup(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseDeleteBackup._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseDeleteBackup._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteBackup", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "DeleteBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._DeleteBackup._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_backup(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_backup_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.delete_backup", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "DeleteBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteBackupPolicy(_BaseNetAppRestTransport._BaseDeleteBackupPolicy, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.DeleteBackupPolicy") + + @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: backup_policy.DeleteBackupPolicyRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the delete backup policy method over HTTP. + + Args: + request (~.backup_policy.DeleteBackupPolicyRequest): + The request object. DeleteBackupPolicyRequest deletes a + backup policy. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseDeleteBackupPolicy._get_http_options() + + request, metadata = self._interceptor.pre_delete_backup_policy(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseDeleteBackupPolicy._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseDeleteBackupPolicy._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteBackupPolicy", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "DeleteBackupPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._DeleteBackupPolicy._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_backup_policy(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_backup_policy_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.delete_backup_policy", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "DeleteBackupPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteBackupVault(_BaseNetAppRestTransport._BaseDeleteBackupVault, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.DeleteBackupVault") + + @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: backup_vault.DeleteBackupVaultRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the delete backup vault method over HTTP. + + Args: + request (~.backup_vault.DeleteBackupVaultRequest): + The request object. DeleteBackupVaultRequest deletes a + backupVault. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseDeleteBackupVault._get_http_options() + + request, metadata = self._interceptor.pre_delete_backup_vault(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseDeleteBackupVault._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseDeleteBackupVault._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteBackupVault", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "DeleteBackupVault", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._DeleteBackupVault._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_backup_vault(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_backup_vault_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.delete_backup_vault", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "DeleteBackupVault", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteKmsConfig(_BaseNetAppRestTransport._BaseDeleteKmsConfig, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.DeleteKmsConfig") + + @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: kms.DeleteKmsConfigRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the delete kms config method over HTTP. + + Args: + request (~.kms.DeleteKmsConfigRequest): + The request object. DeleteKmsConfigRequest deletes a KMS + Config. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseDeleteKmsConfig._get_http_options() + + request, metadata = self._interceptor.pre_delete_kms_config(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseDeleteKmsConfig._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseDeleteKmsConfig._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteKmsConfig", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "DeleteKmsConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._DeleteKmsConfig._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_kms_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_kms_config_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.delete_kms_config", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "DeleteKmsConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteQuotaRule(_BaseNetAppRestTransport._BaseDeleteQuotaRule, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.DeleteQuotaRule") + + @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: quota_rule.DeleteQuotaRuleRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the delete quota rule method over HTTP. + + Args: + request (~.quota_rule.DeleteQuotaRuleRequest): + The request object. DeleteQuotaRuleRequest for deleting a + single quota 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseDeleteQuotaRule._get_http_options() + + request, metadata = self._interceptor.pre_delete_quota_rule(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseDeleteQuotaRule._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseDeleteQuotaRule._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteQuotaRule", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "DeleteQuotaRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._DeleteQuotaRule._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_quota_rule(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_quota_rule_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.delete_quota_rule", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "DeleteQuotaRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteReplication(_BaseNetAppRestTransport._BaseDeleteReplication, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.DeleteReplication") + + @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: replication.DeleteReplicationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the delete replication method over HTTP. + + Args: + request (~.replication.DeleteReplicationRequest): + The request object. DeleteReplicationRequest deletes a + replication. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseDeleteReplication._get_http_options() + + request, metadata = self._interceptor.pre_delete_replication(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseDeleteReplication._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseDeleteReplication._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteReplication", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "DeleteReplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._DeleteReplication._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_replication(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_replication_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.delete_replication", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "DeleteReplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteSnapshot(_BaseNetAppRestTransport._BaseDeleteSnapshot, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.DeleteSnapshot") + + @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: snapshot.DeleteSnapshotRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the delete snapshot method over HTTP. + + Args: + request (~.snapshot.DeleteSnapshotRequest): + The request object. DeleteSnapshotRequest deletes a + snapshot. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseDeleteSnapshot._get_http_options() + + request, metadata = self._interceptor.pre_delete_snapshot(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseDeleteSnapshot._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseDeleteSnapshot._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteSnapshot", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "DeleteSnapshot", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._DeleteSnapshot._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_snapshot(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_snapshot_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.delete_snapshot", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "DeleteSnapshot", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteStoragePool(_BaseNetAppRestTransport._BaseDeleteStoragePool, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.DeleteStoragePool") + + @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: storage_pool.DeleteStoragePoolRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the delete storage pool method over HTTP. + + Args: + request (~.storage_pool.DeleteStoragePoolRequest): + The request object. DeleteStoragePoolRequest deletes a + Storage Pool. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseDeleteStoragePool._get_http_options() + + request, metadata = self._interceptor.pre_delete_storage_pool(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseDeleteStoragePool._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseDeleteStoragePool._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteStoragePool", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "DeleteStoragePool", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._DeleteStoragePool._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_storage_pool(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_storage_pool_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.delete_storage_pool", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "DeleteStoragePool", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteVolume(_BaseNetAppRestTransport._BaseDeleteVolume, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.DeleteVolume") + + @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: volume.DeleteVolumeRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the delete volume method over HTTP. + + Args: + request (~.volume.DeleteVolumeRequest): + The request object. Message for deleting a Volume + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseDeleteVolume._get_http_options() + + request, metadata = self._interceptor.pre_delete_volume(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseDeleteVolume._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseDeleteVolume._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteVolume", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "DeleteVolume", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._DeleteVolume._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_volume(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_volume_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.delete_volume", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "DeleteVolume", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _EncryptVolumes(_BaseNetAppRestTransport._BaseEncryptVolumes, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.EncryptVolumes") + + @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: kms.EncryptVolumesRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the encrypt volumes method over HTTP. + + Args: + request (~.kms.EncryptVolumesRequest): + The request object. EncryptVolumesRequest specifies the + KMS config to encrypt existing volumes. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseEncryptVolumes._get_http_options() + + request, metadata = self._interceptor.pre_encrypt_volumes(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseEncryptVolumes._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseEncryptVolumes._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseEncryptVolumes._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.EncryptVolumes", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "EncryptVolumes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._EncryptVolumes._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_encrypt_volumes(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_encrypt_volumes_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.encrypt_volumes", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "EncryptVolumes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _EstablishPeering(_BaseNetAppRestTransport._BaseEstablishPeering, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.EstablishPeering") + + @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: replication.EstablishPeeringRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the establish peering method over HTTP. + + Args: + request (~.replication.EstablishPeeringRequest): + The request object. EstablishPeeringRequest establishes + cluster and svm peerings between the + source and the destination replications. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseEstablishPeering._get_http_options() + + request, metadata = self._interceptor.pre_establish_peering(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseEstablishPeering._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseEstablishPeering._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseEstablishPeering._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.EstablishPeering", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "EstablishPeering", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._EstablishPeering._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_establish_peering(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_establish_peering_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.establish_peering", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "EstablishPeering", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetActiveDirectory(_BaseNetAppRestTransport._BaseGetActiveDirectory, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.GetActiveDirectory") + + @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: active_directory.GetActiveDirectoryRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> active_directory.ActiveDirectory: + r"""Call the get active directory method over HTTP. + + Args: + request (~.active_directory.GetActiveDirectoryRequest): + The request object. GetActiveDirectory for getting a + single active directory. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.active_directory.ActiveDirectory: + ActiveDirectory is the public + representation of the active directory + config. + + """ + + http_options = _BaseNetAppRestTransport._BaseGetActiveDirectory._get_http_options() + + request, metadata = self._interceptor.pre_get_active_directory(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseGetActiveDirectory._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseGetActiveDirectory._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.GetActiveDirectory", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetActiveDirectory", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._GetActiveDirectory._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 = active_directory.ActiveDirectory() + pb_resp = active_directory.ActiveDirectory.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_active_directory(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_active_directory_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = active_directory.ActiveDirectory.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.get_active_directory", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetActiveDirectory", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetBackup(_BaseNetAppRestTransport._BaseGetBackup, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.GetBackup") + + @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: backup.GetBackupRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> backup.Backup: + r"""Call the get backup method over HTTP. + + Args: + request (~.backup.GetBackupRequest): + The request object. GetBackupRequest gets the state of a + backup. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.backup.Backup: + A NetApp Backup. + """ + + http_options = _BaseNetAppRestTransport._BaseGetBackup._get_http_options() + + request, metadata = self._interceptor.pre_get_backup(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseGetBackup._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseGetBackup._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.GetBackup", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._GetBackup._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 = backup.Backup() + pb_resp = backup.Backup.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_backup(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_backup_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = backup.Backup.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.get_backup", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetBackupPolicy(_BaseNetAppRestTransport._BaseGetBackupPolicy, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.GetBackupPolicy") + + @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: backup_policy.GetBackupPolicyRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> backup_policy.BackupPolicy: + r"""Call the get backup policy method over HTTP. + + Args: + request (~.backup_policy.GetBackupPolicyRequest): + The request object. GetBackupPolicyRequest gets the state + of a backupPolicy. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.backup_policy.BackupPolicy: + Backup Policy. + """ + + http_options = _BaseNetAppRestTransport._BaseGetBackupPolicy._get_http_options() + + request, metadata = self._interceptor.pre_get_backup_policy(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseGetBackupPolicy._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseGetBackupPolicy._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.GetBackupPolicy", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetBackupPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._GetBackupPolicy._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 = backup_policy.BackupPolicy() + pb_resp = backup_policy.BackupPolicy.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_backup_policy(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_backup_policy_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = backup_policy.BackupPolicy.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.get_backup_policy", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetBackupPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetBackupVault(_BaseNetAppRestTransport._BaseGetBackupVault, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.GetBackupVault") + + @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: backup_vault.GetBackupVaultRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> backup_vault.BackupVault: + r"""Call the get backup vault method over HTTP. + + Args: + request (~.backup_vault.GetBackupVaultRequest): + The request object. GetBackupVaultRequest gets the state + of a backupVault. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.backup_vault.BackupVault: + A NetApp BackupVault. + """ + + http_options = _BaseNetAppRestTransport._BaseGetBackupVault._get_http_options() + + request, metadata = self._interceptor.pre_get_backup_vault(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseGetBackupVault._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseGetBackupVault._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.GetBackupVault", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetBackupVault", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._GetBackupVault._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 = backup_vault.BackupVault() + pb_resp = backup_vault.BackupVault.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_backup_vault(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_backup_vault_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = backup_vault.BackupVault.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.get_backup_vault", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetBackupVault", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetKmsConfig(_BaseNetAppRestTransport._BaseGetKmsConfig, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.GetKmsConfig") + + @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: kms.GetKmsConfigRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> kms.KmsConfig: + r"""Call the get kms config method over HTTP. + + Args: + request (~.kms.GetKmsConfigRequest): + The request object. GetKmsConfigRequest gets a KMS + Config. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.kms.KmsConfig: + KmsConfig is the customer managed + encryption key(CMEK) configuration. + + """ + + http_options = _BaseNetAppRestTransport._BaseGetKmsConfig._get_http_options() + + request, metadata = self._interceptor.pre_get_kms_config(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseGetKmsConfig._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseGetKmsConfig._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.GetKmsConfig", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetKmsConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._GetKmsConfig._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 = kms.KmsConfig() + pb_resp = kms.KmsConfig.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_kms_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_kms_config_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = kms.KmsConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.get_kms_config", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetKmsConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetQuotaRule(_BaseNetAppRestTransport._BaseGetQuotaRule, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.GetQuotaRule") + + @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: quota_rule.GetQuotaRuleRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> quota_rule.QuotaRule: + r"""Call the get quota rule method over HTTP. + + Args: + request (~.quota_rule.GetQuotaRuleRequest): + The request object. GetQuotaRuleRequest for getting a + quota 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.quota_rule.QuotaRule: + QuotaRule specifies the maximum disk + space a user or group can use within a + volume. They can be used for creating + default and individual quota rules. + + """ + + http_options = _BaseNetAppRestTransport._BaseGetQuotaRule._get_http_options() + + request, metadata = self._interceptor.pre_get_quota_rule(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseGetQuotaRule._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseGetQuotaRule._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.GetQuotaRule", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetQuotaRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._GetQuotaRule._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 = quota_rule.QuotaRule() + pb_resp = quota_rule.QuotaRule.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_quota_rule(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_quota_rule_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = quota_rule.QuotaRule.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.get_quota_rule", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetQuotaRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetReplication(_BaseNetAppRestTransport._BaseGetReplication, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.GetReplication") + + @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: replication.GetReplicationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> replication.Replication: + r"""Call the get replication method over HTTP. + + Args: + request (~.replication.GetReplicationRequest): + The request object. GetReplicationRequest gets the state + of a replication. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.replication.Replication: + Replication is a nested resource + under Volume, that describes a + cross-region replication relationship + between 2 volumes in different regions. + + """ + + http_options = _BaseNetAppRestTransport._BaseGetReplication._get_http_options() + + request, metadata = self._interceptor.pre_get_replication(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseGetReplication._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseGetReplication._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.GetReplication", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetReplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._GetReplication._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 = replication.Replication() + pb_resp = replication.Replication.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_replication(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_replication_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = replication.Replication.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.get_replication", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetReplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetSnapshot(_BaseNetAppRestTransport._BaseGetSnapshot, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.GetSnapshot") + + @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: snapshot.GetSnapshotRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> snapshot.Snapshot: + r"""Call the get snapshot method over HTTP. + + Args: + request (~.snapshot.GetSnapshotRequest): + The request object. GetSnapshotRequest gets the state of + a snapshot. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.snapshot.Snapshot: + Snapshot is a point-in-time version + of a Volume's content. + + """ + + http_options = _BaseNetAppRestTransport._BaseGetSnapshot._get_http_options() + + request, metadata = self._interceptor.pre_get_snapshot(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseGetSnapshot._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseGetSnapshot._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.GetSnapshot", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetSnapshot", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._GetSnapshot._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 = snapshot.Snapshot() + pb_resp = snapshot.Snapshot.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_snapshot(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_snapshot_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = snapshot.Snapshot.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.get_snapshot", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetSnapshot", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetStoragePool(_BaseNetAppRestTransport._BaseGetStoragePool, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.GetStoragePool") + + @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: storage_pool.GetStoragePoolRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> storage_pool.StoragePool: + r"""Call the get storage pool method over HTTP. + + Args: + request (~.storage_pool.GetStoragePoolRequest): + The request object. GetStoragePoolRequest gets a Storage + Pool. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.storage_pool.StoragePool: + StoragePool is a container for + volumes with a service level and + capacity. Volumes can be created in a + pool of sufficient available capacity. + StoragePool capacity is what you are + billed for. + + """ + + http_options = _BaseNetAppRestTransport._BaseGetStoragePool._get_http_options() + + request, metadata = self._interceptor.pre_get_storage_pool(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseGetStoragePool._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseGetStoragePool._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.GetStoragePool", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetStoragePool", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._GetStoragePool._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 = storage_pool.StoragePool() + pb_resp = storage_pool.StoragePool.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_storage_pool(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_storage_pool_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = storage_pool.StoragePool.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.get_storage_pool", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetStoragePool", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetVolume(_BaseNetAppRestTransport._BaseGetVolume, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.GetVolume") + + @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: volume.GetVolumeRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> volume.Volume: + r"""Call the get volume method over HTTP. + + Args: + request (~.volume.GetVolumeRequest): + The request object. Message for getting a Volume + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.volume.Volume: + Volume provides a filesystem that you + can mount. + + """ + + http_options = _BaseNetAppRestTransport._BaseGetVolume._get_http_options() + + request, metadata = self._interceptor.pre_get_volume(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseGetVolume._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseGetVolume._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.GetVolume", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetVolume", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._GetVolume._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 = volume.Volume() + pb_resp = volume.Volume.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_volume(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_volume_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = volume.Volume.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.get_volume", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetVolume", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListActiveDirectories(_BaseNetAppRestTransport._BaseListActiveDirectories, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.ListActiveDirectories") + + @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: active_directory.ListActiveDirectoriesRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> active_directory.ListActiveDirectoriesResponse: + r"""Call the list active directories method over HTTP. + + Args: + request (~.active_directory.ListActiveDirectoriesRequest): + The request object. ListActiveDirectoriesRequest for + requesting multiple active directories. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.active_directory.ListActiveDirectoriesResponse: + ListActiveDirectoriesResponse + contains all the active directories + requested. + + """ + + http_options = _BaseNetAppRestTransport._BaseListActiveDirectories._get_http_options() + + request, metadata = self._interceptor.pre_list_active_directories(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseListActiveDirectories._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseListActiveDirectories._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.ListActiveDirectories", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListActiveDirectories", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._ListActiveDirectories._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 = active_directory.ListActiveDirectoriesResponse() + pb_resp = active_directory.ListActiveDirectoriesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_active_directories(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_active_directories_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = active_directory.ListActiveDirectoriesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.list_active_directories", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListActiveDirectories", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListBackupPolicies(_BaseNetAppRestTransport._BaseListBackupPolicies, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.ListBackupPolicies") + + @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: backup_policy.ListBackupPoliciesRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> backup_policy.ListBackupPoliciesResponse: + r"""Call the list backup policies method over HTTP. + + Args: + request (~.backup_policy.ListBackupPoliciesRequest): + The request object. ListBackupPoliciesRequest for + requesting multiple backup policies. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.backup_policy.ListBackupPoliciesResponse: + ListBackupPoliciesResponse contains + all the backup policies requested. + + """ + + http_options = _BaseNetAppRestTransport._BaseListBackupPolicies._get_http_options() + + request, metadata = self._interceptor.pre_list_backup_policies(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseListBackupPolicies._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseListBackupPolicies._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.ListBackupPolicies", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListBackupPolicies", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._ListBackupPolicies._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 = backup_policy.ListBackupPoliciesResponse() + pb_resp = backup_policy.ListBackupPoliciesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_backup_policies(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_backup_policies_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = backup_policy.ListBackupPoliciesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.list_backup_policies", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListBackupPolicies", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListBackups(_BaseNetAppRestTransport._BaseListBackups, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.ListBackups") + + @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: backup.ListBackupsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> backup.ListBackupsResponse: + r"""Call the list backups method over HTTP. + + Args: + request (~.backup.ListBackupsRequest): + The request object. ListBackupsRequest lists backups. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.backup.ListBackupsResponse: + ListBackupsResponse is the result of + ListBackupsRequest. + + """ + + http_options = _BaseNetAppRestTransport._BaseListBackups._get_http_options() + + request, metadata = self._interceptor.pre_list_backups(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseListBackups._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseListBackups._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.ListBackups", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListBackups", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._ListBackups._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 = backup.ListBackupsResponse() + pb_resp = backup.ListBackupsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_backups(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_backups_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = backup.ListBackupsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.list_backups", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListBackups", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListBackupVaults(_BaseNetAppRestTransport._BaseListBackupVaults, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.ListBackupVaults") + + @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: backup_vault.ListBackupVaultsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> backup_vault.ListBackupVaultsResponse: + r"""Call the list backup vaults method over HTTP. + + Args: + request (~.backup_vault.ListBackupVaultsRequest): + The request object. ListBackupVaultsRequest lists + backupVaults. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.backup_vault.ListBackupVaultsResponse: + ListBackupVaultsResponse is the + result of ListBackupVaultsRequest. + + """ + + http_options = _BaseNetAppRestTransport._BaseListBackupVaults._get_http_options() + + request, metadata = self._interceptor.pre_list_backup_vaults(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseListBackupVaults._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseListBackupVaults._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.ListBackupVaults", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListBackupVaults", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._ListBackupVaults._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 = backup_vault.ListBackupVaultsResponse() + pb_resp = backup_vault.ListBackupVaultsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_backup_vaults(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_backup_vaults_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = backup_vault.ListBackupVaultsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.list_backup_vaults", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListBackupVaults", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListKmsConfigs(_BaseNetAppRestTransport._BaseListKmsConfigs, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.ListKmsConfigs") + + @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: kms.ListKmsConfigsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> kms.ListKmsConfigsResponse: + r"""Call the list kms configs method over HTTP. + + Args: + request (~.kms.ListKmsConfigsRequest): + The request object. ListKmsConfigsRequest lists KMS + Configs. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.kms.ListKmsConfigsResponse: + ListKmsConfigsResponse is the + response to a ListKmsConfigsRequest. + + """ + + http_options = _BaseNetAppRestTransport._BaseListKmsConfigs._get_http_options() + + request, metadata = self._interceptor.pre_list_kms_configs(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseListKmsConfigs._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseListKmsConfigs._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.ListKmsConfigs", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListKmsConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._ListKmsConfigs._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 = kms.ListKmsConfigsResponse() + pb_resp = kms.ListKmsConfigsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_kms_configs(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_kms_configs_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = kms.ListKmsConfigsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.list_kms_configs", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListKmsConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListQuotaRules(_BaseNetAppRestTransport._BaseListQuotaRules, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.ListQuotaRules") + + @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: quota_rule.ListQuotaRulesRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> quota_rule.ListQuotaRulesResponse: + r"""Call the list quota rules method over HTTP. + + Args: + request (~.quota_rule.ListQuotaRulesRequest): + The request object. ListQuotaRulesRequest for listing + quota 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.quota_rule.ListQuotaRulesResponse: + ListQuotaRulesResponse is the + response to a ListQuotaRulesRequest. + + """ + + http_options = _BaseNetAppRestTransport._BaseListQuotaRules._get_http_options() + + request, metadata = self._interceptor.pre_list_quota_rules(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseListQuotaRules._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseListQuotaRules._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.ListQuotaRules", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListQuotaRules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._ListQuotaRules._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 = quota_rule.ListQuotaRulesResponse() + pb_resp = quota_rule.ListQuotaRulesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_quota_rules(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_quota_rules_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = quota_rule.ListQuotaRulesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.list_quota_rules", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListQuotaRules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListReplications(_BaseNetAppRestTransport._BaseListReplications, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.ListReplications") + + @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: replication.ListReplicationsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> replication.ListReplicationsResponse: + r"""Call the list replications method over HTTP. + + Args: + request (~.replication.ListReplicationsRequest): + The request object. ListReplications lists replications. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.replication.ListReplicationsResponse: + ListReplicationsResponse is the + result of ListReplicationsRequest. + + """ + + http_options = _BaseNetAppRestTransport._BaseListReplications._get_http_options() + + request, metadata = self._interceptor.pre_list_replications(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseListReplications._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseListReplications._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.ListReplications", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListReplications", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._ListReplications._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 = replication.ListReplicationsResponse() + pb_resp = replication.ListReplicationsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_replications(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_replications_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = replication.ListReplicationsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.list_replications", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListReplications", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListSnapshots(_BaseNetAppRestTransport._BaseListSnapshots, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.ListSnapshots") + + @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: snapshot.ListSnapshotsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> snapshot.ListSnapshotsResponse: + r"""Call the list snapshots method over HTTP. + + Args: + request (~.snapshot.ListSnapshotsRequest): + The request object. ListSnapshotsRequest lists snapshots. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.snapshot.ListSnapshotsResponse: + ListSnapshotsResponse is the result + of ListSnapshotsRequest. + + """ + + http_options = _BaseNetAppRestTransport._BaseListSnapshots._get_http_options() + + request, metadata = self._interceptor.pre_list_snapshots(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseListSnapshots._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseListSnapshots._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.ListSnapshots", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListSnapshots", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._ListSnapshots._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 = snapshot.ListSnapshotsResponse() + pb_resp = snapshot.ListSnapshotsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_snapshots(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_snapshots_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = snapshot.ListSnapshotsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.list_snapshots", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListSnapshots", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListStoragePools(_BaseNetAppRestTransport._BaseListStoragePools, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.ListStoragePools") + + @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: storage_pool.ListStoragePoolsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> storage_pool.ListStoragePoolsResponse: + r"""Call the list storage pools method over HTTP. + + Args: + request (~.storage_pool.ListStoragePoolsRequest): + The request object. ListStoragePoolsRequest lists Storage + Pools. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.storage_pool.ListStoragePoolsResponse: + ListStoragePoolsResponse is the + response to a ListStoragePoolsRequest. + + """ + + http_options = _BaseNetAppRestTransport._BaseListStoragePools._get_http_options() + + request, metadata = self._interceptor.pre_list_storage_pools(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseListStoragePools._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseListStoragePools._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.ListStoragePools", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListStoragePools", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._ListStoragePools._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 = storage_pool.ListStoragePoolsResponse() + pb_resp = storage_pool.ListStoragePoolsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_storage_pools(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_storage_pools_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = storage_pool.ListStoragePoolsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.list_storage_pools", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListStoragePools", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListVolumes(_BaseNetAppRestTransport._BaseListVolumes, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.ListVolumes") + + @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: volume.ListVolumesRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> volume.ListVolumesResponse: + r"""Call the list volumes method over HTTP. + + Args: + request (~.volume.ListVolumesRequest): + The request object. Message for requesting list of + Volumes + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.volume.ListVolumesResponse: + Message for response to listing + Volumes + + """ + + http_options = _BaseNetAppRestTransport._BaseListVolumes._get_http_options() + + request, metadata = self._interceptor.pre_list_volumes(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseListVolumes._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseListVolumes._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.ListVolumes", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListVolumes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._ListVolumes._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 = volume.ListVolumesResponse() + pb_resp = volume.ListVolumesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_volumes(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_volumes_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = volume.ListVolumesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.list_volumes", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListVolumes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ResumeReplication(_BaseNetAppRestTransport._BaseResumeReplication, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.ResumeReplication") + + @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: replication.ResumeReplicationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the resume replication method over HTTP. + + Args: + request (~.replication.ResumeReplicationRequest): + The request object. ResumeReplicationRequest resumes a + stopped replication. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseResumeReplication._get_http_options() + + request, metadata = self._interceptor.pre_resume_replication(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseResumeReplication._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseResumeReplication._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseResumeReplication._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.ResumeReplication", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ResumeReplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._ResumeReplication._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_resume_replication(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_resume_replication_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.resume_replication", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ResumeReplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ReverseReplicationDirection(_BaseNetAppRestTransport._BaseReverseReplicationDirection, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.ReverseReplicationDirection") + + @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: replication.ReverseReplicationDirectionRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the reverse replication + direction method over HTTP. + + Args: + request (~.replication.ReverseReplicationDirectionRequest): + The request object. ReverseReplicationDirectionRequest + reverses direction of replication. + Source becomes destination and + destination becomes source. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseReverseReplicationDirection._get_http_options() + + request, metadata = self._interceptor.pre_reverse_replication_direction(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseReverseReplicationDirection._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseReverseReplicationDirection._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseReverseReplicationDirection._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.ReverseReplicationDirection", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ReverseReplicationDirection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._ReverseReplicationDirection._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_reverse_replication_direction(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_reverse_replication_direction_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.reverse_replication_direction", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ReverseReplicationDirection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _RevertVolume(_BaseNetAppRestTransport._BaseRevertVolume, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.RevertVolume") + + @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: volume.RevertVolumeRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the revert volume method over HTTP. + + Args: + request (~.volume.RevertVolumeRequest): + The request object. RevertVolumeRequest reverts the given + volume to the specified snapshot. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseRevertVolume._get_http_options() + + request, metadata = self._interceptor.pre_revert_volume(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseRevertVolume._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseRevertVolume._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseRevertVolume._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.RevertVolume", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "RevertVolume", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._RevertVolume._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_revert_volume(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_revert_volume_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.revert_volume", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "RevertVolume", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _StopReplication(_BaseNetAppRestTransport._BaseStopReplication, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.StopReplication") + + @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: replication.StopReplicationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the stop replication method over HTTP. + + Args: + request (~.replication.StopReplicationRequest): + The request object. StopReplicationRequest stops a + replication until resumed. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseStopReplication._get_http_options() + + request, metadata = self._interceptor.pre_stop_replication(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseStopReplication._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseStopReplication._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseStopReplication._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.StopReplication", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "StopReplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._StopReplication._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_stop_replication(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_stop_replication_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.stop_replication", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "StopReplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _SwitchActiveReplicaZone(_BaseNetAppRestTransport._BaseSwitchActiveReplicaZone, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.SwitchActiveReplicaZone") + + @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: storage_pool.SwitchActiveReplicaZoneRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the switch active replica + zone method over HTTP. + + Args: + request (~.storage_pool.SwitchActiveReplicaZoneRequest): + The request object. SwitchActiveReplicaZoneRequest switch + the active/replica zone for a regional + storagePool. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseSwitchActiveReplicaZone._get_http_options() + + request, metadata = self._interceptor.pre_switch_active_replica_zone(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseSwitchActiveReplicaZone._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseSwitchActiveReplicaZone._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseSwitchActiveReplicaZone._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.SwitchActiveReplicaZone", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "SwitchActiveReplicaZone", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._SwitchActiveReplicaZone._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_switch_active_replica_zone(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_switch_active_replica_zone_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.switch_active_replica_zone", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "SwitchActiveReplicaZone", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _SyncReplication(_BaseNetAppRestTransport._BaseSyncReplication, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.SyncReplication") + + @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: replication.SyncReplicationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the sync replication method over HTTP. + + Args: + request (~.replication.SyncReplicationRequest): + The request object. SyncReplicationRequest syncs the + replication from source to destination. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseSyncReplication._get_http_options() + + request, metadata = self._interceptor.pre_sync_replication(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseSyncReplication._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseSyncReplication._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseSyncReplication._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.SyncReplication", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "SyncReplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._SyncReplication._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_sync_replication(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_sync_replication_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.sync_replication", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "SyncReplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _UpdateActiveDirectory(_BaseNetAppRestTransport._BaseUpdateActiveDirectory, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.UpdateActiveDirectory") + + @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: gcn_active_directory.UpdateActiveDirectoryRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the update active directory method over HTTP. + + Args: + request (~.gcn_active_directory.UpdateActiveDirectoryRequest): + The request object. UpdateActiveDirectoryRequest for + updating an active directory. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseUpdateActiveDirectory._get_http_options() + + request, metadata = self._interceptor.pre_update_active_directory(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseUpdateActiveDirectory._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseUpdateActiveDirectory._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseUpdateActiveDirectory._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.UpdateActiveDirectory", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "UpdateActiveDirectory", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._UpdateActiveDirectory._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_update_active_directory(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_active_directory_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.update_active_directory", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "UpdateActiveDirectory", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _UpdateBackup(_BaseNetAppRestTransport._BaseUpdateBackup, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.UpdateBackup") + + @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: gcn_backup.UpdateBackupRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the update backup method over HTTP. + + Args: + request (~.gcn_backup.UpdateBackupRequest): + The request object. UpdateBackupRequest updates + description and/or labels for a backup. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseUpdateBackup._get_http_options() + + request, metadata = self._interceptor.pre_update_backup(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseUpdateBackup._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseUpdateBackup._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseUpdateBackup._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.UpdateBackup", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "UpdateBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._UpdateBackup._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_update_backup(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_backup_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.update_backup", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "UpdateBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _UpdateBackupPolicy(_BaseNetAppRestTransport._BaseUpdateBackupPolicy, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.UpdateBackupPolicy") + + @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: gcn_backup_policy.UpdateBackupPolicyRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the update backup policy method over HTTP. + + Args: + request (~.gcn_backup_policy.UpdateBackupPolicyRequest): + The request object. UpdateBackupPolicyRequest for + updating a backup policy. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseUpdateBackupPolicy._get_http_options() + + request, metadata = self._interceptor.pre_update_backup_policy(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseUpdateBackupPolicy._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseUpdateBackupPolicy._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseUpdateBackupPolicy._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.UpdateBackupPolicy", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "UpdateBackupPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._UpdateBackupPolicy._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_update_backup_policy(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_backup_policy_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.update_backup_policy", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "UpdateBackupPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _UpdateBackupVault(_BaseNetAppRestTransport._BaseUpdateBackupVault, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.UpdateBackupVault") + + @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: gcn_backup_vault.UpdateBackupVaultRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the update backup vault method over HTTP. + + Args: + request (~.gcn_backup_vault.UpdateBackupVaultRequest): + The request object. UpdateBackupVaultRequest updates + description and/or labels for a + backupVault. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseUpdateBackupVault._get_http_options() + + request, metadata = self._interceptor.pre_update_backup_vault(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseUpdateBackupVault._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseUpdateBackupVault._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseUpdateBackupVault._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.UpdateBackupVault", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "UpdateBackupVault", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._UpdateBackupVault._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_update_backup_vault(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_backup_vault_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.update_backup_vault", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "UpdateBackupVault", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _UpdateKmsConfig(_BaseNetAppRestTransport._BaseUpdateKmsConfig, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.UpdateKmsConfig") + + @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: kms.UpdateKmsConfigRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the update kms config method over HTTP. + + Args: + request (~.kms.UpdateKmsConfigRequest): + The request object. UpdateKmsConfigRequest updates a KMS + Config. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseUpdateKmsConfig._get_http_options() + + request, metadata = self._interceptor.pre_update_kms_config(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseUpdateKmsConfig._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseUpdateKmsConfig._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseUpdateKmsConfig._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.UpdateKmsConfig", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "UpdateKmsConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._UpdateKmsConfig._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_update_kms_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_kms_config_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.update_kms_config", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "UpdateKmsConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _UpdateQuotaRule(_BaseNetAppRestTransport._BaseUpdateQuotaRule, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.UpdateQuotaRule") + + @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: gcn_quota_rule.UpdateQuotaRuleRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the update quota rule method over HTTP. + + Args: + request (~.gcn_quota_rule.UpdateQuotaRuleRequest): + The request object. UpdateQuotaRuleRequest for updating a + quota 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseUpdateQuotaRule._get_http_options() + + request, metadata = self._interceptor.pre_update_quota_rule(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseUpdateQuotaRule._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseUpdateQuotaRule._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseUpdateQuotaRule._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.UpdateQuotaRule", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "UpdateQuotaRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._UpdateQuotaRule._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_update_quota_rule(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_quota_rule_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.update_quota_rule", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "UpdateQuotaRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _UpdateReplication(_BaseNetAppRestTransport._BaseUpdateReplication, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.UpdateReplication") + + @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: gcn_replication.UpdateReplicationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the update replication method over HTTP. + + Args: + request (~.gcn_replication.UpdateReplicationRequest): + The request object. UpdateReplicationRequest updates + description and/or labels for a + replication. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseUpdateReplication._get_http_options() + + request, metadata = self._interceptor.pre_update_replication(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseUpdateReplication._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseUpdateReplication._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseUpdateReplication._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.UpdateReplication", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "UpdateReplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._UpdateReplication._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_update_replication(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_replication_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.update_replication", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "UpdateReplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _UpdateSnapshot(_BaseNetAppRestTransport._BaseUpdateSnapshot, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.UpdateSnapshot") + + @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: gcn_snapshot.UpdateSnapshotRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the update snapshot method over HTTP. + + Args: + request (~.gcn_snapshot.UpdateSnapshotRequest): + The request object. UpdateSnapshotRequest updates + description and/or labels for a + snapshot. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseUpdateSnapshot._get_http_options() + + request, metadata = self._interceptor.pre_update_snapshot(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseUpdateSnapshot._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseUpdateSnapshot._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseUpdateSnapshot._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.UpdateSnapshot", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "UpdateSnapshot", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._UpdateSnapshot._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_update_snapshot(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_snapshot_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.update_snapshot", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "UpdateSnapshot", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _UpdateStoragePool(_BaseNetAppRestTransport._BaseUpdateStoragePool, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.UpdateStoragePool") + + @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: gcn_storage_pool.UpdateStoragePoolRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the update storage pool method over HTTP. + + Args: + request (~.gcn_storage_pool.UpdateStoragePoolRequest): + The request object. UpdateStoragePoolRequest updates a + Storage Pool. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseUpdateStoragePool._get_http_options() + + request, metadata = self._interceptor.pre_update_storage_pool(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseUpdateStoragePool._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseUpdateStoragePool._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseUpdateStoragePool._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.UpdateStoragePool", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "UpdateStoragePool", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._UpdateStoragePool._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_update_storage_pool(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_storage_pool_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.update_storage_pool", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "UpdateStoragePool", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _UpdateVolume(_BaseNetAppRestTransport._BaseUpdateVolume, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.UpdateVolume") + + @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: gcn_volume.UpdateVolumeRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the update volume method over HTTP. + + Args: + request (~.gcn_volume.UpdateVolumeRequest): + The request object. Message for updating a Volume + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseUpdateVolume._get_http_options() + + request, metadata = self._interceptor.pre_update_volume(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseUpdateVolume._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseUpdateVolume._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseUpdateVolume._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.UpdateVolume", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "UpdateVolume", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._UpdateVolume._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_update_volume(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_volume_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.update_volume", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "UpdateVolume", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ValidateDirectoryService(_BaseNetAppRestTransport._BaseValidateDirectoryService, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.ValidateDirectoryService") + + @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: storage_pool.ValidateDirectoryServiceRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the validate directory + service method over HTTP. + + Args: + request (~.storage_pool.ValidateDirectoryServiceRequest): + The request object. ValidateDirectoryServiceRequest + validates the directory service policy + attached to the storage pool. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseNetAppRestTransport._BaseValidateDirectoryService._get_http_options() + + request, metadata = self._interceptor.pre_validate_directory_service(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseValidateDirectoryService._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseValidateDirectoryService._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseValidateDirectoryService._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.ValidateDirectoryService", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ValidateDirectoryService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._ValidateDirectoryService._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_validate_directory_service(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_validate_directory_service_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.validate_directory_service", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ValidateDirectoryService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _VerifyKmsConfig(_BaseNetAppRestTransport._BaseVerifyKmsConfig, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.VerifyKmsConfig") + + @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: kms.VerifyKmsConfigRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> kms.VerifyKmsConfigResponse: + r"""Call the verify kms config method over HTTP. + + Args: + request (~.kms.VerifyKmsConfigRequest): + The request object. VerifyKmsConfigRequest specifies the + KMS config to be validated. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.kms.VerifyKmsConfigResponse: + VerifyKmsConfigResponse contains the + information if the config is correctly + and error message. + + """ + + http_options = _BaseNetAppRestTransport._BaseVerifyKmsConfig._get_http_options() + + request, metadata = self._interceptor.pre_verify_kms_config(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseVerifyKmsConfig._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseVerifyKmsConfig._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseVerifyKmsConfig._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.VerifyKmsConfig", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "VerifyKmsConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._VerifyKmsConfig._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 = kms.VerifyKmsConfigResponse() + pb_resp = kms.VerifyKmsConfigResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_verify_kms_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_verify_kms_config_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = kms.VerifyKmsConfigResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppClient.verify_kms_config", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "VerifyKmsConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + @property + def create_active_directory(self) -> Callable[ + [gcn_active_directory.CreateActiveDirectoryRequest], + 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._CreateActiveDirectory(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_backup(self) -> Callable[ + [gcn_backup.CreateBackupRequest], + 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._CreateBackup(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_backup_policy(self) -> Callable[ + [gcn_backup_policy.CreateBackupPolicyRequest], + 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._CreateBackupPolicy(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_backup_vault(self) -> Callable[ + [gcn_backup_vault.CreateBackupVaultRequest], + 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._CreateBackupVault(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_kms_config(self) -> Callable[ + [kms.CreateKmsConfigRequest], + 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._CreateKmsConfig(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_quota_rule(self) -> Callable[ + [gcn_quota_rule.CreateQuotaRuleRequest], + 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._CreateQuotaRule(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_replication(self) -> Callable[ + [gcn_replication.CreateReplicationRequest], + 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._CreateReplication(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_snapshot(self) -> Callable[ + [gcn_snapshot.CreateSnapshotRequest], + 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._CreateSnapshot(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_storage_pool(self) -> Callable[ + [gcn_storage_pool.CreateStoragePoolRequest], + 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._CreateStoragePool(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_volume(self) -> Callable[ + [gcn_volume.CreateVolumeRequest], + 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._CreateVolume(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_active_directory(self) -> Callable[ + [active_directory.DeleteActiveDirectoryRequest], + 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._DeleteActiveDirectory(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_backup(self) -> Callable[ + [backup.DeleteBackupRequest], + 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._DeleteBackup(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_backup_policy(self) -> Callable[ + [backup_policy.DeleteBackupPolicyRequest], + 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._DeleteBackupPolicy(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_backup_vault(self) -> Callable[ + [backup_vault.DeleteBackupVaultRequest], + 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._DeleteBackupVault(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_kms_config(self) -> Callable[ + [kms.DeleteKmsConfigRequest], + 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._DeleteKmsConfig(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_quota_rule(self) -> Callable[ + [quota_rule.DeleteQuotaRuleRequest], + 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._DeleteQuotaRule(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_replication(self) -> Callable[ + [replication.DeleteReplicationRequest], + 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._DeleteReplication(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_snapshot(self) -> Callable[ + [snapshot.DeleteSnapshotRequest], + 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._DeleteSnapshot(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_storage_pool(self) -> Callable[ + [storage_pool.DeleteStoragePoolRequest], + 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._DeleteStoragePool(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_volume(self) -> Callable[ + [volume.DeleteVolumeRequest], + 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._DeleteVolume(self._session, self._host, self._interceptor) # type: ignore + + @property + def encrypt_volumes(self) -> Callable[ + [kms.EncryptVolumesRequest], + 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._EncryptVolumes(self._session, self._host, self._interceptor) # type: ignore + + @property + def establish_peering(self) -> Callable[ + [replication.EstablishPeeringRequest], + 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._EstablishPeering(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_active_directory(self) -> Callable[ + [active_directory.GetActiveDirectoryRequest], + active_directory.ActiveDirectory]: + # 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._GetActiveDirectory(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_backup(self) -> Callable[ + [backup.GetBackupRequest], + backup.Backup]: + # 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._GetBackup(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_backup_policy(self) -> Callable[ + [backup_policy.GetBackupPolicyRequest], + backup_policy.BackupPolicy]: + # 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._GetBackupPolicy(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_backup_vault(self) -> Callable[ + [backup_vault.GetBackupVaultRequest], + backup_vault.BackupVault]: + # 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._GetBackupVault(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_kms_config(self) -> Callable[ + [kms.GetKmsConfigRequest], + kms.KmsConfig]: + # 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._GetKmsConfig(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_quota_rule(self) -> Callable[ + [quota_rule.GetQuotaRuleRequest], + quota_rule.QuotaRule]: + # 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._GetQuotaRule(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_replication(self) -> Callable[ + [replication.GetReplicationRequest], + replication.Replication]: + # 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._GetReplication(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_snapshot(self) -> Callable[ + [snapshot.GetSnapshotRequest], + snapshot.Snapshot]: + # 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._GetSnapshot(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_storage_pool(self) -> Callable[ + [storage_pool.GetStoragePoolRequest], + storage_pool.StoragePool]: + # 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._GetStoragePool(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_volume(self) -> Callable[ + [volume.GetVolumeRequest], + volume.Volume]: + # 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._GetVolume(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_active_directories(self) -> Callable[ + [active_directory.ListActiveDirectoriesRequest], + active_directory.ListActiveDirectoriesResponse]: + # 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._ListActiveDirectories(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_backup_policies(self) -> Callable[ + [backup_policy.ListBackupPoliciesRequest], + backup_policy.ListBackupPoliciesResponse]: + # 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._ListBackupPolicies(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_backups(self) -> Callable[ + [backup.ListBackupsRequest], + backup.ListBackupsResponse]: + # 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._ListBackups(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_backup_vaults(self) -> Callable[ + [backup_vault.ListBackupVaultsRequest], + backup_vault.ListBackupVaultsResponse]: + # 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._ListBackupVaults(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_kms_configs(self) -> Callable[ + [kms.ListKmsConfigsRequest], + kms.ListKmsConfigsResponse]: + # 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._ListKmsConfigs(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_quota_rules(self) -> Callable[ + [quota_rule.ListQuotaRulesRequest], + quota_rule.ListQuotaRulesResponse]: + # 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._ListQuotaRules(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_replications(self) -> Callable[ + [replication.ListReplicationsRequest], + replication.ListReplicationsResponse]: + # 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._ListReplications(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_snapshots(self) -> Callable[ + [snapshot.ListSnapshotsRequest], + snapshot.ListSnapshotsResponse]: + # 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._ListSnapshots(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_storage_pools(self) -> Callable[ + [storage_pool.ListStoragePoolsRequest], + storage_pool.ListStoragePoolsResponse]: + # 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._ListStoragePools(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_volumes(self) -> Callable[ + [volume.ListVolumesRequest], + volume.ListVolumesResponse]: + # 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._ListVolumes(self._session, self._host, self._interceptor) # type: ignore + + @property + def resume_replication(self) -> Callable[ + [replication.ResumeReplicationRequest], + 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._ResumeReplication(self._session, self._host, self._interceptor) # type: ignore + + @property + def reverse_replication_direction(self) -> Callable[ + [replication.ReverseReplicationDirectionRequest], + 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._ReverseReplicationDirection(self._session, self._host, self._interceptor) # type: ignore + + @property + def revert_volume(self) -> Callable[ + [volume.RevertVolumeRequest], + 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._RevertVolume(self._session, self._host, self._interceptor) # type: ignore + + @property + def stop_replication(self) -> Callable[ + [replication.StopReplicationRequest], + 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._StopReplication(self._session, self._host, self._interceptor) # type: ignore + + @property + def switch_active_replica_zone(self) -> Callable[ + [storage_pool.SwitchActiveReplicaZoneRequest], + 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._SwitchActiveReplicaZone(self._session, self._host, self._interceptor) # type: ignore + + @property + def sync_replication(self) -> Callable[ + [replication.SyncReplicationRequest], + 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._SyncReplication(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_active_directory(self) -> Callable[ + [gcn_active_directory.UpdateActiveDirectoryRequest], + 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._UpdateActiveDirectory(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_backup(self) -> Callable[ + [gcn_backup.UpdateBackupRequest], + 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._UpdateBackup(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_backup_policy(self) -> Callable[ + [gcn_backup_policy.UpdateBackupPolicyRequest], + 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._UpdateBackupPolicy(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_backup_vault(self) -> Callable[ + [gcn_backup_vault.UpdateBackupVaultRequest], + 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._UpdateBackupVault(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_kms_config(self) -> Callable[ + [kms.UpdateKmsConfigRequest], + 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._UpdateKmsConfig(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_quota_rule(self) -> Callable[ + [gcn_quota_rule.UpdateQuotaRuleRequest], + 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._UpdateQuotaRule(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_replication(self) -> Callable[ + [gcn_replication.UpdateReplicationRequest], + 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._UpdateReplication(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_snapshot(self) -> Callable[ + [gcn_snapshot.UpdateSnapshotRequest], + 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._UpdateSnapshot(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_storage_pool(self) -> Callable[ + [gcn_storage_pool.UpdateStoragePoolRequest], + 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._UpdateStoragePool(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_volume(self) -> Callable[ + [gcn_volume.UpdateVolumeRequest], + 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._UpdateVolume(self._session, self._host, self._interceptor) # type: ignore + + @property + def validate_directory_service(self) -> Callable[ + [storage_pool.ValidateDirectoryServiceRequest], + 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._ValidateDirectoryService(self._session, self._host, self._interceptor) # type: ignore + + @property + def verify_kms_config(self) -> Callable[ + [kms.VerifyKmsConfigRequest], + kms.VerifyKmsConfigResponse]: + # 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._VerifyKmsConfig(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(_BaseNetAppRestTransport._BaseGetLocation, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.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, Union[str, bytes]]]=(), + ) -> 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + locations_pb2.Location: Response from GetLocation method. + """ + + http_options = _BaseNetAppRestTransport._BaseGetLocation._get_http_options() + + request, metadata = self._interceptor.pre_get_location(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseGetLocation._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseGetLocation._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.GetLocation", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._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) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppAsyncClient.GetLocation", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) + return resp + + @property + def list_locations(self): + return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore + + class _ListLocations(_BaseNetAppRestTransport._BaseListLocations, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.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, Union[str, bytes]]]=(), + ) -> 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + locations_pb2.ListLocationsResponse: Response from ListLocations method. + """ + + http_options = _BaseNetAppRestTransport._BaseListLocations._get_http_options() + + request, metadata = self._interceptor.pre_list_locations(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseListLocations._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseListLocations._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.ListLocations", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._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) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppAsyncClient.ListLocations", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) + return resp + + @property + def cancel_operation(self): + return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore + + class _CancelOperation(_BaseNetAppRestTransport._BaseCancelOperation, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.CancelOperation") + + @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: operations_pb2.CancelOperationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> None: + + r"""Call the cancel operation method over HTTP. + + Args: + request (operations_pb2.CancelOperationRequest): + The request object for CancelOperation 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + + http_options = _BaseNetAppRestTransport._BaseCancelOperation._get_http_options() + + request, metadata = self._interceptor.pre_cancel_operation(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseCancelOperation._get_transcoded_request(http_options, request) + + body = _BaseNetAppRestTransport._BaseCancelOperation._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseCancelOperation._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.CancelOperation", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._CancelOperation._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 self._interceptor.post_cancel_operation(None) + + @property + def delete_operation(self): + return self._DeleteOperation(self._session, self._host, self._interceptor) # type: ignore + + class _DeleteOperation(_BaseNetAppRestTransport._BaseDeleteOperation, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.DeleteOperation") + + @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.DeleteOperationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> None: + + r"""Call the delete operation method over HTTP. + + Args: + request (operations_pb2.DeleteOperationRequest): + The request object for DeleteOperation 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + + http_options = _BaseNetAppRestTransport._BaseDeleteOperation._get_http_options() + + request, metadata = self._interceptor.pre_delete_operation(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseDeleteOperation._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseDeleteOperation._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteOperation", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._DeleteOperation._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 self._interceptor.post_delete_operation(None) + + @property + def get_operation(self): + return self._GetOperation(self._session, self._host, self._interceptor) # type: ignore + + class _GetOperation(_BaseNetAppRestTransport._BaseGetOperation, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.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, Union[str, bytes]]]=(), + ) -> 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + operations_pb2.Operation: Response from GetOperation method. + """ + + http_options = _BaseNetAppRestTransport._BaseGetOperation._get_http_options() + + request, metadata = self._interceptor.pre_get_operation(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseGetOperation._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseGetOperation._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.GetOperation", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._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) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppAsyncClient.GetOperation", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) + return resp + + @property + def list_operations(self): + return self._ListOperations(self._session, self._host, self._interceptor) # type: ignore + + class _ListOperations(_BaseNetAppRestTransport._BaseListOperations, NetAppRestStub): + def __hash__(self): + return hash("NetAppRestTransport.ListOperations") + + @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.ListOperationsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.ListOperationsResponse: + + r"""Call the list operations method over HTTP. + + Args: + request (operations_pb2.ListOperationsRequest): + The request object for ListOperations 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + operations_pb2.ListOperationsResponse: Response from ListOperations method. + """ + + http_options = _BaseNetAppRestTransport._BaseListOperations._get_http_options() + + request, metadata = self._interceptor.pre_list_operations(request, metadata) + transcoded_request = _BaseNetAppRestTransport._BaseListOperations._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseNetAppRestTransport._BaseListOperations._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.netapp_v1.NetAppClient.ListOperations", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetAppRestTransport._ListOperations._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.ListOperationsResponse() + resp = json_format.Parse(content, resp) + resp = self._interceptor.post_list_operations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.netapp_v1.NetAppAsyncClient.ListOperations", + extra = { + "serviceName": "google.cloud.netapp.v1.NetApp", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) + return resp + + @property + def kind(self) -> str: + return "rest" + + def close(self): + self._session.close() + + +__all__=( + 'NetAppRestTransport', +) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/rest_base.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/rest_base.py new file mode 100644 index 000000000000..925fcfe32010 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/rest_base.py @@ -0,0 +1,2786 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 NetAppTransport, DEFAULT_CLIENT_INFO + +import re +from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union + + +from google.cloud.netapp_v1.types import active_directory +from google.cloud.netapp_v1.types import active_directory as gcn_active_directory +from google.cloud.netapp_v1.types import backup +from google.cloud.netapp_v1.types import backup as gcn_backup +from google.cloud.netapp_v1.types import backup_policy +from google.cloud.netapp_v1.types import backup_policy as gcn_backup_policy +from google.cloud.netapp_v1.types import backup_vault +from google.cloud.netapp_v1.types import backup_vault as gcn_backup_vault +from google.cloud.netapp_v1.types import kms +from google.cloud.netapp_v1.types import quota_rule +from google.cloud.netapp_v1.types import quota_rule as gcn_quota_rule +from google.cloud.netapp_v1.types import replication +from google.cloud.netapp_v1.types import replication as gcn_replication +from google.cloud.netapp_v1.types import snapshot +from google.cloud.netapp_v1.types import snapshot as gcn_snapshot +from google.cloud.netapp_v1.types import storage_pool +from google.cloud.netapp_v1.types import storage_pool as gcn_storage_pool +from google.cloud.netapp_v1.types import volume +from google.cloud.netapp_v1.types import volume as gcn_volume +from google.longrunning import operations_pb2 # type: ignore + + +class _BaseNetAppRestTransport(NetAppTransport): + """Base REST backend transport for NetApp. + + 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 = 'netapp.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: 'netapp.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 _BaseCreateActiveDirectory: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "activeDirectoryId" : "", } + + @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/*}/activeDirectories', + 'body': 'active_directory', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gcn_active_directory.CreateActiveDirectoryRequest.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(_BaseNetAppRestTransport._BaseCreateActiveDirectory._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCreateBackup: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "backupId" : "", } + + @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/*/backupVaults/*}/backups', + 'body': 'backup', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gcn_backup.CreateBackupRequest.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(_BaseNetAppRestTransport._BaseCreateBackup._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCreateBackupPolicy: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "backupPolicyId" : "", } + + @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/*}/backupPolicies', + 'body': 'backup_policy', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gcn_backup_policy.CreateBackupPolicyRequest.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(_BaseNetAppRestTransport._BaseCreateBackupPolicy._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCreateBackupVault: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "backupVaultId" : "", } + + @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/*}/backupVaults', + 'body': 'backup_vault', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gcn_backup_vault.CreateBackupVaultRequest.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(_BaseNetAppRestTransport._BaseCreateBackupVault._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCreateKmsConfig: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "kmsConfigId" : "", } + + @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/*}/kmsConfigs', + 'body': 'kms_config', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = kms.CreateKmsConfigRequest.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(_BaseNetAppRestTransport._BaseCreateKmsConfig._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCreateQuotaRule: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "quotaRuleId" : "", } + + @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/*/volumes/*}/quotaRules', + 'body': 'quota_rule', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gcn_quota_rule.CreateQuotaRuleRequest.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(_BaseNetAppRestTransport._BaseCreateQuotaRule._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCreateReplication: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "replicationId" : "", } + + @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/*/volumes/*}/replications', + 'body': 'replication', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gcn_replication.CreateReplicationRequest.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(_BaseNetAppRestTransport._BaseCreateReplication._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCreateSnapshot: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "snapshotId" : "", } + + @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/*/volumes/*}/snapshots', + 'body': 'snapshot', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gcn_snapshot.CreateSnapshotRequest.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(_BaseNetAppRestTransport._BaseCreateSnapshot._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCreateStoragePool: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "storagePoolId" : "", } + + @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/*}/storagePools', + 'body': 'storage_pool', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gcn_storage_pool.CreateStoragePoolRequest.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(_BaseNetAppRestTransport._BaseCreateStoragePool._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCreateVolume: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "volumeId" : "", } + + @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/*}/volumes', + 'body': 'volume', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gcn_volume.CreateVolumeRequest.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(_BaseNetAppRestTransport._BaseCreateVolume._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteActiveDirectory: + 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/*/activeDirectories/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = active_directory.DeleteActiveDirectoryRequest.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(_BaseNetAppRestTransport._BaseDeleteActiveDirectory._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteBackup: + 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/*/backupVaults/*/backups/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = backup.DeleteBackupRequest.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(_BaseNetAppRestTransport._BaseDeleteBackup._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteBackupPolicy: + 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/*/backupPolicies/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = backup_policy.DeleteBackupPolicyRequest.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(_BaseNetAppRestTransport._BaseDeleteBackupPolicy._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteBackupVault: + 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/*/backupVaults/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = backup_vault.DeleteBackupVaultRequest.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(_BaseNetAppRestTransport._BaseDeleteBackupVault._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteKmsConfig: + 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/*/kmsConfigs/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = kms.DeleteKmsConfigRequest.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(_BaseNetAppRestTransport._BaseDeleteKmsConfig._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteQuotaRule: + 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/*/volumes/*/quotaRules/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = quota_rule.DeleteQuotaRuleRequest.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(_BaseNetAppRestTransport._BaseDeleteQuotaRule._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteReplication: + 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/*/volumes/*/replications/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = replication.DeleteReplicationRequest.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(_BaseNetAppRestTransport._BaseDeleteReplication._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteSnapshot: + 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/*/volumes/*/snapshots/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = snapshot.DeleteSnapshotRequest.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(_BaseNetAppRestTransport._BaseDeleteSnapshot._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteStoragePool: + 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/*/storagePools/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = storage_pool.DeleteStoragePoolRequest.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(_BaseNetAppRestTransport._BaseDeleteStoragePool._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteVolume: + 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/*/volumes/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = volume.DeleteVolumeRequest.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(_BaseNetAppRestTransport._BaseDeleteVolume._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseEncryptVolumes: + 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/{name=projects/*/locations/*/kmsConfigs/*}:encrypt', + 'body': '*', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = kms.EncryptVolumesRequest.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(_BaseNetAppRestTransport._BaseEncryptVolumes._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseEstablishPeering: + 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/{name=projects/*/locations/*/volumes/*/replications/*}:establishPeering', + 'body': '*', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = replication.EstablishPeeringRequest.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(_BaseNetAppRestTransport._BaseEstablishPeering._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetActiveDirectory: + 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/*/activeDirectories/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = active_directory.GetActiveDirectoryRequest.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(_BaseNetAppRestTransport._BaseGetActiveDirectory._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetBackup: + 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/*/backupVaults/*/backups/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = backup.GetBackupRequest.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(_BaseNetAppRestTransport._BaseGetBackup._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetBackupPolicy: + 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/*/backupPolicies/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = backup_policy.GetBackupPolicyRequest.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(_BaseNetAppRestTransport._BaseGetBackupPolicy._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetBackupVault: + 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/*/backupVaults/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = backup_vault.GetBackupVaultRequest.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(_BaseNetAppRestTransport._BaseGetBackupVault._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetKmsConfig: + 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/*/kmsConfigs/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = kms.GetKmsConfigRequest.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(_BaseNetAppRestTransport._BaseGetKmsConfig._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetQuotaRule: + 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/*/volumes/*/quotaRules/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = quota_rule.GetQuotaRuleRequest.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(_BaseNetAppRestTransport._BaseGetQuotaRule._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetReplication: + 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/*/volumes/*/replications/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = replication.GetReplicationRequest.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(_BaseNetAppRestTransport._BaseGetReplication._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetSnapshot: + 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/*/volumes/*/snapshots/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = snapshot.GetSnapshotRequest.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(_BaseNetAppRestTransport._BaseGetSnapshot._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetStoragePool: + 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/*/storagePools/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = storage_pool.GetStoragePoolRequest.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(_BaseNetAppRestTransport._BaseGetStoragePool._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetVolume: + 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/*/volumes/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = volume.GetVolumeRequest.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(_BaseNetAppRestTransport._BaseGetVolume._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListActiveDirectories: + 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/*}/activeDirectories', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = active_directory.ListActiveDirectoriesRequest.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(_BaseNetAppRestTransport._BaseListActiveDirectories._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListBackupPolicies: + 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/*}/backupPolicies', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = backup_policy.ListBackupPoliciesRequest.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(_BaseNetAppRestTransport._BaseListBackupPolicies._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListBackups: + 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/*/backupVaults/*}/backups', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = backup.ListBackupsRequest.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(_BaseNetAppRestTransport._BaseListBackups._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListBackupVaults: + 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/*}/backupVaults', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = backup_vault.ListBackupVaultsRequest.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(_BaseNetAppRestTransport._BaseListBackupVaults._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListKmsConfigs: + 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/*}/kmsConfigs', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = kms.ListKmsConfigsRequest.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(_BaseNetAppRestTransport._BaseListKmsConfigs._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListQuotaRules: + 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/*/volumes/*}/quotaRules', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = quota_rule.ListQuotaRulesRequest.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(_BaseNetAppRestTransport._BaseListQuotaRules._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListReplications: + 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/*/volumes/*}/replications', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = replication.ListReplicationsRequest.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(_BaseNetAppRestTransport._BaseListReplications._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListSnapshots: + 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/*/volumes/*}/snapshots', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = snapshot.ListSnapshotsRequest.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(_BaseNetAppRestTransport._BaseListSnapshots._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListStoragePools: + 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/*}/storagePools', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = storage_pool.ListStoragePoolsRequest.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(_BaseNetAppRestTransport._BaseListStoragePools._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListVolumes: + 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/*}/volumes', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = volume.ListVolumesRequest.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(_BaseNetAppRestTransport._BaseListVolumes._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseResumeReplication: + 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/{name=projects/*/locations/*/volumes/*/replications/*}:resume', + 'body': '*', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = replication.ResumeReplicationRequest.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(_BaseNetAppRestTransport._BaseResumeReplication._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseReverseReplicationDirection: + 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/{name=projects/*/locations/*/volumes/*/replications/*}:reverseDirection', + 'body': '*', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = replication.ReverseReplicationDirectionRequest.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(_BaseNetAppRestTransport._BaseReverseReplicationDirection._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseRevertVolume: + 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/{name=projects/*/locations/*/volumes/*}:revert', + 'body': '*', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = volume.RevertVolumeRequest.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(_BaseNetAppRestTransport._BaseRevertVolume._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseStopReplication: + 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/{name=projects/*/locations/*/volumes/*/replications/*}:stop', + 'body': '*', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = replication.StopReplicationRequest.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(_BaseNetAppRestTransport._BaseStopReplication._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseSwitchActiveReplicaZone: + 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/{name=projects/*/locations/*/storagePools/*}:switch', + 'body': '*', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = storage_pool.SwitchActiveReplicaZoneRequest.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(_BaseNetAppRestTransport._BaseSwitchActiveReplicaZone._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseSyncReplication: + 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/{name=projects/*/locations/*/volumes/*/replications/*}:sync', + 'body': '*', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = replication.SyncReplicationRequest.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(_BaseNetAppRestTransport._BaseSyncReplication._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseUpdateActiveDirectory: + 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/{active_directory.name=projects/*/locations/*/activeDirectories/*}', + 'body': 'active_directory', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gcn_active_directory.UpdateActiveDirectoryRequest.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(_BaseNetAppRestTransport._BaseUpdateActiveDirectory._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseUpdateBackup: + 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/{backup.name=projects/*/locations/*/backupVaults/*/backups/*}', + 'body': 'backup', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gcn_backup.UpdateBackupRequest.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(_BaseNetAppRestTransport._BaseUpdateBackup._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseUpdateBackupPolicy: + 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/{backup_policy.name=projects/*/locations/*/backupPolicies/*}', + 'body': 'backup_policy', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gcn_backup_policy.UpdateBackupPolicyRequest.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(_BaseNetAppRestTransport._BaseUpdateBackupPolicy._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseUpdateBackupVault: + 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/{backup_vault.name=projects/*/locations/*/backupVaults/*}', + 'body': 'backup_vault', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gcn_backup_vault.UpdateBackupVaultRequest.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(_BaseNetAppRestTransport._BaseUpdateBackupVault._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseUpdateKmsConfig: + 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/{kms_config.name=projects/*/locations/*/kmsConfigs/*}', + 'body': 'kms_config', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = kms.UpdateKmsConfigRequest.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(_BaseNetAppRestTransport._BaseUpdateKmsConfig._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseUpdateQuotaRule: + 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/{quota_rule.name=projects/*/locations/*/volumes/*/quotaRules/*}', + 'body': 'quota_rule', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gcn_quota_rule.UpdateQuotaRuleRequest.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(_BaseNetAppRestTransport._BaseUpdateQuotaRule._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseUpdateReplication: + 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/{replication.name=projects/*/locations/*/volumes/*/replications/*}', + 'body': 'replication', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gcn_replication.UpdateReplicationRequest.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(_BaseNetAppRestTransport._BaseUpdateReplication._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseUpdateSnapshot: + 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/{snapshot.name=projects/*/locations/*/volumes/*/snapshots/*}', + 'body': 'snapshot', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gcn_snapshot.UpdateSnapshotRequest.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(_BaseNetAppRestTransport._BaseUpdateSnapshot._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseUpdateStoragePool: + 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/{storage_pool.name=projects/*/locations/*/storagePools/*}', + 'body': 'storage_pool', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gcn_storage_pool.UpdateStoragePoolRequest.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(_BaseNetAppRestTransport._BaseUpdateStoragePool._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseUpdateVolume: + 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/{volume.name=projects/*/locations/*/volumes/*}', + 'body': 'volume', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gcn_volume.UpdateVolumeRequest.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(_BaseNetAppRestTransport._BaseUpdateVolume._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseValidateDirectoryService: + 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/{name=projects/*/locations/*/storagePools/*}:validateDirectoryService', + 'body': '*', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = storage_pool.ValidateDirectoryServiceRequest.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(_BaseNetAppRestTransport._BaseValidateDirectoryService._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseVerifyKmsConfig: + 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/{name=projects/*/locations/*/kmsConfigs/*}:verify', + 'body': '*', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = kms.VerifyKmsConfigRequest.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(_BaseNetAppRestTransport._BaseVerifyKmsConfig._get_unset_required_fields(query_params)) + + 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 _BaseCancelOperation: + 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/{name=projects/*/locations/*/operations/*}:cancel', + 'body': '*', + }, + ] + 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_request_body_json(transcoded_request): + body = json.dumps(transcoded_request['body']) + return body + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json.dumps(transcoded_request['query_params'])) + return query_params + + class _BaseDeleteOperation: + 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/*/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 + + 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 + + class _BaseListOperations: + 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__=( + '_BaseNetAppRestTransport', +) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/__init__.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/__init__.py new file mode 100644 index 000000000000..38df5cf58049 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/__init__.py @@ -0,0 +1,256 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 .active_directory import ( + ActiveDirectory, + CreateActiveDirectoryRequest, + DeleteActiveDirectoryRequest, + GetActiveDirectoryRequest, + ListActiveDirectoriesRequest, + ListActiveDirectoriesResponse, + UpdateActiveDirectoryRequest, +) +from .backup import ( + Backup, + CreateBackupRequest, + DeleteBackupRequest, + GetBackupRequest, + ListBackupsRequest, + ListBackupsResponse, + UpdateBackupRequest, +) +from .backup_policy import ( + BackupPolicy, + CreateBackupPolicyRequest, + DeleteBackupPolicyRequest, + GetBackupPolicyRequest, + ListBackupPoliciesRequest, + ListBackupPoliciesResponse, + UpdateBackupPolicyRequest, +) +from .backup_vault import ( + BackupVault, + CreateBackupVaultRequest, + DeleteBackupVaultRequest, + GetBackupVaultRequest, + ListBackupVaultsRequest, + ListBackupVaultsResponse, + UpdateBackupVaultRequest, +) +from .cloud_netapp_service import ( + OperationMetadata, +) +from .common import ( + LocationMetadata, + DirectoryServiceType, + EncryptionType, + FlexPerformance, + ServiceLevel, +) +from .kms import ( + CreateKmsConfigRequest, + DeleteKmsConfigRequest, + EncryptVolumesRequest, + GetKmsConfigRequest, + KmsConfig, + ListKmsConfigsRequest, + ListKmsConfigsResponse, + UpdateKmsConfigRequest, + VerifyKmsConfigRequest, + VerifyKmsConfigResponse, +) +from .quota_rule import ( + CreateQuotaRuleRequest, + DeleteQuotaRuleRequest, + GetQuotaRuleRequest, + ListQuotaRulesRequest, + ListQuotaRulesResponse, + QuotaRule, + UpdateQuotaRuleRequest, +) +from .replication import ( + CreateReplicationRequest, + DeleteReplicationRequest, + DestinationVolumeParameters, + EstablishPeeringRequest, + GetReplicationRequest, + HybridPeeringDetails, + ListReplicationsRequest, + ListReplicationsResponse, + Replication, + ResumeReplicationRequest, + ReverseReplicationDirectionRequest, + StopReplicationRequest, + SyncReplicationRequest, + TransferStats, + UpdateReplicationRequest, +) +from .snapshot import ( + CreateSnapshotRequest, + DeleteSnapshotRequest, + GetSnapshotRequest, + ListSnapshotsRequest, + ListSnapshotsResponse, + Snapshot, + UpdateSnapshotRequest, +) +from .storage_pool import ( + CreateStoragePoolRequest, + DeleteStoragePoolRequest, + GetStoragePoolRequest, + ListStoragePoolsRequest, + ListStoragePoolsResponse, + StoragePool, + SwitchActiveReplicaZoneRequest, + UpdateStoragePoolRequest, + ValidateDirectoryServiceRequest, +) +from .volume import ( + BackupConfig, + CreateVolumeRequest, + DailySchedule, + DeleteVolumeRequest, + ExportPolicy, + GetVolumeRequest, + HourlySchedule, + HybridReplicationParameters, + ListVolumesRequest, + ListVolumesResponse, + MonthlySchedule, + MountOption, + RestoreParameters, + RevertVolumeRequest, + SimpleExportPolicyRule, + SnapshotPolicy, + TieringPolicy, + UpdateVolumeRequest, + Volume, + WeeklySchedule, + AccessType, + Protocols, + RestrictedAction, + SecurityStyle, + SMBSettings, +) + +__all__ = ( + 'ActiveDirectory', + 'CreateActiveDirectoryRequest', + 'DeleteActiveDirectoryRequest', + 'GetActiveDirectoryRequest', + 'ListActiveDirectoriesRequest', + 'ListActiveDirectoriesResponse', + 'UpdateActiveDirectoryRequest', + 'Backup', + 'CreateBackupRequest', + 'DeleteBackupRequest', + 'GetBackupRequest', + 'ListBackupsRequest', + 'ListBackupsResponse', + 'UpdateBackupRequest', + 'BackupPolicy', + 'CreateBackupPolicyRequest', + 'DeleteBackupPolicyRequest', + 'GetBackupPolicyRequest', + 'ListBackupPoliciesRequest', + 'ListBackupPoliciesResponse', + 'UpdateBackupPolicyRequest', + 'BackupVault', + 'CreateBackupVaultRequest', + 'DeleteBackupVaultRequest', + 'GetBackupVaultRequest', + 'ListBackupVaultsRequest', + 'ListBackupVaultsResponse', + 'UpdateBackupVaultRequest', + 'OperationMetadata', + 'LocationMetadata', + 'DirectoryServiceType', + 'EncryptionType', + 'FlexPerformance', + 'ServiceLevel', + 'CreateKmsConfigRequest', + 'DeleteKmsConfigRequest', + 'EncryptVolumesRequest', + 'GetKmsConfigRequest', + 'KmsConfig', + 'ListKmsConfigsRequest', + 'ListKmsConfigsResponse', + 'UpdateKmsConfigRequest', + 'VerifyKmsConfigRequest', + 'VerifyKmsConfigResponse', + 'CreateQuotaRuleRequest', + 'DeleteQuotaRuleRequest', + 'GetQuotaRuleRequest', + 'ListQuotaRulesRequest', + 'ListQuotaRulesResponse', + 'QuotaRule', + 'UpdateQuotaRuleRequest', + 'CreateReplicationRequest', + 'DeleteReplicationRequest', + 'DestinationVolumeParameters', + 'EstablishPeeringRequest', + 'GetReplicationRequest', + 'HybridPeeringDetails', + 'ListReplicationsRequest', + 'ListReplicationsResponse', + 'Replication', + 'ResumeReplicationRequest', + 'ReverseReplicationDirectionRequest', + 'StopReplicationRequest', + 'SyncReplicationRequest', + 'TransferStats', + 'UpdateReplicationRequest', + 'CreateSnapshotRequest', + 'DeleteSnapshotRequest', + 'GetSnapshotRequest', + 'ListSnapshotsRequest', + 'ListSnapshotsResponse', + 'Snapshot', + 'UpdateSnapshotRequest', + 'CreateStoragePoolRequest', + 'DeleteStoragePoolRequest', + 'GetStoragePoolRequest', + 'ListStoragePoolsRequest', + 'ListStoragePoolsResponse', + 'StoragePool', + 'SwitchActiveReplicaZoneRequest', + 'UpdateStoragePoolRequest', + 'ValidateDirectoryServiceRequest', + 'BackupConfig', + 'CreateVolumeRequest', + 'DailySchedule', + 'DeleteVolumeRequest', + 'ExportPolicy', + 'GetVolumeRequest', + 'HourlySchedule', + 'HybridReplicationParameters', + 'ListVolumesRequest', + 'ListVolumesResponse', + 'MonthlySchedule', + 'MountOption', + 'RestoreParameters', + 'RevertVolumeRequest', + 'SimpleExportPolicyRule', + 'SnapshotPolicy', + 'TieringPolicy', + 'UpdateVolumeRequest', + 'Volume', + 'WeeklySchedule', + 'AccessType', + 'Protocols', + 'RestrictedAction', + 'SecurityStyle', + 'SMBSettings', +) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/active_directory.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/active_directory.py new file mode 100644 index 000000000000..fe4a6ca27b2b --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/active_directory.py @@ -0,0 +1,401 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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.cloud.netapp.v1', + manifest={ + 'ListActiveDirectoriesRequest', + 'ListActiveDirectoriesResponse', + 'GetActiveDirectoryRequest', + 'CreateActiveDirectoryRequest', + 'UpdateActiveDirectoryRequest', + 'DeleteActiveDirectoryRequest', + 'ActiveDirectory', + }, +) + + +class ListActiveDirectoriesRequest(proto.Message): + r"""ListActiveDirectoriesRequest for requesting multiple active + directories. + + Attributes: + parent (str): + Required. Parent value for + ListActiveDirectoriesRequest + page_size (int): + Requested page size. Server may return fewer + items than requested. If unspecified, the server + will pick an appropriate default. + page_token (str): + A token identifying a page of results the + server should return. + filter (str): + Filtering results + order_by (str): + Hint for how to order the results + """ + + 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 ListActiveDirectoriesResponse(proto.Message): + r"""ListActiveDirectoriesResponse contains all the active + directories requested. + + Attributes: + active_directories (MutableSequence[google.cloud.netapp_v1.types.ActiveDirectory]): + The list of active directories. + next_page_token (str): + A token identifying a page of results the + server should return. + unreachable (MutableSequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + active_directories: MutableSequence['ActiveDirectory'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='ActiveDirectory', + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class GetActiveDirectoryRequest(proto.Message): + r"""GetActiveDirectory for getting a single active directory. + + Attributes: + name (str): + Required. Name of the active directory. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateActiveDirectoryRequest(proto.Message): + r"""CreateActiveDirectoryRequest for creating an active + directory. + + Attributes: + parent (str): + Required. Value for parent. + active_directory (google.cloud.netapp_v1.types.ActiveDirectory): + Required. Fields of the to be created active + directory. + active_directory_id (str): + Required. ID of the active directory to + create. Must be unique within the parent + resource. Must contain only letters, numbers and + hyphen, with the first character a letter , the + last a letter or a number, and a 63 character + maximum. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + active_directory: 'ActiveDirectory' = proto.Field( + proto.MESSAGE, + number=2, + message='ActiveDirectory', + ) + active_directory_id: str = proto.Field( + proto.STRING, + number=3, + ) + + +class UpdateActiveDirectoryRequest(proto.Message): + r"""UpdateActiveDirectoryRequest for updating an active + directory. + + Attributes: + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Field mask is used to specify the fields to be + overwritten in the Active Directory resource by the update. + The fields specified in the update_mask are relative to the + resource, not the full request. A field will be overwritten + if it is in the mask. If the user does not provide a mask + then all fields will be overwritten. + active_directory (google.cloud.netapp_v1.types.ActiveDirectory): + Required. The volume being updated + """ + + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=1, + message=field_mask_pb2.FieldMask, + ) + active_directory: 'ActiveDirectory' = proto.Field( + proto.MESSAGE, + number=2, + message='ActiveDirectory', + ) + + +class DeleteActiveDirectoryRequest(proto.Message): + r"""DeleteActiveDirectoryRequest for deleting a single active + directory. + + Attributes: + name (str): + Required. Name of the active directory. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ActiveDirectory(proto.Message): + r"""ActiveDirectory is the public representation of the active + directory config. + + Attributes: + name (str): + Identifier. The resource name of the active directory. + Format: + ``projects/{project_number}/locations/{location_id}/activeDirectories/{active_directory_id}``. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Create time of the active + directory. + state (google.cloud.netapp_v1.types.ActiveDirectory.State): + Output only. The state of the AD. + domain (str): + Required. Name of the Active Directory domain + site (str): + The Active Directory site the service will + limit Domain Controller discovery too. + dns (str): + Required. Comma separated list of DNS server + IP addresses for the Active Directory domain. + net_bios_prefix (str): + Required. NetBIOSPrefix is used as a prefix + for SMB server name. + organizational_unit (str): + The Organizational Unit (OU) within the + Windows Active Directory the user belongs to. + aes_encryption (bool): + If enabled, AES encryption will be enabled + for SMB communication. + username (str): + Required. Username of the Active Directory + domain administrator. + password (str): + Required. Password of the Active Directory + domain administrator. + backup_operators (MutableSequence[str]): + Optional. Users to be added to the Built-in + Backup Operator active directory group. + administrators (MutableSequence[str]): + Optional. Users to be added to the Built-in + Admininstrators group. + security_operators (MutableSequence[str]): + Optional. Domain users to be given the + SeSecurityPrivilege. + kdc_hostname (str): + Name of the active directory machine. This + optional parameter is used only while creating + kerberos volume + kdc_ip (str): + KDC server IP address for the active + directory machine. + nfs_users_with_ldap (bool): + If enabled, will allow access to local users + and LDAP users. If access is needed for only + LDAP users, it has to be disabled. + description (str): + Description of the active directory. + ldap_signing (bool): + Specifies whether or not the LDAP traffic + needs to be signed. + encrypt_dc_connections (bool): + If enabled, traffic between the SMB server to + Domain Controller (DC) will be encrypted. + labels (MutableMapping[str, str]): + Labels for the active directory. + state_details (str): + Output only. The state details of the Active + Directory. + """ + class State(proto.Enum): + r"""The Active Directory States + + Values: + STATE_UNSPECIFIED (0): + Unspecified Active Directory State + CREATING (1): + Active Directory State is Creating + READY (2): + Active Directory State is Ready + UPDATING (3): + Active Directory State is Updating + IN_USE (4): + Active Directory State is In use + DELETING (5): + Active Directory State is Deleting + ERROR (6): + Active Directory State is Error + DIAGNOSING (7): + Active Directory State is Diagnosing. + """ + STATE_UNSPECIFIED = 0 + CREATING = 1 + READY = 2 + UPDATING = 3 + IN_USE = 4 + DELETING = 5 + ERROR = 6 + DIAGNOSING = 7 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + state: State = proto.Field( + proto.ENUM, + number=3, + enum=State, + ) + domain: str = proto.Field( + proto.STRING, + number=4, + ) + site: str = proto.Field( + proto.STRING, + number=5, + ) + dns: str = proto.Field( + proto.STRING, + number=6, + ) + net_bios_prefix: str = proto.Field( + proto.STRING, + number=7, + ) + organizational_unit: str = proto.Field( + proto.STRING, + number=8, + ) + aes_encryption: bool = proto.Field( + proto.BOOL, + number=9, + ) + username: str = proto.Field( + proto.STRING, + number=10, + ) + password: str = proto.Field( + proto.STRING, + number=11, + ) + backup_operators: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=12, + ) + administrators: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=22, + ) + security_operators: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=13, + ) + kdc_hostname: str = proto.Field( + proto.STRING, + number=14, + ) + kdc_ip: str = proto.Field( + proto.STRING, + number=15, + ) + nfs_users_with_ldap: bool = proto.Field( + proto.BOOL, + number=16, + ) + description: str = proto.Field( + proto.STRING, + number=17, + ) + ldap_signing: bool = proto.Field( + proto.BOOL, + number=18, + ) + encrypt_dc_connections: bool = proto.Field( + proto.BOOL, + number=19, + ) + labels: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=20, + ) + state_details: str = proto.Field( + proto.STRING, + number=21, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup.py new file mode 100644 index 000000000000..a8af8d3427b8 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup.py @@ -0,0 +1,372 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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.cloud.netapp.v1', + manifest={ + 'Backup', + 'ListBackupsRequest', + 'ListBackupsResponse', + 'GetBackupRequest', + 'CreateBackupRequest', + 'DeleteBackupRequest', + 'UpdateBackupRequest', + }, +) + + +class Backup(proto.Message): + r"""A NetApp Backup. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + name (str): + Identifier. The resource name of the backup. Format: + ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id}``. + state (google.cloud.netapp_v1.types.Backup.State): + Output only. The backup state. + description (str): + A description of the backup with 2048 + characters or less. Requests with longer + descriptions will be rejected. + volume_usage_bytes (int): + Output only. Size of the file system when the + backup was created. When creating a new volume + from the backup, the volume capacity will have + to be at least as big. + backup_type (google.cloud.netapp_v1.types.Backup.Type): + Output only. Type of backup, manually created + or created by a backup policy. + source_volume (str): + Volume full name of this backup belongs to. Format: + ``projects/{projects_id}/locations/{location}/volumes/{volume_id}`` + source_snapshot (str): + If specified, backup will be created from the given + snapshot. If not specified, there will be a new snapshot + taken to initiate the backup creation. Format: + ``projects/{project_id}/locations/{location}/volumes/{volume_id}/snapshots/{snapshot_id}`` + + This field is a member of `oneof`_ ``_source_snapshot``. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time when the backup was + created. + labels (MutableMapping[str, str]): + Resource labels to represent user provided + metadata. + chain_storage_bytes (int): + Output only. Total size of all backups in a + chain in bytes = baseline backup size + + sum(incremental backup size) + satisfies_pzs (bool): + Output only. Reserved for future use + satisfies_pzi (bool): + Output only. Reserved for future use + """ + class State(proto.Enum): + r"""The Backup States + + Values: + STATE_UNSPECIFIED (0): + State not set. + CREATING (1): + Backup is being created. While in this state, + the snapshot for the backup point-in-time may + not have been created yet, and so the + point-in-time may not have been fixed. + UPLOADING (2): + Backup is being uploaded. While in this + state, none of the writes to the volume will be + included in the backup. + READY (3): + Backup is available for use. + DELETING (4): + Backup is being deleted. + ERROR (5): + Backup is not valid and cannot be used for + creating new volumes or restoring existing + volumes. + UPDATING (6): + Backup is being updated. + """ + STATE_UNSPECIFIED = 0 + CREATING = 1 + UPLOADING = 2 + READY = 3 + DELETING = 4 + ERROR = 5 + UPDATING = 6 + + class Type(proto.Enum): + r"""Backup types. + + Values: + TYPE_UNSPECIFIED (0): + Unspecified backup type. + MANUAL (1): + Manual backup type. + SCHEDULED (2): + Scheduled backup type. + """ + TYPE_UNSPECIFIED = 0 + MANUAL = 1 + SCHEDULED = 2 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + state: State = proto.Field( + proto.ENUM, + number=2, + enum=State, + ) + description: str = proto.Field( + proto.STRING, + number=3, + ) + volume_usage_bytes: int = proto.Field( + proto.INT64, + number=4, + ) + backup_type: Type = proto.Field( + proto.ENUM, + number=5, + enum=Type, + ) + source_volume: str = proto.Field( + proto.STRING, + number=6, + ) + source_snapshot: str = proto.Field( + proto.STRING, + number=7, + optional=True, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) + labels: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=9, + ) + chain_storage_bytes: int = proto.Field( + proto.INT64, + number=10, + ) + satisfies_pzs: bool = proto.Field( + proto.BOOL, + number=11, + ) + satisfies_pzi: bool = proto.Field( + proto.BOOL, + number=12, + ) + + +class ListBackupsRequest(proto.Message): + r"""ListBackupsRequest lists backups. + + Attributes: + parent (str): + Required. The backupVault for which to retrieve backup + information, in the format + ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}``. + To retrieve backup information for all locations, use "-" + for the ``{location}`` value. To retrieve backup information + for all backupVaults, use "-" for the ``{backup_vault_id}`` + value. To retrieve backup information for a volume, use "-" + for the ``{backup_vault_id}`` value and specify volume full + name with the filter. + page_size (int): + The maximum number of items to return. The + service may return fewer than this value. The + maximum value is 1000; values above 1000 will be + coerced to 1000. + page_token (str): + The next_page_token value to use if there are additional + results to retrieve for this list request. + order_by (str): + Sort results. Supported values are "name", + "name desc" or "" (unsorted). + filter (str): + The standard list filter. + If specified, backups will be returned based on + the attribute name that matches the filter + expression. If empty, then no backups are + filtered out. See https://google.aip.dev/160 + """ + + 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, + ) + filter: str = proto.Field( + proto.STRING, + number=5, + ) + + +class ListBackupsResponse(proto.Message): + r"""ListBackupsResponse is the result of ListBackupsRequest. + + Attributes: + backups (MutableSequence[google.cloud.netapp_v1.types.Backup]): + A list of backups in the project. + next_page_token (str): + The token you can use to retrieve the next + page of results. Not returned if there are no + more results in the list. + unreachable (MutableSequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + backups: MutableSequence['Backup'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='Backup', + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class GetBackupRequest(proto.Message): + r"""GetBackupRequest gets the state of a backup. + + Attributes: + name (str): + Required. The backup resource name, in the format + ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id}`` + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateBackupRequest(proto.Message): + r"""CreateBackupRequest creates a backup. + + Attributes: + parent (str): + Required. The NetApp backupVault to create the backups of, + in the format + ``projects/*/locations/*/backupVaults/{backup_vault_id}`` + backup_id (str): + Required. The ID to use for the backup. + The ID must be unique within the specified + backupVault. Must contain only letters, numbers + and hyphen, with the first character a letter, + the last a letter or a + number, and a 63 character maximum. + backup (google.cloud.netapp_v1.types.Backup): + Required. A backup resource + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + backup_id: str = proto.Field( + proto.STRING, + number=2, + ) + backup: 'Backup' = proto.Field( + proto.MESSAGE, + number=3, + message='Backup', + ) + + +class DeleteBackupRequest(proto.Message): + r"""DeleteBackupRequest deletes a backup. + + Attributes: + name (str): + Required. The backup resource name, in the format + ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id}`` + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateBackupRequest(proto.Message): + r"""UpdateBackupRequest updates description and/or labels for a + backup. + + Attributes: + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Field mask is used to specify the fields to be + overwritten in the Backup resource to be updated. The fields + specified in the update_mask are relative to the resource, + not the full request. A field will be overwritten if it is + in the mask. If the user does not provide a mask then all + fields will be overwritten. + backup (google.cloud.netapp_v1.types.Backup): + Required. The backup being updated + """ + + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=1, + message=field_mask_pb2.FieldMask, + ) + backup: 'Backup' = proto.Field( + proto.MESSAGE, + number=2, + message='Backup', + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup_policy.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup_policy.py new file mode 100644 index 000000000000..af1e884c9353 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup_policy.py @@ -0,0 +1,333 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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.cloud.netapp.v1', + manifest={ + 'BackupPolicy', + 'CreateBackupPolicyRequest', + 'GetBackupPolicyRequest', + 'ListBackupPoliciesRequest', + 'ListBackupPoliciesResponse', + 'UpdateBackupPolicyRequest', + 'DeleteBackupPolicyRequest', + }, +) + + +class BackupPolicy(proto.Message): + r"""Backup Policy. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + name (str): + Identifier. The resource name of the backup policy. Format: + ``projects/{project_id}/locations/{location}/backupPolicies/{backup_policy_id}``. + daily_backup_limit (int): + Number of daily backups to keep. Note that + the minimum daily backup limit is 2. + + This field is a member of `oneof`_ ``_daily_backup_limit``. + weekly_backup_limit (int): + Number of weekly backups to keep. Note that + the sum of daily, weekly and monthly backups + should be greater than 1. + + This field is a member of `oneof`_ ``_weekly_backup_limit``. + monthly_backup_limit (int): + Number of monthly backups to keep. Note that + the sum of daily, weekly and monthly backups + should be greater than 1. + + This field is a member of `oneof`_ ``_monthly_backup_limit``. + description (str): + Description of the backup policy. + + This field is a member of `oneof`_ ``_description``. + enabled (bool): + If enabled, make backups automatically + according to the schedules. This will be applied + to all volumes that have this policy attached + and enforced on volume level. If not specified, + default is true. + + This field is a member of `oneof`_ ``_enabled``. + assigned_volume_count (int): + Output only. The total number of volumes + assigned by this backup policy. + + This field is a member of `oneof`_ ``_assigned_volume_count``. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time when the backup policy + was created. + labels (MutableMapping[str, str]): + Resource labels to represent user provided + metadata. + state (google.cloud.netapp_v1.types.BackupPolicy.State): + Output only. The backup policy state. + """ + class State(proto.Enum): + r""" + + Values: + STATE_UNSPECIFIED (0): + State not set. + CREATING (1): + BackupPolicy is being created. + READY (2): + BackupPolicy is available for use. + DELETING (3): + BackupPolicy is being deleted. + ERROR (4): + BackupPolicy is not valid and cannot be used. + UPDATING (5): + BackupPolicy is being updated. + """ + STATE_UNSPECIFIED = 0 + CREATING = 1 + READY = 2 + DELETING = 3 + ERROR = 4 + UPDATING = 5 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + daily_backup_limit: int = proto.Field( + proto.INT32, + number=2, + optional=True, + ) + weekly_backup_limit: int = proto.Field( + proto.INT32, + number=3, + optional=True, + ) + monthly_backup_limit: int = proto.Field( + proto.INT32, + number=4, + optional=True, + ) + description: str = proto.Field( + proto.STRING, + number=5, + optional=True, + ) + enabled: bool = proto.Field( + proto.BOOL, + number=6, + optional=True, + ) + assigned_volume_count: int = proto.Field( + proto.INT32, + number=7, + optional=True, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) + labels: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=9, + ) + state: State = proto.Field( + proto.ENUM, + number=10, + enum=State, + ) + + +class CreateBackupPolicyRequest(proto.Message): + r"""CreateBackupPolicyRequest creates a backupPolicy. + + Attributes: + parent (str): + Required. The location to create the backup policies of, in + the format ``projects/{project_id}/locations/{location}`` + backup_policy (google.cloud.netapp_v1.types.BackupPolicy): + Required. A backupPolicy resource + backup_policy_id (str): + Required. The ID to use for the backup + policy. The ID must be unique within the + specified location. Must contain only letters, + numbers and hyphen, with the first character a + letter, the last a letter or a + number, and a 63 character maximum. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + backup_policy: 'BackupPolicy' = proto.Field( + proto.MESSAGE, + number=2, + message='BackupPolicy', + ) + backup_policy_id: str = proto.Field( + proto.STRING, + number=3, + ) + + +class GetBackupPolicyRequest(proto.Message): + r"""GetBackupPolicyRequest gets the state of a backupPolicy. + + Attributes: + name (str): + Required. The backupPolicy resource name, in the format + ``projects/{project_id}/locations/{location}/backupPolicies/{backup_policy_id}`` + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListBackupPoliciesRequest(proto.Message): + r"""ListBackupPoliciesRequest for requesting multiple backup + policies. + + Attributes: + parent (str): + Required. Parent value for + ListBackupPoliciesRequest + page_size (int): + Requested page size. Server may return fewer + items than requested. If unspecified, the server + will pick an appropriate default. + page_token (str): + A token identifying a page of results the + server should return. + filter (str): + Filtering results + order_by (str): + Hint for how to order the results + """ + + 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 ListBackupPoliciesResponse(proto.Message): + r"""ListBackupPoliciesResponse contains all the backup policies + requested. + + Attributes: + backup_policies (MutableSequence[google.cloud.netapp_v1.types.BackupPolicy]): + The list of backup policies. + next_page_token (str): + A token identifying a page of results the + server should return. + unreachable (MutableSequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + backup_policies: MutableSequence['BackupPolicy'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='BackupPolicy', + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class UpdateBackupPolicyRequest(proto.Message): + r"""UpdateBackupPolicyRequest for updating a backup policy. + + Attributes: + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Field mask is used to specify the fields to be + overwritten in the Backup Policy resource by the update. The + fields specified in the update_mask are relative to the + resource, not the full request. A field will be overwritten + if it is in the mask. If the user does not provide a mask + then all fields will be overwritten. + backup_policy (google.cloud.netapp_v1.types.BackupPolicy): + Required. The backup policy being updated + """ + + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=1, + message=field_mask_pb2.FieldMask, + ) + backup_policy: 'BackupPolicy' = proto.Field( + proto.MESSAGE, + number=2, + message='BackupPolicy', + ) + + +class DeleteBackupPolicyRequest(proto.Message): + r"""DeleteBackupPolicyRequest deletes a backup policy. + + Attributes: + name (str): + Required. The backup policy resource name, in the format + ``projects/{project_id}/locations/{location}/backupPolicies/{backup_policy_id}`` + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup_vault.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup_vault.py new file mode 100644 index 000000000000..449c1d0d26cd --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup_vault.py @@ -0,0 +1,274 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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.cloud.netapp.v1', + manifest={ + 'BackupVault', + 'GetBackupVaultRequest', + 'ListBackupVaultsRequest', + 'ListBackupVaultsResponse', + 'CreateBackupVaultRequest', + 'DeleteBackupVaultRequest', + 'UpdateBackupVaultRequest', + }, +) + + +class BackupVault(proto.Message): + r"""A NetApp BackupVault. + + Attributes: + name (str): + Identifier. The resource name of the backup vault. Format: + ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}``. + state (google.cloud.netapp_v1.types.BackupVault.State): + Output only. The backup vault state. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Create time of the backup vault. + description (str): + Description of the backup vault. + labels (MutableMapping[str, str]): + Resource labels to represent user provided + metadata. + """ + class State(proto.Enum): + r"""The Backup Vault States + + Values: + STATE_UNSPECIFIED (0): + State not set. + CREATING (1): + BackupVault is being created. + READY (2): + BackupVault is available for use. + DELETING (3): + BackupVault is being deleted. + ERROR (4): + BackupVault is not valid and cannot be used. + UPDATING (5): + BackupVault is being updated. + """ + STATE_UNSPECIFIED = 0 + CREATING = 1 + READY = 2 + DELETING = 3 + ERROR = 4 + UPDATING = 5 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + state: State = proto.Field( + proto.ENUM, + number=2, + enum=State, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + description: str = proto.Field( + proto.STRING, + number=4, + ) + labels: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=5, + ) + + +class GetBackupVaultRequest(proto.Message): + r"""GetBackupVaultRequest gets the state of a backupVault. + + Attributes: + name (str): + Required. The backupVault resource name, in the format + ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}`` + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListBackupVaultsRequest(proto.Message): + r"""ListBackupVaultsRequest lists backupVaults. + + Attributes: + parent (str): + Required. The location for which to retrieve backupVault + information, in the format + ``projects/{project_id}/locations/{location}``. + page_size (int): + The maximum number of items to return. + page_token (str): + The next_page_token value to use if there are additional + results to retrieve for this list request. + order_by (str): + Sort results. Supported values are "name", + "name desc" or "" (unsorted). + filter (str): + List filter. + """ + + 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, + ) + filter: str = proto.Field( + proto.STRING, + number=5, + ) + + +class ListBackupVaultsResponse(proto.Message): + r"""ListBackupVaultsResponse is the result of + ListBackupVaultsRequest. + + Attributes: + backup_vaults (MutableSequence[google.cloud.netapp_v1.types.BackupVault]): + A list of backupVaults in the project for the + specified location. + next_page_token (str): + The token you can use to retrieve the next + page of results. Not returned if there are no + more results in the list. + unreachable (MutableSequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + backup_vaults: MutableSequence['BackupVault'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='BackupVault', + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class CreateBackupVaultRequest(proto.Message): + r"""CreateBackupVaultRequest creates a backup vault. + + Attributes: + parent (str): + Required. The location to create the backup vaults, in the + format ``projects/{project_id}/locations/{location}`` + backup_vault_id (str): + Required. The ID to use for the backupVault. + The ID must be unique within the specified + location. Must contain only letters, numbers and + hyphen, with the first character a letter, the + last a letter or a + number, and a 63 character maximum. + backup_vault (google.cloud.netapp_v1.types.BackupVault): + Required. A backupVault resource + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + backup_vault_id: str = proto.Field( + proto.STRING, + number=2, + ) + backup_vault: 'BackupVault' = proto.Field( + proto.MESSAGE, + number=3, + message='BackupVault', + ) + + +class DeleteBackupVaultRequest(proto.Message): + r"""DeleteBackupVaultRequest deletes a backupVault. + + Attributes: + name (str): + Required. The backupVault resource name, in the format + ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}`` + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateBackupVaultRequest(proto.Message): + r"""UpdateBackupVaultRequest updates description and/or labels + for a backupVault. + + Attributes: + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Field mask is used to specify the fields to be + overwritten in the Backup resource to be updated. The fields + specified in the update_mask are relative to the resource, + not the full request. A field will be overwritten if it is + in the mask. If the user does not provide a mask then all + fields will be overwritten. + backup_vault (google.cloud.netapp_v1.types.BackupVault): + Required. The backupVault being updated + """ + + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=1, + message=field_mask_pb2.FieldMask, + ) + backup_vault: 'BackupVault' = proto.Field( + proto.MESSAGE, + number=2, + message='BackupVault', + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/cloud_netapp_service.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/cloud_netapp_service.py new file mode 100644 index 000000000000..2c3fec7fef5f --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/cloud_netapp_service.py @@ -0,0 +1,95 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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.cloud.netapp.v1', + manifest={ + 'OperationMetadata', + }, +) + + +class OperationMetadata(proto.Message): + r"""Represents the metadata of the long-running operation. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + target (str): + Output only. Server-defined resource path for + the target of the operation. + verb (str): + Output only. Name of the verb executed by the + operation. + status_message (str): + Output only. Human-readable status of the + operation, if any. + requested_cancellation (bool): + Output only. Identifies whether the user has requested + cancellation of the operation. Operations that have been + canceled successfully have [Operation.error][] value with a + [google.rpc.Status.code][google.rpc.Status.code] of 1, + corresponding to ``Code.CANCELLED``. + api_version (str): + Output only. API version used to start the + operation. + """ + + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + target: str = proto.Field( + proto.STRING, + number=3, + ) + verb: str = proto.Field( + proto.STRING, + number=4, + ) + status_message: str = proto.Field( + proto.STRING, + number=5, + ) + requested_cancellation: bool = proto.Field( + proto.BOOL, + number=6, + ) + api_version: str = proto.Field( + proto.STRING, + number=7, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/common.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/common.py new file mode 100644 index 000000000000..324846f99933 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/common.py @@ -0,0 +1,130 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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.cloud.netapp.v1', + manifest={ + 'ServiceLevel', + 'FlexPerformance', + 'EncryptionType', + 'DirectoryServiceType', + 'LocationMetadata', + }, +) + + +class ServiceLevel(proto.Enum): + r"""The service level of a storage pool and its volumes. + + Values: + SERVICE_LEVEL_UNSPECIFIED (0): + Unspecified service level. + PREMIUM (1): + Premium service level. + EXTREME (2): + Extreme service level. + STANDARD (3): + Standard service level. + FLEX (4): + Flex service level. + """ + SERVICE_LEVEL_UNSPECIFIED = 0 + PREMIUM = 1 + EXTREME = 2 + STANDARD = 3 + FLEX = 4 + + +class FlexPerformance(proto.Enum): + r"""Flex Storage Pool performance. + + Values: + FLEX_PERFORMANCE_UNSPECIFIED (0): + Unspecified flex performance. + FLEX_PERFORMANCE_DEFAULT (1): + Flex Storage Pool with default performance. + FLEX_PERFORMANCE_CUSTOM (2): + Flex Storage Pool with custom performance. + """ + FLEX_PERFORMANCE_UNSPECIFIED = 0 + FLEX_PERFORMANCE_DEFAULT = 1 + FLEX_PERFORMANCE_CUSTOM = 2 + + +class EncryptionType(proto.Enum): + r"""The volume encryption key source. + + Values: + ENCRYPTION_TYPE_UNSPECIFIED (0): + The source of the encryption key is not + specified. + SERVICE_MANAGED (1): + Google managed encryption key. + CLOUD_KMS (2): + Customer managed encryption key, which is + stored in KMS. + """ + ENCRYPTION_TYPE_UNSPECIFIED = 0 + SERVICE_MANAGED = 1 + CLOUD_KMS = 2 + + +class DirectoryServiceType(proto.Enum): + r"""Type of directory service + + Values: + DIRECTORY_SERVICE_TYPE_UNSPECIFIED (0): + Directory service type is not specified. + ACTIVE_DIRECTORY (1): + Active directory policy attached to the + storage pool. + """ + DIRECTORY_SERVICE_TYPE_UNSPECIFIED = 0 + ACTIVE_DIRECTORY = 1 + + +class LocationMetadata(proto.Message): + r"""Metadata for a given + [google.cloud.location.Location][google.cloud.location.Location]. + + Attributes: + supported_service_levels (MutableSequence[google.cloud.netapp_v1.types.ServiceLevel]): + Output only. Supported service levels in a + location. + supported_flex_performance (MutableSequence[google.cloud.netapp_v1.types.FlexPerformance]): + Output only. Supported flex performance in a + location. + """ + + supported_service_levels: MutableSequence['ServiceLevel'] = proto.RepeatedField( + proto.ENUM, + number=1, + enum='ServiceLevel', + ) + supported_flex_performance: MutableSequence['FlexPerformance'] = proto.RepeatedField( + proto.ENUM, + number=2, + enum='FlexPerformance', + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/kms.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/kms.py new file mode 100644 index 000000000000..e946fa604c6b --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/kms.py @@ -0,0 +1,381 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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.cloud.netapp.v1', + manifest={ + 'GetKmsConfigRequest', + 'ListKmsConfigsRequest', + 'ListKmsConfigsResponse', + 'CreateKmsConfigRequest', + 'UpdateKmsConfigRequest', + 'DeleteKmsConfigRequest', + 'EncryptVolumesRequest', + 'VerifyKmsConfigRequest', + 'VerifyKmsConfigResponse', + 'KmsConfig', + }, +) + + +class GetKmsConfigRequest(proto.Message): + r"""GetKmsConfigRequest gets a KMS Config. + + Attributes: + name (str): + Required. Name of the KmsConfig + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListKmsConfigsRequest(proto.Message): + r"""ListKmsConfigsRequest lists KMS Configs. + + Attributes: + parent (str): + Required. Parent value + page_size (int): + The maximum number of items to return. + page_token (str): + The next_page_token value to use if there are additional + results to retrieve for this list request. + order_by (str): + Sort results. Supported values are "name", + "name desc" or "" (unsorted). + filter (str): + List filter. + """ + + 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, + ) + filter: str = proto.Field( + proto.STRING, + number=5, + ) + + +class ListKmsConfigsResponse(proto.Message): + r"""ListKmsConfigsResponse is the response to a + ListKmsConfigsRequest. + + Attributes: + kms_configs (MutableSequence[google.cloud.netapp_v1.types.KmsConfig]): + The list of KmsConfigs + next_page_token (str): + A token identifying a page of results the + server should return. + unreachable (MutableSequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + kms_configs: MutableSequence['KmsConfig'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='KmsConfig', + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class CreateKmsConfigRequest(proto.Message): + r"""CreateKmsConfigRequest creates a KMS Config. + + Attributes: + parent (str): + Required. Value for parent. + kms_config_id (str): + Required. Id of the requesting KmsConfig. + Must be unique within the parent resource. Must + contain only letters, numbers and hyphen, with + the first character a letter, the last a letter + or a + number, and a 63 character maximum. + kms_config (google.cloud.netapp_v1.types.KmsConfig): + Required. The required parameters to create a + new KmsConfig. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + kms_config_id: str = proto.Field( + proto.STRING, + number=2, + ) + kms_config: 'KmsConfig' = proto.Field( + proto.MESSAGE, + number=3, + message='KmsConfig', + ) + + +class UpdateKmsConfigRequest(proto.Message): + r"""UpdateKmsConfigRequest updates a KMS Config. + + Attributes: + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Field mask is used to specify the fields to be + overwritten in the KmsConfig resource by the update. The + fields specified in the update_mask are relative to the + resource, not the full request. A field will be overwritten + if it is in the mask. If the user does not provide a mask + then all fields will be overwritten. + kms_config (google.cloud.netapp_v1.types.KmsConfig): + Required. The KmsConfig being updated + """ + + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=1, + message=field_mask_pb2.FieldMask, + ) + kms_config: 'KmsConfig' = proto.Field( + proto.MESSAGE, + number=2, + message='KmsConfig', + ) + + +class DeleteKmsConfigRequest(proto.Message): + r"""DeleteKmsConfigRequest deletes a KMS Config. + + Attributes: + name (str): + Required. Name of the KmsConfig. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class EncryptVolumesRequest(proto.Message): + r"""EncryptVolumesRequest specifies the KMS config to encrypt + existing volumes. + + Attributes: + name (str): + Required. Name of the KmsConfig. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class VerifyKmsConfigRequest(proto.Message): + r"""VerifyKmsConfigRequest specifies the KMS config to be + validated. + + Attributes: + name (str): + Required. Name of the KMS Config to be + verified. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class VerifyKmsConfigResponse(proto.Message): + r"""VerifyKmsConfigResponse contains the information if the + config is correctly and error message. + + Attributes: + healthy (bool): + Output only. If the customer key configured + correctly to the encrypt volume. + health_error (str): + Output only. Error message if config is not + healthy. + instructions (str): + Output only. Instructions for the customers + to provide the access to the encryption key. + """ + + healthy: bool = proto.Field( + proto.BOOL, + number=1, + ) + health_error: str = proto.Field( + proto.STRING, + number=2, + ) + instructions: str = proto.Field( + proto.STRING, + number=3, + ) + + +class KmsConfig(proto.Message): + r"""KmsConfig is the customer managed encryption key(CMEK) + configuration. + + Attributes: + name (str): + Identifier. Name of the KmsConfig. + crypto_key_name (str): + Required. Customer managed crypto key resource full name. + Format: + projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{key}. + state (google.cloud.netapp_v1.types.KmsConfig.State): + Output only. State of the KmsConfig. + state_details (str): + Output only. State details of the KmsConfig. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Create time of the KmsConfig. + description (str): + Description of the KmsConfig. + labels (MutableMapping[str, str]): + Labels as key value pairs + instructions (str): + Output only. Instructions to provide the + access to the customer provided encryption key. + service_account (str): + Output only. The Service account which will + have access to the customer provided encryption + key. + """ + class State(proto.Enum): + r"""The KmsConfig States + + Values: + STATE_UNSPECIFIED (0): + Unspecified KmsConfig State + READY (1): + KmsConfig State is Ready + CREATING (2): + KmsConfig State is Creating + DELETING (3): + KmsConfig State is Deleting + UPDATING (4): + KmsConfig State is Updating + IN_USE (5): + KmsConfig State is In Use. + ERROR (6): + KmsConfig State is Error + KEY_CHECK_PENDING (7): + KmsConfig State is Pending to verify crypto + key access. + KEY_NOT_REACHABLE (8): + KmsConfig State is Not accessbile by the SDE + service account to the crypto key. + DISABLING (9): + KmsConfig State is Disabling. + DISABLED (10): + KmsConfig State is Disabled. + MIGRATING (11): + KmsConfig State is Migrating. + The existing volumes are migrating from SMEK to + CMEK. + """ + STATE_UNSPECIFIED = 0 + READY = 1 + CREATING = 2 + DELETING = 3 + UPDATING = 4 + IN_USE = 5 + ERROR = 6 + KEY_CHECK_PENDING = 7 + KEY_NOT_REACHABLE = 8 + DISABLING = 9 + DISABLED = 10 + MIGRATING = 11 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + crypto_key_name: str = proto.Field( + proto.STRING, + number=2, + ) + state: State = proto.Field( + proto.ENUM, + number=3, + enum=State, + ) + state_details: str = proto.Field( + proto.STRING, + number=4, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, + ) + description: str = proto.Field( + proto.STRING, + number=6, + ) + labels: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=7, + ) + instructions: str = proto.Field( + proto.STRING, + number=8, + ) + service_account: str = proto.Field( + proto.STRING, + number=9, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/quota_rule.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/quota_rule.py new file mode 100644 index 000000000000..76310bebc9f8 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/quota_rule.py @@ -0,0 +1,321 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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.cloud.netapp.v1', + manifest={ + 'ListQuotaRulesRequest', + 'ListQuotaRulesResponse', + 'GetQuotaRuleRequest', + 'CreateQuotaRuleRequest', + 'UpdateQuotaRuleRequest', + 'DeleteQuotaRuleRequest', + 'QuotaRule', + }, +) + + +class ListQuotaRulesRequest(proto.Message): + r"""ListQuotaRulesRequest for listing quota rules. + + Attributes: + parent (str): + Required. Parent value for + ListQuotaRulesRequest + page_size (int): + Optional. Requested page size. Server may + return fewer items than requested. If + unspecified, the server will pick an appropriate + default. + page_token (str): + Optional. A token identifying a page of + results the server should return. + filter (str): + Optional. Filtering results + order_by (str): + Optional. Hint for how to order the results + """ + + 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 ListQuotaRulesResponse(proto.Message): + r"""ListQuotaRulesResponse is the response to a + ListQuotaRulesRequest. + + Attributes: + quota_rules (MutableSequence[google.cloud.netapp_v1.types.QuotaRule]): + List of quota rules + next_page_token (str): + A token identifying a page of results the + server should return. + unreachable (MutableSequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + quota_rules: MutableSequence['QuotaRule'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='QuotaRule', + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class GetQuotaRuleRequest(proto.Message): + r"""GetQuotaRuleRequest for getting a quota rule. + + Attributes: + name (str): + Required. Name of the quota rule + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateQuotaRuleRequest(proto.Message): + r"""CreateQuotaRuleRequest for creating a quota rule. + + Attributes: + parent (str): + Required. Parent value for + CreateQuotaRuleRequest + quota_rule (google.cloud.netapp_v1.types.QuotaRule): + Required. Fields of the to be created quota + rule. + quota_rule_id (str): + Required. ID of the quota rule to create. + Must be unique within the parent resource. Must + contain only letters, numbers, underscore and + hyphen, with the first character a letter or + underscore, the last a letter or underscore or a + number, and a 63 character maximum. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + quota_rule: 'QuotaRule' = proto.Field( + proto.MESSAGE, + number=2, + message='QuotaRule', + ) + quota_rule_id: str = proto.Field( + proto.STRING, + number=3, + ) + + +class UpdateQuotaRuleRequest(proto.Message): + r"""UpdateQuotaRuleRequest for updating a quota rule. + + Attributes: + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. Field mask is used to specify the fields to be + overwritten in the Quota Rule resource by the update. The + fields specified in the update_mask are relative to the + resource, not the full request. A field will be overwritten + if it is in the mask. If the user does not provide a mask + then all fields will be overwritten. + quota_rule (google.cloud.netapp_v1.types.QuotaRule): + Required. The quota rule being updated + """ + + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=1, + message=field_mask_pb2.FieldMask, + ) + quota_rule: 'QuotaRule' = proto.Field( + proto.MESSAGE, + number=2, + message='QuotaRule', + ) + + +class DeleteQuotaRuleRequest(proto.Message): + r"""DeleteQuotaRuleRequest for deleting a single quota rule. + + Attributes: + name (str): + Required. Name of the quota rule. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class QuotaRule(proto.Message): + r"""QuotaRule specifies the maximum disk space a user or group + can use within a volume. They can be used for creating default + and individual quota rules. + + Attributes: + name (str): + Identifier. The resource name of the quota rule. Format: + ``projects/{project_number}/locations/{location_id}/volumes/volumes/{volume_id}/quotaRules/{quota_rule_id}``. + target (str): + Optional. The quota rule applies to the + specified user or group, identified by a Unix + UID/GID, Windows SID, or null for default. + type_ (google.cloud.netapp_v1.types.QuotaRule.Type): + Required. The type of quota rule. + disk_limit_mib (int): + Required. The maximum allowed disk space in + MiB. + state (google.cloud.netapp_v1.types.QuotaRule.State): + Output only. State of the quota rule + state_details (str): + Output only. State details of the quota rule + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Create time of the quota rule + description (str): + Optional. Description of the quota rule + labels (MutableMapping[str, str]): + Optional. Labels of the quota rule + """ + class Type(proto.Enum): + r"""Types of Quota Rule + + Values: + TYPE_UNSPECIFIED (0): + Unspecified type for quota rule + INDIVIDUAL_USER_QUOTA (1): + Individual user quota rule + INDIVIDUAL_GROUP_QUOTA (2): + Individual group quota rule + DEFAULT_USER_QUOTA (3): + Default user quota rule + DEFAULT_GROUP_QUOTA (4): + Default group quota rule + """ + TYPE_UNSPECIFIED = 0 + INDIVIDUAL_USER_QUOTA = 1 + INDIVIDUAL_GROUP_QUOTA = 2 + DEFAULT_USER_QUOTA = 3 + DEFAULT_GROUP_QUOTA = 4 + + class State(proto.Enum): + r"""Quota Rule states + + Values: + STATE_UNSPECIFIED (0): + Unspecified state for quota rule + CREATING (1): + Quota rule is creating + UPDATING (2): + Quota rule is updating + DELETING (3): + Quota rule is deleting + READY (4): + Quota rule is ready + ERROR (5): + Quota rule is in error state. + """ + STATE_UNSPECIFIED = 0 + CREATING = 1 + UPDATING = 2 + DELETING = 3 + READY = 4 + ERROR = 5 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + target: str = proto.Field( + proto.STRING, + number=2, + ) + type_: Type = proto.Field( + proto.ENUM, + number=3, + enum=Type, + ) + disk_limit_mib: int = proto.Field( + proto.INT32, + number=4, + ) + state: State = proto.Field( + proto.ENUM, + number=6, + enum=State, + ) + state_details: str = proto.Field( + proto.STRING, + number=7, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) + description: str = proto.Field( + proto.STRING, + number=9, + ) + labels: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=10, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/replication.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/replication.py new file mode 100644 index 000000000000..dcc90cc82f8d --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/replication.py @@ -0,0 +1,817 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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.netapp_v1.types import volume +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.cloud.netapp.v1', + manifest={ + 'TransferStats', + 'Replication', + 'HybridPeeringDetails', + 'ListReplicationsRequest', + 'ListReplicationsResponse', + 'GetReplicationRequest', + 'DestinationVolumeParameters', + 'CreateReplicationRequest', + 'DeleteReplicationRequest', + 'UpdateReplicationRequest', + 'StopReplicationRequest', + 'ResumeReplicationRequest', + 'ReverseReplicationDirectionRequest', + 'EstablishPeeringRequest', + 'SyncReplicationRequest', + }, +) + + +class TransferStats(proto.Message): + r"""TransferStats reports all statistics related to replication + transfer. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + transfer_bytes (int): + Cumulative bytes trasferred so far for the + replication relatinonship. + + This field is a member of `oneof`_ ``_transfer_bytes``. + total_transfer_duration (google.protobuf.duration_pb2.Duration): + Cumulative time taken across all transfers + for the replication relationship. + + This field is a member of `oneof`_ ``_total_transfer_duration``. + last_transfer_bytes (int): + Last transfer size in bytes. + + This field is a member of `oneof`_ ``_last_transfer_bytes``. + last_transfer_duration (google.protobuf.duration_pb2.Duration): + Time taken during last transfer. + + This field is a member of `oneof`_ ``_last_transfer_duration``. + lag_duration (google.protobuf.duration_pb2.Duration): + Lag duration indicates the duration by which + Destination region volume content lags behind + the primary region volume content. + + This field is a member of `oneof`_ ``_lag_duration``. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Time when progress was updated last. + + This field is a member of `oneof`_ ``_update_time``. + last_transfer_end_time (google.protobuf.timestamp_pb2.Timestamp): + Time when last transfer completed. + + This field is a member of `oneof`_ ``_last_transfer_end_time``. + last_transfer_error (str): + A message describing the cause of the last + transfer failure. + + This field is a member of `oneof`_ ``_last_transfer_error``. + """ + + transfer_bytes: int = proto.Field( + proto.INT64, + number=1, + optional=True, + ) + total_transfer_duration: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=2, + optional=True, + message=duration_pb2.Duration, + ) + last_transfer_bytes: int = proto.Field( + proto.INT64, + number=3, + optional=True, + ) + last_transfer_duration: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=4, + optional=True, + message=duration_pb2.Duration, + ) + lag_duration: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=5, + optional=True, + message=duration_pb2.Duration, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=6, + optional=True, + message=timestamp_pb2.Timestamp, + ) + last_transfer_end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=7, + optional=True, + message=timestamp_pb2.Timestamp, + ) + last_transfer_error: str = proto.Field( + proto.STRING, + number=8, + optional=True, + ) + + +class Replication(proto.Message): + r"""Replication is a nested resource under Volume, that describes + a cross-region replication relationship between 2 volumes in + different regions. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + name (str): + Identifier. The resource name of the Replication. Format: + ``projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}``. + state (google.cloud.netapp_v1.types.Replication.State): + Output only. State of the replication. + state_details (str): + Output only. State details of the + replication. + role (google.cloud.netapp_v1.types.Replication.ReplicationRole): + Output only. Indicates whether this points to + source or destination. + replication_schedule (google.cloud.netapp_v1.types.Replication.ReplicationSchedule): + Required. Indicates the schedule for + replication. + mirror_state (google.cloud.netapp_v1.types.Replication.MirrorState): + Output only. Indicates the state of + mirroring. + healthy (bool): + Output only. Condition of the relationship. + Can be one of the following: + + - true: The replication relationship is healthy. + It has not missed the most recent scheduled + transfer. + - false: The replication relationship is not + healthy. It has missed the most recent + scheduled transfer. + + This field is a member of `oneof`_ ``_healthy``. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Replication create time. + destination_volume (str): + Output only. Full name of destination volume resource. + Example : + "projects/{project}/locations/{location}/volumes/{volume_id}". + transfer_stats (google.cloud.netapp_v1.types.TransferStats): + Output only. Replication transfer statistics. + labels (MutableMapping[str, str]): + Resource labels to represent user provided + metadata. + description (str): + A description about this replication + relationship. + + This field is a member of `oneof`_ ``_description``. + destination_volume_parameters (google.cloud.netapp_v1.types.DestinationVolumeParameters): + Required. Input only. Destination volume + parameters + source_volume (str): + Output only. Full name of source volume resource. Example : + "projects/{project}/locations/{location}/volumes/{volume_id}". + hybrid_peering_details (google.cloud.netapp_v1.types.HybridPeeringDetails): + Output only. Hybrid peering details. + cluster_location (str): + Optional. Location of the user cluster. + hybrid_replication_type (google.cloud.netapp_v1.types.Replication.HybridReplicationType): + Output only. Type of the hybrid replication. + """ + class State(proto.Enum): + r"""The replication states + New enum values may be added in future to indicate possible new + states. + + Values: + STATE_UNSPECIFIED (0): + Unspecified replication State + CREATING (1): + Replication is creating. + READY (2): + Replication is ready. + UPDATING (3): + Replication is updating. + DELETING (5): + Replication is deleting. + ERROR (6): + Replication is in error state. + PENDING_CLUSTER_PEERING (8): + Replication is waiting for cluster peering to + be established. + PENDING_SVM_PEERING (9): + Replication is waiting for SVM peering to be + established. + """ + STATE_UNSPECIFIED = 0 + CREATING = 1 + READY = 2 + UPDATING = 3 + DELETING = 5 + ERROR = 6 + PENDING_CLUSTER_PEERING = 8 + PENDING_SVM_PEERING = 9 + + class ReplicationRole(proto.Enum): + r"""New enum values may be added in future to support different + replication topology. + + Values: + REPLICATION_ROLE_UNSPECIFIED (0): + Unspecified replication role + SOURCE (1): + Indicates Source volume. + DESTINATION (2): + Indicates Destination volume. + """ + REPLICATION_ROLE_UNSPECIFIED = 0 + SOURCE = 1 + DESTINATION = 2 + + class ReplicationSchedule(proto.Enum): + r"""Schedule for Replication. + New enum values may be added in future to support different + frequency of replication. + + Values: + REPLICATION_SCHEDULE_UNSPECIFIED (0): + Unspecified ReplicationSchedule + EVERY_10_MINUTES (1): + Replication happens once every 10 minutes. + HOURLY (2): + Replication happens once every hour. + DAILY (3): + Replication happens once every day. + """ + REPLICATION_SCHEDULE_UNSPECIFIED = 0 + EVERY_10_MINUTES = 1 + HOURLY = 2 + DAILY = 3 + + class MirrorState(proto.Enum): + r"""Mirroring states. + No new value is expected to be added in future. + + Values: + MIRROR_STATE_UNSPECIFIED (0): + Unspecified MirrorState + PREPARING (1): + Destination volume is being prepared. + MIRRORED (2): + Destination volume has been initialized and + is ready to receive replication transfers. + STOPPED (3): + Destination volume is not receiving + replication transfers. + TRANSFERRING (4): + Incremental replication is in progress. + BASELINE_TRANSFERRING (5): + Baseline replication is in progress. + ABORTED (6): + Replication is aborted. + """ + MIRROR_STATE_UNSPECIFIED = 0 + PREPARING = 1 + MIRRORED = 2 + STOPPED = 3 + TRANSFERRING = 4 + BASELINE_TRANSFERRING = 5 + ABORTED = 6 + + class HybridReplicationType(proto.Enum): + r"""Hybrid replication type. + + Values: + HYBRID_REPLICATION_TYPE_UNSPECIFIED (0): + Unspecified hybrid replication type. + MIGRATION (1): + Hybrid replication type for migration. + CONTINUOUS_REPLICATION (2): + Hybrid replication type for continuous + replication. + """ + HYBRID_REPLICATION_TYPE_UNSPECIFIED = 0 + MIGRATION = 1 + CONTINUOUS_REPLICATION = 2 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + state: State = proto.Field( + proto.ENUM, + number=2, + enum=State, + ) + state_details: str = proto.Field( + proto.STRING, + number=3, + ) + role: ReplicationRole = proto.Field( + proto.ENUM, + number=4, + enum=ReplicationRole, + ) + replication_schedule: ReplicationSchedule = proto.Field( + proto.ENUM, + number=5, + enum=ReplicationSchedule, + ) + mirror_state: MirrorState = proto.Field( + proto.ENUM, + number=6, + enum=MirrorState, + ) + healthy: bool = proto.Field( + proto.BOOL, + number=8, + optional=True, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=9, + message=timestamp_pb2.Timestamp, + ) + destination_volume: str = proto.Field( + proto.STRING, + number=10, + ) + transfer_stats: 'TransferStats' = proto.Field( + proto.MESSAGE, + number=11, + message='TransferStats', + ) + labels: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=12, + ) + description: str = proto.Field( + proto.STRING, + number=13, + optional=True, + ) + destination_volume_parameters: 'DestinationVolumeParameters' = proto.Field( + proto.MESSAGE, + number=14, + message='DestinationVolumeParameters', + ) + source_volume: str = proto.Field( + proto.STRING, + number=15, + ) + hybrid_peering_details: 'HybridPeeringDetails' = proto.Field( + proto.MESSAGE, + number=16, + message='HybridPeeringDetails', + ) + cluster_location: str = proto.Field( + proto.STRING, + number=18, + ) + hybrid_replication_type: HybridReplicationType = proto.Field( + proto.ENUM, + number=19, + enum=HybridReplicationType, + ) + + +class HybridPeeringDetails(proto.Message): + r"""HybridPeeringDetails contains details about the hybrid + peering. + + Attributes: + subnet_ip (str): + Optional. IP address of the subnet. + command (str): + Optional. Copy-paste-able commands to be used + on user's ONTAP to accept peering requests. + command_expiry_time (google.protobuf.timestamp_pb2.Timestamp): + Optional. Expiration time for the peering + command to be executed on user's ONTAP. + passphrase (str): + Optional. Temporary passphrase generated to + accept cluster peering command. + peer_volume_name (str): + Optional. Name of the user's local source + volume to be peered with the destination volume. + peer_cluster_name (str): + Optional. Name of the user's local source + cluster to be peered with the destination + cluster. + peer_svm_name (str): + Optional. Name of the user's local source + vserver svm to be peered with the destination + vserver svm. + """ + + subnet_ip: str = proto.Field( + proto.STRING, + number=1, + ) + command: str = proto.Field( + proto.STRING, + number=2, + ) + command_expiry_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + passphrase: str = proto.Field( + proto.STRING, + number=4, + ) + peer_volume_name: str = proto.Field( + proto.STRING, + number=5, + ) + peer_cluster_name: str = proto.Field( + proto.STRING, + number=6, + ) + peer_svm_name: str = proto.Field( + proto.STRING, + number=7, + ) + + +class ListReplicationsRequest(proto.Message): + r"""ListReplications lists replications. + + Attributes: + parent (str): + Required. The volume for which to retrieve replication + information, in the format + ``projects/{project_id}/locations/{location}/volumes/{volume_id}``. + page_size (int): + The maximum number of items to return. + page_token (str): + The next_page_token value to use if there are additional + results to retrieve for this list request. + order_by (str): + Sort results. Supported values are "name", + "name desc" or "" (unsorted). + filter (str): + List filter. + """ + + 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, + ) + filter: str = proto.Field( + proto.STRING, + number=5, + ) + + +class ListReplicationsResponse(proto.Message): + r"""ListReplicationsResponse is the result of + ListReplicationsRequest. + + Attributes: + replications (MutableSequence[google.cloud.netapp_v1.types.Replication]): + A list of replications in the project for the + specified volume. + next_page_token (str): + The token you can use to retrieve the next + page of results. Not returned if there are no + more results in the list. + unreachable (MutableSequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + replications: MutableSequence['Replication'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='Replication', + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class GetReplicationRequest(proto.Message): + r"""GetReplicationRequest gets the state of a replication. + + Attributes: + name (str): + Required. The replication resource name, in the format + ``projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}`` + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class DestinationVolumeParameters(proto.Message): + r"""DestinationVolumeParameters specify input parameters used for + creating destination volume. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + storage_pool (str): + Required. Existing destination StoragePool + name. + volume_id (str): + Desired destination volume resource id. If + not specified, source volume's resource id will + be used. This value must start with a lowercase + letter followed by up to 62 lowercase letters, + numbers, or hyphens, and cannot end with a + hyphen. + share_name (str): + Destination volume's share name. If not + specified, source volume's share name will be + used. + description (str): + Description for the destination volume. + + This field is a member of `oneof`_ ``_description``. + tiering_policy (google.cloud.netapp_v1.types.TieringPolicy): + Optional. Tiering policy for the volume. + + This field is a member of `oneof`_ ``_tiering_policy``. + """ + + storage_pool: str = proto.Field( + proto.STRING, + number=1, + ) + volume_id: str = proto.Field( + proto.STRING, + number=2, + ) + share_name: str = proto.Field( + proto.STRING, + number=3, + ) + description: str = proto.Field( + proto.STRING, + number=4, + optional=True, + ) + tiering_policy: volume.TieringPolicy = proto.Field( + proto.MESSAGE, + number=5, + optional=True, + message=volume.TieringPolicy, + ) + + +class CreateReplicationRequest(proto.Message): + r"""CreateReplicationRequest creates a replication. + + Attributes: + parent (str): + Required. The NetApp volume to create the replications of, + in the format + ``projects/{project_id}/locations/{location}/volumes/{volume_id}`` + replication (google.cloud.netapp_v1.types.Replication): + Required. A replication resource + replication_id (str): + Required. ID of the replication to create. + Must be unique within the parent resource. Must + contain only letters, numbers and hyphen, with + the first character a letter, the last a letter + or a + number, and a 63 character maximum. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + replication: 'Replication' = proto.Field( + proto.MESSAGE, + number=2, + message='Replication', + ) + replication_id: str = proto.Field( + proto.STRING, + number=3, + ) + + +class DeleteReplicationRequest(proto.Message): + r"""DeleteReplicationRequest deletes a replication. + + Attributes: + name (str): + Required. The replication resource name, in the format + ``projects/*/locations/*/volumes/*/replications/{replication_id}`` + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateReplicationRequest(proto.Message): + r"""UpdateReplicationRequest updates description and/or labels + for a replication. + + Attributes: + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Mask of fields to update. At least + one path must be supplied in this field. + replication (google.cloud.netapp_v1.types.Replication): + Required. A replication resource + """ + + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=1, + message=field_mask_pb2.FieldMask, + ) + replication: 'Replication' = proto.Field( + proto.MESSAGE, + number=2, + message='Replication', + ) + + +class StopReplicationRequest(proto.Message): + r"""StopReplicationRequest stops a replication until resumed. + + Attributes: + name (str): + Required. The resource name of the replication, in the + format of + projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}. + force (bool): + Indicates whether to stop replication + forcefully while data transfer is in progress. + Warning! if force is true, this will abort any + current transfers and can lead to data loss due + to partial transfer. If force is false, stop + replication will fail while data transfer is in + progress and you will need to retry later. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + force: bool = proto.Field( + proto.BOOL, + number=2, + ) + + +class ResumeReplicationRequest(proto.Message): + r"""ResumeReplicationRequest resumes a stopped replication. + + Attributes: + name (str): + Required. The resource name of the replication, in the + format of + projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ReverseReplicationDirectionRequest(proto.Message): + r"""ReverseReplicationDirectionRequest reverses direction of + replication. Source becomes destination and destination becomes + source. + + Attributes: + name (str): + Required. The resource name of the replication, in the + format of + projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class EstablishPeeringRequest(proto.Message): + r"""EstablishPeeringRequest establishes cluster and svm peerings + between the source and the destination replications. + + Attributes: + name (str): + Required. The resource name of the replication, in the + format of + projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}. + peer_cluster_name (str): + Required. Name of the user's local source + cluster to be peered with the destination + cluster. + peer_svm_name (str): + Required. Name of the user's local source + vserver svm to be peered with the destination + vserver svm. + peer_ip_addresses (MutableSequence[str]): + Optional. List of IPv4 ip addresses to be + used for peering. + peer_volume_name (str): + Required. Name of the user's local source + volume to be peered with the destination volume. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + peer_cluster_name: str = proto.Field( + proto.STRING, + number=2, + ) + peer_svm_name: str = proto.Field( + proto.STRING, + number=3, + ) + peer_ip_addresses: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=4, + ) + peer_volume_name: str = proto.Field( + proto.STRING, + number=5, + ) + + +class SyncReplicationRequest(proto.Message): + r"""SyncReplicationRequest syncs the replication from source to + destination. + + Attributes: + name (str): + Required. The resource name of the replication, in the + format of + projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/snapshot.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/snapshot.py new file mode 100644 index 000000000000..f0f3f17cdbbb --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/snapshot.py @@ -0,0 +1,290 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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.cloud.netapp.v1', + manifest={ + 'ListSnapshotsRequest', + 'ListSnapshotsResponse', + 'GetSnapshotRequest', + 'CreateSnapshotRequest', + 'DeleteSnapshotRequest', + 'UpdateSnapshotRequest', + 'Snapshot', + }, +) + + +class ListSnapshotsRequest(proto.Message): + r"""ListSnapshotsRequest lists snapshots. + + Attributes: + parent (str): + Required. The volume for which to retrieve snapshot + information, in the format + ``projects/{project_id}/locations/{location}/volumes/{volume_id}``. + page_size (int): + The maximum number of items to return. + page_token (str): + The next_page_token value to use if there are additional + results to retrieve for this list request. + order_by (str): + Sort results. Supported values are "name", + "name desc" or "" (unsorted). + filter (str): + List filter. + """ + + 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, + ) + filter: str = proto.Field( + proto.STRING, + number=5, + ) + + +class ListSnapshotsResponse(proto.Message): + r"""ListSnapshotsResponse is the result of ListSnapshotsRequest. + + Attributes: + snapshots (MutableSequence[google.cloud.netapp_v1.types.Snapshot]): + A list of snapshots in the project for the + specified volume. + next_page_token (str): + The token you can use to retrieve the next + page of results. Not returned if there are no + more results in the list. + unreachable (MutableSequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + snapshots: MutableSequence['Snapshot'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='Snapshot', + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class GetSnapshotRequest(proto.Message): + r"""GetSnapshotRequest gets the state of a snapshot. + + Attributes: + name (str): + Required. The snapshot resource name, in the format + ``projects/{project_id}/locations/{location}/volumes/{volume_id}/snapshots/{snapshot_id}`` + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateSnapshotRequest(proto.Message): + r"""CreateSnapshotRequest creates a snapshot. + + Attributes: + parent (str): + Required. The NetApp volume to create the snapshots of, in + the format + ``projects/{project_id}/locations/{location}/volumes/{volume_id}`` + snapshot (google.cloud.netapp_v1.types.Snapshot): + Required. A snapshot resource + snapshot_id (str): + Required. ID of the snapshot to create. Must + be unique within the parent resource. Must + contain only letters, numbers and hyphen, with + the first character a letter, the last a letter + or a + number, and a 63 character maximum. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + snapshot: 'Snapshot' = proto.Field( + proto.MESSAGE, + number=2, + message='Snapshot', + ) + snapshot_id: str = proto.Field( + proto.STRING, + number=3, + ) + + +class DeleteSnapshotRequest(proto.Message): + r"""DeleteSnapshotRequest deletes a snapshot. + + Attributes: + name (str): + Required. The snapshot resource name, in the format + ``projects/*/locations/*/volumes/*/snapshots/{snapshot_id}`` + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateSnapshotRequest(proto.Message): + r"""UpdateSnapshotRequest updates description and/or labels for a + snapshot. + + Attributes: + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Mask of fields to update. At least + one path must be supplied in this field. + snapshot (google.cloud.netapp_v1.types.Snapshot): + Required. A snapshot resource + """ + + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=1, + message=field_mask_pb2.FieldMask, + ) + snapshot: 'Snapshot' = proto.Field( + proto.MESSAGE, + number=2, + message='Snapshot', + ) + + +class Snapshot(proto.Message): + r"""Snapshot is a point-in-time version of a Volume's content. + + Attributes: + name (str): + Identifier. The resource name of the snapshot. Format: + ``projects/{project_id}/locations/{location}/volumes/{volume_id}/snapshots/{snapshot_id}``. + state (google.cloud.netapp_v1.types.Snapshot.State): + Output only. The snapshot state. + state_details (str): + Output only. State details of the storage + pool + description (str): + A description of the snapshot with 2048 + characters or less. Requests with longer + descriptions will be rejected. + used_bytes (float): + Output only. Current storage usage for the + snapshot in bytes. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time when the snapshot was + created. + labels (MutableMapping[str, str]): + Resource labels to represent user provided + metadata. + """ + class State(proto.Enum): + r"""The Snapshot States + + Values: + STATE_UNSPECIFIED (0): + Unspecified Snapshot State + READY (1): + Snapshot State is Ready + CREATING (2): + Snapshot State is Creating + DELETING (3): + Snapshot State is Deleting + UPDATING (4): + Snapshot State is Updating + DISABLED (5): + Snapshot State is Disabled + ERROR (6): + Snapshot State is Error + """ + STATE_UNSPECIFIED = 0 + READY = 1 + CREATING = 2 + DELETING = 3 + UPDATING = 4 + DISABLED = 5 + ERROR = 6 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + state: State = proto.Field( + proto.ENUM, + number=2, + enum=State, + ) + state_details: str = proto.Field( + proto.STRING, + number=3, + ) + description: str = proto.Field( + proto.STRING, + number=4, + ) + used_bytes: float = proto.Field( + proto.DOUBLE, + number=5, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + labels: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=7, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/storage_pool.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/storage_pool.py new file mode 100644 index 000000000000..526379c6e072 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/storage_pool.py @@ -0,0 +1,440 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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.netapp_v1.types import common +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.netapp.v1', + manifest={ + 'GetStoragePoolRequest', + 'ListStoragePoolsRequest', + 'ListStoragePoolsResponse', + 'CreateStoragePoolRequest', + 'UpdateStoragePoolRequest', + 'DeleteStoragePoolRequest', + 'SwitchActiveReplicaZoneRequest', + 'StoragePool', + 'ValidateDirectoryServiceRequest', + }, +) + + +class GetStoragePoolRequest(proto.Message): + r"""GetStoragePoolRequest gets a Storage Pool. + + Attributes: + name (str): + Required. Name of the storage pool + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListStoragePoolsRequest(proto.Message): + r"""ListStoragePoolsRequest lists Storage Pools. + + Attributes: + parent (str): + Required. Parent value + page_size (int): + Optional. The maximum number of items to + return. + page_token (str): + Optional. The next_page_token value to use if there are + additional results to retrieve for this list request. + order_by (str): + Optional. Sort results. Supported values are + "name", "name desc" or "" (unsorted). + filter (str): + Optional. List filter. + """ + + 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, + ) + filter: str = proto.Field( + proto.STRING, + number=5, + ) + + +class ListStoragePoolsResponse(proto.Message): + r"""ListStoragePoolsResponse is the response to a + ListStoragePoolsRequest. + + Attributes: + storage_pools (MutableSequence[google.cloud.netapp_v1.types.StoragePool]): + The list of StoragePools + next_page_token (str): + A token identifying a page of results the + server should return. + unreachable (MutableSequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + storage_pools: MutableSequence['StoragePool'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='StoragePool', + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class CreateStoragePoolRequest(proto.Message): + r"""CreateStoragePoolRequest creates a Storage Pool. + + Attributes: + parent (str): + Required. Value for parent. + storage_pool_id (str): + Required. Id of the requesting storage pool. + Must be unique within the parent resource. Must + contain only letters, numbers and hyphen, with + the first character a letter, the last a letter + or a number, and a 63 character maximum. + storage_pool (google.cloud.netapp_v1.types.StoragePool): + Required. The required parameters to create a + new storage pool. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + storage_pool_id: str = proto.Field( + proto.STRING, + number=2, + ) + storage_pool: 'StoragePool' = proto.Field( + proto.MESSAGE, + number=3, + message='StoragePool', + ) + + +class UpdateStoragePoolRequest(proto.Message): + r"""UpdateStoragePoolRequest updates a Storage Pool. + + Attributes: + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Field mask is used to specify the fields to be + overwritten in the StoragePool resource by the update. The + fields specified in the update_mask are relative to the + resource, not the full request. A field will be overwritten + if it is in the mask. If the user does not provide a mask + then all fields will be overwritten. + storage_pool (google.cloud.netapp_v1.types.StoragePool): + Required. The pool being updated + """ + + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=1, + message=field_mask_pb2.FieldMask, + ) + storage_pool: 'StoragePool' = proto.Field( + proto.MESSAGE, + number=2, + message='StoragePool', + ) + + +class DeleteStoragePoolRequest(proto.Message): + r"""DeleteStoragePoolRequest deletes a Storage Pool. + + Attributes: + name (str): + Required. Name of the storage pool + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class SwitchActiveReplicaZoneRequest(proto.Message): + r"""SwitchActiveReplicaZoneRequest switch the active/replica zone + for a regional storagePool. + + Attributes: + name (str): + Required. Name of the storage pool + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class StoragePool(proto.Message): + r"""StoragePool is a container for volumes with a service level + and capacity. Volumes can be created in a pool of sufficient + available capacity. StoragePool capacity is what you are billed + for. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + name (str): + Identifier. Name of the storage pool + service_level (google.cloud.netapp_v1.types.ServiceLevel): + Required. Service level of the storage pool + capacity_gib (int): + Required. Capacity in GIB of the pool + volume_capacity_gib (int): + Output only. Allocated size of all volumes in + GIB in the storage pool + volume_count (int): + Output only. Volume count of the storage pool + state (google.cloud.netapp_v1.types.StoragePool.State): + Output only. State of the storage pool + state_details (str): + Output only. State details of the storage + pool + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Create time of the storage pool + description (str): + Optional. Description of the storage pool + labels (MutableMapping[str, str]): + Optional. Labels as key value pairs + network (str): + Required. VPC Network name. + Format: + projects/{project}/global/networks/{network} + active_directory (str): + Optional. Specifies the Active Directory to + be used for creating a SMB volume. + kms_config (str): + Optional. Specifies the KMS config to be used + for volume encryption. + ldap_enabled (bool): + Optional. Flag indicating if the pool is NFS + LDAP enabled or not. + psa_range (str): + Optional. This field is not implemented. The + values provided in this field are ignored. + encryption_type (google.cloud.netapp_v1.types.EncryptionType): + Output only. Specifies the current pool + encryption key source. + global_access_allowed (bool): + Deprecated. Used to allow SO pool to access + AD or DNS server from other regions. + + This field is a member of `oneof`_ ``_global_access_allowed``. + allow_auto_tiering (bool): + Optional. True if the storage pool supports + Auto Tiering enabled volumes. Default is false. + Auto-tiering can be enabled after storage pool + creation but it can't be disabled once enabled. + replica_zone (str): + Optional. Specifies the replica zone for + regional storagePool. + zone (str): + Optional. Specifies the active zone for + regional storagePool. + satisfies_pzs (bool): + Output only. Reserved for future use + satisfies_pzi (bool): + Output only. Reserved for future use + """ + class State(proto.Enum): + r"""The Storage Pool States + + Values: + STATE_UNSPECIFIED (0): + Unspecified Storage Pool State + READY (1): + Storage Pool State is Ready + CREATING (2): + Storage Pool State is Creating + DELETING (3): + Storage Pool State is Deleting + UPDATING (4): + Storage Pool State is Updating + RESTORING (5): + Storage Pool State is Restoring + DISABLED (6): + Storage Pool State is Disabled + ERROR (7): + Storage Pool State is Error + """ + STATE_UNSPECIFIED = 0 + READY = 1 + CREATING = 2 + DELETING = 3 + UPDATING = 4 + RESTORING = 5 + DISABLED = 6 + ERROR = 7 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + service_level: common.ServiceLevel = proto.Field( + proto.ENUM, + number=2, + enum=common.ServiceLevel, + ) + capacity_gib: int = proto.Field( + proto.INT64, + number=3, + ) + volume_capacity_gib: int = proto.Field( + proto.INT64, + number=4, + ) + volume_count: int = proto.Field( + proto.INT32, + number=5, + ) + state: State = proto.Field( + proto.ENUM, + number=6, + enum=State, + ) + state_details: str = proto.Field( + proto.STRING, + number=7, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) + description: str = proto.Field( + proto.STRING, + number=9, + ) + labels: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=10, + ) + network: str = proto.Field( + proto.STRING, + number=11, + ) + active_directory: str = proto.Field( + proto.STRING, + number=12, + ) + kms_config: str = proto.Field( + proto.STRING, + number=13, + ) + ldap_enabled: bool = proto.Field( + proto.BOOL, + number=14, + ) + psa_range: str = proto.Field( + proto.STRING, + number=15, + ) + encryption_type: common.EncryptionType = proto.Field( + proto.ENUM, + number=16, + enum=common.EncryptionType, + ) + global_access_allowed: bool = proto.Field( + proto.BOOL, + number=17, + optional=True, + ) + allow_auto_tiering: bool = proto.Field( + proto.BOOL, + number=18, + ) + replica_zone: str = proto.Field( + proto.STRING, + number=20, + ) + zone: str = proto.Field( + proto.STRING, + number=21, + ) + satisfies_pzs: bool = proto.Field( + proto.BOOL, + number=23, + ) + satisfies_pzi: bool = proto.Field( + proto.BOOL, + number=24, + ) + + +class ValidateDirectoryServiceRequest(proto.Message): + r"""ValidateDirectoryServiceRequest validates the directory + service policy attached to the storage pool. + + Attributes: + name (str): + Required. Name of the storage pool + directory_service_type (google.cloud.netapp_v1.types.DirectoryServiceType): + Type of directory service policy attached to + the storage pool. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + directory_service_type: common.DirectoryServiceType = proto.Field( + proto.ENUM, + number=2, + enum=common.DirectoryServiceType, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/volume.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/volume.py new file mode 100644 index 000000000000..2e4febc008e5 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/volume.py @@ -0,0 +1,1322 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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.netapp_v1.types import common +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.netapp.v1', + manifest={ + 'Protocols', + 'AccessType', + 'SMBSettings', + 'SecurityStyle', + 'RestrictedAction', + 'ListVolumesRequest', + 'ListVolumesResponse', + 'GetVolumeRequest', + 'CreateVolumeRequest', + 'UpdateVolumeRequest', + 'DeleteVolumeRequest', + 'RevertVolumeRequest', + 'Volume', + 'ExportPolicy', + 'SimpleExportPolicyRule', + 'SnapshotPolicy', + 'HourlySchedule', + 'DailySchedule', + 'WeeklySchedule', + 'MonthlySchedule', + 'MountOption', + 'RestoreParameters', + 'BackupConfig', + 'TieringPolicy', + 'HybridReplicationParameters', + }, +) + + +class Protocols(proto.Enum): + r"""Protocols is an enum of all the supported network protocols + for a volume. + + Values: + PROTOCOLS_UNSPECIFIED (0): + Unspecified protocol + NFSV3 (1): + NFS V3 protocol + NFSV4 (2): + NFS V4 protocol + SMB (3): + SMB protocol + """ + PROTOCOLS_UNSPECIFIED = 0 + NFSV3 = 1 + NFSV4 = 2 + SMB = 3 + + +class AccessType(proto.Enum): + r"""AccessType is an enum of all the supported access types for a + volume. + + Values: + ACCESS_TYPE_UNSPECIFIED (0): + Unspecified Access Type + READ_ONLY (1): + Read Only + READ_WRITE (2): + Read Write + READ_NONE (3): + None + """ + ACCESS_TYPE_UNSPECIFIED = 0 + READ_ONLY = 1 + READ_WRITE = 2 + READ_NONE = 3 + + +class SMBSettings(proto.Enum): + r"""SMBSettings + Modifies the behaviour of a SMB volume. + + Values: + SMB_SETTINGS_UNSPECIFIED (0): + Unspecified default option + ENCRYPT_DATA (1): + SMB setting encrypt data + BROWSABLE (2): + SMB setting browsable + CHANGE_NOTIFY (3): + SMB setting notify change + NON_BROWSABLE (4): + SMB setting not to notify change + OPLOCKS (5): + SMB setting oplocks + SHOW_SNAPSHOT (6): + SMB setting to show snapshots + SHOW_PREVIOUS_VERSIONS (7): + SMB setting to show previous versions + ACCESS_BASED_ENUMERATION (8): + SMB setting to access volume based on + enumerartion + CONTINUOUSLY_AVAILABLE (9): + Continuously available enumeration + """ + SMB_SETTINGS_UNSPECIFIED = 0 + ENCRYPT_DATA = 1 + BROWSABLE = 2 + CHANGE_NOTIFY = 3 + NON_BROWSABLE = 4 + OPLOCKS = 5 + SHOW_SNAPSHOT = 6 + SHOW_PREVIOUS_VERSIONS = 7 + ACCESS_BASED_ENUMERATION = 8 + CONTINUOUSLY_AVAILABLE = 9 + + +class SecurityStyle(proto.Enum): + r"""The security style of the volume, can be either UNIX or NTFS. + + Values: + SECURITY_STYLE_UNSPECIFIED (0): + SecurityStyle is unspecified + NTFS (1): + SecurityStyle uses NTFS + UNIX (2): + SecurityStyle uses UNIX + """ + SECURITY_STYLE_UNSPECIFIED = 0 + NTFS = 1 + UNIX = 2 + + +class RestrictedAction(proto.Enum): + r"""Actions to be restricted for a volume. + + Values: + RESTRICTED_ACTION_UNSPECIFIED (0): + Unspecified restricted action + DELETE (1): + Prevent volume from being deleted when + mounted. + """ + RESTRICTED_ACTION_UNSPECIFIED = 0 + DELETE = 1 + + +class ListVolumesRequest(proto.Message): + r"""Message for requesting list of Volumes + + Attributes: + parent (str): + Required. Parent value for ListVolumesRequest + page_size (int): + Requested page size. Server may return fewer + items than requested. If unspecified, the server + will pick an appropriate default. + page_token (str): + A token identifying a page of results the + server should return. + filter (str): + Filtering results + order_by (str): + Hint for how to order the results + """ + + 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 ListVolumesResponse(proto.Message): + r"""Message for response to listing Volumes + + Attributes: + volumes (MutableSequence[google.cloud.netapp_v1.types.Volume]): + The list of Volume + next_page_token (str): + A token identifying a page of results the + server should return. + unreachable (MutableSequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + volumes: MutableSequence['Volume'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='Volume', + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class GetVolumeRequest(proto.Message): + r"""Message for getting a Volume + + Attributes: + name (str): + Required. Name of the volume + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateVolumeRequest(proto.Message): + r"""Message for creating a Volume + + Attributes: + parent (str): + Required. Value for parent. + volume_id (str): + Required. Id of the requesting volume. Must + be unique within the parent resource. Must + contain only letters, numbers and hyphen, with + the first character a letter, the last a letter + or a number, and a 63 character maximum. + volume (google.cloud.netapp_v1.types.Volume): + Required. The volume being created. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + volume_id: str = proto.Field( + proto.STRING, + number=2, + ) + volume: 'Volume' = proto.Field( + proto.MESSAGE, + number=3, + message='Volume', + ) + + +class UpdateVolumeRequest(proto.Message): + r"""Message for updating a Volume + + Attributes: + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Field mask is used to specify the fields to be + overwritten in the Volume resource by the update. The fields + specified in the update_mask are relative to the resource, + not the full request. A field will be overwritten if it is + in the mask. If the user does not provide a mask then all + fields will be overwritten. + volume (google.cloud.netapp_v1.types.Volume): + Required. The volume being updated + """ + + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=1, + message=field_mask_pb2.FieldMask, + ) + volume: 'Volume' = proto.Field( + proto.MESSAGE, + number=2, + message='Volume', + ) + + +class DeleteVolumeRequest(proto.Message): + r"""Message for deleting a Volume + + Attributes: + name (str): + Required. Name of the volume + force (bool): + If this field is set as true, CCFE will not + block the volume resource deletion even if it + has any snapshots resource. (Otherwise, the + request will only work if the volume has no + snapshots.) + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + force: bool = proto.Field( + proto.BOOL, + number=2, + ) + + +class RevertVolumeRequest(proto.Message): + r"""RevertVolumeRequest reverts the given volume to the specified + snapshot. + + Attributes: + name (str): + Required. The resource name of the volume, in the format of + projects/{project_id}/locations/{location}/volumes/{volume_id}. + snapshot_id (str): + Required. The snapshot resource ID, in the format + 'my-snapshot', where the specified ID is the {snapshot_id} + of the fully qualified name like + projects/{project_id}/locations/{location_id}/volumes/{volume_id}/snapshots/{snapshot_id} + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + snapshot_id: str = proto.Field( + proto.STRING, + number=2, + ) + + +class Volume(proto.Message): + r"""Volume provides a filesystem that you can mount. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + name (str): + Identifier. Name of the volume + state (google.cloud.netapp_v1.types.Volume.State): + Output only. State of the volume + state_details (str): + Output only. State details of the volume + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Create time of the volume + share_name (str): + Required. Share name of the volume + psa_range (str): + Output only. This field is not implemented. + The values provided in this field are ignored. + storage_pool (str): + Required. StoragePool name of the volume + network (str): + Output only. VPC Network name. + Format: + projects/{project}/global/networks/{network} + service_level (google.cloud.netapp_v1.types.ServiceLevel): + Output only. Service level of the volume + capacity_gib (int): + Required. Capacity in GIB of the volume + export_policy (google.cloud.netapp_v1.types.ExportPolicy): + Optional. Export policy of the volume + protocols (MutableSequence[google.cloud.netapp_v1.types.Protocols]): + Required. Protocols required for the volume + smb_settings (MutableSequence[google.cloud.netapp_v1.types.SMBSettings]): + Optional. SMB share settings for the volume. + mount_options (MutableSequence[google.cloud.netapp_v1.types.MountOption]): + Output only. Mount options of this volume + unix_permissions (str): + Optional. Default unix style permission (e.g. + 777) the mount point will be created with. + Applicable for NFS protocol types only. + labels (MutableMapping[str, str]): + Optional. Labels as key value pairs + description (str): + Optional. Description of the volume + snapshot_policy (google.cloud.netapp_v1.types.SnapshotPolicy): + Optional. SnapshotPolicy for a volume. + snap_reserve (float): + Optional. Snap_reserve specifies percentage of volume + storage reserved for snapshot storage. Default is 0 percent. + snapshot_directory (bool): + Optional. Snapshot_directory if enabled (true) the volume + will contain a read-only .snapshot directory which provides + access to each of the volume's snapshots. + used_gib (int): + Output only. Used capacity in GIB of the + volume. This is computed periodically and it + does not represent the realtime usage. + security_style (google.cloud.netapp_v1.types.SecurityStyle): + Optional. Security Style of the Volume + kerberos_enabled (bool): + Optional. Flag indicating if the volume is a + kerberos volume or not, export policy rules + control kerberos security modes (krb5, krb5i, + krb5p). + ldap_enabled (bool): + Output only. Flag indicating if the volume is + NFS LDAP enabled or not. + active_directory (str): + Output only. Specifies the ActiveDirectory + name of a SMB volume. + restore_parameters (google.cloud.netapp_v1.types.RestoreParameters): + Optional. Specifies the source of the volume + to be created from. + kms_config (str): + Output only. Specifies the KMS config to be + used for volume encryption. + encryption_type (google.cloud.netapp_v1.types.EncryptionType): + Output only. Specified the current volume + encryption key source. + has_replication (bool): + Output only. Indicates whether the volume is + part of a replication relationship. + backup_config (google.cloud.netapp_v1.types.BackupConfig): + BackupConfig of the volume. + + This field is a member of `oneof`_ ``_backup_config``. + restricted_actions (MutableSequence[google.cloud.netapp_v1.types.RestrictedAction]): + Optional. List of actions that are restricted + on this volume. + large_capacity (bool): + Optional. Flag indicating if the volume will + be a large capacity volume or a regular volume. + multiple_endpoints (bool): + Optional. Flag indicating if the volume will have an IP + address per node for volumes supporting multiple IP + endpoints. Only the volume with large_capacity will be + allowed to have multiple endpoints. + tiering_policy (google.cloud.netapp_v1.types.TieringPolicy): + Tiering policy for the volume. + + This field is a member of `oneof`_ ``_tiering_policy``. + replica_zone (str): + Output only. Specifies the replica zone for + regional volume. + zone (str): + Output only. Specifies the active zone for + regional volume. + cold_tier_size_gib (int): + Output only. Size of the volume cold tier + data in GiB. + hybrid_replication_parameters (google.cloud.netapp_v1.types.HybridReplicationParameters): + Optional. The Hybrid Replication parameters + for the volume. + """ + class State(proto.Enum): + r"""The volume states + + Values: + STATE_UNSPECIFIED (0): + Unspecified Volume State + READY (1): + Volume State is Ready + CREATING (2): + Volume State is Creating + DELETING (3): + Volume State is Deleting + UPDATING (4): + Volume State is Updating + RESTORING (5): + Volume State is Restoring + DISABLED (6): + Volume State is Disabled + ERROR (7): + Volume State is Error + PREPARING (8): + Volume State is Preparing. Note that this is + different from CREATING where CREATING means the + volume is being created, while PREPARING means + the volume is created and now being prepared for + the replication. + READ_ONLY (9): + Volume State is Read Only + """ + STATE_UNSPECIFIED = 0 + READY = 1 + CREATING = 2 + DELETING = 3 + UPDATING = 4 + RESTORING = 5 + DISABLED = 6 + ERROR = 7 + PREPARING = 8 + READ_ONLY = 9 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + state: State = proto.Field( + proto.ENUM, + number=2, + enum=State, + ) + state_details: str = proto.Field( + proto.STRING, + number=3, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + share_name: str = proto.Field( + proto.STRING, + number=5, + ) + psa_range: str = proto.Field( + proto.STRING, + number=6, + ) + storage_pool: str = proto.Field( + proto.STRING, + number=7, + ) + network: str = proto.Field( + proto.STRING, + number=8, + ) + service_level: common.ServiceLevel = proto.Field( + proto.ENUM, + number=9, + enum=common.ServiceLevel, + ) + capacity_gib: int = proto.Field( + proto.INT64, + number=10, + ) + export_policy: 'ExportPolicy' = proto.Field( + proto.MESSAGE, + number=11, + message='ExportPolicy', + ) + protocols: MutableSequence['Protocols'] = proto.RepeatedField( + proto.ENUM, + number=12, + enum='Protocols', + ) + smb_settings: MutableSequence['SMBSettings'] = proto.RepeatedField( + proto.ENUM, + number=13, + enum='SMBSettings', + ) + mount_options: MutableSequence['MountOption'] = proto.RepeatedField( + proto.MESSAGE, + number=14, + message='MountOption', + ) + unix_permissions: str = proto.Field( + proto.STRING, + number=15, + ) + labels: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=16, + ) + description: str = proto.Field( + proto.STRING, + number=17, + ) + snapshot_policy: 'SnapshotPolicy' = proto.Field( + proto.MESSAGE, + number=18, + message='SnapshotPolicy', + ) + snap_reserve: float = proto.Field( + proto.DOUBLE, + number=19, + ) + snapshot_directory: bool = proto.Field( + proto.BOOL, + number=20, + ) + used_gib: int = proto.Field( + proto.INT64, + number=21, + ) + security_style: 'SecurityStyle' = proto.Field( + proto.ENUM, + number=22, + enum='SecurityStyle', + ) + kerberos_enabled: bool = proto.Field( + proto.BOOL, + number=23, + ) + ldap_enabled: bool = proto.Field( + proto.BOOL, + number=24, + ) + active_directory: str = proto.Field( + proto.STRING, + number=25, + ) + restore_parameters: 'RestoreParameters' = proto.Field( + proto.MESSAGE, + number=26, + message='RestoreParameters', + ) + kms_config: str = proto.Field( + proto.STRING, + number=27, + ) + encryption_type: common.EncryptionType = proto.Field( + proto.ENUM, + number=28, + enum=common.EncryptionType, + ) + has_replication: bool = proto.Field( + proto.BOOL, + number=29, + ) + backup_config: 'BackupConfig' = proto.Field( + proto.MESSAGE, + number=30, + optional=True, + message='BackupConfig', + ) + restricted_actions: MutableSequence['RestrictedAction'] = proto.RepeatedField( + proto.ENUM, + number=31, + enum='RestrictedAction', + ) + large_capacity: bool = proto.Field( + proto.BOOL, + number=32, + ) + multiple_endpoints: bool = proto.Field( + proto.BOOL, + number=33, + ) + tiering_policy: 'TieringPolicy' = proto.Field( + proto.MESSAGE, + number=34, + optional=True, + message='TieringPolicy', + ) + replica_zone: str = proto.Field( + proto.STRING, + number=36, + ) + zone: str = proto.Field( + proto.STRING, + number=37, + ) + cold_tier_size_gib: int = proto.Field( + proto.INT64, + number=39, + ) + hybrid_replication_parameters: 'HybridReplicationParameters' = proto.Field( + proto.MESSAGE, + number=40, + message='HybridReplicationParameters', + ) + + +class ExportPolicy(proto.Message): + r"""Defines the export policy for the volume. + + Attributes: + rules (MutableSequence[google.cloud.netapp_v1.types.SimpleExportPolicyRule]): + Required. List of export policy rules + """ + + rules: MutableSequence['SimpleExportPolicyRule'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='SimpleExportPolicyRule', + ) + + +class SimpleExportPolicyRule(proto.Message): + r"""An export policy rule describing various export options. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + allowed_clients (str): + Comma separated list of allowed clients IP + addresses + + This field is a member of `oneof`_ ``_allowed_clients``. + has_root_access (str): + Whether Unix root access will be granted. + + This field is a member of `oneof`_ ``_has_root_access``. + access_type (google.cloud.netapp_v1.types.AccessType): + Access type (ReadWrite, ReadOnly, None) + + This field is a member of `oneof`_ ``_access_type``. + nfsv3 (bool): + NFS V3 protocol. + + This field is a member of `oneof`_ ``_nfsv3``. + nfsv4 (bool): + NFS V4 protocol. + + This field is a member of `oneof`_ ``_nfsv4``. + kerberos_5_read_only (bool): + If enabled (true) the rule defines a read + only access for clients matching the + 'allowedClients' specification. It enables nfs + clients to mount using 'authentication' kerberos + security mode. + + This field is a member of `oneof`_ ``_kerberos_5_read_only``. + kerberos_5_read_write (bool): + If enabled (true) the rule defines read and + write access for clients matching the + 'allowedClients' specification. It enables nfs + clients to mount using 'authentication' kerberos + security mode. The 'kerberos5ReadOnly' value be + ignored if this is enabled. + + This field is a member of `oneof`_ ``_kerberos_5_read_write``. + kerberos_5i_read_only (bool): + If enabled (true) the rule defines a read + only access for clients matching the + 'allowedClients' specification. It enables nfs + clients to mount using 'integrity' kerberos + security mode. + + This field is a member of `oneof`_ ``_kerberos_5i_read_only``. + kerberos_5i_read_write (bool): + If enabled (true) the rule defines read and + write access for clients matching the + 'allowedClients' specification. It enables nfs + clients to mount using 'integrity' kerberos + security mode. The 'kerberos5iReadOnly' value be + ignored if this is enabled. + + This field is a member of `oneof`_ ``_kerberos_5i_read_write``. + kerberos_5p_read_only (bool): + If enabled (true) the rule defines a read + only access for clients matching the + 'allowedClients' specification. It enables nfs + clients to mount using 'privacy' kerberos + security mode. + + This field is a member of `oneof`_ ``_kerberos_5p_read_only``. + kerberos_5p_read_write (bool): + If enabled (true) the rule defines read and + write access for clients matching the + 'allowedClients' specification. It enables nfs + clients to mount using 'privacy' kerberos + security mode. The 'kerberos5pReadOnly' value be + ignored if this is enabled. + + This field is a member of `oneof`_ ``_kerberos_5p_read_write``. + """ + + allowed_clients: str = proto.Field( + proto.STRING, + number=1, + optional=True, + ) + has_root_access: str = proto.Field( + proto.STRING, + number=2, + optional=True, + ) + access_type: 'AccessType' = proto.Field( + proto.ENUM, + number=3, + optional=True, + enum='AccessType', + ) + nfsv3: bool = proto.Field( + proto.BOOL, + number=4, + optional=True, + ) + nfsv4: bool = proto.Field( + proto.BOOL, + number=5, + optional=True, + ) + kerberos_5_read_only: bool = proto.Field( + proto.BOOL, + number=6, + optional=True, + ) + kerberos_5_read_write: bool = proto.Field( + proto.BOOL, + number=7, + optional=True, + ) + kerberos_5i_read_only: bool = proto.Field( + proto.BOOL, + number=8, + optional=True, + ) + kerberos_5i_read_write: bool = proto.Field( + proto.BOOL, + number=9, + optional=True, + ) + kerberos_5p_read_only: bool = proto.Field( + proto.BOOL, + number=10, + optional=True, + ) + kerberos_5p_read_write: bool = proto.Field( + proto.BOOL, + number=11, + optional=True, + ) + + +class SnapshotPolicy(proto.Message): + r"""Snapshot Policy for a volume. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + enabled (bool): + If enabled, make snapshots automatically + according to the schedules. Default is false. + + This field is a member of `oneof`_ ``_enabled``. + hourly_schedule (google.cloud.netapp_v1.types.HourlySchedule): + Hourly schedule policy. + + This field is a member of `oneof`_ ``_hourly_schedule``. + daily_schedule (google.cloud.netapp_v1.types.DailySchedule): + Daily schedule policy. + + This field is a member of `oneof`_ ``_daily_schedule``. + weekly_schedule (google.cloud.netapp_v1.types.WeeklySchedule): + Weekly schedule policy. + + This field is a member of `oneof`_ ``_weekly_schedule``. + monthly_schedule (google.cloud.netapp_v1.types.MonthlySchedule): + Monthly schedule policy. + + This field is a member of `oneof`_ ``_monthly_schedule``. + """ + + enabled: bool = proto.Field( + proto.BOOL, + number=1, + optional=True, + ) + hourly_schedule: 'HourlySchedule' = proto.Field( + proto.MESSAGE, + number=2, + optional=True, + message='HourlySchedule', + ) + daily_schedule: 'DailySchedule' = proto.Field( + proto.MESSAGE, + number=3, + optional=True, + message='DailySchedule', + ) + weekly_schedule: 'WeeklySchedule' = proto.Field( + proto.MESSAGE, + number=4, + optional=True, + message='WeeklySchedule', + ) + monthly_schedule: 'MonthlySchedule' = proto.Field( + proto.MESSAGE, + number=5, + optional=True, + message='MonthlySchedule', + ) + + +class HourlySchedule(proto.Message): + r"""Make a snapshot every hour e.g. at 04:00, 05:00, 06:00. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + snapshots_to_keep (float): + The maximum number of Snapshots to keep for + the hourly schedule + + This field is a member of `oneof`_ ``_snapshots_to_keep``. + minute (float): + Set the minute of the hour to start the + snapshot (0-59), defaults to the top of the hour + (0). + + This field is a member of `oneof`_ ``_minute``. + """ + + snapshots_to_keep: float = proto.Field( + proto.DOUBLE, + number=1, + optional=True, + ) + minute: float = proto.Field( + proto.DOUBLE, + number=2, + optional=True, + ) + + +class DailySchedule(proto.Message): + r"""Make a snapshot every day e.g. at 04:00, 05:20, 23:50 + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + snapshots_to_keep (float): + The maximum number of Snapshots to keep for + the hourly schedule + + This field is a member of `oneof`_ ``_snapshots_to_keep``. + minute (float): + Set the minute of the hour to start the + snapshot (0-59), defaults to the top of the hour + (0). + + This field is a member of `oneof`_ ``_minute``. + hour (float): + Set the hour to start the snapshot (0-23), + defaults to midnight (0). + + This field is a member of `oneof`_ ``_hour``. + """ + + snapshots_to_keep: float = proto.Field( + proto.DOUBLE, + number=1, + optional=True, + ) + minute: float = proto.Field( + proto.DOUBLE, + number=2, + optional=True, + ) + hour: float = proto.Field( + proto.DOUBLE, + number=3, + optional=True, + ) + + +class WeeklySchedule(proto.Message): + r"""Make a snapshot every week e.g. at Monday 04:00, Wednesday + 05:20, Sunday 23:50 + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + snapshots_to_keep (float): + The maximum number of Snapshots to keep for + the hourly schedule + + This field is a member of `oneof`_ ``_snapshots_to_keep``. + minute (float): + Set the minute of the hour to start the + snapshot (0-59), defaults to the top of the hour + (0). + + This field is a member of `oneof`_ ``_minute``. + hour (float): + Set the hour to start the snapshot (0-23), + defaults to midnight (0). + + This field is a member of `oneof`_ ``_hour``. + day (str): + Set the day or days of the week to make a + snapshot. Accepts a comma separated days of the + week. Defaults to 'Sunday'. + + This field is a member of `oneof`_ ``_day``. + """ + + snapshots_to_keep: float = proto.Field( + proto.DOUBLE, + number=1, + optional=True, + ) + minute: float = proto.Field( + proto.DOUBLE, + number=2, + optional=True, + ) + hour: float = proto.Field( + proto.DOUBLE, + number=3, + optional=True, + ) + day: str = proto.Field( + proto.STRING, + number=4, + optional=True, + ) + + +class MonthlySchedule(proto.Message): + r"""Make a snapshot once a month e.g. at 2nd 04:00, 7th 05:20, + 24th 23:50 + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + snapshots_to_keep (float): + The maximum number of Snapshots to keep for + the hourly schedule + + This field is a member of `oneof`_ ``_snapshots_to_keep``. + minute (float): + Set the minute of the hour to start the + snapshot (0-59), defaults to the top of the hour + (0). + + This field is a member of `oneof`_ ``_minute``. + hour (float): + Set the hour to start the snapshot (0-23), + defaults to midnight (0). + + This field is a member of `oneof`_ ``_hour``. + days_of_month (str): + Set the day or days of the month to make a + snapshot (1-31). Accepts a comma separated + number of days. Defaults to '1'. + + This field is a member of `oneof`_ ``_days_of_month``. + """ + + snapshots_to_keep: float = proto.Field( + proto.DOUBLE, + number=1, + optional=True, + ) + minute: float = proto.Field( + proto.DOUBLE, + number=2, + optional=True, + ) + hour: float = proto.Field( + proto.DOUBLE, + number=3, + optional=True, + ) + days_of_month: str = proto.Field( + proto.STRING, + number=4, + optional=True, + ) + + +class MountOption(proto.Message): + r"""View only mount options for a volume. + + Attributes: + export (str): + Export string + export_full (str): + Full export string + protocol (google.cloud.netapp_v1.types.Protocols): + Protocol to mount with. + instructions (str): + Instructions for mounting + ip_address (str): + Output only. IP Address. + """ + + export: str = proto.Field( + proto.STRING, + number=1, + ) + export_full: str = proto.Field( + proto.STRING, + number=2, + ) + protocol: 'Protocols' = proto.Field( + proto.ENUM, + number=3, + enum='Protocols', + ) + instructions: str = proto.Field( + proto.STRING, + number=4, + ) + ip_address: str = proto.Field( + proto.STRING, + number=5, + ) + + +class RestoreParameters(proto.Message): + r"""The RestoreParameters if volume is created from a snapshot or + backup. + + 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: + source_snapshot (str): + Full name of the snapshot resource. + Format: + + projects/{project}/locations/{location}/volumes/{volume}/snapshots/{snapshot} + + This field is a member of `oneof`_ ``source``. + source_backup (str): + Full name of the backup resource. Format: + projects/{project}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id} + + This field is a member of `oneof`_ ``source``. + """ + + source_snapshot: str = proto.Field( + proto.STRING, + number=1, + oneof='source', + ) + source_backup: str = proto.Field( + proto.STRING, + number=2, + oneof='source', + ) + + +class BackupConfig(proto.Message): + r"""BackupConfig contains backup related config on a volume. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + backup_policies (MutableSequence[str]): + Optional. When specified, schedule backups + will be created based on the policy + configuration. + backup_vault (str): + Optional. Name of backup vault. Format: + projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id} + scheduled_backup_enabled (bool): + Optional. When set to true, scheduled backup + is enabled on the volume. This field should be + nil when there's no backup policy attached. + + This field is a member of `oneof`_ ``_scheduled_backup_enabled``. + backup_chain_bytes (int): + Output only. Total size of all backups in a + chain in bytes = baseline backup size + + sum(incremental backup size). + + This field is a member of `oneof`_ ``_backup_chain_bytes``. + """ + + backup_policies: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=1, + ) + backup_vault: str = proto.Field( + proto.STRING, + number=2, + ) + scheduled_backup_enabled: bool = proto.Field( + proto.BOOL, + number=3, + optional=True, + ) + backup_chain_bytes: int = proto.Field( + proto.INT64, + number=4, + optional=True, + ) + + +class TieringPolicy(proto.Message): + r"""Defines tiering policy for the volume. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + tier_action (google.cloud.netapp_v1.types.TieringPolicy.TierAction): + Optional. Flag indicating if the volume has + tiering policy enable/pause. Default is PAUSED. + + This field is a member of `oneof`_ ``_tier_action``. + cooling_threshold_days (int): + Optional. Time in days to mark the volume's + data block as cold and make it eligible for + tiering, can be range from 2-183. Default is 31. + + This field is a member of `oneof`_ ``_cooling_threshold_days``. + """ + class TierAction(proto.Enum): + r"""Tier action for the volume. + + Values: + TIER_ACTION_UNSPECIFIED (0): + Unspecified. + ENABLED (1): + When tiering is enabled, new cold data will + be tiered. + PAUSED (2): + When paused, tiering won't be performed on + new data. Existing data stays tiered until + accessed. + """ + TIER_ACTION_UNSPECIFIED = 0 + ENABLED = 1 + PAUSED = 2 + + tier_action: TierAction = proto.Field( + proto.ENUM, + number=1, + optional=True, + enum=TierAction, + ) + cooling_threshold_days: int = proto.Field( + proto.INT32, + number=2, + optional=True, + ) + + +class HybridReplicationParameters(proto.Message): + r"""The Hybrid Replication parameters for the volume. + + Attributes: + replication (str): + Required. Desired name for the replication of + this volume. + peer_volume_name (str): + Required. Name of the user's local source + volume to be peered with the destination volume. + peer_cluster_name (str): + Required. Name of the user's local source + cluster to be peered with the destination + cluster. + peer_svm_name (str): + Required. Name of the user's local source + vserver svm to be peered with the destination + vserver svm. + peer_ip_addresses (MutableSequence[str]): + Required. List of node ip addresses to be + peered with. + cluster_location (str): + Optional. Name of source cluster location + associated with the Hybrid replication. This is + a free-form field for the display purpose only. + description (str): + Optional. Description of the replication. + labels (MutableMapping[str, str]): + Optional. Labels to be added to the + replication as the key value pairs. + """ + + replication: str = proto.Field( + proto.STRING, + number=1, + ) + peer_volume_name: str = proto.Field( + proto.STRING, + number=2, + ) + peer_cluster_name: str = proto.Field( + proto.STRING, + number=3, + ) + peer_svm_name: str = proto.Field( + proto.STRING, + number=4, + ) + peer_ip_addresses: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=5, + ) + cluster_location: str = proto.Field( + proto.STRING, + number=6, + ) + description: str = proto.Field( + proto.STRING, + number=7, + ) + labels: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=8, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/mypy.ini b/owl-bot-staging/google-cloud-netapp/v1/mypy.ini new file mode 100644 index 000000000000..574c5aed394b --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/mypy.ini @@ -0,0 +1,3 @@ +[mypy] +python_version = 3.7 +namespace_packages = True diff --git a/owl-bot-staging/google-cloud-netapp/v1/noxfile.py b/owl-bot-staging/google-cloud-netapp/v1/noxfile.py new file mode 100644 index 000000000000..2cfb1a836588 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/noxfile.py @@ -0,0 +1,591 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 + +from typing import Dict, List +import warnings + +import nox + +BLACK_VERSION = "black[jupyter]==23.7.0" +ISORT_VERSION = "isort==5.11.0" + +LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] + +ALL_PYTHON = [ + "3.7", + "3.8", + "3.9", + "3.10", + "3.11", + "3.12", + "3.13", +] + +DEFAULT_PYTHON_VERSION = ALL_PYTHON[-1] + +CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() + +LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" +PACKAGE_NAME = "google-cloud-netapp" + +UNIT_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "asyncmock", + "pytest", + "pytest-cov", + "pytest-asyncio", +] +UNIT_TEST_EXTERNAL_DEPENDENCIES: List[str] = [] +UNIT_TEST_LOCAL_DEPENDENCIES: List[str] = [] +UNIT_TEST_DEPENDENCIES: List[str] = [] +UNIT_TEST_EXTRAS: List[str] = [] +UNIT_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {} + +SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] +SYSTEM_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "pytest", + "google-cloud-testutils", +] +SYSTEM_TEST_EXTERNAL_DEPENDENCIES: List[str] = [] +SYSTEM_TEST_LOCAL_DEPENDENCIES: List[str] = [] +SYSTEM_TEST_DEPENDENCIES: List[str] = [] +SYSTEM_TEST_EXTRAS: List[str] = [] +SYSTEM_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {} + +nox.options.sessions = [ + "unit", + "system", + "cover", + "lint", + "lint_setup_py", + "blacken", + "docs", +] + +# Error if a python version is missing +nox.options.error_on_missing_interpreters = True + + +@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 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", + *LINT_PATHS, + ) + + session.run("flake8", "google", "tests") + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def blacken(session): + """Run black. Format code to uniform standard.""" + session.install(BLACK_VERSION) + session.run( + "black", + *LINT_PATHS, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def format(session): + """ + Run isort to sort imports. Then run black + to format code to uniform standard. + """ + session.install(BLACK_VERSION, ISORT_VERSION) + # Use the --fss option to sort imports using strict alphabetical order. + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections + session.run( + "isort", + "--fss", + *LINT_PATHS, + ) + session.run( + "black", + *LINT_PATHS, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def lint_setup_py(session): + """Verify that setup.py is valid (including RST check).""" + session.install("setuptools", "docutils", "pygments") + session.run("python", "setup.py", "check", "--restructuredtext", "--strict") + + +def install_unittest_dependencies(session, *constraints): + standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES + session.install(*standard_deps, *constraints) + + if UNIT_TEST_EXTERNAL_DEPENDENCIES: + warnings.warn( + "'unit_test_external_dependencies' is deprecated. Instead, please " + "use 'unit_test_dependencies' or 'unit_test_local_dependencies'.", + DeprecationWarning, + ) + session.install(*UNIT_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_LOCAL_DEPENDENCIES: + session.install(*UNIT_TEST_LOCAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_EXTRAS_BY_PYTHON: + extras = UNIT_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif UNIT_TEST_EXTRAS: + extras = UNIT_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + +@nox.session(python=ALL_PYTHON) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def unit(session, protobuf_implementation): + # Install all test dependencies, then install this package in-place. + + 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+") + + constraints_path = str( + CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" + ) + install_unittest_dependencies(session, "-c", constraints_path) + + # TODO(https://github.com/googleapis/synthtool/issues/1976): + # 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") + + # Run py.test against the unit tests. + session.run( + "py.test", + "--quiet", + f"--junitxml=unit_{session.python}_sponge_log.xml", + "--cov=google", + "--cov=tests/unit", + "--cov-append", + "--cov-config=.coveragerc", + "--cov-report=", + "--cov-fail-under=0", + os.path.join("tests", "unit"), + *session.posargs, + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) + + +def install_systemtest_dependencies(session, *constraints): + session.install("--pre", "grpcio") + + session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTERNAL_DEPENDENCIES: + session.install(*SYSTEM_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_LOCAL_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_LOCAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTRAS_BY_PYTHON: + extras = SYSTEM_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif SYSTEM_TEST_EXTRAS: + extras = SYSTEM_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + +@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) +def system(session): + """Run the system test suite.""" + constraints_path = str( + CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" + ) + system_test_path = os.path.join("tests", "system.py") + system_test_folder_path = os.path.join("tests", "system") + + # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true. + if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false": + session.skip("RUN_SYSTEM_TESTS is set to false, skipping") + # Install pyopenssl for mTLS testing. + if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true": + session.install("pyopenssl") + + system_test_exists = os.path.exists(system_test_path) + system_test_folder_exists = os.path.exists(system_test_folder_path) + # Sanity check: only run tests if found. + if not system_test_exists and not system_test_folder_exists: + session.skip("System tests were not found") + + install_systemtest_dependencies(session, "-c", constraints_path) + + # Run py.test against the system tests. + if system_test_exists: + session.run( + "py.test", + "--quiet", + f"--junitxml=system_{session.python}_sponge_log.xml", + system_test_path, + *session.posargs, + ) + if system_test_folder_exists: + session.run( + "py.test", + "--quiet", + f"--junitxml=system_{session.python}_sponge_log.xml", + system_test_folder_path, + *session.posargs, + ) + + +@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="3.10") +def docs(session): + """Build the docs for this library.""" + + session.install("-e", ".") + session.install( + # We need to pin to specific versions of the `sphinxcontrib-*` packages + # which still support sphinx 4.x. + # See https://github.com/googleapis/sphinx-docfx-yaml/issues/344 + # and https://github.com/googleapis/sphinx-docfx-yaml/issues/345. + "sphinxcontrib-applehelp==1.0.4", + "sphinxcontrib-devhelp==1.0.2", + "sphinxcontrib-htmlhelp==2.0.1", + "sphinxcontrib-qthelp==1.0.3", + "sphinxcontrib-serializinghtml==1.1.5", + "sphinx==4.5.0", + "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="3.10") +def docfx(session): + """Build the docfx yaml files for this library.""" + + session.install("-e", ".") + session.install( + # We need to pin to specific versions of the `sphinxcontrib-*` packages + # which still support sphinx 4.x. + # See https://github.com/googleapis/sphinx-docfx-yaml/issues/344 + # and https://github.com/googleapis/sphinx-docfx-yaml/issues/345. + "sphinxcontrib-applehelp==1.0.4", + "sphinxcontrib-devhelp==1.0.2", + "sphinxcontrib-htmlhelp==2.0.1", + "sphinxcontrib-qthelp==1.0.3", + "sphinxcontrib-serializinghtml==1.1.5", + "gcp-sphinx-docfx-yaml", + "alabaster", + "recommonmark", + ) + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-T", # show full traceback on exception + "-N", # no colors + "-D", + ( + "extensions=sphinx.ext.autodoc," + "sphinx.ext.autosummary," + "docfx_yaml.extension," + "sphinx.ext.intersphinx," + "sphinx.ext.coverage," + "sphinx.ext.napoleon," + "sphinx.ext.todo," + "sphinx.ext.viewcode," + "recommonmark" + ), + "-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) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def prerelease_deps(session, protobuf_implementation): + """ + Run all tests with pre-release versions of dependencies installed + rather than the standard non pre-release versions. + Pre-release versions can be installed using + `pip install --pre `. + """ + + 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 all dependencies + session.install("-e", ".") + + # Install dependencies for the unit test environment + unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES + session.install(*unit_deps_all) + + # Install dependencies for the system test environment + system_deps_all = ( + SYSTEM_TEST_STANDARD_DEPENDENCIES + + SYSTEM_TEST_EXTERNAL_DEPENDENCIES + + SYSTEM_TEST_EXTRAS + ) + session.install(*system_deps_all) + + # Because we test minimum dependency versions on the minimum Python + # version, the first version we test with in the unit tests sessions has a + # constraints file containing all 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 + ) + ] + + # Install dependencies specified in `testing/constraints-X.txt`. + session.install(*constraints_deps) + + # Note: If a dependency is added to the `prerel_deps` list, + # the `core_dependencies_from_source` list in the `core_deps_from_source` + # nox session should also be updated. + prerel_deps = [ + "googleapis-common-protos", + "google-api-core", + "google-auth", + "grpc-google-iam-v1", + "grpcio", + "grpcio-status", + "protobuf", + "proto-plus", + ] + + for dep in prerel_deps: + session.install("--pre", "--no-deps", "--ignore-installed", dep) + # TODO(https://github.com/grpc/grpc/issues/38965): Add `grpcio-status`` + # to the dictionary below once this bug is fixed. + # TODO(https://github.com/googleapis/google-cloud-python/issues/13643): Add + # `googleapis-common-protos` and `grpc-google-iam-v1` to the dictionary below + # once this bug is fixed. + package_namespaces = { + "google-api-core": "google.api_core", + "google-auth": "google.auth", + "grpcio": "grpc", + "protobuf": "google.protobuf", + "proto-plus": "proto", + } + + version_namespace = package_namespaces.get(dep) + + print(f"Installed {dep}") + if version_namespace: + session.run( + "python", + "-c", + f"import {version_namespace}; print({version_namespace}.__version__)", + ) + + session.run( + "py.test", + "tests/unit", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb"], +) +def core_deps_from_source(session, protobuf_implementation): + """Run all tests with core dependencies installed from source + rather than pulling the dependencies from PyPI. + """ + + # Install all dependencies + session.install("-e", ".") + + # Install dependencies for the unit test environment + unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES + session.install(*unit_deps_all) + + # Install dependencies for the system test environment + system_deps_all = ( + SYSTEM_TEST_STANDARD_DEPENDENCIES + + SYSTEM_TEST_EXTERNAL_DEPENDENCIES + + SYSTEM_TEST_EXTRAS + ) + session.install(*system_deps_all) + + # Because we test minimum dependency versions on the minimum Python + # version, the first version we test with in the unit tests sessions has a + # constraints file containing all 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 + ) + ] + + # Install dependencies specified in `testing/constraints-X.txt`. + session.install(*constraints_deps) + + # TODO(https://github.com/googleapis/gapic-generator-python/issues/2358): `grpcio` and + # `grpcio-status` should be added to the list below so that they are installed from source, + # rather than PyPI. + # TODO(https://github.com/googleapis/gapic-generator-python/issues/2357): `protobuf` should be + # added to the list below so that it is installed from source, rather than PyPI + # Note: If a dependency is added to the `core_dependencies_from_source` list, + # the `prerel_deps` list in the `prerelease_deps` nox session should also be updated. + core_dependencies_from_source = [ + "googleapis-common-protos @ git+https://github.com/googleapis/google-cloud-python#egg=googleapis-common-protos&subdirectory=packages/googleapis-common-protos", + "google-api-core @ git+https://github.com/googleapis/python-api-core.git", + "google-auth @ git+https://github.com/googleapis/google-auth-library-python.git", + "grpc-google-iam-v1 @ git+https://github.com/googleapis/google-cloud-python#egg=grpc-google-iam-v1&subdirectory=packages/grpc-google-iam-v1", + "proto-plus @ git+https://github.com/googleapis/proto-plus-python.git", + ] + + for dep in core_dependencies_from_source: + session.install(dep, "--no-deps", "--ignore-installed") + print(f"Installed {dep}") + + session.run( + "py.test", + "tests/unit", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_active_directory_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_active_directory_async.py new file mode 100644 index 000000000000..68db13f439cb --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_active_directory_async.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 CreateActiveDirectory +# 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-netapp + + +# [START netapp_v1_generated_NetApp_CreateActiveDirectory_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 netapp_v1 + + +async def sample_create_active_directory(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + active_directory = netapp_v1.ActiveDirectory() + active_directory.domain = "domain_value" + active_directory.dns = "dns_value" + active_directory.net_bios_prefix = "net_bios_prefix_value" + active_directory.username = "username_value" + active_directory.password = "password_value" + + request = netapp_v1.CreateActiveDirectoryRequest( + parent="parent_value", + active_directory=active_directory, + active_directory_id="active_directory_id_value", + ) + + # Make the request + operation = client.create_active_directory(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_CreateActiveDirectory_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_active_directory_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_active_directory_sync.py new file mode 100644 index 000000000000..dbeb51d4eb88 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_active_directory_sync.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 CreateActiveDirectory +# 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-netapp + + +# [START netapp_v1_generated_NetApp_CreateActiveDirectory_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 netapp_v1 + + +def sample_create_active_directory(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + active_directory = netapp_v1.ActiveDirectory() + active_directory.domain = "domain_value" + active_directory.dns = "dns_value" + active_directory.net_bios_prefix = "net_bios_prefix_value" + active_directory.username = "username_value" + active_directory.password = "password_value" + + request = netapp_v1.CreateActiveDirectoryRequest( + parent="parent_value", + active_directory=active_directory, + active_directory_id="active_directory_id_value", + ) + + # Make the request + operation = client.create_active_directory(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_CreateActiveDirectory_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_async.py new file mode 100644 index 000000000000..a0637addb59b --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 CreateBackup +# 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-netapp + + +# [START netapp_v1_generated_NetApp_CreateBackup_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 netapp_v1 + + +async def sample_create_backup(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.CreateBackupRequest( + parent="parent_value", + backup_id="backup_id_value", + ) + + # Make the request + operation = client.create_backup(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_CreateBackup_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_policy_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_policy_async.py new file mode 100644 index 000000000000..62f847456233 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_policy_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 CreateBackupPolicy +# 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-netapp + + +# [START netapp_v1_generated_NetApp_CreateBackupPolicy_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 netapp_v1 + + +async def sample_create_backup_policy(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.CreateBackupPolicyRequest( + parent="parent_value", + backup_policy_id="backup_policy_id_value", + ) + + # Make the request + operation = client.create_backup_policy(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_CreateBackupPolicy_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_policy_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_policy_sync.py new file mode 100644 index 000000000000..35b63b7d35a6 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_policy_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 CreateBackupPolicy +# 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-netapp + + +# [START netapp_v1_generated_NetApp_CreateBackupPolicy_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 netapp_v1 + + +def sample_create_backup_policy(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.CreateBackupPolicyRequest( + parent="parent_value", + backup_policy_id="backup_policy_id_value", + ) + + # Make the request + operation = client.create_backup_policy(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_CreateBackupPolicy_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_sync.py new file mode 100644 index 000000000000..e37762062ff2 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 CreateBackup +# 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-netapp + + +# [START netapp_v1_generated_NetApp_CreateBackup_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 netapp_v1 + + +def sample_create_backup(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.CreateBackupRequest( + parent="parent_value", + backup_id="backup_id_value", + ) + + # Make the request + operation = client.create_backup(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_CreateBackup_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_vault_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_vault_async.py new file mode 100644 index 000000000000..90dba3250398 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_vault_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 CreateBackupVault +# 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-netapp + + +# [START netapp_v1_generated_NetApp_CreateBackupVault_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 netapp_v1 + + +async def sample_create_backup_vault(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.CreateBackupVaultRequest( + parent="parent_value", + backup_vault_id="backup_vault_id_value", + ) + + # Make the request + operation = client.create_backup_vault(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_CreateBackupVault_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_vault_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_vault_sync.py new file mode 100644 index 000000000000..3436f0b95416 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_vault_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 CreateBackupVault +# 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-netapp + + +# [START netapp_v1_generated_NetApp_CreateBackupVault_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 netapp_v1 + + +def sample_create_backup_vault(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.CreateBackupVaultRequest( + parent="parent_value", + backup_vault_id="backup_vault_id_value", + ) + + # Make the request + operation = client.create_backup_vault(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_CreateBackupVault_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_kms_config_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_kms_config_async.py new file mode 100644 index 000000000000..af1ad187dd76 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_kms_config_async.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 CreateKmsConfig +# 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-netapp + + +# [START netapp_v1_generated_NetApp_CreateKmsConfig_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 netapp_v1 + + +async def sample_create_kms_config(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + kms_config = netapp_v1.KmsConfig() + kms_config.crypto_key_name = "crypto_key_name_value" + + request = netapp_v1.CreateKmsConfigRequest( + parent="parent_value", + kms_config_id="kms_config_id_value", + kms_config=kms_config, + ) + + # Make the request + operation = client.create_kms_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_CreateKmsConfig_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_kms_config_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_kms_config_sync.py new file mode 100644 index 000000000000..e747809cbf7d --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_kms_config_sync.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 CreateKmsConfig +# 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-netapp + + +# [START netapp_v1_generated_NetApp_CreateKmsConfig_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 netapp_v1 + + +def sample_create_kms_config(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + kms_config = netapp_v1.KmsConfig() + kms_config.crypto_key_name = "crypto_key_name_value" + + request = netapp_v1.CreateKmsConfigRequest( + parent="parent_value", + kms_config_id="kms_config_id_value", + kms_config=kms_config, + ) + + # Make the request + operation = client.create_kms_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_CreateKmsConfig_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_quota_rule_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_quota_rule_async.py new file mode 100644 index 000000000000..cdacc5c35f32 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_quota_rule_async.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 CreateQuotaRule +# 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-netapp + + +# [START netapp_v1_generated_NetApp_CreateQuotaRule_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 netapp_v1 + + +async def sample_create_quota_rule(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + quota_rule = netapp_v1.QuotaRule() + quota_rule.type_ = "DEFAULT_GROUP_QUOTA" + quota_rule.disk_limit_mib = 1472 + + request = netapp_v1.CreateQuotaRuleRequest( + parent="parent_value", + quota_rule=quota_rule, + quota_rule_id="quota_rule_id_value", + ) + + # Make the request + operation = client.create_quota_rule(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_CreateQuotaRule_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_quota_rule_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_quota_rule_sync.py new file mode 100644 index 000000000000..378365cf9610 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_quota_rule_sync.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 CreateQuotaRule +# 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-netapp + + +# [START netapp_v1_generated_NetApp_CreateQuotaRule_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 netapp_v1 + + +def sample_create_quota_rule(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + quota_rule = netapp_v1.QuotaRule() + quota_rule.type_ = "DEFAULT_GROUP_QUOTA" + quota_rule.disk_limit_mib = 1472 + + request = netapp_v1.CreateQuotaRuleRequest( + parent="parent_value", + quota_rule=quota_rule, + quota_rule_id="quota_rule_id_value", + ) + + # Make the request + operation = client.create_quota_rule(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_CreateQuotaRule_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_replication_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_replication_async.py new file mode 100644 index 000000000000..7173a0fedba6 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_replication_async.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 CreateReplication +# 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-netapp + + +# [START netapp_v1_generated_NetApp_CreateReplication_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 netapp_v1 + + +async def sample_create_replication(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + replication = netapp_v1.Replication() + replication.replication_schedule = "DAILY" + replication.destination_volume_parameters.storage_pool = "storage_pool_value" + + request = netapp_v1.CreateReplicationRequest( + parent="parent_value", + replication=replication, + replication_id="replication_id_value", + ) + + # Make the request + operation = client.create_replication(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_CreateReplication_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_replication_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_replication_sync.py new file mode 100644 index 000000000000..651f49b4e486 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_replication_sync.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 CreateReplication +# 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-netapp + + +# [START netapp_v1_generated_NetApp_CreateReplication_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 netapp_v1 + + +def sample_create_replication(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + replication = netapp_v1.Replication() + replication.replication_schedule = "DAILY" + replication.destination_volume_parameters.storage_pool = "storage_pool_value" + + request = netapp_v1.CreateReplicationRequest( + parent="parent_value", + replication=replication, + replication_id="replication_id_value", + ) + + # Make the request + operation = client.create_replication(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_CreateReplication_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_snapshot_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_snapshot_async.py new file mode 100644 index 000000000000..5871e5653f71 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_snapshot_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 CreateSnapshot +# 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-netapp + + +# [START netapp_v1_generated_NetApp_CreateSnapshot_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 netapp_v1 + + +async def sample_create_snapshot(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.CreateSnapshotRequest( + parent="parent_value", + snapshot_id="snapshot_id_value", + ) + + # Make the request + operation = client.create_snapshot(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_CreateSnapshot_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_snapshot_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_snapshot_sync.py new file mode 100644 index 000000000000..48ddd6bca703 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_snapshot_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 CreateSnapshot +# 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-netapp + + +# [START netapp_v1_generated_NetApp_CreateSnapshot_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 netapp_v1 + + +def sample_create_snapshot(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.CreateSnapshotRequest( + parent="parent_value", + snapshot_id="snapshot_id_value", + ) + + # Make the request + operation = client.create_snapshot(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_CreateSnapshot_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_storage_pool_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_storage_pool_async.py new file mode 100644 index 000000000000..37c7ebdaa309 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_storage_pool_async.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 CreateStoragePool +# 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-netapp + + +# [START netapp_v1_generated_NetApp_CreateStoragePool_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 netapp_v1 + + +async def sample_create_storage_pool(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + storage_pool = netapp_v1.StoragePool() + storage_pool.service_level = "FLEX" + storage_pool.capacity_gib = 1247 + storage_pool.network = "network_value" + + request = netapp_v1.CreateStoragePoolRequest( + parent="parent_value", + storage_pool_id="storage_pool_id_value", + storage_pool=storage_pool, + ) + + # Make the request + operation = client.create_storage_pool(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_CreateStoragePool_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_storage_pool_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_storage_pool_sync.py new file mode 100644 index 000000000000..8cc857ef3bc8 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_storage_pool_sync.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 CreateStoragePool +# 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-netapp + + +# [START netapp_v1_generated_NetApp_CreateStoragePool_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 netapp_v1 + + +def sample_create_storage_pool(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + storage_pool = netapp_v1.StoragePool() + storage_pool.service_level = "FLEX" + storage_pool.capacity_gib = 1247 + storage_pool.network = "network_value" + + request = netapp_v1.CreateStoragePoolRequest( + parent="parent_value", + storage_pool_id="storage_pool_id_value", + storage_pool=storage_pool, + ) + + # Make the request + operation = client.create_storage_pool(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_CreateStoragePool_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_volume_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_volume_async.py new file mode 100644 index 000000000000..7eeb7e350539 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_volume_async.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 CreateVolume +# 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-netapp + + +# [START netapp_v1_generated_NetApp_CreateVolume_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 netapp_v1 + + +async def sample_create_volume(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + volume = netapp_v1.Volume() + volume.share_name = "share_name_value" + volume.storage_pool = "storage_pool_value" + volume.capacity_gib = 1247 + volume.protocols = ['SMB'] + + request = netapp_v1.CreateVolumeRequest( + parent="parent_value", + volume_id="volume_id_value", + volume=volume, + ) + + # Make the request + operation = client.create_volume(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_CreateVolume_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_volume_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_volume_sync.py new file mode 100644 index 000000000000..44df864734bb --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_volume_sync.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 CreateVolume +# 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-netapp + + +# [START netapp_v1_generated_NetApp_CreateVolume_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 netapp_v1 + + +def sample_create_volume(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + volume = netapp_v1.Volume() + volume.share_name = "share_name_value" + volume.storage_pool = "storage_pool_value" + volume.capacity_gib = 1247 + volume.protocols = ['SMB'] + + request = netapp_v1.CreateVolumeRequest( + parent="parent_value", + volume_id="volume_id_value", + volume=volume, + ) + + # Make the request + operation = client.create_volume(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_CreateVolume_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_active_directory_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_active_directory_async.py new file mode 100644 index 000000000000..e52627384057 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_active_directory_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 DeleteActiveDirectory +# 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-netapp + + +# [START netapp_v1_generated_NetApp_DeleteActiveDirectory_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 netapp_v1 + + +async def sample_delete_active_directory(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteActiveDirectoryRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_active_directory(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_DeleteActiveDirectory_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_active_directory_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_active_directory_sync.py new file mode 100644 index 000000000000..3aba485d1423 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_active_directory_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 DeleteActiveDirectory +# 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-netapp + + +# [START netapp_v1_generated_NetApp_DeleteActiveDirectory_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 netapp_v1 + + +def sample_delete_active_directory(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteActiveDirectoryRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_active_directory(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_DeleteActiveDirectory_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_async.py new file mode 100644 index 000000000000..d42e7ab02301 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 DeleteBackup +# 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-netapp + + +# [START netapp_v1_generated_NetApp_DeleteBackup_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 netapp_v1 + + +async def sample_delete_backup(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteBackupRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_backup(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_DeleteBackup_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_policy_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_policy_async.py new file mode 100644 index 000000000000..d032f9f1e4d8 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_policy_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 DeleteBackupPolicy +# 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-netapp + + +# [START netapp_v1_generated_NetApp_DeleteBackupPolicy_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 netapp_v1 + + +async def sample_delete_backup_policy(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteBackupPolicyRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_backup_policy(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_DeleteBackupPolicy_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_policy_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_policy_sync.py new file mode 100644 index 000000000000..dfef618513ff --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_policy_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 DeleteBackupPolicy +# 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-netapp + + +# [START netapp_v1_generated_NetApp_DeleteBackupPolicy_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 netapp_v1 + + +def sample_delete_backup_policy(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteBackupPolicyRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_backup_policy(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_DeleteBackupPolicy_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_sync.py new file mode 100644 index 000000000000..239666c79a47 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 DeleteBackup +# 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-netapp + + +# [START netapp_v1_generated_NetApp_DeleteBackup_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 netapp_v1 + + +def sample_delete_backup(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteBackupRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_backup(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_DeleteBackup_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_vault_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_vault_async.py new file mode 100644 index 000000000000..739e29110da3 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_vault_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 DeleteBackupVault +# 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-netapp + + +# [START netapp_v1_generated_NetApp_DeleteBackupVault_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 netapp_v1 + + +async def sample_delete_backup_vault(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteBackupVaultRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_backup_vault(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_DeleteBackupVault_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_vault_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_vault_sync.py new file mode 100644 index 000000000000..3ebe471bef8e --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_vault_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 DeleteBackupVault +# 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-netapp + + +# [START netapp_v1_generated_NetApp_DeleteBackupVault_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 netapp_v1 + + +def sample_delete_backup_vault(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteBackupVaultRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_backup_vault(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_DeleteBackupVault_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_kms_config_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_kms_config_async.py new file mode 100644 index 000000000000..9c12eaabba11 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_kms_config_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 DeleteKmsConfig +# 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-netapp + + +# [START netapp_v1_generated_NetApp_DeleteKmsConfig_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 netapp_v1 + + +async def sample_delete_kms_config(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteKmsConfigRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_kms_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_DeleteKmsConfig_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_kms_config_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_kms_config_sync.py new file mode 100644 index 000000000000..aa0ec1dca192 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_kms_config_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 DeleteKmsConfig +# 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-netapp + + +# [START netapp_v1_generated_NetApp_DeleteKmsConfig_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 netapp_v1 + + +def sample_delete_kms_config(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteKmsConfigRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_kms_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_DeleteKmsConfig_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_quota_rule_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_quota_rule_async.py new file mode 100644 index 000000000000..5ce02f7d731e --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_quota_rule_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 DeleteQuotaRule +# 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-netapp + + +# [START netapp_v1_generated_NetApp_DeleteQuotaRule_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 netapp_v1 + + +async def sample_delete_quota_rule(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteQuotaRuleRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_quota_rule(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_DeleteQuotaRule_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_quota_rule_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_quota_rule_sync.py new file mode 100644 index 000000000000..55e4148e07db --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_quota_rule_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 DeleteQuotaRule +# 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-netapp + + +# [START netapp_v1_generated_NetApp_DeleteQuotaRule_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 netapp_v1 + + +def sample_delete_quota_rule(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteQuotaRuleRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_quota_rule(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_DeleteQuotaRule_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_replication_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_replication_async.py new file mode 100644 index 000000000000..b7584460a4da --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_replication_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 DeleteReplication +# 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-netapp + + +# [START netapp_v1_generated_NetApp_DeleteReplication_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 netapp_v1 + + +async def sample_delete_replication(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteReplicationRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_replication(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_DeleteReplication_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_replication_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_replication_sync.py new file mode 100644 index 000000000000..916a9f19bbba --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_replication_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 DeleteReplication +# 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-netapp + + +# [START netapp_v1_generated_NetApp_DeleteReplication_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 netapp_v1 + + +def sample_delete_replication(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteReplicationRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_replication(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_DeleteReplication_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_snapshot_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_snapshot_async.py new file mode 100644 index 000000000000..9bfcaa1d58b0 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_snapshot_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 DeleteSnapshot +# 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-netapp + + +# [START netapp_v1_generated_NetApp_DeleteSnapshot_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 netapp_v1 + + +async def sample_delete_snapshot(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteSnapshotRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_snapshot(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_DeleteSnapshot_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_snapshot_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_snapshot_sync.py new file mode 100644 index 000000000000..27de789c2042 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_snapshot_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 DeleteSnapshot +# 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-netapp + + +# [START netapp_v1_generated_NetApp_DeleteSnapshot_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 netapp_v1 + + +def sample_delete_snapshot(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteSnapshotRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_snapshot(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_DeleteSnapshot_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_storage_pool_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_storage_pool_async.py new file mode 100644 index 000000000000..130c5e1bfbbb --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_storage_pool_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 DeleteStoragePool +# 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-netapp + + +# [START netapp_v1_generated_NetApp_DeleteStoragePool_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 netapp_v1 + + +async def sample_delete_storage_pool(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteStoragePoolRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_storage_pool(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_DeleteStoragePool_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_storage_pool_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_storage_pool_sync.py new file mode 100644 index 000000000000..bcc5c964ba27 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_storage_pool_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 DeleteStoragePool +# 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-netapp + + +# [START netapp_v1_generated_NetApp_DeleteStoragePool_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 netapp_v1 + + +def sample_delete_storage_pool(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteStoragePoolRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_storage_pool(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_DeleteStoragePool_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_volume_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_volume_async.py new file mode 100644 index 000000000000..af546bde6238 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_volume_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 DeleteVolume +# 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-netapp + + +# [START netapp_v1_generated_NetApp_DeleteVolume_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 netapp_v1 + + +async def sample_delete_volume(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteVolumeRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_volume(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_DeleteVolume_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_volume_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_volume_sync.py new file mode 100644 index 000000000000..8cd2ff1adaae --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_volume_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 DeleteVolume +# 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-netapp + + +# [START netapp_v1_generated_NetApp_DeleteVolume_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 netapp_v1 + + +def sample_delete_volume(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.DeleteVolumeRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_volume(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_DeleteVolume_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_encrypt_volumes_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_encrypt_volumes_async.py new file mode 100644 index 000000000000..0429cd3bb171 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_encrypt_volumes_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 EncryptVolumes +# 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-netapp + + +# [START netapp_v1_generated_NetApp_EncryptVolumes_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 netapp_v1 + + +async def sample_encrypt_volumes(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.EncryptVolumesRequest( + name="name_value", + ) + + # Make the request + operation = client.encrypt_volumes(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_EncryptVolumes_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_encrypt_volumes_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_encrypt_volumes_sync.py new file mode 100644 index 000000000000..d9fdc0531033 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_encrypt_volumes_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 EncryptVolumes +# 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-netapp + + +# [START netapp_v1_generated_NetApp_EncryptVolumes_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 netapp_v1 + + +def sample_encrypt_volumes(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.EncryptVolumesRequest( + name="name_value", + ) + + # Make the request + operation = client.encrypt_volumes(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_EncryptVolumes_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_establish_peering_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_establish_peering_async.py new file mode 100644 index 000000000000..d4e5fd989c0c --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_establish_peering_async.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 EstablishPeering +# 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-netapp + + +# [START netapp_v1_generated_NetApp_EstablishPeering_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 netapp_v1 + + +async def sample_establish_peering(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.EstablishPeeringRequest( + name="name_value", + peer_cluster_name="peer_cluster_name_value", + peer_svm_name="peer_svm_name_value", + peer_volume_name="peer_volume_name_value", + ) + + # Make the request + operation = client.establish_peering(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_EstablishPeering_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_establish_peering_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_establish_peering_sync.py new file mode 100644 index 000000000000..2ea87d047c3f --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_establish_peering_sync.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 EstablishPeering +# 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-netapp + + +# [START netapp_v1_generated_NetApp_EstablishPeering_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 netapp_v1 + + +def sample_establish_peering(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.EstablishPeeringRequest( + name="name_value", + peer_cluster_name="peer_cluster_name_value", + peer_svm_name="peer_svm_name_value", + peer_volume_name="peer_volume_name_value", + ) + + # Make the request + operation = client.establish_peering(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_EstablishPeering_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_active_directory_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_active_directory_async.py new file mode 100644 index 000000000000..d97bee09ca0f --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_active_directory_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 GetActiveDirectory +# 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-netapp + + +# [START netapp_v1_generated_NetApp_GetActiveDirectory_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 netapp_v1 + + +async def sample_get_active_directory(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.GetActiveDirectoryRequest( + name="name_value", + ) + + # Make the request + response = await client.get_active_directory(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_GetActiveDirectory_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_active_directory_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_active_directory_sync.py new file mode 100644 index 000000000000..19e29f8db2d2 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_active_directory_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 GetActiveDirectory +# 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-netapp + + +# [START netapp_v1_generated_NetApp_GetActiveDirectory_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 netapp_v1 + + +def sample_get_active_directory(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.GetActiveDirectoryRequest( + name="name_value", + ) + + # Make the request + response = client.get_active_directory(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_GetActiveDirectory_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_async.py new file mode 100644 index 000000000000..1682f4f212b1 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 GetBackup +# 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-netapp + + +# [START netapp_v1_generated_NetApp_GetBackup_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 netapp_v1 + + +async def sample_get_backup(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.GetBackupRequest( + name="name_value", + ) + + # Make the request + response = await client.get_backup(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_GetBackup_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_policy_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_policy_async.py new file mode 100644 index 000000000000..7db112c2ff9d --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_policy_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 GetBackupPolicy +# 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-netapp + + +# [START netapp_v1_generated_NetApp_GetBackupPolicy_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 netapp_v1 + + +async def sample_get_backup_policy(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.GetBackupPolicyRequest( + name="name_value", + ) + + # Make the request + response = await client.get_backup_policy(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_GetBackupPolicy_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_policy_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_policy_sync.py new file mode 100644 index 000000000000..32564bd4e65a --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_policy_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 GetBackupPolicy +# 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-netapp + + +# [START netapp_v1_generated_NetApp_GetBackupPolicy_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 netapp_v1 + + +def sample_get_backup_policy(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.GetBackupPolicyRequest( + name="name_value", + ) + + # Make the request + response = client.get_backup_policy(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_GetBackupPolicy_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_sync.py new file mode 100644 index 000000000000..6db31307d7dc --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 GetBackup +# 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-netapp + + +# [START netapp_v1_generated_NetApp_GetBackup_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 netapp_v1 + + +def sample_get_backup(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.GetBackupRequest( + name="name_value", + ) + + # Make the request + response = client.get_backup(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_GetBackup_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_vault_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_vault_async.py new file mode 100644 index 000000000000..f75d6b658feb --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_vault_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 GetBackupVault +# 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-netapp + + +# [START netapp_v1_generated_NetApp_GetBackupVault_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 netapp_v1 + + +async def sample_get_backup_vault(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.GetBackupVaultRequest( + name="name_value", + ) + + # Make the request + response = await client.get_backup_vault(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_GetBackupVault_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_vault_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_vault_sync.py new file mode 100644 index 000000000000..83deff7dfaaf --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_vault_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 GetBackupVault +# 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-netapp + + +# [START netapp_v1_generated_NetApp_GetBackupVault_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 netapp_v1 + + +def sample_get_backup_vault(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.GetBackupVaultRequest( + name="name_value", + ) + + # Make the request + response = client.get_backup_vault(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_GetBackupVault_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_kms_config_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_kms_config_async.py new file mode 100644 index 000000000000..beed80da366c --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_kms_config_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 GetKmsConfig +# 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-netapp + + +# [START netapp_v1_generated_NetApp_GetKmsConfig_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 netapp_v1 + + +async def sample_get_kms_config(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.GetKmsConfigRequest( + name="name_value", + ) + + # Make the request + response = await client.get_kms_config(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_GetKmsConfig_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_kms_config_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_kms_config_sync.py new file mode 100644 index 000000000000..6eb24f195ea5 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_kms_config_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 GetKmsConfig +# 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-netapp + + +# [START netapp_v1_generated_NetApp_GetKmsConfig_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 netapp_v1 + + +def sample_get_kms_config(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.GetKmsConfigRequest( + name="name_value", + ) + + # Make the request + response = client.get_kms_config(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_GetKmsConfig_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_quota_rule_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_quota_rule_async.py new file mode 100644 index 000000000000..4f2efeae6482 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_quota_rule_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 GetQuotaRule +# 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-netapp + + +# [START netapp_v1_generated_NetApp_GetQuotaRule_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 netapp_v1 + + +async def sample_get_quota_rule(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.GetQuotaRuleRequest( + name="name_value", + ) + + # Make the request + response = await client.get_quota_rule(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_GetQuotaRule_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_quota_rule_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_quota_rule_sync.py new file mode 100644 index 000000000000..658449d977d7 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_quota_rule_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 GetQuotaRule +# 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-netapp + + +# [START netapp_v1_generated_NetApp_GetQuotaRule_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 netapp_v1 + + +def sample_get_quota_rule(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.GetQuotaRuleRequest( + name="name_value", + ) + + # Make the request + response = client.get_quota_rule(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_GetQuotaRule_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_replication_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_replication_async.py new file mode 100644 index 000000000000..c62a97d5ffb9 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_replication_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 GetReplication +# 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-netapp + + +# [START netapp_v1_generated_NetApp_GetReplication_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 netapp_v1 + + +async def sample_get_replication(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.GetReplicationRequest( + name="name_value", + ) + + # Make the request + response = await client.get_replication(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_GetReplication_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_replication_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_replication_sync.py new file mode 100644 index 000000000000..7fa9188d65a1 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_replication_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 GetReplication +# 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-netapp + + +# [START netapp_v1_generated_NetApp_GetReplication_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 netapp_v1 + + +def sample_get_replication(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.GetReplicationRequest( + name="name_value", + ) + + # Make the request + response = client.get_replication(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_GetReplication_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_snapshot_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_snapshot_async.py new file mode 100644 index 000000000000..2a163e73d010 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_snapshot_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 GetSnapshot +# 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-netapp + + +# [START netapp_v1_generated_NetApp_GetSnapshot_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 netapp_v1 + + +async def sample_get_snapshot(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.GetSnapshotRequest( + name="name_value", + ) + + # Make the request + response = await client.get_snapshot(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_GetSnapshot_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_snapshot_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_snapshot_sync.py new file mode 100644 index 000000000000..b5877a0bde61 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_snapshot_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 GetSnapshot +# 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-netapp + + +# [START netapp_v1_generated_NetApp_GetSnapshot_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 netapp_v1 + + +def sample_get_snapshot(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.GetSnapshotRequest( + name="name_value", + ) + + # Make the request + response = client.get_snapshot(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_GetSnapshot_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_storage_pool_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_storage_pool_async.py new file mode 100644 index 000000000000..741ef8435aa8 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_storage_pool_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 GetStoragePool +# 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-netapp + + +# [START netapp_v1_generated_NetApp_GetStoragePool_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 netapp_v1 + + +async def sample_get_storage_pool(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.GetStoragePoolRequest( + name="name_value", + ) + + # Make the request + response = await client.get_storage_pool(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_GetStoragePool_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_storage_pool_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_storage_pool_sync.py new file mode 100644 index 000000000000..fbbef2efca11 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_storage_pool_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 GetStoragePool +# 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-netapp + + +# [START netapp_v1_generated_NetApp_GetStoragePool_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 netapp_v1 + + +def sample_get_storage_pool(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.GetStoragePoolRequest( + name="name_value", + ) + + # Make the request + response = client.get_storage_pool(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_GetStoragePool_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_volume_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_volume_async.py new file mode 100644 index 000000000000..368b07d6b400 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_volume_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 GetVolume +# 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-netapp + + +# [START netapp_v1_generated_NetApp_GetVolume_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 netapp_v1 + + +async def sample_get_volume(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.GetVolumeRequest( + name="name_value", + ) + + # Make the request + response = await client.get_volume(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_GetVolume_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_volume_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_volume_sync.py new file mode 100644 index 000000000000..225fec682f2e --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_volume_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 GetVolume +# 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-netapp + + +# [START netapp_v1_generated_NetApp_GetVolume_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 netapp_v1 + + +def sample_get_volume(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.GetVolumeRequest( + name="name_value", + ) + + # Make the request + response = client.get_volume(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_GetVolume_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_active_directories_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_active_directories_async.py new file mode 100644 index 000000000000..0c2e0ee2be3c --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_active_directories_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ListActiveDirectories +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ListActiveDirectories_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 netapp_v1 + + +async def sample_list_active_directories(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ListActiveDirectoriesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_active_directories(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END netapp_v1_generated_NetApp_ListActiveDirectories_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_active_directories_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_active_directories_sync.py new file mode 100644 index 000000000000..c26c74e5e8a4 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_active_directories_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ListActiveDirectories +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ListActiveDirectories_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 netapp_v1 + + +def sample_list_active_directories(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ListActiveDirectoriesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_active_directories(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END netapp_v1_generated_NetApp_ListActiveDirectories_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_policies_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_policies_async.py new file mode 100644 index 000000000000..e5501e2b863e --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_policies_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ListBackupPolicies +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ListBackupPolicies_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 netapp_v1 + + +async def sample_list_backup_policies(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ListBackupPoliciesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_backup_policies(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END netapp_v1_generated_NetApp_ListBackupPolicies_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_policies_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_policies_sync.py new file mode 100644 index 000000000000..78ba50a73755 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_policies_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ListBackupPolicies +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ListBackupPolicies_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 netapp_v1 + + +def sample_list_backup_policies(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ListBackupPoliciesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_backup_policies(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END netapp_v1_generated_NetApp_ListBackupPolicies_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_vaults_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_vaults_async.py new file mode 100644 index 000000000000..363a6e994e47 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_vaults_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ListBackupVaults +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ListBackupVaults_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 netapp_v1 + + +async def sample_list_backup_vaults(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ListBackupVaultsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_backup_vaults(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END netapp_v1_generated_NetApp_ListBackupVaults_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_vaults_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_vaults_sync.py new file mode 100644 index 000000000000..ffacc1cd9508 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_vaults_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ListBackupVaults +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ListBackupVaults_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 netapp_v1 + + +def sample_list_backup_vaults(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ListBackupVaultsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_backup_vaults(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END netapp_v1_generated_NetApp_ListBackupVaults_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backups_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backups_async.py new file mode 100644 index 000000000000..6bc8399cb19c --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backups_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ListBackups +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ListBackups_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 netapp_v1 + + +async def sample_list_backups(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ListBackupsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_backups(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END netapp_v1_generated_NetApp_ListBackups_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backups_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backups_sync.py new file mode 100644 index 000000000000..6947c5392560 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backups_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ListBackups +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ListBackups_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 netapp_v1 + + +def sample_list_backups(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ListBackupsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_backups(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END netapp_v1_generated_NetApp_ListBackups_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_kms_configs_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_kms_configs_async.py new file mode 100644 index 000000000000..b9a6cd457249 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_kms_configs_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ListKmsConfigs +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ListKmsConfigs_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 netapp_v1 + + +async def sample_list_kms_configs(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ListKmsConfigsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_kms_configs(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END netapp_v1_generated_NetApp_ListKmsConfigs_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_kms_configs_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_kms_configs_sync.py new file mode 100644 index 000000000000..325c8896feba --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_kms_configs_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ListKmsConfigs +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ListKmsConfigs_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 netapp_v1 + + +def sample_list_kms_configs(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ListKmsConfigsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_kms_configs(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END netapp_v1_generated_NetApp_ListKmsConfigs_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_quota_rules_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_quota_rules_async.py new file mode 100644 index 000000000000..5f0467611351 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_quota_rules_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ListQuotaRules +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ListQuotaRules_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 netapp_v1 + + +async def sample_list_quota_rules(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ListQuotaRulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_quota_rules(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END netapp_v1_generated_NetApp_ListQuotaRules_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_quota_rules_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_quota_rules_sync.py new file mode 100644 index 000000000000..dc8134556656 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_quota_rules_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ListQuotaRules +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ListQuotaRules_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 netapp_v1 + + +def sample_list_quota_rules(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ListQuotaRulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_quota_rules(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END netapp_v1_generated_NetApp_ListQuotaRules_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_replications_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_replications_async.py new file mode 100644 index 000000000000..2cfe1808b1e0 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_replications_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ListReplications +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ListReplications_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 netapp_v1 + + +async def sample_list_replications(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ListReplicationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_replications(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END netapp_v1_generated_NetApp_ListReplications_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_replications_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_replications_sync.py new file mode 100644 index 000000000000..9be705416091 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_replications_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ListReplications +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ListReplications_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 netapp_v1 + + +def sample_list_replications(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ListReplicationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_replications(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END netapp_v1_generated_NetApp_ListReplications_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_snapshots_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_snapshots_async.py new file mode 100644 index 000000000000..9ed4edf2851e --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_snapshots_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ListSnapshots +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ListSnapshots_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 netapp_v1 + + +async def sample_list_snapshots(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ListSnapshotsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_snapshots(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END netapp_v1_generated_NetApp_ListSnapshots_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_snapshots_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_snapshots_sync.py new file mode 100644 index 000000000000..c784ba2ecf62 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_snapshots_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ListSnapshots +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ListSnapshots_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 netapp_v1 + + +def sample_list_snapshots(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ListSnapshotsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_snapshots(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END netapp_v1_generated_NetApp_ListSnapshots_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_storage_pools_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_storage_pools_async.py new file mode 100644 index 000000000000..7c93ff5f79d8 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_storage_pools_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ListStoragePools +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ListStoragePools_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 netapp_v1 + + +async def sample_list_storage_pools(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ListStoragePoolsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_storage_pools(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END netapp_v1_generated_NetApp_ListStoragePools_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_storage_pools_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_storage_pools_sync.py new file mode 100644 index 000000000000..fa35a4e7918e --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_storage_pools_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ListStoragePools +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ListStoragePools_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 netapp_v1 + + +def sample_list_storage_pools(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ListStoragePoolsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_storage_pools(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END netapp_v1_generated_NetApp_ListStoragePools_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_volumes_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_volumes_async.py new file mode 100644 index 000000000000..13b9c408b694 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_volumes_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ListVolumes +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ListVolumes_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 netapp_v1 + + +async def sample_list_volumes(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ListVolumesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_volumes(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END netapp_v1_generated_NetApp_ListVolumes_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_volumes_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_volumes_sync.py new file mode 100644 index 000000000000..14fff2b8e3b3 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_volumes_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ListVolumes +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ListVolumes_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 netapp_v1 + + +def sample_list_volumes(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ListVolumesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_volumes(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END netapp_v1_generated_NetApp_ListVolumes_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_resume_replication_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_resume_replication_async.py new file mode 100644 index 000000000000..9848bc814886 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_resume_replication_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ResumeReplication +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ResumeReplication_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 netapp_v1 + + +async def sample_resume_replication(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ResumeReplicationRequest( + name="name_value", + ) + + # Make the request + operation = client.resume_replication(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_ResumeReplication_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_resume_replication_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_resume_replication_sync.py new file mode 100644 index 000000000000..918b479f6f00 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_resume_replication_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ResumeReplication +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ResumeReplication_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 netapp_v1 + + +def sample_resume_replication(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ResumeReplicationRequest( + name="name_value", + ) + + # Make the request + operation = client.resume_replication(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_ResumeReplication_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_reverse_replication_direction_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_reverse_replication_direction_async.py new file mode 100644 index 000000000000..3e4600e46fcd --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_reverse_replication_direction_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ReverseReplicationDirection +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ReverseReplicationDirection_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 netapp_v1 + + +async def sample_reverse_replication_direction(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ReverseReplicationDirectionRequest( + name="name_value", + ) + + # Make the request + operation = client.reverse_replication_direction(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_ReverseReplicationDirection_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_reverse_replication_direction_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_reverse_replication_direction_sync.py new file mode 100644 index 000000000000..8de151ce9ce3 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_reverse_replication_direction_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ReverseReplicationDirection +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ReverseReplicationDirection_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 netapp_v1 + + +def sample_reverse_replication_direction(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ReverseReplicationDirectionRequest( + name="name_value", + ) + + # Make the request + operation = client.reverse_replication_direction(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_ReverseReplicationDirection_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_revert_volume_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_revert_volume_async.py new file mode 100644 index 000000000000..52d540a715da --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_revert_volume_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 RevertVolume +# 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-netapp + + +# [START netapp_v1_generated_NetApp_RevertVolume_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 netapp_v1 + + +async def sample_revert_volume(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.RevertVolumeRequest( + name="name_value", + snapshot_id="snapshot_id_value", + ) + + # Make the request + operation = client.revert_volume(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_RevertVolume_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_revert_volume_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_revert_volume_sync.py new file mode 100644 index 000000000000..cbbee6a7923a --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_revert_volume_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 RevertVolume +# 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-netapp + + +# [START netapp_v1_generated_NetApp_RevertVolume_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 netapp_v1 + + +def sample_revert_volume(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.RevertVolumeRequest( + name="name_value", + snapshot_id="snapshot_id_value", + ) + + # Make the request + operation = client.revert_volume(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_RevertVolume_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_stop_replication_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_stop_replication_async.py new file mode 100644 index 000000000000..47de97775f33 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_stop_replication_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 StopReplication +# 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-netapp + + +# [START netapp_v1_generated_NetApp_StopReplication_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 netapp_v1 + + +async def sample_stop_replication(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.StopReplicationRequest( + name="name_value", + ) + + # Make the request + operation = client.stop_replication(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_StopReplication_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_stop_replication_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_stop_replication_sync.py new file mode 100644 index 000000000000..0b4f1814e0c8 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_stop_replication_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 StopReplication +# 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-netapp + + +# [START netapp_v1_generated_NetApp_StopReplication_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 netapp_v1 + + +def sample_stop_replication(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.StopReplicationRequest( + name="name_value", + ) + + # Make the request + operation = client.stop_replication(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_StopReplication_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_switch_active_replica_zone_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_switch_active_replica_zone_async.py new file mode 100644 index 000000000000..0d525351cf47 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_switch_active_replica_zone_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 SwitchActiveReplicaZone +# 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-netapp + + +# [START netapp_v1_generated_NetApp_SwitchActiveReplicaZone_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 netapp_v1 + + +async def sample_switch_active_replica_zone(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.SwitchActiveReplicaZoneRequest( + name="name_value", + ) + + # Make the request + operation = client.switch_active_replica_zone(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_SwitchActiveReplicaZone_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_switch_active_replica_zone_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_switch_active_replica_zone_sync.py new file mode 100644 index 000000000000..15ef1a413752 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_switch_active_replica_zone_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 SwitchActiveReplicaZone +# 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-netapp + + +# [START netapp_v1_generated_NetApp_SwitchActiveReplicaZone_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 netapp_v1 + + +def sample_switch_active_replica_zone(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.SwitchActiveReplicaZoneRequest( + name="name_value", + ) + + # Make the request + operation = client.switch_active_replica_zone(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_SwitchActiveReplicaZone_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_sync_replication_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_sync_replication_async.py new file mode 100644 index 000000000000..c8fbb37c96fb --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_sync_replication_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 SyncReplication +# 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-netapp + + +# [START netapp_v1_generated_NetApp_SyncReplication_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 netapp_v1 + + +async def sample_sync_replication(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.SyncReplicationRequest( + name="name_value", + ) + + # Make the request + operation = client.sync_replication(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_SyncReplication_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_sync_replication_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_sync_replication_sync.py new file mode 100644 index 000000000000..46b7d6e4c94d --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_sync_replication_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 SyncReplication +# 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-netapp + + +# [START netapp_v1_generated_NetApp_SyncReplication_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 netapp_v1 + + +def sample_sync_replication(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.SyncReplicationRequest( + name="name_value", + ) + + # Make the request + operation = client.sync_replication(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_SyncReplication_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_active_directory_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_active_directory_async.py new file mode 100644 index 000000000000..7f073528eb59 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_active_directory_async.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 UpdateActiveDirectory +# 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-netapp + + +# [START netapp_v1_generated_NetApp_UpdateActiveDirectory_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 netapp_v1 + + +async def sample_update_active_directory(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + active_directory = netapp_v1.ActiveDirectory() + active_directory.domain = "domain_value" + active_directory.dns = "dns_value" + active_directory.net_bios_prefix = "net_bios_prefix_value" + active_directory.username = "username_value" + active_directory.password = "password_value" + + request = netapp_v1.UpdateActiveDirectoryRequest( + active_directory=active_directory, + ) + + # Make the request + operation = client.update_active_directory(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_UpdateActiveDirectory_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_active_directory_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_active_directory_sync.py new file mode 100644 index 000000000000..5d6495c79739 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_active_directory_sync.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 UpdateActiveDirectory +# 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-netapp + + +# [START netapp_v1_generated_NetApp_UpdateActiveDirectory_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 netapp_v1 + + +def sample_update_active_directory(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + active_directory = netapp_v1.ActiveDirectory() + active_directory.domain = "domain_value" + active_directory.dns = "dns_value" + active_directory.net_bios_prefix = "net_bios_prefix_value" + active_directory.username = "username_value" + active_directory.password = "password_value" + + request = netapp_v1.UpdateActiveDirectoryRequest( + active_directory=active_directory, + ) + + # Make the request + operation = client.update_active_directory(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_UpdateActiveDirectory_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_async.py new file mode 100644 index 000000000000..ca705c2e25c2 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_async.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 UpdateBackup +# 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-netapp + + +# [START netapp_v1_generated_NetApp_UpdateBackup_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 netapp_v1 + + +async def sample_update_backup(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.UpdateBackupRequest( + ) + + # Make the request + operation = client.update_backup(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_UpdateBackup_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_policy_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_policy_async.py new file mode 100644 index 000000000000..09e2b0a77430 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_policy_async.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 UpdateBackupPolicy +# 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-netapp + + +# [START netapp_v1_generated_NetApp_UpdateBackupPolicy_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 netapp_v1 + + +async def sample_update_backup_policy(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.UpdateBackupPolicyRequest( + ) + + # Make the request + operation = client.update_backup_policy(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_UpdateBackupPolicy_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_policy_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_policy_sync.py new file mode 100644 index 000000000000..ed77b39e5b49 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_policy_sync.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 UpdateBackupPolicy +# 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-netapp + + +# [START netapp_v1_generated_NetApp_UpdateBackupPolicy_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 netapp_v1 + + +def sample_update_backup_policy(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.UpdateBackupPolicyRequest( + ) + + # Make the request + operation = client.update_backup_policy(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_UpdateBackupPolicy_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_sync.py new file mode 100644 index 000000000000..d74d12a32032 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_sync.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 UpdateBackup +# 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-netapp + + +# [START netapp_v1_generated_NetApp_UpdateBackup_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 netapp_v1 + + +def sample_update_backup(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.UpdateBackupRequest( + ) + + # Make the request + operation = client.update_backup(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_UpdateBackup_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_vault_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_vault_async.py new file mode 100644 index 000000000000..d841e4400c1b --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_vault_async.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 UpdateBackupVault +# 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-netapp + + +# [START netapp_v1_generated_NetApp_UpdateBackupVault_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 netapp_v1 + + +async def sample_update_backup_vault(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.UpdateBackupVaultRequest( + ) + + # Make the request + operation = client.update_backup_vault(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_UpdateBackupVault_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_vault_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_vault_sync.py new file mode 100644 index 000000000000..e4fc6120d21f --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_vault_sync.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 UpdateBackupVault +# 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-netapp + + +# [START netapp_v1_generated_NetApp_UpdateBackupVault_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 netapp_v1 + + +def sample_update_backup_vault(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.UpdateBackupVaultRequest( + ) + + # Make the request + operation = client.update_backup_vault(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_UpdateBackupVault_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_kms_config_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_kms_config_async.py new file mode 100644 index 000000000000..fab3b0c1f176 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_kms_config_async.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 UpdateKmsConfig +# 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-netapp + + +# [START netapp_v1_generated_NetApp_UpdateKmsConfig_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 netapp_v1 + + +async def sample_update_kms_config(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + kms_config = netapp_v1.KmsConfig() + kms_config.crypto_key_name = "crypto_key_name_value" + + request = netapp_v1.UpdateKmsConfigRequest( + kms_config=kms_config, + ) + + # Make the request + operation = client.update_kms_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_UpdateKmsConfig_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_kms_config_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_kms_config_sync.py new file mode 100644 index 000000000000..3be0e1feb618 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_kms_config_sync.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 UpdateKmsConfig +# 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-netapp + + +# [START netapp_v1_generated_NetApp_UpdateKmsConfig_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 netapp_v1 + + +def sample_update_kms_config(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + kms_config = netapp_v1.KmsConfig() + kms_config.crypto_key_name = "crypto_key_name_value" + + request = netapp_v1.UpdateKmsConfigRequest( + kms_config=kms_config, + ) + + # Make the request + operation = client.update_kms_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_UpdateKmsConfig_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_quota_rule_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_quota_rule_async.py new file mode 100644 index 000000000000..81ae846fef1a --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_quota_rule_async.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 UpdateQuotaRule +# 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-netapp + + +# [START netapp_v1_generated_NetApp_UpdateQuotaRule_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 netapp_v1 + + +async def sample_update_quota_rule(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + quota_rule = netapp_v1.QuotaRule() + quota_rule.type_ = "DEFAULT_GROUP_QUOTA" + quota_rule.disk_limit_mib = 1472 + + request = netapp_v1.UpdateQuotaRuleRequest( + quota_rule=quota_rule, + ) + + # Make the request + operation = client.update_quota_rule(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_UpdateQuotaRule_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_quota_rule_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_quota_rule_sync.py new file mode 100644 index 000000000000..0d45f7fe7cb9 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_quota_rule_sync.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 UpdateQuotaRule +# 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-netapp + + +# [START netapp_v1_generated_NetApp_UpdateQuotaRule_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 netapp_v1 + + +def sample_update_quota_rule(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + quota_rule = netapp_v1.QuotaRule() + quota_rule.type_ = "DEFAULT_GROUP_QUOTA" + quota_rule.disk_limit_mib = 1472 + + request = netapp_v1.UpdateQuotaRuleRequest( + quota_rule=quota_rule, + ) + + # Make the request + operation = client.update_quota_rule(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_UpdateQuotaRule_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_replication_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_replication_async.py new file mode 100644 index 000000000000..2009635bd229 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_replication_async.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 UpdateReplication +# 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-netapp + + +# [START netapp_v1_generated_NetApp_UpdateReplication_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 netapp_v1 + + +async def sample_update_replication(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + replication = netapp_v1.Replication() + replication.replication_schedule = "DAILY" + replication.destination_volume_parameters.storage_pool = "storage_pool_value" + + request = netapp_v1.UpdateReplicationRequest( + replication=replication, + ) + + # Make the request + operation = client.update_replication(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_UpdateReplication_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_replication_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_replication_sync.py new file mode 100644 index 000000000000..30b07ff90309 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_replication_sync.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 UpdateReplication +# 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-netapp + + +# [START netapp_v1_generated_NetApp_UpdateReplication_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 netapp_v1 + + +def sample_update_replication(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + replication = netapp_v1.Replication() + replication.replication_schedule = "DAILY" + replication.destination_volume_parameters.storage_pool = "storage_pool_value" + + request = netapp_v1.UpdateReplicationRequest( + replication=replication, + ) + + # Make the request + operation = client.update_replication(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_UpdateReplication_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_snapshot_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_snapshot_async.py new file mode 100644 index 000000000000..0bd358a6acc9 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_snapshot_async.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 UpdateSnapshot +# 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-netapp + + +# [START netapp_v1_generated_NetApp_UpdateSnapshot_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 netapp_v1 + + +async def sample_update_snapshot(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.UpdateSnapshotRequest( + ) + + # Make the request + operation = client.update_snapshot(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_UpdateSnapshot_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_snapshot_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_snapshot_sync.py new file mode 100644 index 000000000000..5b7aa65a9352 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_snapshot_sync.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 UpdateSnapshot +# 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-netapp + + +# [START netapp_v1_generated_NetApp_UpdateSnapshot_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 netapp_v1 + + +def sample_update_snapshot(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.UpdateSnapshotRequest( + ) + + # Make the request + operation = client.update_snapshot(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_UpdateSnapshot_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_storage_pool_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_storage_pool_async.py new file mode 100644 index 000000000000..adb8dadd9565 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_storage_pool_async.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 UpdateStoragePool +# 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-netapp + + +# [START netapp_v1_generated_NetApp_UpdateStoragePool_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 netapp_v1 + + +async def sample_update_storage_pool(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + storage_pool = netapp_v1.StoragePool() + storage_pool.service_level = "FLEX" + storage_pool.capacity_gib = 1247 + storage_pool.network = "network_value" + + request = netapp_v1.UpdateStoragePoolRequest( + storage_pool=storage_pool, + ) + + # Make the request + operation = client.update_storage_pool(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_UpdateStoragePool_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_storage_pool_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_storage_pool_sync.py new file mode 100644 index 000000000000..458dec81bb23 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_storage_pool_sync.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 UpdateStoragePool +# 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-netapp + + +# [START netapp_v1_generated_NetApp_UpdateStoragePool_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 netapp_v1 + + +def sample_update_storage_pool(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + storage_pool = netapp_v1.StoragePool() + storage_pool.service_level = "FLEX" + storage_pool.capacity_gib = 1247 + storage_pool.network = "network_value" + + request = netapp_v1.UpdateStoragePoolRequest( + storage_pool=storage_pool, + ) + + # Make the request + operation = client.update_storage_pool(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_UpdateStoragePool_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_volume_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_volume_async.py new file mode 100644 index 000000000000..737f5332650d --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_volume_async.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 UpdateVolume +# 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-netapp + + +# [START netapp_v1_generated_NetApp_UpdateVolume_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 netapp_v1 + + +async def sample_update_volume(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + volume = netapp_v1.Volume() + volume.share_name = "share_name_value" + volume.storage_pool = "storage_pool_value" + volume.capacity_gib = 1247 + volume.protocols = ['SMB'] + + request = netapp_v1.UpdateVolumeRequest( + volume=volume, + ) + + # Make the request + operation = client.update_volume(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_UpdateVolume_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_volume_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_volume_sync.py new file mode 100644 index 000000000000..a4fc0731d75d --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_volume_sync.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 UpdateVolume +# 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-netapp + + +# [START netapp_v1_generated_NetApp_UpdateVolume_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 netapp_v1 + + +def sample_update_volume(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + volume = netapp_v1.Volume() + volume.share_name = "share_name_value" + volume.storage_pool = "storage_pool_value" + volume.capacity_gib = 1247 + volume.protocols = ['SMB'] + + request = netapp_v1.UpdateVolumeRequest( + volume=volume, + ) + + # Make the request + operation = client.update_volume(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_UpdateVolume_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_validate_directory_service_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_validate_directory_service_async.py new file mode 100644 index 000000000000..128629200c77 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_validate_directory_service_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ValidateDirectoryService +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ValidateDirectoryService_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 netapp_v1 + + +async def sample_validate_directory_service(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.ValidateDirectoryServiceRequest( + name="name_value", + ) + + # Make the request + operation = client.validate_directory_service(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_ValidateDirectoryService_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_validate_directory_service_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_validate_directory_service_sync.py new file mode 100644 index 000000000000..83cc3bb7839e --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_validate_directory_service_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 ValidateDirectoryService +# 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-netapp + + +# [START netapp_v1_generated_NetApp_ValidateDirectoryService_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 netapp_v1 + + +def sample_validate_directory_service(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.ValidateDirectoryServiceRequest( + name="name_value", + ) + + # Make the request + operation = client.validate_directory_service(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_ValidateDirectoryService_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_verify_kms_config_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_verify_kms_config_async.py new file mode 100644 index 000000000000..40d65dfaa2f7 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_verify_kms_config_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 VerifyKmsConfig +# 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-netapp + + +# [START netapp_v1_generated_NetApp_VerifyKmsConfig_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 netapp_v1 + + +async def sample_verify_kms_config(): + # Create a client + client = netapp_v1.NetAppAsyncClient() + + # Initialize request argument(s) + request = netapp_v1.VerifyKmsConfigRequest( + name="name_value", + ) + + # Make the request + response = await client.verify_kms_config(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_VerifyKmsConfig_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_verify_kms_config_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_verify_kms_config_sync.py new file mode 100644 index 000000000000..95ca55b4b031 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_verify_kms_config_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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 VerifyKmsConfig +# 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-netapp + + +# [START netapp_v1_generated_NetApp_VerifyKmsConfig_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 netapp_v1 + + +def sample_verify_kms_config(): + # Create a client + client = netapp_v1.NetAppClient() + + # Initialize request argument(s) + request = netapp_v1.VerifyKmsConfigRequest( + name="name_value", + ) + + # Make the request + response = client.verify_kms_config(request=request) + + # Handle the response + print(response) + +# [END netapp_v1_generated_NetApp_VerifyKmsConfig_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/snippet_metadata_google.cloud.netapp.v1.json b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/snippet_metadata_google.cloud.netapp.v1.json new file mode 100644 index 000000000000..59d2f45cdea3 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/snippet_metadata_google.cloud.netapp.v1.json @@ -0,0 +1,9835 @@ +{ + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.netapp.v1", + "version": "v1" + } + ], + "language": "PYTHON", + "name": "google-cloud-netapp", + "version": "0.1.0" + }, + "snippets": [ + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.create_active_directory", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.CreateActiveDirectory", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "CreateActiveDirectory" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.CreateActiveDirectoryRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "active_directory", + "type": "google.cloud.netapp_v1.types.ActiveDirectory" + }, + { + "name": "active_directory_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_active_directory" + }, + "description": "Sample for CreateActiveDirectory", + "file": "netapp_v1_generated_net_app_create_active_directory_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_CreateActiveDirectory_async", + "segments": [ + { + "end": 64, + "start": 27, + "type": "FULL" + }, + { + "end": 64, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 54, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 61, + "start": 55, + "type": "REQUEST_EXECUTION" + }, + { + "end": 65, + "start": 62, + "type": "RESPONSE_HANDLING" + } + ], + "title": "netapp_v1_generated_net_app_create_active_directory_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.create_active_directory", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.CreateActiveDirectory", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "CreateActiveDirectory" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.CreateActiveDirectoryRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "active_directory", + "type": "google.cloud.netapp_v1.types.ActiveDirectory" + }, + { + "name": "active_directory_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_active_directory" + }, + "description": "Sample for CreateActiveDirectory", + "file": "netapp_v1_generated_net_app_create_active_directory_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_CreateActiveDirectory_sync", + "segments": [ + { + "end": 64, + "start": 27, + "type": "FULL" + }, + { + "end": 64, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 54, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 61, + "start": 55, + "type": "REQUEST_EXECUTION" + }, + { + "end": 65, + "start": 62, + "type": "RESPONSE_HANDLING" + } + ], + "title": "netapp_v1_generated_net_app_create_active_directory_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.create_backup_policy", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.CreateBackupPolicy", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "CreateBackupPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.CreateBackupPolicyRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "backup_policy", + "type": "google.cloud.netapp_v1.types.BackupPolicy" + }, + { + "name": "backup_policy_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_backup_policy" + }, + "description": "Sample for CreateBackupPolicy", + "file": "netapp_v1_generated_net_app_create_backup_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_CreateBackupPolicy_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": "netapp_v1_generated_net_app_create_backup_policy_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.create_backup_policy", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.CreateBackupPolicy", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "CreateBackupPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.CreateBackupPolicyRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "backup_policy", + "type": "google.cloud.netapp_v1.types.BackupPolicy" + }, + { + "name": "backup_policy_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_backup_policy" + }, + "description": "Sample for CreateBackupPolicy", + "file": "netapp_v1_generated_net_app_create_backup_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_CreateBackupPolicy_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": "netapp_v1_generated_net_app_create_backup_policy_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.create_backup_vault", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.CreateBackupVault", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "CreateBackupVault" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.CreateBackupVaultRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "backup_vault", + "type": "google.cloud.netapp_v1.types.BackupVault" + }, + { + "name": "backup_vault_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_backup_vault" + }, + "description": "Sample for CreateBackupVault", + "file": "netapp_v1_generated_net_app_create_backup_vault_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_CreateBackupVault_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": "netapp_v1_generated_net_app_create_backup_vault_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.create_backup_vault", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.CreateBackupVault", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "CreateBackupVault" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.CreateBackupVaultRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "backup_vault", + "type": "google.cloud.netapp_v1.types.BackupVault" + }, + { + "name": "backup_vault_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_backup_vault" + }, + "description": "Sample for CreateBackupVault", + "file": "netapp_v1_generated_net_app_create_backup_vault_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_CreateBackupVault_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": "netapp_v1_generated_net_app_create_backup_vault_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.create_backup", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.CreateBackup", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "CreateBackup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.CreateBackupRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "backup", + "type": "google.cloud.netapp_v1.types.Backup" + }, + { + "name": "backup_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_backup" + }, + "description": "Sample for CreateBackup", + "file": "netapp_v1_generated_net_app_create_backup_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_CreateBackup_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": "netapp_v1_generated_net_app_create_backup_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.create_backup", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.CreateBackup", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "CreateBackup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.CreateBackupRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "backup", + "type": "google.cloud.netapp_v1.types.Backup" + }, + { + "name": "backup_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_backup" + }, + "description": "Sample for CreateBackup", + "file": "netapp_v1_generated_net_app_create_backup_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_CreateBackup_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": "netapp_v1_generated_net_app_create_backup_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.create_kms_config", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.CreateKmsConfig", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "CreateKmsConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.CreateKmsConfigRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "kms_config", + "type": "google.cloud.netapp_v1.types.KmsConfig" + }, + { + "name": "kms_config_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_kms_config" + }, + "description": "Sample for CreateKmsConfig", + "file": "netapp_v1_generated_net_app_create_kms_config_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_CreateKmsConfig_async", + "segments": [ + { + "end": 60, + "start": 27, + "type": "FULL" + }, + { + "end": 60, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 50, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 57, + "start": 51, + "type": "REQUEST_EXECUTION" + }, + { + "end": 61, + "start": 58, + "type": "RESPONSE_HANDLING" + } + ], + "title": "netapp_v1_generated_net_app_create_kms_config_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.create_kms_config", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.CreateKmsConfig", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "CreateKmsConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.CreateKmsConfigRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "kms_config", + "type": "google.cloud.netapp_v1.types.KmsConfig" + }, + { + "name": "kms_config_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_kms_config" + }, + "description": "Sample for CreateKmsConfig", + "file": "netapp_v1_generated_net_app_create_kms_config_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_CreateKmsConfig_sync", + "segments": [ + { + "end": 60, + "start": 27, + "type": "FULL" + }, + { + "end": 60, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 50, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 57, + "start": 51, + "type": "REQUEST_EXECUTION" + }, + { + "end": 61, + "start": 58, + "type": "RESPONSE_HANDLING" + } + ], + "title": "netapp_v1_generated_net_app_create_kms_config_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.create_quota_rule", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.CreateQuotaRule", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "CreateQuotaRule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.CreateQuotaRuleRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "quota_rule", + "type": "google.cloud.netapp_v1.types.QuotaRule" + }, + { + "name": "quota_rule_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_quota_rule" + }, + "description": "Sample for CreateQuotaRule", + "file": "netapp_v1_generated_net_app_create_quota_rule_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_CreateQuotaRule_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": "netapp_v1_generated_net_app_create_quota_rule_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.create_quota_rule", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.CreateQuotaRule", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "CreateQuotaRule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.CreateQuotaRuleRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "quota_rule", + "type": "google.cloud.netapp_v1.types.QuotaRule" + }, + { + "name": "quota_rule_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_quota_rule" + }, + "description": "Sample for CreateQuotaRule", + "file": "netapp_v1_generated_net_app_create_quota_rule_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_CreateQuotaRule_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": "netapp_v1_generated_net_app_create_quota_rule_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.create_replication", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.CreateReplication", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "CreateReplication" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.CreateReplicationRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "replication", + "type": "google.cloud.netapp_v1.types.Replication" + }, + { + "name": "replication_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_replication" + }, + "description": "Sample for CreateReplication", + "file": "netapp_v1_generated_net_app_create_replication_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_CreateReplication_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": "netapp_v1_generated_net_app_create_replication_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.create_replication", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.CreateReplication", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "CreateReplication" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.CreateReplicationRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "replication", + "type": "google.cloud.netapp_v1.types.Replication" + }, + { + "name": "replication_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_replication" + }, + "description": "Sample for CreateReplication", + "file": "netapp_v1_generated_net_app_create_replication_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_CreateReplication_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": "netapp_v1_generated_net_app_create_replication_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.create_snapshot", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.CreateSnapshot", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "CreateSnapshot" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.CreateSnapshotRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "snapshot", + "type": "google.cloud.netapp_v1.types.Snapshot" + }, + { + "name": "snapshot_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_snapshot" + }, + "description": "Sample for CreateSnapshot", + "file": "netapp_v1_generated_net_app_create_snapshot_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_CreateSnapshot_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": "netapp_v1_generated_net_app_create_snapshot_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.create_snapshot", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.CreateSnapshot", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "CreateSnapshot" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.CreateSnapshotRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "snapshot", + "type": "google.cloud.netapp_v1.types.Snapshot" + }, + { + "name": "snapshot_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_snapshot" + }, + "description": "Sample for CreateSnapshot", + "file": "netapp_v1_generated_net_app_create_snapshot_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_CreateSnapshot_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": "netapp_v1_generated_net_app_create_snapshot_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.create_storage_pool", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.CreateStoragePool", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "CreateStoragePool" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.CreateStoragePoolRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "storage_pool", + "type": "google.cloud.netapp_v1.types.StoragePool" + }, + { + "name": "storage_pool_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_storage_pool" + }, + "description": "Sample for CreateStoragePool", + "file": "netapp_v1_generated_net_app_create_storage_pool_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_CreateStoragePool_async", + "segments": [ + { + "end": 62, + "start": 27, + "type": "FULL" + }, + { + "end": 62, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 59, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 63, + "start": 60, + "type": "RESPONSE_HANDLING" + } + ], + "title": "netapp_v1_generated_net_app_create_storage_pool_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.create_storage_pool", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.CreateStoragePool", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "CreateStoragePool" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.CreateStoragePoolRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "storage_pool", + "type": "google.cloud.netapp_v1.types.StoragePool" + }, + { + "name": "storage_pool_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_storage_pool" + }, + "description": "Sample for CreateStoragePool", + "file": "netapp_v1_generated_net_app_create_storage_pool_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_CreateStoragePool_sync", + "segments": [ + { + "end": 62, + "start": 27, + "type": "FULL" + }, + { + "end": 62, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 59, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 63, + "start": 60, + "type": "RESPONSE_HANDLING" + } + ], + "title": "netapp_v1_generated_net_app_create_storage_pool_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.create_volume", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.CreateVolume", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "CreateVolume" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.CreateVolumeRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "volume", + "type": "google.cloud.netapp_v1.types.Volume" + }, + { + "name": "volume_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_volume" + }, + "description": "Sample for CreateVolume", + "file": "netapp_v1_generated_net_app_create_volume_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_CreateVolume_async", + "segments": [ + { + "end": 63, + "start": 27, + "type": "FULL" + }, + { + "end": 63, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 53, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 60, + "start": 54, + "type": "REQUEST_EXECUTION" + }, + { + "end": 64, + "start": 61, + "type": "RESPONSE_HANDLING" + } + ], + "title": "netapp_v1_generated_net_app_create_volume_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.create_volume", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.CreateVolume", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "CreateVolume" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.CreateVolumeRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "volume", + "type": "google.cloud.netapp_v1.types.Volume" + }, + { + "name": "volume_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_volume" + }, + "description": "Sample for CreateVolume", + "file": "netapp_v1_generated_net_app_create_volume_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_CreateVolume_sync", + "segments": [ + { + "end": 63, + "start": 27, + "type": "FULL" + }, + { + "end": 63, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 53, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 60, + "start": 54, + "type": "REQUEST_EXECUTION" + }, + { + "end": 64, + "start": 61, + "type": "RESPONSE_HANDLING" + } + ], + "title": "netapp_v1_generated_net_app_create_volume_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.delete_active_directory", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.DeleteActiveDirectory", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "DeleteActiveDirectory" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.DeleteActiveDirectoryRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_active_directory" + }, + "description": "Sample for DeleteActiveDirectory", + "file": "netapp_v1_generated_net_app_delete_active_directory_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_DeleteActiveDirectory_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": "netapp_v1_generated_net_app_delete_active_directory_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.delete_active_directory", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.DeleteActiveDirectory", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "DeleteActiveDirectory" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.DeleteActiveDirectoryRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_active_directory" + }, + "description": "Sample for DeleteActiveDirectory", + "file": "netapp_v1_generated_net_app_delete_active_directory_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_DeleteActiveDirectory_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": "netapp_v1_generated_net_app_delete_active_directory_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.delete_backup_policy", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.DeleteBackupPolicy", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "DeleteBackupPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.DeleteBackupPolicyRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_backup_policy" + }, + "description": "Sample for DeleteBackupPolicy", + "file": "netapp_v1_generated_net_app_delete_backup_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_DeleteBackupPolicy_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": "netapp_v1_generated_net_app_delete_backup_policy_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.delete_backup_policy", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.DeleteBackupPolicy", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "DeleteBackupPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.DeleteBackupPolicyRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_backup_policy" + }, + "description": "Sample for DeleteBackupPolicy", + "file": "netapp_v1_generated_net_app_delete_backup_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_DeleteBackupPolicy_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": "netapp_v1_generated_net_app_delete_backup_policy_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.delete_backup_vault", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.DeleteBackupVault", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "DeleteBackupVault" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.DeleteBackupVaultRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_backup_vault" + }, + "description": "Sample for DeleteBackupVault", + "file": "netapp_v1_generated_net_app_delete_backup_vault_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_DeleteBackupVault_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": "netapp_v1_generated_net_app_delete_backup_vault_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.delete_backup_vault", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.DeleteBackupVault", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "DeleteBackupVault" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.DeleteBackupVaultRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_backup_vault" + }, + "description": "Sample for DeleteBackupVault", + "file": "netapp_v1_generated_net_app_delete_backup_vault_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_DeleteBackupVault_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": "netapp_v1_generated_net_app_delete_backup_vault_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.delete_backup", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.DeleteBackup", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "DeleteBackup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.DeleteBackupRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_backup" + }, + "description": "Sample for DeleteBackup", + "file": "netapp_v1_generated_net_app_delete_backup_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_DeleteBackup_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": "netapp_v1_generated_net_app_delete_backup_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.delete_backup", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.DeleteBackup", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "DeleteBackup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.DeleteBackupRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_backup" + }, + "description": "Sample for DeleteBackup", + "file": "netapp_v1_generated_net_app_delete_backup_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_DeleteBackup_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": "netapp_v1_generated_net_app_delete_backup_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.delete_kms_config", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.DeleteKmsConfig", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "DeleteKmsConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.DeleteKmsConfigRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_kms_config" + }, + "description": "Sample for DeleteKmsConfig", + "file": "netapp_v1_generated_net_app_delete_kms_config_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_DeleteKmsConfig_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": "netapp_v1_generated_net_app_delete_kms_config_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.delete_kms_config", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.DeleteKmsConfig", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "DeleteKmsConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.DeleteKmsConfigRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_kms_config" + }, + "description": "Sample for DeleteKmsConfig", + "file": "netapp_v1_generated_net_app_delete_kms_config_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_DeleteKmsConfig_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": "netapp_v1_generated_net_app_delete_kms_config_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.delete_quota_rule", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.DeleteQuotaRule", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "DeleteQuotaRule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.DeleteQuotaRuleRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_quota_rule" + }, + "description": "Sample for DeleteQuotaRule", + "file": "netapp_v1_generated_net_app_delete_quota_rule_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_DeleteQuotaRule_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": "netapp_v1_generated_net_app_delete_quota_rule_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.delete_quota_rule", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.DeleteQuotaRule", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "DeleteQuotaRule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.DeleteQuotaRuleRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_quota_rule" + }, + "description": "Sample for DeleteQuotaRule", + "file": "netapp_v1_generated_net_app_delete_quota_rule_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_DeleteQuotaRule_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": "netapp_v1_generated_net_app_delete_quota_rule_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.delete_replication", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.DeleteReplication", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "DeleteReplication" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.DeleteReplicationRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_replication" + }, + "description": "Sample for DeleteReplication", + "file": "netapp_v1_generated_net_app_delete_replication_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_DeleteReplication_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": "netapp_v1_generated_net_app_delete_replication_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.delete_replication", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.DeleteReplication", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "DeleteReplication" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.DeleteReplicationRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_replication" + }, + "description": "Sample for DeleteReplication", + "file": "netapp_v1_generated_net_app_delete_replication_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_DeleteReplication_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": "netapp_v1_generated_net_app_delete_replication_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.delete_snapshot", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.DeleteSnapshot", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "DeleteSnapshot" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.DeleteSnapshotRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_snapshot" + }, + "description": "Sample for DeleteSnapshot", + "file": "netapp_v1_generated_net_app_delete_snapshot_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_DeleteSnapshot_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": "netapp_v1_generated_net_app_delete_snapshot_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.delete_snapshot", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.DeleteSnapshot", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "DeleteSnapshot" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.DeleteSnapshotRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_snapshot" + }, + "description": "Sample for DeleteSnapshot", + "file": "netapp_v1_generated_net_app_delete_snapshot_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_DeleteSnapshot_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": "netapp_v1_generated_net_app_delete_snapshot_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.delete_storage_pool", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.DeleteStoragePool", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "DeleteStoragePool" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.DeleteStoragePoolRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_storage_pool" + }, + "description": "Sample for DeleteStoragePool", + "file": "netapp_v1_generated_net_app_delete_storage_pool_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_DeleteStoragePool_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": "netapp_v1_generated_net_app_delete_storage_pool_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.delete_storage_pool", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.DeleteStoragePool", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "DeleteStoragePool" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.DeleteStoragePoolRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_storage_pool" + }, + "description": "Sample for DeleteStoragePool", + "file": "netapp_v1_generated_net_app_delete_storage_pool_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_DeleteStoragePool_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": "netapp_v1_generated_net_app_delete_storage_pool_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.delete_volume", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.DeleteVolume", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "DeleteVolume" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.DeleteVolumeRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_volume" + }, + "description": "Sample for DeleteVolume", + "file": "netapp_v1_generated_net_app_delete_volume_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_DeleteVolume_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": "netapp_v1_generated_net_app_delete_volume_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.delete_volume", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.DeleteVolume", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "DeleteVolume" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.DeleteVolumeRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_volume" + }, + "description": "Sample for DeleteVolume", + "file": "netapp_v1_generated_net_app_delete_volume_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_DeleteVolume_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": "netapp_v1_generated_net_app_delete_volume_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.encrypt_volumes", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.EncryptVolumes", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "EncryptVolumes" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.EncryptVolumesRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "encrypt_volumes" + }, + "description": "Sample for EncryptVolumes", + "file": "netapp_v1_generated_net_app_encrypt_volumes_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_EncryptVolumes_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": "netapp_v1_generated_net_app_encrypt_volumes_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.encrypt_volumes", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.EncryptVolumes", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "EncryptVolumes" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.EncryptVolumesRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "encrypt_volumes" + }, + "description": "Sample for EncryptVolumes", + "file": "netapp_v1_generated_net_app_encrypt_volumes_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_EncryptVolumes_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": "netapp_v1_generated_net_app_encrypt_volumes_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.establish_peering", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.EstablishPeering", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "EstablishPeering" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.EstablishPeeringRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "establish_peering" + }, + "description": "Sample for EstablishPeering", + "file": "netapp_v1_generated_net_app_establish_peering_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_EstablishPeering_async", + "segments": [ + { + "end": 58, + "start": 27, + "type": "FULL" + }, + { + "end": 58, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 48, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 55, + "start": 49, + "type": "REQUEST_EXECUTION" + }, + { + "end": 59, + "start": 56, + "type": "RESPONSE_HANDLING" + } + ], + "title": "netapp_v1_generated_net_app_establish_peering_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.establish_peering", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.EstablishPeering", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "EstablishPeering" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.EstablishPeeringRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "establish_peering" + }, + "description": "Sample for EstablishPeering", + "file": "netapp_v1_generated_net_app_establish_peering_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_EstablishPeering_sync", + "segments": [ + { + "end": 58, + "start": 27, + "type": "FULL" + }, + { + "end": 58, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 48, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 55, + "start": 49, + "type": "REQUEST_EXECUTION" + }, + { + "end": 59, + "start": 56, + "type": "RESPONSE_HANDLING" + } + ], + "title": "netapp_v1_generated_net_app_establish_peering_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.get_active_directory", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.GetActiveDirectory", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "GetActiveDirectory" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.GetActiveDirectoryRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.ActiveDirectory", + "shortName": "get_active_directory" + }, + "description": "Sample for GetActiveDirectory", + "file": "netapp_v1_generated_net_app_get_active_directory_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_GetActiveDirectory_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": "netapp_v1_generated_net_app_get_active_directory_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.get_active_directory", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.GetActiveDirectory", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "GetActiveDirectory" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.GetActiveDirectoryRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.ActiveDirectory", + "shortName": "get_active_directory" + }, + "description": "Sample for GetActiveDirectory", + "file": "netapp_v1_generated_net_app_get_active_directory_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_GetActiveDirectory_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": "netapp_v1_generated_net_app_get_active_directory_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.get_backup_policy", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.GetBackupPolicy", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "GetBackupPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.GetBackupPolicyRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.BackupPolicy", + "shortName": "get_backup_policy" + }, + "description": "Sample for GetBackupPolicy", + "file": "netapp_v1_generated_net_app_get_backup_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_GetBackupPolicy_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": "netapp_v1_generated_net_app_get_backup_policy_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.get_backup_policy", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.GetBackupPolicy", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "GetBackupPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.GetBackupPolicyRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.BackupPolicy", + "shortName": "get_backup_policy" + }, + "description": "Sample for GetBackupPolicy", + "file": "netapp_v1_generated_net_app_get_backup_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_GetBackupPolicy_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": "netapp_v1_generated_net_app_get_backup_policy_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.get_backup_vault", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.GetBackupVault", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "GetBackupVault" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.GetBackupVaultRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.BackupVault", + "shortName": "get_backup_vault" + }, + "description": "Sample for GetBackupVault", + "file": "netapp_v1_generated_net_app_get_backup_vault_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_GetBackupVault_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": "netapp_v1_generated_net_app_get_backup_vault_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.get_backup_vault", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.GetBackupVault", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "GetBackupVault" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.GetBackupVaultRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.BackupVault", + "shortName": "get_backup_vault" + }, + "description": "Sample for GetBackupVault", + "file": "netapp_v1_generated_net_app_get_backup_vault_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_GetBackupVault_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": "netapp_v1_generated_net_app_get_backup_vault_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.get_backup", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.GetBackup", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "GetBackup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.GetBackupRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.Backup", + "shortName": "get_backup" + }, + "description": "Sample for GetBackup", + "file": "netapp_v1_generated_net_app_get_backup_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_GetBackup_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": "netapp_v1_generated_net_app_get_backup_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.get_backup", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.GetBackup", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "GetBackup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.GetBackupRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.Backup", + "shortName": "get_backup" + }, + "description": "Sample for GetBackup", + "file": "netapp_v1_generated_net_app_get_backup_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_GetBackup_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": "netapp_v1_generated_net_app_get_backup_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.get_kms_config", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.GetKmsConfig", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "GetKmsConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.GetKmsConfigRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.KmsConfig", + "shortName": "get_kms_config" + }, + "description": "Sample for GetKmsConfig", + "file": "netapp_v1_generated_net_app_get_kms_config_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_GetKmsConfig_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": "netapp_v1_generated_net_app_get_kms_config_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.get_kms_config", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.GetKmsConfig", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "GetKmsConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.GetKmsConfigRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.KmsConfig", + "shortName": "get_kms_config" + }, + "description": "Sample for GetKmsConfig", + "file": "netapp_v1_generated_net_app_get_kms_config_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_GetKmsConfig_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": "netapp_v1_generated_net_app_get_kms_config_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.get_quota_rule", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.GetQuotaRule", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "GetQuotaRule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.GetQuotaRuleRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.QuotaRule", + "shortName": "get_quota_rule" + }, + "description": "Sample for GetQuotaRule", + "file": "netapp_v1_generated_net_app_get_quota_rule_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_GetQuotaRule_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": "netapp_v1_generated_net_app_get_quota_rule_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.get_quota_rule", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.GetQuotaRule", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "GetQuotaRule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.GetQuotaRuleRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.QuotaRule", + "shortName": "get_quota_rule" + }, + "description": "Sample for GetQuotaRule", + "file": "netapp_v1_generated_net_app_get_quota_rule_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_GetQuotaRule_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": "netapp_v1_generated_net_app_get_quota_rule_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.get_replication", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.GetReplication", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "GetReplication" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.GetReplicationRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.Replication", + "shortName": "get_replication" + }, + "description": "Sample for GetReplication", + "file": "netapp_v1_generated_net_app_get_replication_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_GetReplication_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": "netapp_v1_generated_net_app_get_replication_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.get_replication", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.GetReplication", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "GetReplication" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.GetReplicationRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.Replication", + "shortName": "get_replication" + }, + "description": "Sample for GetReplication", + "file": "netapp_v1_generated_net_app_get_replication_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_GetReplication_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": "netapp_v1_generated_net_app_get_replication_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.get_snapshot", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.GetSnapshot", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "GetSnapshot" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.GetSnapshotRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.Snapshot", + "shortName": "get_snapshot" + }, + "description": "Sample for GetSnapshot", + "file": "netapp_v1_generated_net_app_get_snapshot_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_GetSnapshot_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": "netapp_v1_generated_net_app_get_snapshot_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.get_snapshot", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.GetSnapshot", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "GetSnapshot" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.GetSnapshotRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.Snapshot", + "shortName": "get_snapshot" + }, + "description": "Sample for GetSnapshot", + "file": "netapp_v1_generated_net_app_get_snapshot_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_GetSnapshot_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": "netapp_v1_generated_net_app_get_snapshot_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.get_storage_pool", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.GetStoragePool", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "GetStoragePool" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.GetStoragePoolRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.StoragePool", + "shortName": "get_storage_pool" + }, + "description": "Sample for GetStoragePool", + "file": "netapp_v1_generated_net_app_get_storage_pool_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_GetStoragePool_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": "netapp_v1_generated_net_app_get_storage_pool_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.get_storage_pool", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.GetStoragePool", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "GetStoragePool" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.GetStoragePoolRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.StoragePool", + "shortName": "get_storage_pool" + }, + "description": "Sample for GetStoragePool", + "file": "netapp_v1_generated_net_app_get_storage_pool_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_GetStoragePool_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": "netapp_v1_generated_net_app_get_storage_pool_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.get_volume", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.GetVolume", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "GetVolume" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.GetVolumeRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.Volume", + "shortName": "get_volume" + }, + "description": "Sample for GetVolume", + "file": "netapp_v1_generated_net_app_get_volume_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_GetVolume_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": "netapp_v1_generated_net_app_get_volume_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.get_volume", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.GetVolume", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "GetVolume" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.GetVolumeRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.Volume", + "shortName": "get_volume" + }, + "description": "Sample for GetVolume", + "file": "netapp_v1_generated_net_app_get_volume_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_GetVolume_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": "netapp_v1_generated_net_app_get_volume_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.list_active_directories", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ListActiveDirectories", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ListActiveDirectories" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ListActiveDirectoriesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListActiveDirectoriesAsyncPager", + "shortName": "list_active_directories" + }, + "description": "Sample for ListActiveDirectories", + "file": "netapp_v1_generated_net_app_list_active_directories_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ListActiveDirectories_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": "netapp_v1_generated_net_app_list_active_directories_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.list_active_directories", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ListActiveDirectories", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ListActiveDirectories" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ListActiveDirectoriesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListActiveDirectoriesPager", + "shortName": "list_active_directories" + }, + "description": "Sample for ListActiveDirectories", + "file": "netapp_v1_generated_net_app_list_active_directories_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ListActiveDirectories_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": "netapp_v1_generated_net_app_list_active_directories_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.list_backup_policies", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ListBackupPolicies", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ListBackupPolicies" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ListBackupPoliciesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListBackupPoliciesAsyncPager", + "shortName": "list_backup_policies" + }, + "description": "Sample for ListBackupPolicies", + "file": "netapp_v1_generated_net_app_list_backup_policies_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ListBackupPolicies_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": "netapp_v1_generated_net_app_list_backup_policies_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.list_backup_policies", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ListBackupPolicies", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ListBackupPolicies" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ListBackupPoliciesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListBackupPoliciesPager", + "shortName": "list_backup_policies" + }, + "description": "Sample for ListBackupPolicies", + "file": "netapp_v1_generated_net_app_list_backup_policies_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ListBackupPolicies_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": "netapp_v1_generated_net_app_list_backup_policies_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.list_backup_vaults", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ListBackupVaults", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ListBackupVaults" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ListBackupVaultsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListBackupVaultsAsyncPager", + "shortName": "list_backup_vaults" + }, + "description": "Sample for ListBackupVaults", + "file": "netapp_v1_generated_net_app_list_backup_vaults_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ListBackupVaults_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": "netapp_v1_generated_net_app_list_backup_vaults_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.list_backup_vaults", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ListBackupVaults", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ListBackupVaults" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ListBackupVaultsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListBackupVaultsPager", + "shortName": "list_backup_vaults" + }, + "description": "Sample for ListBackupVaults", + "file": "netapp_v1_generated_net_app_list_backup_vaults_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ListBackupVaults_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": "netapp_v1_generated_net_app_list_backup_vaults_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.list_backups", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ListBackups", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ListBackups" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ListBackupsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListBackupsAsyncPager", + "shortName": "list_backups" + }, + "description": "Sample for ListBackups", + "file": "netapp_v1_generated_net_app_list_backups_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ListBackups_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": "netapp_v1_generated_net_app_list_backups_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.list_backups", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ListBackups", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ListBackups" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ListBackupsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListBackupsPager", + "shortName": "list_backups" + }, + "description": "Sample for ListBackups", + "file": "netapp_v1_generated_net_app_list_backups_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ListBackups_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": "netapp_v1_generated_net_app_list_backups_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.list_kms_configs", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ListKmsConfigs", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ListKmsConfigs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ListKmsConfigsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListKmsConfigsAsyncPager", + "shortName": "list_kms_configs" + }, + "description": "Sample for ListKmsConfigs", + "file": "netapp_v1_generated_net_app_list_kms_configs_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ListKmsConfigs_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": "netapp_v1_generated_net_app_list_kms_configs_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.list_kms_configs", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ListKmsConfigs", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ListKmsConfigs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ListKmsConfigsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListKmsConfigsPager", + "shortName": "list_kms_configs" + }, + "description": "Sample for ListKmsConfigs", + "file": "netapp_v1_generated_net_app_list_kms_configs_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ListKmsConfigs_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": "netapp_v1_generated_net_app_list_kms_configs_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.list_quota_rules", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ListQuotaRules", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ListQuotaRules" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ListQuotaRulesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListQuotaRulesAsyncPager", + "shortName": "list_quota_rules" + }, + "description": "Sample for ListQuotaRules", + "file": "netapp_v1_generated_net_app_list_quota_rules_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ListQuotaRules_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": "netapp_v1_generated_net_app_list_quota_rules_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.list_quota_rules", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ListQuotaRules", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ListQuotaRules" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ListQuotaRulesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListQuotaRulesPager", + "shortName": "list_quota_rules" + }, + "description": "Sample for ListQuotaRules", + "file": "netapp_v1_generated_net_app_list_quota_rules_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ListQuotaRules_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": "netapp_v1_generated_net_app_list_quota_rules_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.list_replications", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ListReplications", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ListReplications" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ListReplicationsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListReplicationsAsyncPager", + "shortName": "list_replications" + }, + "description": "Sample for ListReplications", + "file": "netapp_v1_generated_net_app_list_replications_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ListReplications_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": "netapp_v1_generated_net_app_list_replications_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.list_replications", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ListReplications", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ListReplications" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ListReplicationsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListReplicationsPager", + "shortName": "list_replications" + }, + "description": "Sample for ListReplications", + "file": "netapp_v1_generated_net_app_list_replications_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ListReplications_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": "netapp_v1_generated_net_app_list_replications_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.list_snapshots", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ListSnapshots", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ListSnapshots" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ListSnapshotsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListSnapshotsAsyncPager", + "shortName": "list_snapshots" + }, + "description": "Sample for ListSnapshots", + "file": "netapp_v1_generated_net_app_list_snapshots_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ListSnapshots_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": "netapp_v1_generated_net_app_list_snapshots_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.list_snapshots", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ListSnapshots", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ListSnapshots" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ListSnapshotsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListSnapshotsPager", + "shortName": "list_snapshots" + }, + "description": "Sample for ListSnapshots", + "file": "netapp_v1_generated_net_app_list_snapshots_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ListSnapshots_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": "netapp_v1_generated_net_app_list_snapshots_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.list_storage_pools", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ListStoragePools", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ListStoragePools" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ListStoragePoolsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListStoragePoolsAsyncPager", + "shortName": "list_storage_pools" + }, + "description": "Sample for ListStoragePools", + "file": "netapp_v1_generated_net_app_list_storage_pools_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ListStoragePools_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": "netapp_v1_generated_net_app_list_storage_pools_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.list_storage_pools", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ListStoragePools", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ListStoragePools" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ListStoragePoolsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListStoragePoolsPager", + "shortName": "list_storage_pools" + }, + "description": "Sample for ListStoragePools", + "file": "netapp_v1_generated_net_app_list_storage_pools_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ListStoragePools_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": "netapp_v1_generated_net_app_list_storage_pools_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.list_volumes", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ListVolumes", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ListVolumes" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ListVolumesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListVolumesAsyncPager", + "shortName": "list_volumes" + }, + "description": "Sample for ListVolumes", + "file": "netapp_v1_generated_net_app_list_volumes_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ListVolumes_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": "netapp_v1_generated_net_app_list_volumes_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.list_volumes", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ListVolumes", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ListVolumes" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ListVolumesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListVolumesPager", + "shortName": "list_volumes" + }, + "description": "Sample for ListVolumes", + "file": "netapp_v1_generated_net_app_list_volumes_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ListVolumes_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": "netapp_v1_generated_net_app_list_volumes_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.resume_replication", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ResumeReplication", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ResumeReplication" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ResumeReplicationRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "resume_replication" + }, + "description": "Sample for ResumeReplication", + "file": "netapp_v1_generated_net_app_resume_replication_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ResumeReplication_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": "netapp_v1_generated_net_app_resume_replication_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.resume_replication", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ResumeReplication", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ResumeReplication" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ResumeReplicationRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "resume_replication" + }, + "description": "Sample for ResumeReplication", + "file": "netapp_v1_generated_net_app_resume_replication_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ResumeReplication_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": "netapp_v1_generated_net_app_resume_replication_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.reverse_replication_direction", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ReverseReplicationDirection", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ReverseReplicationDirection" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ReverseReplicationDirectionRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "reverse_replication_direction" + }, + "description": "Sample for ReverseReplicationDirection", + "file": "netapp_v1_generated_net_app_reverse_replication_direction_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ReverseReplicationDirection_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": "netapp_v1_generated_net_app_reverse_replication_direction_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.reverse_replication_direction", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ReverseReplicationDirection", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ReverseReplicationDirection" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ReverseReplicationDirectionRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "reverse_replication_direction" + }, + "description": "Sample for ReverseReplicationDirection", + "file": "netapp_v1_generated_net_app_reverse_replication_direction_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ReverseReplicationDirection_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": "netapp_v1_generated_net_app_reverse_replication_direction_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.revert_volume", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.RevertVolume", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "RevertVolume" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.RevertVolumeRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "revert_volume" + }, + "description": "Sample for RevertVolume", + "file": "netapp_v1_generated_net_app_revert_volume_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_RevertVolume_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": "netapp_v1_generated_net_app_revert_volume_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.revert_volume", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.RevertVolume", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "RevertVolume" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.RevertVolumeRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "revert_volume" + }, + "description": "Sample for RevertVolume", + "file": "netapp_v1_generated_net_app_revert_volume_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_RevertVolume_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": "netapp_v1_generated_net_app_revert_volume_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.stop_replication", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.StopReplication", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "StopReplication" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.StopReplicationRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "stop_replication" + }, + "description": "Sample for StopReplication", + "file": "netapp_v1_generated_net_app_stop_replication_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_StopReplication_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": "netapp_v1_generated_net_app_stop_replication_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.stop_replication", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.StopReplication", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "StopReplication" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.StopReplicationRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "stop_replication" + }, + "description": "Sample for StopReplication", + "file": "netapp_v1_generated_net_app_stop_replication_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_StopReplication_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": "netapp_v1_generated_net_app_stop_replication_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.switch_active_replica_zone", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.SwitchActiveReplicaZone", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "SwitchActiveReplicaZone" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.SwitchActiveReplicaZoneRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "switch_active_replica_zone" + }, + "description": "Sample for SwitchActiveReplicaZone", + "file": "netapp_v1_generated_net_app_switch_active_replica_zone_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_SwitchActiveReplicaZone_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": "netapp_v1_generated_net_app_switch_active_replica_zone_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.switch_active_replica_zone", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.SwitchActiveReplicaZone", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "SwitchActiveReplicaZone" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.SwitchActiveReplicaZoneRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "switch_active_replica_zone" + }, + "description": "Sample for SwitchActiveReplicaZone", + "file": "netapp_v1_generated_net_app_switch_active_replica_zone_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_SwitchActiveReplicaZone_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": "netapp_v1_generated_net_app_switch_active_replica_zone_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.sync_replication", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.SyncReplication", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "SyncReplication" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.SyncReplicationRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "sync_replication" + }, + "description": "Sample for SyncReplication", + "file": "netapp_v1_generated_net_app_sync_replication_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_SyncReplication_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": "netapp_v1_generated_net_app_sync_replication_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.sync_replication", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.SyncReplication", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "SyncReplication" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.SyncReplicationRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "sync_replication" + }, + "description": "Sample for SyncReplication", + "file": "netapp_v1_generated_net_app_sync_replication_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_SyncReplication_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": "netapp_v1_generated_net_app_sync_replication_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.update_active_directory", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.UpdateActiveDirectory", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "UpdateActiveDirectory" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.UpdateActiveDirectoryRequest" + }, + { + "name": "active_directory", + "type": "google.cloud.netapp_v1.types.ActiveDirectory" + }, + { + "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, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_active_directory" + }, + "description": "Sample for UpdateActiveDirectory", + "file": "netapp_v1_generated_net_app_update_active_directory_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_UpdateActiveDirectory_async", + "segments": [ + { + "end": 62, + "start": 27, + "type": "FULL" + }, + { + "end": 62, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 59, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 63, + "start": 60, + "type": "RESPONSE_HANDLING" + } + ], + "title": "netapp_v1_generated_net_app_update_active_directory_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.update_active_directory", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.UpdateActiveDirectory", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "UpdateActiveDirectory" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.UpdateActiveDirectoryRequest" + }, + { + "name": "active_directory", + "type": "google.cloud.netapp_v1.types.ActiveDirectory" + }, + { + "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, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_active_directory" + }, + "description": "Sample for UpdateActiveDirectory", + "file": "netapp_v1_generated_net_app_update_active_directory_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_UpdateActiveDirectory_sync", + "segments": [ + { + "end": 62, + "start": 27, + "type": "FULL" + }, + { + "end": 62, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 59, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 63, + "start": 60, + "type": "RESPONSE_HANDLING" + } + ], + "title": "netapp_v1_generated_net_app_update_active_directory_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.update_backup_policy", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.UpdateBackupPolicy", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "UpdateBackupPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.UpdateBackupPolicyRequest" + }, + { + "name": "backup_policy", + "type": "google.cloud.netapp_v1.types.BackupPolicy" + }, + { + "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, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_backup_policy" + }, + "description": "Sample for UpdateBackupPolicy", + "file": "netapp_v1_generated_net_app_update_backup_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_UpdateBackupPolicy_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": "netapp_v1_generated_net_app_update_backup_policy_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.update_backup_policy", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.UpdateBackupPolicy", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "UpdateBackupPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.UpdateBackupPolicyRequest" + }, + { + "name": "backup_policy", + "type": "google.cloud.netapp_v1.types.BackupPolicy" + }, + { + "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, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_backup_policy" + }, + "description": "Sample for UpdateBackupPolicy", + "file": "netapp_v1_generated_net_app_update_backup_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_UpdateBackupPolicy_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": "netapp_v1_generated_net_app_update_backup_policy_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.update_backup_vault", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.UpdateBackupVault", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "UpdateBackupVault" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.UpdateBackupVaultRequest" + }, + { + "name": "backup_vault", + "type": "google.cloud.netapp_v1.types.BackupVault" + }, + { + "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, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_backup_vault" + }, + "description": "Sample for UpdateBackupVault", + "file": "netapp_v1_generated_net_app_update_backup_vault_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_UpdateBackupVault_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": "netapp_v1_generated_net_app_update_backup_vault_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.update_backup_vault", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.UpdateBackupVault", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "UpdateBackupVault" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.UpdateBackupVaultRequest" + }, + { + "name": "backup_vault", + "type": "google.cloud.netapp_v1.types.BackupVault" + }, + { + "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, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_backup_vault" + }, + "description": "Sample for UpdateBackupVault", + "file": "netapp_v1_generated_net_app_update_backup_vault_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_UpdateBackupVault_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": "netapp_v1_generated_net_app_update_backup_vault_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.update_backup", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.UpdateBackup", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "UpdateBackup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.UpdateBackupRequest" + }, + { + "name": "backup", + "type": "google.cloud.netapp_v1.types.Backup" + }, + { + "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, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_backup" + }, + "description": "Sample for UpdateBackup", + "file": "netapp_v1_generated_net_app_update_backup_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_UpdateBackup_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": "netapp_v1_generated_net_app_update_backup_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.update_backup", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.UpdateBackup", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "UpdateBackup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.UpdateBackupRequest" + }, + { + "name": "backup", + "type": "google.cloud.netapp_v1.types.Backup" + }, + { + "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, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_backup" + }, + "description": "Sample for UpdateBackup", + "file": "netapp_v1_generated_net_app_update_backup_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_UpdateBackup_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": "netapp_v1_generated_net_app_update_backup_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.update_kms_config", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.UpdateKmsConfig", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "UpdateKmsConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.UpdateKmsConfigRequest" + }, + { + "name": "kms_config", + "type": "google.cloud.netapp_v1.types.KmsConfig" + }, + { + "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, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_kms_config" + }, + "description": "Sample for UpdateKmsConfig", + "file": "netapp_v1_generated_net_app_update_kms_config_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_UpdateKmsConfig_async", + "segments": [ + { + "end": 58, + "start": 27, + "type": "FULL" + }, + { + "end": 58, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 48, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 55, + "start": 49, + "type": "REQUEST_EXECUTION" + }, + { + "end": 59, + "start": 56, + "type": "RESPONSE_HANDLING" + } + ], + "title": "netapp_v1_generated_net_app_update_kms_config_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.update_kms_config", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.UpdateKmsConfig", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "UpdateKmsConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.UpdateKmsConfigRequest" + }, + { + "name": "kms_config", + "type": "google.cloud.netapp_v1.types.KmsConfig" + }, + { + "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, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_kms_config" + }, + "description": "Sample for UpdateKmsConfig", + "file": "netapp_v1_generated_net_app_update_kms_config_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_UpdateKmsConfig_sync", + "segments": [ + { + "end": 58, + "start": 27, + "type": "FULL" + }, + { + "end": 58, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 48, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 55, + "start": 49, + "type": "REQUEST_EXECUTION" + }, + { + "end": 59, + "start": 56, + "type": "RESPONSE_HANDLING" + } + ], + "title": "netapp_v1_generated_net_app_update_kms_config_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.update_quota_rule", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.UpdateQuotaRule", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "UpdateQuotaRule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.UpdateQuotaRuleRequest" + }, + { + "name": "quota_rule", + "type": "google.cloud.netapp_v1.types.QuotaRule" + }, + { + "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, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_quota_rule" + }, + "description": "Sample for UpdateQuotaRule", + "file": "netapp_v1_generated_net_app_update_quota_rule_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_UpdateQuotaRule_async", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 56, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 57, + "type": "RESPONSE_HANDLING" + } + ], + "title": "netapp_v1_generated_net_app_update_quota_rule_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.update_quota_rule", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.UpdateQuotaRule", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "UpdateQuotaRule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.UpdateQuotaRuleRequest" + }, + { + "name": "quota_rule", + "type": "google.cloud.netapp_v1.types.QuotaRule" + }, + { + "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, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_quota_rule" + }, + "description": "Sample for UpdateQuotaRule", + "file": "netapp_v1_generated_net_app_update_quota_rule_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_UpdateQuotaRule_sync", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 56, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 57, + "type": "RESPONSE_HANDLING" + } + ], + "title": "netapp_v1_generated_net_app_update_quota_rule_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.update_replication", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.UpdateReplication", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "UpdateReplication" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.UpdateReplicationRequest" + }, + { + "name": "replication", + "type": "google.cloud.netapp_v1.types.Replication" + }, + { + "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, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_replication" + }, + "description": "Sample for UpdateReplication", + "file": "netapp_v1_generated_net_app_update_replication_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_UpdateReplication_async", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 56, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 57, + "type": "RESPONSE_HANDLING" + } + ], + "title": "netapp_v1_generated_net_app_update_replication_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.update_replication", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.UpdateReplication", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "UpdateReplication" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.UpdateReplicationRequest" + }, + { + "name": "replication", + "type": "google.cloud.netapp_v1.types.Replication" + }, + { + "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, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_replication" + }, + "description": "Sample for UpdateReplication", + "file": "netapp_v1_generated_net_app_update_replication_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_UpdateReplication_sync", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 56, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 57, + "type": "RESPONSE_HANDLING" + } + ], + "title": "netapp_v1_generated_net_app_update_replication_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.update_snapshot", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.UpdateSnapshot", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "UpdateSnapshot" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.UpdateSnapshotRequest" + }, + { + "name": "snapshot", + "type": "google.cloud.netapp_v1.types.Snapshot" + }, + { + "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, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_snapshot" + }, + "description": "Sample for UpdateSnapshot", + "file": "netapp_v1_generated_net_app_update_snapshot_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_UpdateSnapshot_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": "netapp_v1_generated_net_app_update_snapshot_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.update_snapshot", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.UpdateSnapshot", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "UpdateSnapshot" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.UpdateSnapshotRequest" + }, + { + "name": "snapshot", + "type": "google.cloud.netapp_v1.types.Snapshot" + }, + { + "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, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_snapshot" + }, + "description": "Sample for UpdateSnapshot", + "file": "netapp_v1_generated_net_app_update_snapshot_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_UpdateSnapshot_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": "netapp_v1_generated_net_app_update_snapshot_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.update_storage_pool", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.UpdateStoragePool", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "UpdateStoragePool" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.UpdateStoragePoolRequest" + }, + { + "name": "storage_pool", + "type": "google.cloud.netapp_v1.types.StoragePool" + }, + { + "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, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_storage_pool" + }, + "description": "Sample for UpdateStoragePool", + "file": "netapp_v1_generated_net_app_update_storage_pool_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_UpdateStoragePool_async", + "segments": [ + { + "end": 60, + "start": 27, + "type": "FULL" + }, + { + "end": 60, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 50, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 57, + "start": 51, + "type": "REQUEST_EXECUTION" + }, + { + "end": 61, + "start": 58, + "type": "RESPONSE_HANDLING" + } + ], + "title": "netapp_v1_generated_net_app_update_storage_pool_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.update_storage_pool", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.UpdateStoragePool", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "UpdateStoragePool" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.UpdateStoragePoolRequest" + }, + { + "name": "storage_pool", + "type": "google.cloud.netapp_v1.types.StoragePool" + }, + { + "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, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_storage_pool" + }, + "description": "Sample for UpdateStoragePool", + "file": "netapp_v1_generated_net_app_update_storage_pool_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_UpdateStoragePool_sync", + "segments": [ + { + "end": 60, + "start": 27, + "type": "FULL" + }, + { + "end": 60, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 50, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 57, + "start": 51, + "type": "REQUEST_EXECUTION" + }, + { + "end": 61, + "start": 58, + "type": "RESPONSE_HANDLING" + } + ], + "title": "netapp_v1_generated_net_app_update_storage_pool_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.update_volume", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.UpdateVolume", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "UpdateVolume" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.UpdateVolumeRequest" + }, + { + "name": "volume", + "type": "google.cloud.netapp_v1.types.Volume" + }, + { + "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, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_volume" + }, + "description": "Sample for UpdateVolume", + "file": "netapp_v1_generated_net_app_update_volume_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_UpdateVolume_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": "netapp_v1_generated_net_app_update_volume_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.update_volume", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.UpdateVolume", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "UpdateVolume" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.UpdateVolumeRequest" + }, + { + "name": "volume", + "type": "google.cloud.netapp_v1.types.Volume" + }, + { + "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, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_volume" + }, + "description": "Sample for UpdateVolume", + "file": "netapp_v1_generated_net_app_update_volume_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_UpdateVolume_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": "netapp_v1_generated_net_app_update_volume_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.validate_directory_service", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ValidateDirectoryService", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ValidateDirectoryService" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ValidateDirectoryServiceRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "validate_directory_service" + }, + "description": "Sample for ValidateDirectoryService", + "file": "netapp_v1_generated_net_app_validate_directory_service_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ValidateDirectoryService_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": "netapp_v1_generated_net_app_validate_directory_service_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.validate_directory_service", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.ValidateDirectoryService", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "ValidateDirectoryService" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.ValidateDirectoryServiceRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "validate_directory_service" + }, + "description": "Sample for ValidateDirectoryService", + "file": "netapp_v1_generated_net_app_validate_directory_service_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_ValidateDirectoryService_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": "netapp_v1_generated_net_app_validate_directory_service_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", + "shortName": "NetAppAsyncClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.verify_kms_config", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.VerifyKmsConfig", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "VerifyKmsConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.VerifyKmsConfigRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.VerifyKmsConfigResponse", + "shortName": "verify_kms_config" + }, + "description": "Sample for VerifyKmsConfig", + "file": "netapp_v1_generated_net_app_verify_kms_config_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_VerifyKmsConfig_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": "netapp_v1_generated_net_app_verify_kms_config_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.netapp_v1.NetAppClient", + "shortName": "NetAppClient" + }, + "fullName": "google.cloud.netapp_v1.NetAppClient.verify_kms_config", + "method": { + "fullName": "google.cloud.netapp.v1.NetApp.VerifyKmsConfig", + "service": { + "fullName": "google.cloud.netapp.v1.NetApp", + "shortName": "NetApp" + }, + "shortName": "VerifyKmsConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.netapp_v1.types.VerifyKmsConfigRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.netapp_v1.types.VerifyKmsConfigResponse", + "shortName": "verify_kms_config" + }, + "description": "Sample for VerifyKmsConfig", + "file": "netapp_v1_generated_net_app_verify_kms_config_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "netapp_v1_generated_NetApp_VerifyKmsConfig_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": "netapp_v1_generated_net_app_verify_kms_config_sync.py" + } + ] +} diff --git a/owl-bot-staging/google-cloud-netapp/v1/scripts/fixup_netapp_v1_keywords.py b/owl-bot-staging/google-cloud-netapp/v1/scripts/fixup_netapp_v1_keywords.py new file mode 100644 index 000000000000..c8c3b6032598 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/scripts/fixup_netapp_v1_keywords.py @@ -0,0 +1,235 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2025 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 netappCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'create_active_directory': ('parent', 'active_directory', 'active_directory_id', ), + 'create_backup': ('parent', 'backup_id', 'backup', ), + 'create_backup_policy': ('parent', 'backup_policy', 'backup_policy_id', ), + 'create_backup_vault': ('parent', 'backup_vault_id', 'backup_vault', ), + 'create_kms_config': ('parent', 'kms_config_id', 'kms_config', ), + 'create_quota_rule': ('parent', 'quota_rule', 'quota_rule_id', ), + 'create_replication': ('parent', 'replication', 'replication_id', ), + 'create_snapshot': ('parent', 'snapshot', 'snapshot_id', ), + 'create_storage_pool': ('parent', 'storage_pool_id', 'storage_pool', ), + 'create_volume': ('parent', 'volume_id', 'volume', ), + 'delete_active_directory': ('name', ), + 'delete_backup': ('name', ), + 'delete_backup_policy': ('name', ), + 'delete_backup_vault': ('name', ), + 'delete_kms_config': ('name', ), + 'delete_quota_rule': ('name', ), + 'delete_replication': ('name', ), + 'delete_snapshot': ('name', ), + 'delete_storage_pool': ('name', ), + 'delete_volume': ('name', 'force', ), + 'encrypt_volumes': ('name', ), + 'establish_peering': ('name', 'peer_cluster_name', 'peer_svm_name', 'peer_volume_name', 'peer_ip_addresses', ), + 'get_active_directory': ('name', ), + 'get_backup': ('name', ), + 'get_backup_policy': ('name', ), + 'get_backup_vault': ('name', ), + 'get_kms_config': ('name', ), + 'get_quota_rule': ('name', ), + 'get_replication': ('name', ), + 'get_snapshot': ('name', ), + 'get_storage_pool': ('name', ), + 'get_volume': ('name', ), + 'list_active_directories': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_backup_policies': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_backups': ('parent', 'page_size', 'page_token', 'order_by', 'filter', ), + 'list_backup_vaults': ('parent', 'page_size', 'page_token', 'order_by', 'filter', ), + 'list_kms_configs': ('parent', 'page_size', 'page_token', 'order_by', 'filter', ), + 'list_quota_rules': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_replications': ('parent', 'page_size', 'page_token', 'order_by', 'filter', ), + 'list_snapshots': ('parent', 'page_size', 'page_token', 'order_by', 'filter', ), + 'list_storage_pools': ('parent', 'page_size', 'page_token', 'order_by', 'filter', ), + 'list_volumes': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'resume_replication': ('name', ), + 'reverse_replication_direction': ('name', ), + 'revert_volume': ('name', 'snapshot_id', ), + 'stop_replication': ('name', 'force', ), + 'switch_active_replica_zone': ('name', ), + 'sync_replication': ('name', ), + 'update_active_directory': ('update_mask', 'active_directory', ), + 'update_backup': ('update_mask', 'backup', ), + 'update_backup_policy': ('update_mask', 'backup_policy', ), + 'update_backup_vault': ('update_mask', 'backup_vault', ), + 'update_kms_config': ('update_mask', 'kms_config', ), + 'update_quota_rule': ('quota_rule', 'update_mask', ), + 'update_replication': ('update_mask', 'replication', ), + 'update_snapshot': ('update_mask', 'snapshot', ), + 'update_storage_pool': ('update_mask', 'storage_pool', ), + 'update_volume': ('update_mask', 'volume', ), + 'validate_directory_service': ('name', 'directory_service_type', ), + 'verify_kms_config': ('name', ), + } + + 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=netappCallTransformer(), +): + """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 netapp 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-netapp/v1/setup.py b/owl-bot-staging/google-cloud-netapp/v1/setup.py new file mode 100644 index 000000000000..bdf343c39ab4 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/setup.py @@ -0,0 +1,98 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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-netapp' + + +description = "Google Cloud Netapp API client library" + +version = None + +with open(os.path.join(package_root, 'google/cloud/netapp/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.0,!=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.0,!=2.24.0,!=2.25.0", + "proto-plus >= 1.22.3, <2.0.0", + "proto-plus >= 1.25.0, <2.0.0; python_version >= '3.13'", + "protobuf>=3.20.2,<7.0.0,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", +] +extras = { +} +url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-netapp" + +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-netapp/v1/testing/constraints-3.10.txt b/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.10.txt new file mode 100644 index 000000000000..ed7f9aed2559 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.10.txt @@ -0,0 +1,6 @@ +# -*- 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 diff --git a/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.11.txt b/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.11.txt new file mode 100644 index 000000000000..ed7f9aed2559 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.11.txt @@ -0,0 +1,6 @@ +# -*- 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 diff --git a/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.12.txt b/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.12.txt new file mode 100644 index 000000000000..ed7f9aed2559 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.12.txt @@ -0,0 +1,6 @@ +# -*- 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 diff --git a/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.13.txt b/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.13.txt new file mode 100644 index 000000000000..c20a77817caa --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.13.txt @@ -0,0 +1,11 @@ +# We use the constraints file for the latest Python version +# (currently this file) to check that the latest +# major versions of dependencies are supported in setup.py. +# List all library dependencies and extras in this file. +# Require the latest major version be installed for each dependency. +# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0", +# Then this file should have google-cloud-foo>=1 +google-api-core>=2 +google-auth>=2 +proto-plus>=1 +protobuf>=6 diff --git a/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.7.txt b/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.7.txt new file mode 100644 index 000000000000..a77f12bc13e4 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.7.txt @@ -0,0 +1,10 @@ +# 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.0", +# 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 diff --git a/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.8.txt b/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.8.txt new file mode 100644 index 000000000000..ed7f9aed2559 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.8.txt @@ -0,0 +1,6 @@ +# -*- 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 diff --git a/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.9.txt b/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.9.txt new file mode 100644 index 000000000000..ed7f9aed2559 --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.9.txt @@ -0,0 +1,6 @@ +# -*- 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 diff --git a/owl-bot-staging/google-cloud-netapp/v1/tests/__init__.py b/owl-bot-staging/google-cloud-netapp/v1/tests/__init__.py new file mode 100644 index 000000000000..191773d5572d --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/tests/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2025 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-netapp/v1/tests/unit/__init__.py b/owl-bot-staging/google-cloud-netapp/v1/tests/unit/__init__.py new file mode 100644 index 000000000000..191773d5572d --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/tests/unit/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2025 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-netapp/v1/tests/unit/gapic/__init__.py b/owl-bot-staging/google-cloud-netapp/v1/tests/unit/gapic/__init__.py new file mode 100644 index 000000000000..191773d5572d --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/tests/unit/gapic/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2025 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-netapp/v1/tests/unit/gapic/netapp_v1/__init__.py b/owl-bot-staging/google-cloud-netapp/v1/tests/unit/gapic/netapp_v1/__init__.py new file mode 100644 index 000000000000..191773d5572d --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/tests/unit/gapic/netapp_v1/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2025 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-netapp/v1/tests/unit/gapic/netapp_v1/test_net_app.py b/owl-bot-staging/google-cloud-netapp/v1/tests/unit/gapic/netapp_v1/test_net_app.py new file mode 100644 index 000000000000..7068978e200f --- /dev/null +++ b/owl-bot-staging/google-cloud-netapp/v1/tests/unit/gapic/netapp_v1/test_net_app.py @@ -0,0 +1,46391 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 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.location import locations_pb2 +from google.cloud.netapp_v1.services.net_app import NetAppAsyncClient +from google.cloud.netapp_v1.services.net_app import NetAppClient +from google.cloud.netapp_v1.services.net_app import pagers +from google.cloud.netapp_v1.services.net_app import transports +from google.cloud.netapp_v1.types import active_directory +from google.cloud.netapp_v1.types import active_directory as gcn_active_directory +from google.cloud.netapp_v1.types import backup +from google.cloud.netapp_v1.types import backup as gcn_backup +from google.cloud.netapp_v1.types import backup_policy +from google.cloud.netapp_v1.types import backup_policy as gcn_backup_policy +from google.cloud.netapp_v1.types import backup_vault +from google.cloud.netapp_v1.types import backup_vault as gcn_backup_vault +from google.cloud.netapp_v1.types import cloud_netapp_service +from google.cloud.netapp_v1.types import common +from google.cloud.netapp_v1.types import kms +from google.cloud.netapp_v1.types import quota_rule +from google.cloud.netapp_v1.types import quota_rule as gcn_quota_rule +from google.cloud.netapp_v1.types import replication +from google.cloud.netapp_v1.types import replication as gcn_replication +from google.cloud.netapp_v1.types import snapshot +from google.cloud.netapp_v1.types import snapshot as gcn_snapshot +from google.cloud.netapp_v1.types import storage_pool +from google.cloud.netapp_v1.types import storage_pool as gcn_storage_pool +from google.cloud.netapp_v1.types import volume +from google.cloud.netapp_v1.types import volume as gcn_volume +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 timestamp_pb2 # type: ignore +import google.auth + + + +CRED_INFO_JSON = { + "credential_source": "/path/to/file", + "credential_type": "service account credentials", + "principal": "service-account@example.com", +} +CRED_INFO_STRING = json.dumps(CRED_INFO_JSON) + + +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 NetAppClient._get_default_mtls_endpoint(None) is None + assert NetAppClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert NetAppClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert NetAppClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert NetAppClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert NetAppClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + +def test__read_environment_variables(): + assert NetAppClient._read_environment_variables() == (False, "auto", None) + + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + assert NetAppClient._read_environment_variables() == (True, "auto", None) + + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + assert NetAppClient._read_environment_variables() == (False, "auto", None) + + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): + with pytest.raises(ValueError) as excinfo: + NetAppClient._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 NetAppClient._read_environment_variables() == (False, "never", None) + + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + assert NetAppClient._read_environment_variables() == (False, "always", None) + + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}): + assert NetAppClient._read_environment_variables() == (False, "auto", None) + + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): + with pytest.raises(MutualTLSChannelError) as excinfo: + NetAppClient._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 NetAppClient._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 NetAppClient._get_client_cert_source(None, False) is None + assert NetAppClient._get_client_cert_source(mock_provided_cert_source, False) is None + assert NetAppClient._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 NetAppClient._get_client_cert_source(None, True) is mock_default_cert_source + assert NetAppClient._get_client_cert_source(mock_provided_cert_source, "true") is mock_provided_cert_source + +@mock.patch.object(NetAppClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(NetAppClient)) +@mock.patch.object(NetAppAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(NetAppAsyncClient)) +def test__get_api_endpoint(): + api_override = "foo.com" + mock_client_cert_source = mock.Mock() + default_universe = NetAppClient._DEFAULT_UNIVERSE + default_endpoint = NetAppClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=default_universe) + mock_universe = "bar.com" + mock_endpoint = NetAppClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=mock_universe) + + assert NetAppClient._get_api_endpoint(api_override, mock_client_cert_source, default_universe, "always") == api_override + assert NetAppClient._get_api_endpoint(None, mock_client_cert_source, default_universe, "auto") == NetAppClient.DEFAULT_MTLS_ENDPOINT + assert NetAppClient._get_api_endpoint(None, None, default_universe, "auto") == default_endpoint + assert NetAppClient._get_api_endpoint(None, None, default_universe, "always") == NetAppClient.DEFAULT_MTLS_ENDPOINT + assert NetAppClient._get_api_endpoint(None, mock_client_cert_source, default_universe, "always") == NetAppClient.DEFAULT_MTLS_ENDPOINT + assert NetAppClient._get_api_endpoint(None, None, mock_universe, "never") == mock_endpoint + assert NetAppClient._get_api_endpoint(None, None, default_universe, "never") == default_endpoint + + with pytest.raises(MutualTLSChannelError) as excinfo: + NetAppClient._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 NetAppClient._get_universe_domain(client_universe_domain, universe_domain_env) == client_universe_domain + assert NetAppClient._get_universe_domain(None, universe_domain_env) == universe_domain_env + assert NetAppClient._get_universe_domain(None, None) == NetAppClient._DEFAULT_UNIVERSE + + with pytest.raises(ValueError) as excinfo: + NetAppClient._get_universe_domain("", None) + assert str(excinfo.value) == "Universe Domain cannot be an empty string." + +@pytest.mark.parametrize("error_code,cred_info_json,show_cred_info", [ + (401, CRED_INFO_JSON, True), + (403, CRED_INFO_JSON, True), + (404, CRED_INFO_JSON, True), + (500, CRED_INFO_JSON, False), + (401, None, False), + (403, None, False), + (404, None, False), + (500, None, False) +]) +def test__add_cred_info_for_auth_errors(error_code, cred_info_json, show_cred_info): + cred = mock.Mock(["get_cred_info"]) + cred.get_cred_info = mock.Mock(return_value=cred_info_json) + client = NetAppClient(credentials=cred) + client._transport._credentials = cred + + error = core_exceptions.GoogleAPICallError("message", details=["foo"]) + error.code = error_code + + client._add_cred_info_for_auth_errors(error) + if show_cred_info: + assert error.details == ["foo", CRED_INFO_STRING] + else: + assert error.details == ["foo"] + +@pytest.mark.parametrize("error_code", [401,403,404,500]) +def test__add_cred_info_for_auth_errors_no_get_cred_info(error_code): + cred = mock.Mock([]) + assert not hasattr(cred, "get_cred_info") + client = NetAppClient(credentials=cred) + client._transport._credentials = cred + + error = core_exceptions.GoogleAPICallError("message", details=[]) + error.code = error_code + + client._add_cred_info_for_auth_errors(error) + assert error.details == [] + +@pytest.mark.parametrize("client_class,transport_name", [ + (NetAppClient, "grpc"), + (NetAppAsyncClient, "grpc_asyncio"), + (NetAppClient, "rest"), +]) +def test_net_app_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 == ( + 'netapp.googleapis.com:443' + if transport_name in ['grpc', 'grpc_asyncio'] + else + 'https://netapp.googleapis.com' + ) + + +@pytest.mark.parametrize("transport_class,transport_name", [ + (transports.NetAppGrpcTransport, "grpc"), + (transports.NetAppGrpcAsyncIOTransport, "grpc_asyncio"), + (transports.NetAppRestTransport, "rest"), +]) +def test_net_app_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", [ + (NetAppClient, "grpc"), + (NetAppAsyncClient, "grpc_asyncio"), + (NetAppClient, "rest"), +]) +def test_net_app_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 == ( + 'netapp.googleapis.com:443' + if transport_name in ['grpc', 'grpc_asyncio'] + else + 'https://netapp.googleapis.com' + ) + + +def test_net_app_client_get_transport_class(): + transport = NetAppClient.get_transport_class() + available_transports = [ + transports.NetAppGrpcTransport, + transports.NetAppRestTransport, + ] + assert transport in available_transports + + transport = NetAppClient.get_transport_class("grpc") + assert transport == transports.NetAppGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (NetAppClient, transports.NetAppGrpcTransport, "grpc"), + (NetAppAsyncClient, transports.NetAppGrpcAsyncIOTransport, "grpc_asyncio"), + (NetAppClient, transports.NetAppRestTransport, "rest"), +]) +@mock.patch.object(NetAppClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(NetAppClient)) +@mock.patch.object(NetAppAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(NetAppAsyncClient)) +def test_net_app_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(NetAppClient, '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(NetAppClient, '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", [ + (NetAppClient, transports.NetAppGrpcTransport, "grpc", "true"), + (NetAppAsyncClient, transports.NetAppGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (NetAppClient, transports.NetAppGrpcTransport, "grpc", "false"), + (NetAppAsyncClient, transports.NetAppGrpcAsyncIOTransport, "grpc_asyncio", "false"), + (NetAppClient, transports.NetAppRestTransport, "rest", "true"), + (NetAppClient, transports.NetAppRestTransport, "rest", "false"), +]) +@mock.patch.object(NetAppClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(NetAppClient)) +@mock.patch.object(NetAppAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(NetAppAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_net_app_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", [ + NetAppClient, NetAppAsyncClient +]) +@mock.patch.object(NetAppClient, "DEFAULT_ENDPOINT", modify_default_endpoint(NetAppClient)) +@mock.patch.object(NetAppAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(NetAppAsyncClient)) +def test_net_app_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", [ + NetAppClient, NetAppAsyncClient +]) +@mock.patch.object(NetAppClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(NetAppClient)) +@mock.patch.object(NetAppAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(NetAppAsyncClient)) +def test_net_app_client_client_api_endpoint(client_class): + mock_client_cert_source = client_cert_source_callback + api_override = "foo.com" + default_universe = NetAppClient._DEFAULT_UNIVERSE + default_endpoint = NetAppClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=default_universe) + mock_universe = "bar.com" + mock_endpoint = NetAppClient._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", [ + (NetAppClient, transports.NetAppGrpcTransport, "grpc"), + (NetAppAsyncClient, transports.NetAppGrpcAsyncIOTransport, "grpc_asyncio"), + (NetAppClient, transports.NetAppRestTransport, "rest"), +]) +def test_net_app_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", [ + (NetAppClient, transports.NetAppGrpcTransport, "grpc", grpc_helpers), + (NetAppAsyncClient, transports.NetAppGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), + (NetAppClient, transports.NetAppRestTransport, "rest", None), +]) +def test_net_app_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_net_app_client_client_options_from_dict(): + with mock.patch('google.cloud.netapp_v1.services.net_app.transports.NetAppGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = NetAppClient( + 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", [ + (NetAppClient, transports.NetAppGrpcTransport, "grpc", grpc_helpers), + (NetAppAsyncClient, transports.NetAppGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_net_app_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( + "netapp.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + scopes=None, + default_host="netapp.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize("request_type", [ + storage_pool.ListStoragePoolsRequest, + dict, +]) +def test_list_storage_pools(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_storage_pools), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = storage_pool.ListStoragePoolsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_storage_pools(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = storage_pool.ListStoragePoolsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListStoragePoolsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_storage_pools_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 = NetAppClient( + 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 = storage_pool.ListStoragePoolsRequest( + 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_storage_pools), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.list_storage_pools(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == storage_pool.ListStoragePoolsRequest( + parent='parent_value', + page_token='page_token_value', + order_by='order_by_value', + filter='filter_value', + ) + +def test_list_storage_pools_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 = NetAppClient( + 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_storage_pools 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_storage_pools] = mock_rpc + request = {} + client.list_storage_pools(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_storage_pools(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_storage_pools_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 = NetAppAsyncClient( + 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_storage_pools 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_storage_pools] = mock_rpc + + request = {} + await client.list_storage_pools(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_storage_pools(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_storage_pools_async(transport: str = 'grpc_asyncio', request_type=storage_pool.ListStoragePoolsRequest): + client = NetAppAsyncClient( + 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_storage_pools), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(storage_pool.ListStoragePoolsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_storage_pools(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = storage_pool.ListStoragePoolsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListStoragePoolsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_storage_pools_async_from_dict(): + await test_list_storage_pools_async(request_type=dict) + +def test_list_storage_pools_field_headers(): + client = NetAppClient( + 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 = storage_pool.ListStoragePoolsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_storage_pools), + '__call__') as call: + call.return_value = storage_pool.ListStoragePoolsResponse() + client.list_storage_pools(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_storage_pools_field_headers_async(): + client = NetAppAsyncClient( + 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 = storage_pool.ListStoragePoolsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_storage_pools), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(storage_pool.ListStoragePoolsResponse()) + await client.list_storage_pools(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_storage_pools_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_storage_pools), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = storage_pool.ListStoragePoolsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_storage_pools( + 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_storage_pools_flattened_error(): + client = NetAppClient( + 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_storage_pools( + storage_pool.ListStoragePoolsRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_storage_pools_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_storage_pools), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = storage_pool.ListStoragePoolsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(storage_pool.ListStoragePoolsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_storage_pools( + 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_storage_pools_flattened_error_async(): + client = NetAppAsyncClient( + 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_storage_pools( + storage_pool.ListStoragePoolsRequest(), + parent='parent_value', + ) + + +def test_list_storage_pools_pager(transport_name: str = "grpc"): + client = NetAppClient( + 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_storage_pools), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + storage_pool.ListStoragePoolsResponse( + storage_pools=[ + storage_pool.StoragePool(), + storage_pool.StoragePool(), + storage_pool.StoragePool(), + ], + next_page_token='abc', + ), + storage_pool.ListStoragePoolsResponse( + storage_pools=[], + next_page_token='def', + ), + storage_pool.ListStoragePoolsResponse( + storage_pools=[ + storage_pool.StoragePool(), + ], + next_page_token='ghi', + ), + storage_pool.ListStoragePoolsResponse( + storage_pools=[ + storage_pool.StoragePool(), + storage_pool.StoragePool(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_storage_pools(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, storage_pool.StoragePool) + for i in results) +def test_list_storage_pools_pages(transport_name: str = "grpc"): + client = NetAppClient( + 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_storage_pools), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + storage_pool.ListStoragePoolsResponse( + storage_pools=[ + storage_pool.StoragePool(), + storage_pool.StoragePool(), + storage_pool.StoragePool(), + ], + next_page_token='abc', + ), + storage_pool.ListStoragePoolsResponse( + storage_pools=[], + next_page_token='def', + ), + storage_pool.ListStoragePoolsResponse( + storage_pools=[ + storage_pool.StoragePool(), + ], + next_page_token='ghi', + ), + storage_pool.ListStoragePoolsResponse( + storage_pools=[ + storage_pool.StoragePool(), + storage_pool.StoragePool(), + ], + ), + RuntimeError, + ) + pages = list(client.list_storage_pools(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_storage_pools_async_pager(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_storage_pools), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + storage_pool.ListStoragePoolsResponse( + storage_pools=[ + storage_pool.StoragePool(), + storage_pool.StoragePool(), + storage_pool.StoragePool(), + ], + next_page_token='abc', + ), + storage_pool.ListStoragePoolsResponse( + storage_pools=[], + next_page_token='def', + ), + storage_pool.ListStoragePoolsResponse( + storage_pools=[ + storage_pool.StoragePool(), + ], + next_page_token='ghi', + ), + storage_pool.ListStoragePoolsResponse( + storage_pools=[ + storage_pool.StoragePool(), + storage_pool.StoragePool(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_storage_pools(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, storage_pool.StoragePool) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_storage_pools_async_pages(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_storage_pools), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + storage_pool.ListStoragePoolsResponse( + storage_pools=[ + storage_pool.StoragePool(), + storage_pool.StoragePool(), + storage_pool.StoragePool(), + ], + next_page_token='abc', + ), + storage_pool.ListStoragePoolsResponse( + storage_pools=[], + next_page_token='def', + ), + storage_pool.ListStoragePoolsResponse( + storage_pools=[ + storage_pool.StoragePool(), + ], + next_page_token='ghi', + ), + storage_pool.ListStoragePoolsResponse( + storage_pools=[ + storage_pool.StoragePool(), + storage_pool.StoragePool(), + ], + ), + 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_storage_pools(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", [ + gcn_storage_pool.CreateStoragePoolRequest, + dict, +]) +def test_create_storage_pool(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_storage_pool), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_storage_pool(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gcn_storage_pool.CreateStoragePoolRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_storage_pool_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 = NetAppClient( + 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 = gcn_storage_pool.CreateStoragePoolRequest( + parent='parent_value', + storage_pool_id='storage_pool_id_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_storage_pool), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.create_storage_pool(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gcn_storage_pool.CreateStoragePoolRequest( + parent='parent_value', + storage_pool_id='storage_pool_id_value', + ) + +def test_create_storage_pool_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 = NetAppClient( + 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_storage_pool 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_storage_pool] = mock_rpc + request = {} + client.create_storage_pool(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_storage_pool(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_storage_pool_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 = NetAppAsyncClient( + 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_storage_pool 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_storage_pool] = mock_rpc + + request = {} + await client.create_storage_pool(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_storage_pool(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_storage_pool_async(transport: str = 'grpc_asyncio', request_type=gcn_storage_pool.CreateStoragePoolRequest): + client = NetAppAsyncClient( + 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_storage_pool), + '__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_storage_pool(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gcn_storage_pool.CreateStoragePoolRequest() + 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_storage_pool_async_from_dict(): + await test_create_storage_pool_async(request_type=dict) + +def test_create_storage_pool_field_headers(): + client = NetAppClient( + 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 = gcn_storage_pool.CreateStoragePoolRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_storage_pool), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_storage_pool(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_storage_pool_field_headers_async(): + client = NetAppAsyncClient( + 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 = gcn_storage_pool.CreateStoragePoolRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_storage_pool), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_storage_pool(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_storage_pool_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_storage_pool), + '__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_storage_pool( + parent='parent_value', + storage_pool=gcn_storage_pool.StoragePool(name='name_value'), + storage_pool_id='storage_pool_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].storage_pool + mock_val = gcn_storage_pool.StoragePool(name='name_value') + assert arg == mock_val + arg = args[0].storage_pool_id + mock_val = 'storage_pool_id_value' + assert arg == mock_val + + +def test_create_storage_pool_flattened_error(): + client = NetAppClient( + 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_storage_pool( + gcn_storage_pool.CreateStoragePoolRequest(), + parent='parent_value', + storage_pool=gcn_storage_pool.StoragePool(name='name_value'), + storage_pool_id='storage_pool_id_value', + ) + +@pytest.mark.asyncio +async def test_create_storage_pool_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_storage_pool), + '__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_storage_pool( + parent='parent_value', + storage_pool=gcn_storage_pool.StoragePool(name='name_value'), + storage_pool_id='storage_pool_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].storage_pool + mock_val = gcn_storage_pool.StoragePool(name='name_value') + assert arg == mock_val + arg = args[0].storage_pool_id + mock_val = 'storage_pool_id_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_storage_pool_flattened_error_async(): + client = NetAppAsyncClient( + 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_storage_pool( + gcn_storage_pool.CreateStoragePoolRequest(), + parent='parent_value', + storage_pool=gcn_storage_pool.StoragePool(name='name_value'), + storage_pool_id='storage_pool_id_value', + ) + + +@pytest.mark.parametrize("request_type", [ + storage_pool.GetStoragePoolRequest, + dict, +]) +def test_get_storage_pool(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_storage_pool), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = storage_pool.StoragePool( + name='name_value', + service_level=common.ServiceLevel.PREMIUM, + capacity_gib=1247, + volume_capacity_gib=2006, + volume_count=1312, + state=storage_pool.StoragePool.State.READY, + state_details='state_details_value', + description='description_value', + network='network_value', + active_directory='active_directory_value', + kms_config='kms_config_value', + ldap_enabled=True, + psa_range='psa_range_value', + encryption_type=common.EncryptionType.SERVICE_MANAGED, + global_access_allowed=True, + allow_auto_tiering=True, + replica_zone='replica_zone_value', + zone='zone_value', + satisfies_pzs=True, + satisfies_pzi=True, + ) + response = client.get_storage_pool(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = storage_pool.GetStoragePoolRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, storage_pool.StoragePool) + assert response.name == 'name_value' + assert response.service_level == common.ServiceLevel.PREMIUM + assert response.capacity_gib == 1247 + assert response.volume_capacity_gib == 2006 + assert response.volume_count == 1312 + assert response.state == storage_pool.StoragePool.State.READY + assert response.state_details == 'state_details_value' + assert response.description == 'description_value' + assert response.network == 'network_value' + assert response.active_directory == 'active_directory_value' + assert response.kms_config == 'kms_config_value' + assert response.ldap_enabled is True + assert response.psa_range == 'psa_range_value' + assert response.encryption_type == common.EncryptionType.SERVICE_MANAGED + assert response.global_access_allowed is True + assert response.allow_auto_tiering is True + assert response.replica_zone == 'replica_zone_value' + assert response.zone == 'zone_value' + assert response.satisfies_pzs is True + assert response.satisfies_pzi is True + + +def test_get_storage_pool_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 = NetAppClient( + 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 = storage_pool.GetStoragePoolRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_storage_pool), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.get_storage_pool(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == storage_pool.GetStoragePoolRequest( + name='name_value', + ) + +def test_get_storage_pool_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 = NetAppClient( + 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_storage_pool 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_storage_pool] = mock_rpc + request = {} + client.get_storage_pool(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_storage_pool(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_storage_pool_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 = NetAppAsyncClient( + 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_storage_pool 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_storage_pool] = mock_rpc + + request = {} + await client.get_storage_pool(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_storage_pool(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_storage_pool_async(transport: str = 'grpc_asyncio', request_type=storage_pool.GetStoragePoolRequest): + client = NetAppAsyncClient( + 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_storage_pool), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(storage_pool.StoragePool( + name='name_value', + service_level=common.ServiceLevel.PREMIUM, + capacity_gib=1247, + volume_capacity_gib=2006, + volume_count=1312, + state=storage_pool.StoragePool.State.READY, + state_details='state_details_value', + description='description_value', + network='network_value', + active_directory='active_directory_value', + kms_config='kms_config_value', + ldap_enabled=True, + psa_range='psa_range_value', + encryption_type=common.EncryptionType.SERVICE_MANAGED, + global_access_allowed=True, + allow_auto_tiering=True, + replica_zone='replica_zone_value', + zone='zone_value', + satisfies_pzs=True, + satisfies_pzi=True, + )) + response = await client.get_storage_pool(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = storage_pool.GetStoragePoolRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, storage_pool.StoragePool) + assert response.name == 'name_value' + assert response.service_level == common.ServiceLevel.PREMIUM + assert response.capacity_gib == 1247 + assert response.volume_capacity_gib == 2006 + assert response.volume_count == 1312 + assert response.state == storage_pool.StoragePool.State.READY + assert response.state_details == 'state_details_value' + assert response.description == 'description_value' + assert response.network == 'network_value' + assert response.active_directory == 'active_directory_value' + assert response.kms_config == 'kms_config_value' + assert response.ldap_enabled is True + assert response.psa_range == 'psa_range_value' + assert response.encryption_type == common.EncryptionType.SERVICE_MANAGED + assert response.global_access_allowed is True + assert response.allow_auto_tiering is True + assert response.replica_zone == 'replica_zone_value' + assert response.zone == 'zone_value' + assert response.satisfies_pzs is True + assert response.satisfies_pzi is True + + +@pytest.mark.asyncio +async def test_get_storage_pool_async_from_dict(): + await test_get_storage_pool_async(request_type=dict) + +def test_get_storage_pool_field_headers(): + client = NetAppClient( + 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 = storage_pool.GetStoragePoolRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_storage_pool), + '__call__') as call: + call.return_value = storage_pool.StoragePool() + client.get_storage_pool(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_storage_pool_field_headers_async(): + client = NetAppAsyncClient( + 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 = storage_pool.GetStoragePoolRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_storage_pool), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(storage_pool.StoragePool()) + await client.get_storage_pool(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_storage_pool_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_storage_pool), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = storage_pool.StoragePool() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_storage_pool( + 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_storage_pool_flattened_error(): + client = NetAppClient( + 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_storage_pool( + storage_pool.GetStoragePoolRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_storage_pool_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_storage_pool), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = storage_pool.StoragePool() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(storage_pool.StoragePool()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_storage_pool( + 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_storage_pool_flattened_error_async(): + client = NetAppAsyncClient( + 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_storage_pool( + storage_pool.GetStoragePoolRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + gcn_storage_pool.UpdateStoragePoolRequest, + dict, +]) +def test_update_storage_pool(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_storage_pool), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_storage_pool(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gcn_storage_pool.UpdateStoragePoolRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_storage_pool_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 = NetAppClient( + 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 = gcn_storage_pool.UpdateStoragePoolRequest( + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_storage_pool), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.update_storage_pool(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gcn_storage_pool.UpdateStoragePoolRequest( + ) + +def test_update_storage_pool_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 = NetAppClient( + 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_storage_pool 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_storage_pool] = mock_rpc + request = {} + client.update_storage_pool(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.update_storage_pool(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_storage_pool_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 = NetAppAsyncClient( + 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_storage_pool 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_storage_pool] = mock_rpc + + request = {} + await client.update_storage_pool(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.update_storage_pool(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_storage_pool_async(transport: str = 'grpc_asyncio', request_type=gcn_storage_pool.UpdateStoragePoolRequest): + client = NetAppAsyncClient( + 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_storage_pool), + '__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.update_storage_pool(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gcn_storage_pool.UpdateStoragePoolRequest() + 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_update_storage_pool_async_from_dict(): + await test_update_storage_pool_async(request_type=dict) + +def test_update_storage_pool_field_headers(): + client = NetAppClient( + 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 = gcn_storage_pool.UpdateStoragePoolRequest() + + request.storage_pool.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_storage_pool), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_storage_pool(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', + 'storage_pool.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_storage_pool_field_headers_async(): + client = NetAppAsyncClient( + 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 = gcn_storage_pool.UpdateStoragePoolRequest() + + request.storage_pool.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_storage_pool), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_storage_pool(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', + 'storage_pool.name=name_value', + ) in kw['metadata'] + + +def test_update_storage_pool_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_storage_pool), + '__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.update_storage_pool( + storage_pool=gcn_storage_pool.StoragePool(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].storage_pool + mock_val = gcn_storage_pool.StoragePool(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_storage_pool_flattened_error(): + client = NetAppClient( + 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_storage_pool( + gcn_storage_pool.UpdateStoragePoolRequest(), + storage_pool=gcn_storage_pool.StoragePool(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_storage_pool_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_storage_pool), + '__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.update_storage_pool( + storage_pool=gcn_storage_pool.StoragePool(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].storage_pool + mock_val = gcn_storage_pool.StoragePool(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_storage_pool_flattened_error_async(): + client = NetAppAsyncClient( + 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_storage_pool( + gcn_storage_pool.UpdateStoragePoolRequest(), + storage_pool=gcn_storage_pool.StoragePool(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + storage_pool.DeleteStoragePoolRequest, + dict, +]) +def test_delete_storage_pool(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_storage_pool), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_storage_pool(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = storage_pool.DeleteStoragePoolRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_storage_pool_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 = NetAppClient( + 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 = storage_pool.DeleteStoragePoolRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_storage_pool), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.delete_storage_pool(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == storage_pool.DeleteStoragePoolRequest( + name='name_value', + ) + +def test_delete_storage_pool_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 = NetAppClient( + 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_storage_pool 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_storage_pool] = mock_rpc + request = {} + client.delete_storage_pool(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_storage_pool(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_storage_pool_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 = NetAppAsyncClient( + 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_storage_pool 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_storage_pool] = mock_rpc + + request = {} + await client.delete_storage_pool(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_storage_pool(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_storage_pool_async(transport: str = 'grpc_asyncio', request_type=storage_pool.DeleteStoragePoolRequest): + client = NetAppAsyncClient( + 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_storage_pool), + '__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_storage_pool(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = storage_pool.DeleteStoragePoolRequest() + 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_storage_pool_async_from_dict(): + await test_delete_storage_pool_async(request_type=dict) + +def test_delete_storage_pool_field_headers(): + client = NetAppClient( + 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 = storage_pool.DeleteStoragePoolRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_storage_pool), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_storage_pool(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_storage_pool_field_headers_async(): + client = NetAppAsyncClient( + 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 = storage_pool.DeleteStoragePoolRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_storage_pool), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_storage_pool(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_storage_pool_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_storage_pool), + '__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_storage_pool( + 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_storage_pool_flattened_error(): + client = NetAppClient( + 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_storage_pool( + storage_pool.DeleteStoragePoolRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_storage_pool_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_storage_pool), + '__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_storage_pool( + 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_storage_pool_flattened_error_async(): + client = NetAppAsyncClient( + 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_storage_pool( + storage_pool.DeleteStoragePoolRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + storage_pool.ValidateDirectoryServiceRequest, + dict, +]) +def test_validate_directory_service(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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.validate_directory_service), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.validate_directory_service(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = storage_pool.ValidateDirectoryServiceRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_validate_directory_service_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 = NetAppClient( + 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 = storage_pool.ValidateDirectoryServiceRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.validate_directory_service), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.validate_directory_service(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == storage_pool.ValidateDirectoryServiceRequest( + name='name_value', + ) + +def test_validate_directory_service_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 = NetAppClient( + 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.validate_directory_service 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.validate_directory_service] = mock_rpc + request = {} + client.validate_directory_service(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.validate_directory_service(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_validate_directory_service_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 = NetAppAsyncClient( + 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.validate_directory_service 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.validate_directory_service] = mock_rpc + + request = {} + await client.validate_directory_service(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.validate_directory_service(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_validate_directory_service_async(transport: str = 'grpc_asyncio', request_type=storage_pool.ValidateDirectoryServiceRequest): + client = NetAppAsyncClient( + 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.validate_directory_service), + '__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.validate_directory_service(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = storage_pool.ValidateDirectoryServiceRequest() + 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_validate_directory_service_async_from_dict(): + await test_validate_directory_service_async(request_type=dict) + +def test_validate_directory_service_field_headers(): + client = NetAppClient( + 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 = storage_pool.ValidateDirectoryServiceRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.validate_directory_service), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.validate_directory_service(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_validate_directory_service_field_headers_async(): + client = NetAppAsyncClient( + 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 = storage_pool.ValidateDirectoryServiceRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.validate_directory_service), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.validate_directory_service(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'] + + +@pytest.mark.parametrize("request_type", [ + storage_pool.SwitchActiveReplicaZoneRequest, + dict, +]) +def test_switch_active_replica_zone(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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.switch_active_replica_zone), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.switch_active_replica_zone(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = storage_pool.SwitchActiveReplicaZoneRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_switch_active_replica_zone_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 = NetAppClient( + 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 = storage_pool.SwitchActiveReplicaZoneRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.switch_active_replica_zone), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.switch_active_replica_zone(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == storage_pool.SwitchActiveReplicaZoneRequest( + name='name_value', + ) + +def test_switch_active_replica_zone_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 = NetAppClient( + 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.switch_active_replica_zone 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.switch_active_replica_zone] = mock_rpc + request = {} + client.switch_active_replica_zone(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.switch_active_replica_zone(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_switch_active_replica_zone_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 = NetAppAsyncClient( + 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.switch_active_replica_zone 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.switch_active_replica_zone] = mock_rpc + + request = {} + await client.switch_active_replica_zone(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.switch_active_replica_zone(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_switch_active_replica_zone_async(transport: str = 'grpc_asyncio', request_type=storage_pool.SwitchActiveReplicaZoneRequest): + client = NetAppAsyncClient( + 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.switch_active_replica_zone), + '__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.switch_active_replica_zone(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = storage_pool.SwitchActiveReplicaZoneRequest() + 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_switch_active_replica_zone_async_from_dict(): + await test_switch_active_replica_zone_async(request_type=dict) + +def test_switch_active_replica_zone_field_headers(): + client = NetAppClient( + 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 = storage_pool.SwitchActiveReplicaZoneRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.switch_active_replica_zone), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.switch_active_replica_zone(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_switch_active_replica_zone_field_headers_async(): + client = NetAppAsyncClient( + 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 = storage_pool.SwitchActiveReplicaZoneRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.switch_active_replica_zone), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.switch_active_replica_zone(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'] + + +@pytest.mark.parametrize("request_type", [ + volume.ListVolumesRequest, + dict, +]) +def test_list_volumes(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_volumes), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = volume.ListVolumesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_volumes(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = volume.ListVolumesRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListVolumesPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_volumes_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 = NetAppClient( + 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 = volume.ListVolumesRequest( + 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_volumes), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.list_volumes(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == volume.ListVolumesRequest( + parent='parent_value', + page_token='page_token_value', + filter='filter_value', + order_by='order_by_value', + ) + +def test_list_volumes_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 = NetAppClient( + 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_volumes 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_volumes] = mock_rpc + request = {} + client.list_volumes(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_volumes(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_volumes_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 = NetAppAsyncClient( + 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_volumes 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_volumes] = mock_rpc + + request = {} + await client.list_volumes(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_volumes(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_volumes_async(transport: str = 'grpc_asyncio', request_type=volume.ListVolumesRequest): + client = NetAppAsyncClient( + 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_volumes), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(volume.ListVolumesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_volumes(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = volume.ListVolumesRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListVolumesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_volumes_async_from_dict(): + await test_list_volumes_async(request_type=dict) + +def test_list_volumes_field_headers(): + client = NetAppClient( + 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 = volume.ListVolumesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_volumes), + '__call__') as call: + call.return_value = volume.ListVolumesResponse() + client.list_volumes(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_volumes_field_headers_async(): + client = NetAppAsyncClient( + 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 = volume.ListVolumesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_volumes), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(volume.ListVolumesResponse()) + await client.list_volumes(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_volumes_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_volumes), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = volume.ListVolumesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_volumes( + 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_volumes_flattened_error(): + client = NetAppClient( + 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_volumes( + volume.ListVolumesRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_volumes_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_volumes), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = volume.ListVolumesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(volume.ListVolumesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_volumes( + 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_volumes_flattened_error_async(): + client = NetAppAsyncClient( + 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_volumes( + volume.ListVolumesRequest(), + parent='parent_value', + ) + + +def test_list_volumes_pager(transport_name: str = "grpc"): + client = NetAppClient( + 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_volumes), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + volume.ListVolumesResponse( + volumes=[ + volume.Volume(), + volume.Volume(), + volume.Volume(), + ], + next_page_token='abc', + ), + volume.ListVolumesResponse( + volumes=[], + next_page_token='def', + ), + volume.ListVolumesResponse( + volumes=[ + volume.Volume(), + ], + next_page_token='ghi', + ), + volume.ListVolumesResponse( + volumes=[ + volume.Volume(), + volume.Volume(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_volumes(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, volume.Volume) + for i in results) +def test_list_volumes_pages(transport_name: str = "grpc"): + client = NetAppClient( + 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_volumes), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + volume.ListVolumesResponse( + volumes=[ + volume.Volume(), + volume.Volume(), + volume.Volume(), + ], + next_page_token='abc', + ), + volume.ListVolumesResponse( + volumes=[], + next_page_token='def', + ), + volume.ListVolumesResponse( + volumes=[ + volume.Volume(), + ], + next_page_token='ghi', + ), + volume.ListVolumesResponse( + volumes=[ + volume.Volume(), + volume.Volume(), + ], + ), + RuntimeError, + ) + pages = list(client.list_volumes(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_volumes_async_pager(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_volumes), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + volume.ListVolumesResponse( + volumes=[ + volume.Volume(), + volume.Volume(), + volume.Volume(), + ], + next_page_token='abc', + ), + volume.ListVolumesResponse( + volumes=[], + next_page_token='def', + ), + volume.ListVolumesResponse( + volumes=[ + volume.Volume(), + ], + next_page_token='ghi', + ), + volume.ListVolumesResponse( + volumes=[ + volume.Volume(), + volume.Volume(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_volumes(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, volume.Volume) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_volumes_async_pages(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_volumes), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + volume.ListVolumesResponse( + volumes=[ + volume.Volume(), + volume.Volume(), + volume.Volume(), + ], + next_page_token='abc', + ), + volume.ListVolumesResponse( + volumes=[], + next_page_token='def', + ), + volume.ListVolumesResponse( + volumes=[ + volume.Volume(), + ], + next_page_token='ghi', + ), + volume.ListVolumesResponse( + volumes=[ + volume.Volume(), + volume.Volume(), + ], + ), + 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_volumes(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", [ + volume.GetVolumeRequest, + dict, +]) +def test_get_volume(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_volume), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = volume.Volume( + name='name_value', + state=volume.Volume.State.READY, + state_details='state_details_value', + share_name='share_name_value', + psa_range='psa_range_value', + storage_pool='storage_pool_value', + network='network_value', + service_level=common.ServiceLevel.PREMIUM, + capacity_gib=1247, + protocols=[volume.Protocols.NFSV3], + smb_settings=[volume.SMBSettings.ENCRYPT_DATA], + unix_permissions='unix_permissions_value', + description='description_value', + snap_reserve=0.1293, + snapshot_directory=True, + used_gib=834, + security_style=volume.SecurityStyle.NTFS, + kerberos_enabled=True, + ldap_enabled=True, + active_directory='active_directory_value', + kms_config='kms_config_value', + encryption_type=common.EncryptionType.SERVICE_MANAGED, + has_replication=True, + restricted_actions=[volume.RestrictedAction.DELETE], + large_capacity=True, + multiple_endpoints=True, + replica_zone='replica_zone_value', + zone='zone_value', + cold_tier_size_gib=1888, + ) + response = client.get_volume(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = volume.GetVolumeRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, volume.Volume) + assert response.name == 'name_value' + assert response.state == volume.Volume.State.READY + assert response.state_details == 'state_details_value' + assert response.share_name == 'share_name_value' + assert response.psa_range == 'psa_range_value' + assert response.storage_pool == 'storage_pool_value' + assert response.network == 'network_value' + assert response.service_level == common.ServiceLevel.PREMIUM + assert response.capacity_gib == 1247 + assert response.protocols == [volume.Protocols.NFSV3] + assert response.smb_settings == [volume.SMBSettings.ENCRYPT_DATA] + assert response.unix_permissions == 'unix_permissions_value' + assert response.description == 'description_value' + assert math.isclose(response.snap_reserve, 0.1293, rel_tol=1e-6) + assert response.snapshot_directory is True + assert response.used_gib == 834 + assert response.security_style == volume.SecurityStyle.NTFS + assert response.kerberos_enabled is True + assert response.ldap_enabled is True + assert response.active_directory == 'active_directory_value' + assert response.kms_config == 'kms_config_value' + assert response.encryption_type == common.EncryptionType.SERVICE_MANAGED + assert response.has_replication is True + assert response.restricted_actions == [volume.RestrictedAction.DELETE] + assert response.large_capacity is True + assert response.multiple_endpoints is True + assert response.replica_zone == 'replica_zone_value' + assert response.zone == 'zone_value' + assert response.cold_tier_size_gib == 1888 + + +def test_get_volume_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 = NetAppClient( + 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 = volume.GetVolumeRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_volume), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.get_volume(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == volume.GetVolumeRequest( + name='name_value', + ) + +def test_get_volume_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 = NetAppClient( + 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_volume 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_volume] = mock_rpc + request = {} + client.get_volume(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_volume(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_volume_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 = NetAppAsyncClient( + 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_volume 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_volume] = mock_rpc + + request = {} + await client.get_volume(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_volume(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_volume_async(transport: str = 'grpc_asyncio', request_type=volume.GetVolumeRequest): + client = NetAppAsyncClient( + 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_volume), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(volume.Volume( + name='name_value', + state=volume.Volume.State.READY, + state_details='state_details_value', + share_name='share_name_value', + psa_range='psa_range_value', + storage_pool='storage_pool_value', + network='network_value', + service_level=common.ServiceLevel.PREMIUM, + capacity_gib=1247, + protocols=[volume.Protocols.NFSV3], + smb_settings=[volume.SMBSettings.ENCRYPT_DATA], + unix_permissions='unix_permissions_value', + description='description_value', + snap_reserve=0.1293, + snapshot_directory=True, + used_gib=834, + security_style=volume.SecurityStyle.NTFS, + kerberos_enabled=True, + ldap_enabled=True, + active_directory='active_directory_value', + kms_config='kms_config_value', + encryption_type=common.EncryptionType.SERVICE_MANAGED, + has_replication=True, + restricted_actions=[volume.RestrictedAction.DELETE], + large_capacity=True, + multiple_endpoints=True, + replica_zone='replica_zone_value', + zone='zone_value', + cold_tier_size_gib=1888, + )) + response = await client.get_volume(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = volume.GetVolumeRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, volume.Volume) + assert response.name == 'name_value' + assert response.state == volume.Volume.State.READY + assert response.state_details == 'state_details_value' + assert response.share_name == 'share_name_value' + assert response.psa_range == 'psa_range_value' + assert response.storage_pool == 'storage_pool_value' + assert response.network == 'network_value' + assert response.service_level == common.ServiceLevel.PREMIUM + assert response.capacity_gib == 1247 + assert response.protocols == [volume.Protocols.NFSV3] + assert response.smb_settings == [volume.SMBSettings.ENCRYPT_DATA] + assert response.unix_permissions == 'unix_permissions_value' + assert response.description == 'description_value' + assert math.isclose(response.snap_reserve, 0.1293, rel_tol=1e-6) + assert response.snapshot_directory is True + assert response.used_gib == 834 + assert response.security_style == volume.SecurityStyle.NTFS + assert response.kerberos_enabled is True + assert response.ldap_enabled is True + assert response.active_directory == 'active_directory_value' + assert response.kms_config == 'kms_config_value' + assert response.encryption_type == common.EncryptionType.SERVICE_MANAGED + assert response.has_replication is True + assert response.restricted_actions == [volume.RestrictedAction.DELETE] + assert response.large_capacity is True + assert response.multiple_endpoints is True + assert response.replica_zone == 'replica_zone_value' + assert response.zone == 'zone_value' + assert response.cold_tier_size_gib == 1888 + + +@pytest.mark.asyncio +async def test_get_volume_async_from_dict(): + await test_get_volume_async(request_type=dict) + +def test_get_volume_field_headers(): + client = NetAppClient( + 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 = volume.GetVolumeRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_volume), + '__call__') as call: + call.return_value = volume.Volume() + client.get_volume(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_volume_field_headers_async(): + client = NetAppAsyncClient( + 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 = volume.GetVolumeRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_volume), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(volume.Volume()) + await client.get_volume(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_volume_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_volume), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = volume.Volume() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_volume( + 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_volume_flattened_error(): + client = NetAppClient( + 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_volume( + volume.GetVolumeRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_volume_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_volume), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = volume.Volume() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(volume.Volume()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_volume( + 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_volume_flattened_error_async(): + client = NetAppAsyncClient( + 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_volume( + volume.GetVolumeRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + gcn_volume.CreateVolumeRequest, + dict, +]) +def test_create_volume(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_volume), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_volume(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gcn_volume.CreateVolumeRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_volume_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 = NetAppClient( + 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 = gcn_volume.CreateVolumeRequest( + parent='parent_value', + volume_id='volume_id_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_volume), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.create_volume(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gcn_volume.CreateVolumeRequest( + parent='parent_value', + volume_id='volume_id_value', + ) + +def test_create_volume_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 = NetAppClient( + 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_volume 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_volume] = mock_rpc + request = {} + client.create_volume(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_volume(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_volume_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 = NetAppAsyncClient( + 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_volume 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_volume] = mock_rpc + + request = {} + await client.create_volume(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_volume(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_volume_async(transport: str = 'grpc_asyncio', request_type=gcn_volume.CreateVolumeRequest): + client = NetAppAsyncClient( + 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_volume), + '__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_volume(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gcn_volume.CreateVolumeRequest() + 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_volume_async_from_dict(): + await test_create_volume_async(request_type=dict) + +def test_create_volume_field_headers(): + client = NetAppClient( + 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 = gcn_volume.CreateVolumeRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_volume), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_volume(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_volume_field_headers_async(): + client = NetAppAsyncClient( + 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 = gcn_volume.CreateVolumeRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_volume), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_volume(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_volume_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_volume), + '__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_volume( + parent='parent_value', + volume=gcn_volume.Volume(name='name_value'), + volume_id='volume_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].volume + mock_val = gcn_volume.Volume(name='name_value') + assert arg == mock_val + arg = args[0].volume_id + mock_val = 'volume_id_value' + assert arg == mock_val + + +def test_create_volume_flattened_error(): + client = NetAppClient( + 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_volume( + gcn_volume.CreateVolumeRequest(), + parent='parent_value', + volume=gcn_volume.Volume(name='name_value'), + volume_id='volume_id_value', + ) + +@pytest.mark.asyncio +async def test_create_volume_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_volume), + '__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_volume( + parent='parent_value', + volume=gcn_volume.Volume(name='name_value'), + volume_id='volume_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].volume + mock_val = gcn_volume.Volume(name='name_value') + assert arg == mock_val + arg = args[0].volume_id + mock_val = 'volume_id_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_volume_flattened_error_async(): + client = NetAppAsyncClient( + 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_volume( + gcn_volume.CreateVolumeRequest(), + parent='parent_value', + volume=gcn_volume.Volume(name='name_value'), + volume_id='volume_id_value', + ) + + +@pytest.mark.parametrize("request_type", [ + gcn_volume.UpdateVolumeRequest, + dict, +]) +def test_update_volume(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_volume), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_volume(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gcn_volume.UpdateVolumeRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_volume_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 = NetAppClient( + 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 = gcn_volume.UpdateVolumeRequest( + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_volume), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.update_volume(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gcn_volume.UpdateVolumeRequest( + ) + +def test_update_volume_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 = NetAppClient( + 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_volume 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_volume] = mock_rpc + request = {} + client.update_volume(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.update_volume(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_volume_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 = NetAppAsyncClient( + 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_volume 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_volume] = mock_rpc + + request = {} + await client.update_volume(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.update_volume(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_volume_async(transport: str = 'grpc_asyncio', request_type=gcn_volume.UpdateVolumeRequest): + client = NetAppAsyncClient( + 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_volume), + '__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.update_volume(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gcn_volume.UpdateVolumeRequest() + 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_update_volume_async_from_dict(): + await test_update_volume_async(request_type=dict) + +def test_update_volume_field_headers(): + client = NetAppClient( + 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 = gcn_volume.UpdateVolumeRequest() + + request.volume.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_volume), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_volume(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', + 'volume.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_volume_field_headers_async(): + client = NetAppAsyncClient( + 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 = gcn_volume.UpdateVolumeRequest() + + request.volume.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_volume), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_volume(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', + 'volume.name=name_value', + ) in kw['metadata'] + + +def test_update_volume_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_volume), + '__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.update_volume( + volume=gcn_volume.Volume(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].volume + mock_val = gcn_volume.Volume(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_volume_flattened_error(): + client = NetAppClient( + 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_volume( + gcn_volume.UpdateVolumeRequest(), + volume=gcn_volume.Volume(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_volume_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_volume), + '__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.update_volume( + volume=gcn_volume.Volume(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].volume + mock_val = gcn_volume.Volume(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_volume_flattened_error_async(): + client = NetAppAsyncClient( + 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_volume( + gcn_volume.UpdateVolumeRequest(), + volume=gcn_volume.Volume(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + volume.DeleteVolumeRequest, + dict, +]) +def test_delete_volume(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_volume), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_volume(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = volume.DeleteVolumeRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_volume_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 = NetAppClient( + 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 = volume.DeleteVolumeRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_volume), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.delete_volume(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == volume.DeleteVolumeRequest( + name='name_value', + ) + +def test_delete_volume_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 = NetAppClient( + 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_volume 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_volume] = mock_rpc + request = {} + client.delete_volume(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_volume(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_volume_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 = NetAppAsyncClient( + 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_volume 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_volume] = mock_rpc + + request = {} + await client.delete_volume(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_volume(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_volume_async(transport: str = 'grpc_asyncio', request_type=volume.DeleteVolumeRequest): + client = NetAppAsyncClient( + 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_volume), + '__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_volume(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = volume.DeleteVolumeRequest() + 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_volume_async_from_dict(): + await test_delete_volume_async(request_type=dict) + +def test_delete_volume_field_headers(): + client = NetAppClient( + 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 = volume.DeleteVolumeRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_volume), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_volume(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_volume_field_headers_async(): + client = NetAppAsyncClient( + 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 = volume.DeleteVolumeRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_volume), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_volume(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_volume_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_volume), + '__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_volume( + 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_volume_flattened_error(): + client = NetAppClient( + 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_volume( + volume.DeleteVolumeRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_volume_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_volume), + '__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_volume( + 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_volume_flattened_error_async(): + client = NetAppAsyncClient( + 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_volume( + volume.DeleteVolumeRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + volume.RevertVolumeRequest, + dict, +]) +def test_revert_volume(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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.revert_volume), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.revert_volume(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = volume.RevertVolumeRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_revert_volume_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 = NetAppClient( + 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 = volume.RevertVolumeRequest( + name='name_value', + snapshot_id='snapshot_id_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.revert_volume), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.revert_volume(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == volume.RevertVolumeRequest( + name='name_value', + snapshot_id='snapshot_id_value', + ) + +def test_revert_volume_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 = NetAppClient( + 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.revert_volume 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.revert_volume] = mock_rpc + request = {} + client.revert_volume(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.revert_volume(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_revert_volume_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 = NetAppAsyncClient( + 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.revert_volume 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.revert_volume] = mock_rpc + + request = {} + await client.revert_volume(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.revert_volume(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_revert_volume_async(transport: str = 'grpc_asyncio', request_type=volume.RevertVolumeRequest): + client = NetAppAsyncClient( + 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.revert_volume), + '__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.revert_volume(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = volume.RevertVolumeRequest() + 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_revert_volume_async_from_dict(): + await test_revert_volume_async(request_type=dict) + +def test_revert_volume_field_headers(): + client = NetAppClient( + 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 = volume.RevertVolumeRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.revert_volume), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.revert_volume(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_revert_volume_field_headers_async(): + client = NetAppAsyncClient( + 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 = volume.RevertVolumeRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.revert_volume), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.revert_volume(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'] + + +@pytest.mark.parametrize("request_type", [ + snapshot.ListSnapshotsRequest, + dict, +]) +def test_list_snapshots(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_snapshots), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = snapshot.ListSnapshotsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_snapshots(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = snapshot.ListSnapshotsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListSnapshotsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_snapshots_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 = NetAppClient( + 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 = snapshot.ListSnapshotsRequest( + 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_snapshots), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.list_snapshots(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == snapshot.ListSnapshotsRequest( + parent='parent_value', + page_token='page_token_value', + order_by='order_by_value', + filter='filter_value', + ) + +def test_list_snapshots_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 = NetAppClient( + 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_snapshots 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_snapshots] = mock_rpc + request = {} + client.list_snapshots(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_snapshots(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_snapshots_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 = NetAppAsyncClient( + 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_snapshots 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_snapshots] = mock_rpc + + request = {} + await client.list_snapshots(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_snapshots(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_snapshots_async(transport: str = 'grpc_asyncio', request_type=snapshot.ListSnapshotsRequest): + client = NetAppAsyncClient( + 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_snapshots), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(snapshot.ListSnapshotsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_snapshots(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = snapshot.ListSnapshotsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListSnapshotsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_snapshots_async_from_dict(): + await test_list_snapshots_async(request_type=dict) + +def test_list_snapshots_field_headers(): + client = NetAppClient( + 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 = snapshot.ListSnapshotsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_snapshots), + '__call__') as call: + call.return_value = snapshot.ListSnapshotsResponse() + client.list_snapshots(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_snapshots_field_headers_async(): + client = NetAppAsyncClient( + 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 = snapshot.ListSnapshotsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_snapshots), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(snapshot.ListSnapshotsResponse()) + await client.list_snapshots(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_snapshots_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_snapshots), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = snapshot.ListSnapshotsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_snapshots( + 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_snapshots_flattened_error(): + client = NetAppClient( + 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_snapshots( + snapshot.ListSnapshotsRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_snapshots_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_snapshots), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = snapshot.ListSnapshotsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(snapshot.ListSnapshotsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_snapshots( + 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_snapshots_flattened_error_async(): + client = NetAppAsyncClient( + 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_snapshots( + snapshot.ListSnapshotsRequest(), + parent='parent_value', + ) + + +def test_list_snapshots_pager(transport_name: str = "grpc"): + client = NetAppClient( + 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_snapshots), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + snapshot.ListSnapshotsResponse( + snapshots=[ + snapshot.Snapshot(), + snapshot.Snapshot(), + snapshot.Snapshot(), + ], + next_page_token='abc', + ), + snapshot.ListSnapshotsResponse( + snapshots=[], + next_page_token='def', + ), + snapshot.ListSnapshotsResponse( + snapshots=[ + snapshot.Snapshot(), + ], + next_page_token='ghi', + ), + snapshot.ListSnapshotsResponse( + snapshots=[ + snapshot.Snapshot(), + snapshot.Snapshot(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_snapshots(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, snapshot.Snapshot) + for i in results) +def test_list_snapshots_pages(transport_name: str = "grpc"): + client = NetAppClient( + 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_snapshots), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + snapshot.ListSnapshotsResponse( + snapshots=[ + snapshot.Snapshot(), + snapshot.Snapshot(), + snapshot.Snapshot(), + ], + next_page_token='abc', + ), + snapshot.ListSnapshotsResponse( + snapshots=[], + next_page_token='def', + ), + snapshot.ListSnapshotsResponse( + snapshots=[ + snapshot.Snapshot(), + ], + next_page_token='ghi', + ), + snapshot.ListSnapshotsResponse( + snapshots=[ + snapshot.Snapshot(), + snapshot.Snapshot(), + ], + ), + RuntimeError, + ) + pages = list(client.list_snapshots(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_snapshots_async_pager(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_snapshots), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + snapshot.ListSnapshotsResponse( + snapshots=[ + snapshot.Snapshot(), + snapshot.Snapshot(), + snapshot.Snapshot(), + ], + next_page_token='abc', + ), + snapshot.ListSnapshotsResponse( + snapshots=[], + next_page_token='def', + ), + snapshot.ListSnapshotsResponse( + snapshots=[ + snapshot.Snapshot(), + ], + next_page_token='ghi', + ), + snapshot.ListSnapshotsResponse( + snapshots=[ + snapshot.Snapshot(), + snapshot.Snapshot(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_snapshots(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, snapshot.Snapshot) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_snapshots_async_pages(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_snapshots), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + snapshot.ListSnapshotsResponse( + snapshots=[ + snapshot.Snapshot(), + snapshot.Snapshot(), + snapshot.Snapshot(), + ], + next_page_token='abc', + ), + snapshot.ListSnapshotsResponse( + snapshots=[], + next_page_token='def', + ), + snapshot.ListSnapshotsResponse( + snapshots=[ + snapshot.Snapshot(), + ], + next_page_token='ghi', + ), + snapshot.ListSnapshotsResponse( + snapshots=[ + snapshot.Snapshot(), + snapshot.Snapshot(), + ], + ), + 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_snapshots(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", [ + snapshot.GetSnapshotRequest, + dict, +]) +def test_get_snapshot(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_snapshot), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = snapshot.Snapshot( + name='name_value', + state=snapshot.Snapshot.State.READY, + state_details='state_details_value', + description='description_value', + used_bytes=0.10790000000000001, + ) + response = client.get_snapshot(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = snapshot.GetSnapshotRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, snapshot.Snapshot) + assert response.name == 'name_value' + assert response.state == snapshot.Snapshot.State.READY + assert response.state_details == 'state_details_value' + assert response.description == 'description_value' + assert math.isclose(response.used_bytes, 0.10790000000000001, rel_tol=1e-6) + + +def test_get_snapshot_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 = NetAppClient( + 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 = snapshot.GetSnapshotRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_snapshot), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.get_snapshot(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == snapshot.GetSnapshotRequest( + name='name_value', + ) + +def test_get_snapshot_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 = NetAppClient( + 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_snapshot 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_snapshot] = mock_rpc + request = {} + client.get_snapshot(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_snapshot(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_snapshot_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 = NetAppAsyncClient( + 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_snapshot 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_snapshot] = mock_rpc + + request = {} + await client.get_snapshot(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_snapshot(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_snapshot_async(transport: str = 'grpc_asyncio', request_type=snapshot.GetSnapshotRequest): + client = NetAppAsyncClient( + 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_snapshot), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(snapshot.Snapshot( + name='name_value', + state=snapshot.Snapshot.State.READY, + state_details='state_details_value', + description='description_value', + used_bytes=0.10790000000000001, + )) + response = await client.get_snapshot(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = snapshot.GetSnapshotRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, snapshot.Snapshot) + assert response.name == 'name_value' + assert response.state == snapshot.Snapshot.State.READY + assert response.state_details == 'state_details_value' + assert response.description == 'description_value' + assert math.isclose(response.used_bytes, 0.10790000000000001, rel_tol=1e-6) + + +@pytest.mark.asyncio +async def test_get_snapshot_async_from_dict(): + await test_get_snapshot_async(request_type=dict) + +def test_get_snapshot_field_headers(): + client = NetAppClient( + 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 = snapshot.GetSnapshotRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_snapshot), + '__call__') as call: + call.return_value = snapshot.Snapshot() + client.get_snapshot(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_snapshot_field_headers_async(): + client = NetAppAsyncClient( + 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 = snapshot.GetSnapshotRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_snapshot), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(snapshot.Snapshot()) + await client.get_snapshot(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_snapshot_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_snapshot), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = snapshot.Snapshot() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_snapshot( + 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_snapshot_flattened_error(): + client = NetAppClient( + 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_snapshot( + snapshot.GetSnapshotRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_snapshot_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_snapshot), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = snapshot.Snapshot() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(snapshot.Snapshot()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_snapshot( + 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_snapshot_flattened_error_async(): + client = NetAppAsyncClient( + 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_snapshot( + snapshot.GetSnapshotRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + gcn_snapshot.CreateSnapshotRequest, + dict, +]) +def test_create_snapshot(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_snapshot), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_snapshot(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gcn_snapshot.CreateSnapshotRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_snapshot_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 = NetAppClient( + 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 = gcn_snapshot.CreateSnapshotRequest( + parent='parent_value', + snapshot_id='snapshot_id_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_snapshot), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.create_snapshot(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gcn_snapshot.CreateSnapshotRequest( + parent='parent_value', + snapshot_id='snapshot_id_value', + ) + +def test_create_snapshot_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 = NetAppClient( + 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_snapshot 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_snapshot] = mock_rpc + request = {} + client.create_snapshot(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_snapshot(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_snapshot_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 = NetAppAsyncClient( + 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_snapshot 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_snapshot] = mock_rpc + + request = {} + await client.create_snapshot(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_snapshot(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_snapshot_async(transport: str = 'grpc_asyncio', request_type=gcn_snapshot.CreateSnapshotRequest): + client = NetAppAsyncClient( + 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_snapshot), + '__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_snapshot(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gcn_snapshot.CreateSnapshotRequest() + 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_snapshot_async_from_dict(): + await test_create_snapshot_async(request_type=dict) + +def test_create_snapshot_field_headers(): + client = NetAppClient( + 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 = gcn_snapshot.CreateSnapshotRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_snapshot), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_snapshot(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_snapshot_field_headers_async(): + client = NetAppAsyncClient( + 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 = gcn_snapshot.CreateSnapshotRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_snapshot), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_snapshot(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_snapshot_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_snapshot), + '__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_snapshot( + parent='parent_value', + snapshot=gcn_snapshot.Snapshot(name='name_value'), + snapshot_id='snapshot_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].snapshot + mock_val = gcn_snapshot.Snapshot(name='name_value') + assert arg == mock_val + arg = args[0].snapshot_id + mock_val = 'snapshot_id_value' + assert arg == mock_val + + +def test_create_snapshot_flattened_error(): + client = NetAppClient( + 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_snapshot( + gcn_snapshot.CreateSnapshotRequest(), + parent='parent_value', + snapshot=gcn_snapshot.Snapshot(name='name_value'), + snapshot_id='snapshot_id_value', + ) + +@pytest.mark.asyncio +async def test_create_snapshot_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_snapshot), + '__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_snapshot( + parent='parent_value', + snapshot=gcn_snapshot.Snapshot(name='name_value'), + snapshot_id='snapshot_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].snapshot + mock_val = gcn_snapshot.Snapshot(name='name_value') + assert arg == mock_val + arg = args[0].snapshot_id + mock_val = 'snapshot_id_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_snapshot_flattened_error_async(): + client = NetAppAsyncClient( + 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_snapshot( + gcn_snapshot.CreateSnapshotRequest(), + parent='parent_value', + snapshot=gcn_snapshot.Snapshot(name='name_value'), + snapshot_id='snapshot_id_value', + ) + + +@pytest.mark.parametrize("request_type", [ + snapshot.DeleteSnapshotRequest, + dict, +]) +def test_delete_snapshot(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_snapshot), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_snapshot(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = snapshot.DeleteSnapshotRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_snapshot_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 = NetAppClient( + 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 = snapshot.DeleteSnapshotRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_snapshot), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.delete_snapshot(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == snapshot.DeleteSnapshotRequest( + name='name_value', + ) + +def test_delete_snapshot_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 = NetAppClient( + 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_snapshot 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_snapshot] = mock_rpc + request = {} + client.delete_snapshot(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_snapshot(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_snapshot_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 = NetAppAsyncClient( + 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_snapshot 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_snapshot] = mock_rpc + + request = {} + await client.delete_snapshot(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_snapshot(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_snapshot_async(transport: str = 'grpc_asyncio', request_type=snapshot.DeleteSnapshotRequest): + client = NetAppAsyncClient( + 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_snapshot), + '__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_snapshot(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = snapshot.DeleteSnapshotRequest() + 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_snapshot_async_from_dict(): + await test_delete_snapshot_async(request_type=dict) + +def test_delete_snapshot_field_headers(): + client = NetAppClient( + 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 = snapshot.DeleteSnapshotRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_snapshot), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_snapshot(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_snapshot_field_headers_async(): + client = NetAppAsyncClient( + 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 = snapshot.DeleteSnapshotRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_snapshot), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_snapshot(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_snapshot_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_snapshot), + '__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_snapshot( + 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_snapshot_flattened_error(): + client = NetAppClient( + 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_snapshot( + snapshot.DeleteSnapshotRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_snapshot_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_snapshot), + '__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_snapshot( + 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_snapshot_flattened_error_async(): + client = NetAppAsyncClient( + 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_snapshot( + snapshot.DeleteSnapshotRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + gcn_snapshot.UpdateSnapshotRequest, + dict, +]) +def test_update_snapshot(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_snapshot), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_snapshot(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gcn_snapshot.UpdateSnapshotRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_snapshot_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 = NetAppClient( + 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 = gcn_snapshot.UpdateSnapshotRequest( + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_snapshot), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.update_snapshot(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gcn_snapshot.UpdateSnapshotRequest( + ) + +def test_update_snapshot_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 = NetAppClient( + 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_snapshot 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_snapshot] = mock_rpc + request = {} + client.update_snapshot(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.update_snapshot(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_snapshot_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 = NetAppAsyncClient( + 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_snapshot 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_snapshot] = mock_rpc + + request = {} + await client.update_snapshot(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.update_snapshot(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_snapshot_async(transport: str = 'grpc_asyncio', request_type=gcn_snapshot.UpdateSnapshotRequest): + client = NetAppAsyncClient( + 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_snapshot), + '__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.update_snapshot(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gcn_snapshot.UpdateSnapshotRequest() + 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_update_snapshot_async_from_dict(): + await test_update_snapshot_async(request_type=dict) + +def test_update_snapshot_field_headers(): + client = NetAppClient( + 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 = gcn_snapshot.UpdateSnapshotRequest() + + request.snapshot.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_snapshot), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_snapshot(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', + 'snapshot.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_snapshot_field_headers_async(): + client = NetAppAsyncClient( + 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 = gcn_snapshot.UpdateSnapshotRequest() + + request.snapshot.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_snapshot), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_snapshot(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', + 'snapshot.name=name_value', + ) in kw['metadata'] + + +def test_update_snapshot_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_snapshot), + '__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.update_snapshot( + snapshot=gcn_snapshot.Snapshot(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].snapshot + mock_val = gcn_snapshot.Snapshot(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_snapshot_flattened_error(): + client = NetAppClient( + 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_snapshot( + gcn_snapshot.UpdateSnapshotRequest(), + snapshot=gcn_snapshot.Snapshot(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_snapshot_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_snapshot), + '__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.update_snapshot( + snapshot=gcn_snapshot.Snapshot(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].snapshot + mock_val = gcn_snapshot.Snapshot(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_snapshot_flattened_error_async(): + client = NetAppAsyncClient( + 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_snapshot( + gcn_snapshot.UpdateSnapshotRequest(), + snapshot=gcn_snapshot.Snapshot(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + active_directory.ListActiveDirectoriesRequest, + dict, +]) +def test_list_active_directories(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_active_directories), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = active_directory.ListActiveDirectoriesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_active_directories(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = active_directory.ListActiveDirectoriesRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListActiveDirectoriesPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_active_directories_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 = NetAppClient( + 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 = active_directory.ListActiveDirectoriesRequest( + 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_active_directories), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.list_active_directories(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == active_directory.ListActiveDirectoriesRequest( + parent='parent_value', + page_token='page_token_value', + filter='filter_value', + order_by='order_by_value', + ) + +def test_list_active_directories_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 = NetAppClient( + 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_active_directories 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_active_directories] = mock_rpc + request = {} + client.list_active_directories(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_active_directories(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_active_directories_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 = NetAppAsyncClient( + 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_active_directories 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_active_directories] = mock_rpc + + request = {} + await client.list_active_directories(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_active_directories(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_active_directories_async(transport: str = 'grpc_asyncio', request_type=active_directory.ListActiveDirectoriesRequest): + client = NetAppAsyncClient( + 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_active_directories), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(active_directory.ListActiveDirectoriesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_active_directories(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = active_directory.ListActiveDirectoriesRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListActiveDirectoriesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_active_directories_async_from_dict(): + await test_list_active_directories_async(request_type=dict) + +def test_list_active_directories_field_headers(): + client = NetAppClient( + 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 = active_directory.ListActiveDirectoriesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_active_directories), + '__call__') as call: + call.return_value = active_directory.ListActiveDirectoriesResponse() + client.list_active_directories(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_active_directories_field_headers_async(): + client = NetAppAsyncClient( + 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 = active_directory.ListActiveDirectoriesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_active_directories), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(active_directory.ListActiveDirectoriesResponse()) + await client.list_active_directories(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_active_directories_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_active_directories), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = active_directory.ListActiveDirectoriesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_active_directories( + 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_active_directories_flattened_error(): + client = NetAppClient( + 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_active_directories( + active_directory.ListActiveDirectoriesRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_active_directories_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_active_directories), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = active_directory.ListActiveDirectoriesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(active_directory.ListActiveDirectoriesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_active_directories( + 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_active_directories_flattened_error_async(): + client = NetAppAsyncClient( + 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_active_directories( + active_directory.ListActiveDirectoriesRequest(), + parent='parent_value', + ) + + +def test_list_active_directories_pager(transport_name: str = "grpc"): + client = NetAppClient( + 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_active_directories), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + active_directory.ListActiveDirectoriesResponse( + active_directories=[ + active_directory.ActiveDirectory(), + active_directory.ActiveDirectory(), + active_directory.ActiveDirectory(), + ], + next_page_token='abc', + ), + active_directory.ListActiveDirectoriesResponse( + active_directories=[], + next_page_token='def', + ), + active_directory.ListActiveDirectoriesResponse( + active_directories=[ + active_directory.ActiveDirectory(), + ], + next_page_token='ghi', + ), + active_directory.ListActiveDirectoriesResponse( + active_directories=[ + active_directory.ActiveDirectory(), + active_directory.ActiveDirectory(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_active_directories(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, active_directory.ActiveDirectory) + for i in results) +def test_list_active_directories_pages(transport_name: str = "grpc"): + client = NetAppClient( + 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_active_directories), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + active_directory.ListActiveDirectoriesResponse( + active_directories=[ + active_directory.ActiveDirectory(), + active_directory.ActiveDirectory(), + active_directory.ActiveDirectory(), + ], + next_page_token='abc', + ), + active_directory.ListActiveDirectoriesResponse( + active_directories=[], + next_page_token='def', + ), + active_directory.ListActiveDirectoriesResponse( + active_directories=[ + active_directory.ActiveDirectory(), + ], + next_page_token='ghi', + ), + active_directory.ListActiveDirectoriesResponse( + active_directories=[ + active_directory.ActiveDirectory(), + active_directory.ActiveDirectory(), + ], + ), + RuntimeError, + ) + pages = list(client.list_active_directories(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_active_directories_async_pager(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_active_directories), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + active_directory.ListActiveDirectoriesResponse( + active_directories=[ + active_directory.ActiveDirectory(), + active_directory.ActiveDirectory(), + active_directory.ActiveDirectory(), + ], + next_page_token='abc', + ), + active_directory.ListActiveDirectoriesResponse( + active_directories=[], + next_page_token='def', + ), + active_directory.ListActiveDirectoriesResponse( + active_directories=[ + active_directory.ActiveDirectory(), + ], + next_page_token='ghi', + ), + active_directory.ListActiveDirectoriesResponse( + active_directories=[ + active_directory.ActiveDirectory(), + active_directory.ActiveDirectory(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_active_directories(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, active_directory.ActiveDirectory) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_active_directories_async_pages(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_active_directories), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + active_directory.ListActiveDirectoriesResponse( + active_directories=[ + active_directory.ActiveDirectory(), + active_directory.ActiveDirectory(), + active_directory.ActiveDirectory(), + ], + next_page_token='abc', + ), + active_directory.ListActiveDirectoriesResponse( + active_directories=[], + next_page_token='def', + ), + active_directory.ListActiveDirectoriesResponse( + active_directories=[ + active_directory.ActiveDirectory(), + ], + next_page_token='ghi', + ), + active_directory.ListActiveDirectoriesResponse( + active_directories=[ + active_directory.ActiveDirectory(), + active_directory.ActiveDirectory(), + ], + ), + 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_active_directories(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", [ + active_directory.GetActiveDirectoryRequest, + dict, +]) +def test_get_active_directory(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_active_directory), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = active_directory.ActiveDirectory( + name='name_value', + state=active_directory.ActiveDirectory.State.CREATING, + domain='domain_value', + site='site_value', + dns='dns_value', + net_bios_prefix='net_bios_prefix_value', + organizational_unit='organizational_unit_value', + aes_encryption=True, + username='username_value', + password='password_value', + backup_operators=['backup_operators_value'], + administrators=['administrators_value'], + security_operators=['security_operators_value'], + kdc_hostname='kdc_hostname_value', + kdc_ip='kdc_ip_value', + nfs_users_with_ldap=True, + description='description_value', + ldap_signing=True, + encrypt_dc_connections=True, + state_details='state_details_value', + ) + response = client.get_active_directory(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = active_directory.GetActiveDirectoryRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, active_directory.ActiveDirectory) + assert response.name == 'name_value' + assert response.state == active_directory.ActiveDirectory.State.CREATING + assert response.domain == 'domain_value' + assert response.site == 'site_value' + assert response.dns == 'dns_value' + assert response.net_bios_prefix == 'net_bios_prefix_value' + assert response.organizational_unit == 'organizational_unit_value' + assert response.aes_encryption is True + assert response.username == 'username_value' + assert response.password == 'password_value' + assert response.backup_operators == ['backup_operators_value'] + assert response.administrators == ['administrators_value'] + assert response.security_operators == ['security_operators_value'] + assert response.kdc_hostname == 'kdc_hostname_value' + assert response.kdc_ip == 'kdc_ip_value' + assert response.nfs_users_with_ldap is True + assert response.description == 'description_value' + assert response.ldap_signing is True + assert response.encrypt_dc_connections is True + assert response.state_details == 'state_details_value' + + +def test_get_active_directory_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 = NetAppClient( + 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 = active_directory.GetActiveDirectoryRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_active_directory), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.get_active_directory(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == active_directory.GetActiveDirectoryRequest( + name='name_value', + ) + +def test_get_active_directory_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 = NetAppClient( + 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_active_directory 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_active_directory] = mock_rpc + request = {} + client.get_active_directory(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_active_directory(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_active_directory_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 = NetAppAsyncClient( + 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_active_directory 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_active_directory] = mock_rpc + + request = {} + await client.get_active_directory(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_active_directory(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_active_directory_async(transport: str = 'grpc_asyncio', request_type=active_directory.GetActiveDirectoryRequest): + client = NetAppAsyncClient( + 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_active_directory), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(active_directory.ActiveDirectory( + name='name_value', + state=active_directory.ActiveDirectory.State.CREATING, + domain='domain_value', + site='site_value', + dns='dns_value', + net_bios_prefix='net_bios_prefix_value', + organizational_unit='organizational_unit_value', + aes_encryption=True, + username='username_value', + password='password_value', + backup_operators=['backup_operators_value'], + administrators=['administrators_value'], + security_operators=['security_operators_value'], + kdc_hostname='kdc_hostname_value', + kdc_ip='kdc_ip_value', + nfs_users_with_ldap=True, + description='description_value', + ldap_signing=True, + encrypt_dc_connections=True, + state_details='state_details_value', + )) + response = await client.get_active_directory(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = active_directory.GetActiveDirectoryRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, active_directory.ActiveDirectory) + assert response.name == 'name_value' + assert response.state == active_directory.ActiveDirectory.State.CREATING + assert response.domain == 'domain_value' + assert response.site == 'site_value' + assert response.dns == 'dns_value' + assert response.net_bios_prefix == 'net_bios_prefix_value' + assert response.organizational_unit == 'organizational_unit_value' + assert response.aes_encryption is True + assert response.username == 'username_value' + assert response.password == 'password_value' + assert response.backup_operators == ['backup_operators_value'] + assert response.administrators == ['administrators_value'] + assert response.security_operators == ['security_operators_value'] + assert response.kdc_hostname == 'kdc_hostname_value' + assert response.kdc_ip == 'kdc_ip_value' + assert response.nfs_users_with_ldap is True + assert response.description == 'description_value' + assert response.ldap_signing is True + assert response.encrypt_dc_connections is True + assert response.state_details == 'state_details_value' + + +@pytest.mark.asyncio +async def test_get_active_directory_async_from_dict(): + await test_get_active_directory_async(request_type=dict) + +def test_get_active_directory_field_headers(): + client = NetAppClient( + 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 = active_directory.GetActiveDirectoryRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_active_directory), + '__call__') as call: + call.return_value = active_directory.ActiveDirectory() + client.get_active_directory(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_active_directory_field_headers_async(): + client = NetAppAsyncClient( + 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 = active_directory.GetActiveDirectoryRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_active_directory), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(active_directory.ActiveDirectory()) + await client.get_active_directory(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_active_directory_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_active_directory), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = active_directory.ActiveDirectory() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_active_directory( + 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_active_directory_flattened_error(): + client = NetAppClient( + 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_active_directory( + active_directory.GetActiveDirectoryRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_active_directory_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_active_directory), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = active_directory.ActiveDirectory() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(active_directory.ActiveDirectory()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_active_directory( + 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_active_directory_flattened_error_async(): + client = NetAppAsyncClient( + 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_active_directory( + active_directory.GetActiveDirectoryRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + gcn_active_directory.CreateActiveDirectoryRequest, + dict, +]) +def test_create_active_directory(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_active_directory), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_active_directory(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gcn_active_directory.CreateActiveDirectoryRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_active_directory_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 = NetAppClient( + 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 = gcn_active_directory.CreateActiveDirectoryRequest( + parent='parent_value', + active_directory_id='active_directory_id_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_active_directory), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.create_active_directory(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gcn_active_directory.CreateActiveDirectoryRequest( + parent='parent_value', + active_directory_id='active_directory_id_value', + ) + +def test_create_active_directory_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 = NetAppClient( + 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_active_directory 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_active_directory] = mock_rpc + request = {} + client.create_active_directory(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_active_directory(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_active_directory_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 = NetAppAsyncClient( + 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_active_directory 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_active_directory] = mock_rpc + + request = {} + await client.create_active_directory(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_active_directory(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_active_directory_async(transport: str = 'grpc_asyncio', request_type=gcn_active_directory.CreateActiveDirectoryRequest): + client = NetAppAsyncClient( + 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_active_directory), + '__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_active_directory(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gcn_active_directory.CreateActiveDirectoryRequest() + 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_active_directory_async_from_dict(): + await test_create_active_directory_async(request_type=dict) + +def test_create_active_directory_field_headers(): + client = NetAppClient( + 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 = gcn_active_directory.CreateActiveDirectoryRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_active_directory), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_active_directory(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_active_directory_field_headers_async(): + client = NetAppAsyncClient( + 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 = gcn_active_directory.CreateActiveDirectoryRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_active_directory), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_active_directory(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_active_directory_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_active_directory), + '__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_active_directory( + parent='parent_value', + active_directory=gcn_active_directory.ActiveDirectory(name='name_value'), + active_directory_id='active_directory_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].active_directory + mock_val = gcn_active_directory.ActiveDirectory(name='name_value') + assert arg == mock_val + arg = args[0].active_directory_id + mock_val = 'active_directory_id_value' + assert arg == mock_val + + +def test_create_active_directory_flattened_error(): + client = NetAppClient( + 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_active_directory( + gcn_active_directory.CreateActiveDirectoryRequest(), + parent='parent_value', + active_directory=gcn_active_directory.ActiveDirectory(name='name_value'), + active_directory_id='active_directory_id_value', + ) + +@pytest.mark.asyncio +async def test_create_active_directory_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_active_directory), + '__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_active_directory( + parent='parent_value', + active_directory=gcn_active_directory.ActiveDirectory(name='name_value'), + active_directory_id='active_directory_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].active_directory + mock_val = gcn_active_directory.ActiveDirectory(name='name_value') + assert arg == mock_val + arg = args[0].active_directory_id + mock_val = 'active_directory_id_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_active_directory_flattened_error_async(): + client = NetAppAsyncClient( + 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_active_directory( + gcn_active_directory.CreateActiveDirectoryRequest(), + parent='parent_value', + active_directory=gcn_active_directory.ActiveDirectory(name='name_value'), + active_directory_id='active_directory_id_value', + ) + + +@pytest.mark.parametrize("request_type", [ + gcn_active_directory.UpdateActiveDirectoryRequest, + dict, +]) +def test_update_active_directory(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_active_directory), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_active_directory(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gcn_active_directory.UpdateActiveDirectoryRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_active_directory_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 = NetAppClient( + 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 = gcn_active_directory.UpdateActiveDirectoryRequest( + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_active_directory), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.update_active_directory(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gcn_active_directory.UpdateActiveDirectoryRequest( + ) + +def test_update_active_directory_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 = NetAppClient( + 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_active_directory 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_active_directory] = mock_rpc + request = {} + client.update_active_directory(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.update_active_directory(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_active_directory_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 = NetAppAsyncClient( + 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_active_directory 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_active_directory] = mock_rpc + + request = {} + await client.update_active_directory(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.update_active_directory(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_active_directory_async(transport: str = 'grpc_asyncio', request_type=gcn_active_directory.UpdateActiveDirectoryRequest): + client = NetAppAsyncClient( + 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_active_directory), + '__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.update_active_directory(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gcn_active_directory.UpdateActiveDirectoryRequest() + 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_update_active_directory_async_from_dict(): + await test_update_active_directory_async(request_type=dict) + +def test_update_active_directory_field_headers(): + client = NetAppClient( + 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 = gcn_active_directory.UpdateActiveDirectoryRequest() + + request.active_directory.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_active_directory), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_active_directory(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', + 'active_directory.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_active_directory_field_headers_async(): + client = NetAppAsyncClient( + 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 = gcn_active_directory.UpdateActiveDirectoryRequest() + + request.active_directory.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_active_directory), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_active_directory(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', + 'active_directory.name=name_value', + ) in kw['metadata'] + + +def test_update_active_directory_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_active_directory), + '__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.update_active_directory( + active_directory=gcn_active_directory.ActiveDirectory(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].active_directory + mock_val = gcn_active_directory.ActiveDirectory(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_active_directory_flattened_error(): + client = NetAppClient( + 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_active_directory( + gcn_active_directory.UpdateActiveDirectoryRequest(), + active_directory=gcn_active_directory.ActiveDirectory(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_active_directory_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_active_directory), + '__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.update_active_directory( + active_directory=gcn_active_directory.ActiveDirectory(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].active_directory + mock_val = gcn_active_directory.ActiveDirectory(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_active_directory_flattened_error_async(): + client = NetAppAsyncClient( + 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_active_directory( + gcn_active_directory.UpdateActiveDirectoryRequest(), + active_directory=gcn_active_directory.ActiveDirectory(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + active_directory.DeleteActiveDirectoryRequest, + dict, +]) +def test_delete_active_directory(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_active_directory), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_active_directory(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = active_directory.DeleteActiveDirectoryRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_active_directory_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 = NetAppClient( + 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 = active_directory.DeleteActiveDirectoryRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_active_directory), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.delete_active_directory(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == active_directory.DeleteActiveDirectoryRequest( + name='name_value', + ) + +def test_delete_active_directory_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 = NetAppClient( + 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_active_directory 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_active_directory] = mock_rpc + request = {} + client.delete_active_directory(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_active_directory(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_active_directory_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 = NetAppAsyncClient( + 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_active_directory 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_active_directory] = mock_rpc + + request = {} + await client.delete_active_directory(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_active_directory(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_active_directory_async(transport: str = 'grpc_asyncio', request_type=active_directory.DeleteActiveDirectoryRequest): + client = NetAppAsyncClient( + 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_active_directory), + '__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_active_directory(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = active_directory.DeleteActiveDirectoryRequest() + 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_active_directory_async_from_dict(): + await test_delete_active_directory_async(request_type=dict) + +def test_delete_active_directory_field_headers(): + client = NetAppClient( + 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 = active_directory.DeleteActiveDirectoryRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_active_directory), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_active_directory(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_active_directory_field_headers_async(): + client = NetAppAsyncClient( + 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 = active_directory.DeleteActiveDirectoryRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_active_directory), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_active_directory(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_active_directory_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_active_directory), + '__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_active_directory( + 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_active_directory_flattened_error(): + client = NetAppClient( + 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_active_directory( + active_directory.DeleteActiveDirectoryRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_active_directory_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_active_directory), + '__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_active_directory( + 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_active_directory_flattened_error_async(): + client = NetAppAsyncClient( + 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_active_directory( + active_directory.DeleteActiveDirectoryRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + kms.ListKmsConfigsRequest, + dict, +]) +def test_list_kms_configs(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_kms_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = kms.ListKmsConfigsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_kms_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = kms.ListKmsConfigsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListKmsConfigsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_kms_configs_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 = NetAppClient( + 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 = kms.ListKmsConfigsRequest( + 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_kms_configs), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.list_kms_configs(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == kms.ListKmsConfigsRequest( + parent='parent_value', + page_token='page_token_value', + order_by='order_by_value', + filter='filter_value', + ) + +def test_list_kms_configs_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 = NetAppClient( + 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_kms_configs 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_kms_configs] = mock_rpc + request = {} + client.list_kms_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_kms_configs(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_kms_configs_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 = NetAppAsyncClient( + 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_kms_configs 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_kms_configs] = mock_rpc + + request = {} + await client.list_kms_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_kms_configs(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_kms_configs_async(transport: str = 'grpc_asyncio', request_type=kms.ListKmsConfigsRequest): + client = NetAppAsyncClient( + 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_kms_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(kms.ListKmsConfigsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_kms_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = kms.ListKmsConfigsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListKmsConfigsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_kms_configs_async_from_dict(): + await test_list_kms_configs_async(request_type=dict) + +def test_list_kms_configs_field_headers(): + client = NetAppClient( + 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 = kms.ListKmsConfigsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_kms_configs), + '__call__') as call: + call.return_value = kms.ListKmsConfigsResponse() + client.list_kms_configs(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_kms_configs_field_headers_async(): + client = NetAppAsyncClient( + 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 = kms.ListKmsConfigsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_kms_configs), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(kms.ListKmsConfigsResponse()) + await client.list_kms_configs(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_kms_configs_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_kms_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = kms.ListKmsConfigsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_kms_configs( + 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_kms_configs_flattened_error(): + client = NetAppClient( + 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_kms_configs( + kms.ListKmsConfigsRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_kms_configs_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_kms_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = kms.ListKmsConfigsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(kms.ListKmsConfigsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_kms_configs( + 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_kms_configs_flattened_error_async(): + client = NetAppAsyncClient( + 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_kms_configs( + kms.ListKmsConfigsRequest(), + parent='parent_value', + ) + + +def test_list_kms_configs_pager(transport_name: str = "grpc"): + client = NetAppClient( + 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_kms_configs), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + kms.ListKmsConfigsResponse( + kms_configs=[ + kms.KmsConfig(), + kms.KmsConfig(), + kms.KmsConfig(), + ], + next_page_token='abc', + ), + kms.ListKmsConfigsResponse( + kms_configs=[], + next_page_token='def', + ), + kms.ListKmsConfigsResponse( + kms_configs=[ + kms.KmsConfig(), + ], + next_page_token='ghi', + ), + kms.ListKmsConfigsResponse( + kms_configs=[ + kms.KmsConfig(), + kms.KmsConfig(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_kms_configs(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, kms.KmsConfig) + for i in results) +def test_list_kms_configs_pages(transport_name: str = "grpc"): + client = NetAppClient( + 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_kms_configs), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + kms.ListKmsConfigsResponse( + kms_configs=[ + kms.KmsConfig(), + kms.KmsConfig(), + kms.KmsConfig(), + ], + next_page_token='abc', + ), + kms.ListKmsConfigsResponse( + kms_configs=[], + next_page_token='def', + ), + kms.ListKmsConfigsResponse( + kms_configs=[ + kms.KmsConfig(), + ], + next_page_token='ghi', + ), + kms.ListKmsConfigsResponse( + kms_configs=[ + kms.KmsConfig(), + kms.KmsConfig(), + ], + ), + RuntimeError, + ) + pages = list(client.list_kms_configs(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_kms_configs_async_pager(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_kms_configs), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + kms.ListKmsConfigsResponse( + kms_configs=[ + kms.KmsConfig(), + kms.KmsConfig(), + kms.KmsConfig(), + ], + next_page_token='abc', + ), + kms.ListKmsConfigsResponse( + kms_configs=[], + next_page_token='def', + ), + kms.ListKmsConfigsResponse( + kms_configs=[ + kms.KmsConfig(), + ], + next_page_token='ghi', + ), + kms.ListKmsConfigsResponse( + kms_configs=[ + kms.KmsConfig(), + kms.KmsConfig(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_kms_configs(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, kms.KmsConfig) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_kms_configs_async_pages(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_kms_configs), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + kms.ListKmsConfigsResponse( + kms_configs=[ + kms.KmsConfig(), + kms.KmsConfig(), + kms.KmsConfig(), + ], + next_page_token='abc', + ), + kms.ListKmsConfigsResponse( + kms_configs=[], + next_page_token='def', + ), + kms.ListKmsConfigsResponse( + kms_configs=[ + kms.KmsConfig(), + ], + next_page_token='ghi', + ), + kms.ListKmsConfigsResponse( + kms_configs=[ + kms.KmsConfig(), + kms.KmsConfig(), + ], + ), + 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_kms_configs(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", [ + kms.CreateKmsConfigRequest, + dict, +]) +def test_create_kms_config(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_kms_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_kms_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = kms.CreateKmsConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_kms_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 = NetAppClient( + 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 = kms.CreateKmsConfigRequest( + parent='parent_value', + kms_config_id='kms_config_id_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_kms_config), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.create_kms_config(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == kms.CreateKmsConfigRequest( + parent='parent_value', + kms_config_id='kms_config_id_value', + ) + +def test_create_kms_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 = NetAppClient( + 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_kms_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.create_kms_config] = mock_rpc + request = {} + client.create_kms_config(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_kms_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_create_kms_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 = NetAppAsyncClient( + 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_kms_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.create_kms_config] = mock_rpc + + request = {} + await client.create_kms_config(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_kms_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_create_kms_config_async(transport: str = 'grpc_asyncio', request_type=kms.CreateKmsConfigRequest): + client = NetAppAsyncClient( + 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_kms_config), + '__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_kms_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = kms.CreateKmsConfigRequest() + 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_kms_config_async_from_dict(): + await test_create_kms_config_async(request_type=dict) + +def test_create_kms_config_field_headers(): + client = NetAppClient( + 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 = kms.CreateKmsConfigRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_kms_config), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_kms_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', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_create_kms_config_field_headers_async(): + client = NetAppAsyncClient( + 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 = kms.CreateKmsConfigRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_kms_config), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_kms_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', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_create_kms_config_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_kms_config), + '__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_kms_config( + parent='parent_value', + kms_config=kms.KmsConfig(name='name_value'), + kms_config_id='kms_config_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].kms_config + mock_val = kms.KmsConfig(name='name_value') + assert arg == mock_val + arg = args[0].kms_config_id + mock_val = 'kms_config_id_value' + assert arg == mock_val + + +def test_create_kms_config_flattened_error(): + client = NetAppClient( + 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_kms_config( + kms.CreateKmsConfigRequest(), + parent='parent_value', + kms_config=kms.KmsConfig(name='name_value'), + kms_config_id='kms_config_id_value', + ) + +@pytest.mark.asyncio +async def test_create_kms_config_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_kms_config), + '__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_kms_config( + parent='parent_value', + kms_config=kms.KmsConfig(name='name_value'), + kms_config_id='kms_config_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].kms_config + mock_val = kms.KmsConfig(name='name_value') + assert arg == mock_val + arg = args[0].kms_config_id + mock_val = 'kms_config_id_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_kms_config_flattened_error_async(): + client = NetAppAsyncClient( + 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_kms_config( + kms.CreateKmsConfigRequest(), + parent='parent_value', + kms_config=kms.KmsConfig(name='name_value'), + kms_config_id='kms_config_id_value', + ) + + +@pytest.mark.parametrize("request_type", [ + kms.GetKmsConfigRequest, + dict, +]) +def test_get_kms_config(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_kms_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = kms.KmsConfig( + name='name_value', + crypto_key_name='crypto_key_name_value', + state=kms.KmsConfig.State.READY, + state_details='state_details_value', + description='description_value', + instructions='instructions_value', + service_account='service_account_value', + ) + response = client.get_kms_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = kms.GetKmsConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, kms.KmsConfig) + assert response.name == 'name_value' + assert response.crypto_key_name == 'crypto_key_name_value' + assert response.state == kms.KmsConfig.State.READY + assert response.state_details == 'state_details_value' + assert response.description == 'description_value' + assert response.instructions == 'instructions_value' + assert response.service_account == 'service_account_value' + + +def test_get_kms_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 = NetAppClient( + 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 = kms.GetKmsConfigRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_kms_config), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.get_kms_config(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == kms.GetKmsConfigRequest( + name='name_value', + ) + +def test_get_kms_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 = NetAppClient( + 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_kms_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_kms_config] = mock_rpc + request = {} + client.get_kms_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_kms_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_kms_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 = NetAppAsyncClient( + 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_kms_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_kms_config] = mock_rpc + + request = {} + await client.get_kms_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_kms_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_kms_config_async(transport: str = 'grpc_asyncio', request_type=kms.GetKmsConfigRequest): + client = NetAppAsyncClient( + 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_kms_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(kms.KmsConfig( + name='name_value', + crypto_key_name='crypto_key_name_value', + state=kms.KmsConfig.State.READY, + state_details='state_details_value', + description='description_value', + instructions='instructions_value', + service_account='service_account_value', + )) + response = await client.get_kms_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = kms.GetKmsConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, kms.KmsConfig) + assert response.name == 'name_value' + assert response.crypto_key_name == 'crypto_key_name_value' + assert response.state == kms.KmsConfig.State.READY + assert response.state_details == 'state_details_value' + assert response.description == 'description_value' + assert response.instructions == 'instructions_value' + assert response.service_account == 'service_account_value' + + +@pytest.mark.asyncio +async def test_get_kms_config_async_from_dict(): + await test_get_kms_config_async(request_type=dict) + +def test_get_kms_config_field_headers(): + client = NetAppClient( + 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 = kms.GetKmsConfigRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_kms_config), + '__call__') as call: + call.return_value = kms.KmsConfig() + client.get_kms_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_kms_config_field_headers_async(): + client = NetAppAsyncClient( + 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 = kms.GetKmsConfigRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_kms_config), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(kms.KmsConfig()) + await client.get_kms_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_kms_config_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_kms_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = kms.KmsConfig() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_kms_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_kms_config_flattened_error(): + client = NetAppClient( + 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_kms_config( + kms.GetKmsConfigRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_kms_config_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_kms_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = kms.KmsConfig() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(kms.KmsConfig()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_kms_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_kms_config_flattened_error_async(): + client = NetAppAsyncClient( + 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_kms_config( + kms.GetKmsConfigRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + kms.UpdateKmsConfigRequest, + dict, +]) +def test_update_kms_config(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_kms_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_kms_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = kms.UpdateKmsConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_kms_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 = NetAppClient( + 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 = kms.UpdateKmsConfigRequest( + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_kms_config), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.update_kms_config(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == kms.UpdateKmsConfigRequest( + ) + +def test_update_kms_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 = NetAppClient( + 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_kms_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_kms_config] = mock_rpc + request = {} + client.update_kms_config(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.update_kms_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_kms_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 = NetAppAsyncClient( + 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_kms_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_kms_config] = mock_rpc + + request = {} + await client.update_kms_config(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.update_kms_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_kms_config_async(transport: str = 'grpc_asyncio', request_type=kms.UpdateKmsConfigRequest): + client = NetAppAsyncClient( + 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_kms_config), + '__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.update_kms_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = kms.UpdateKmsConfigRequest() + 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_update_kms_config_async_from_dict(): + await test_update_kms_config_async(request_type=dict) + +def test_update_kms_config_field_headers(): + client = NetAppClient( + 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 = kms.UpdateKmsConfigRequest() + + request.kms_config.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_kms_config), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_kms_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', + 'kms_config.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_kms_config_field_headers_async(): + client = NetAppAsyncClient( + 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 = kms.UpdateKmsConfigRequest() + + request.kms_config.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_kms_config), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_kms_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', + 'kms_config.name=name_value', + ) in kw['metadata'] + + +def test_update_kms_config_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_kms_config), + '__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.update_kms_config( + kms_config=kms.KmsConfig(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].kms_config + mock_val = kms.KmsConfig(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_kms_config_flattened_error(): + client = NetAppClient( + 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_kms_config( + kms.UpdateKmsConfigRequest(), + kms_config=kms.KmsConfig(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_kms_config_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_kms_config), + '__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.update_kms_config( + kms_config=kms.KmsConfig(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].kms_config + mock_val = kms.KmsConfig(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_kms_config_flattened_error_async(): + client = NetAppAsyncClient( + 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_kms_config( + kms.UpdateKmsConfigRequest(), + kms_config=kms.KmsConfig(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + kms.EncryptVolumesRequest, + dict, +]) +def test_encrypt_volumes(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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.encrypt_volumes), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.encrypt_volumes(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = kms.EncryptVolumesRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_encrypt_volumes_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 = NetAppClient( + 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 = kms.EncryptVolumesRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.encrypt_volumes), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.encrypt_volumes(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == kms.EncryptVolumesRequest( + name='name_value', + ) + +def test_encrypt_volumes_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 = NetAppClient( + 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.encrypt_volumes 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.encrypt_volumes] = mock_rpc + request = {} + client.encrypt_volumes(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.encrypt_volumes(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_encrypt_volumes_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 = NetAppAsyncClient( + 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.encrypt_volumes 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.encrypt_volumes] = mock_rpc + + request = {} + await client.encrypt_volumes(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.encrypt_volumes(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_encrypt_volumes_async(transport: str = 'grpc_asyncio', request_type=kms.EncryptVolumesRequest): + client = NetAppAsyncClient( + 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.encrypt_volumes), + '__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.encrypt_volumes(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = kms.EncryptVolumesRequest() + 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_encrypt_volumes_async_from_dict(): + await test_encrypt_volumes_async(request_type=dict) + +def test_encrypt_volumes_field_headers(): + client = NetAppClient( + 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 = kms.EncryptVolumesRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.encrypt_volumes), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.encrypt_volumes(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_encrypt_volumes_field_headers_async(): + client = NetAppAsyncClient( + 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 = kms.EncryptVolumesRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.encrypt_volumes), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.encrypt_volumes(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'] + + +@pytest.mark.parametrize("request_type", [ + kms.VerifyKmsConfigRequest, + dict, +]) +def test_verify_kms_config(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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.verify_kms_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = kms.VerifyKmsConfigResponse( + healthy=True, + health_error='health_error_value', + instructions='instructions_value', + ) + response = client.verify_kms_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = kms.VerifyKmsConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, kms.VerifyKmsConfigResponse) + assert response.healthy is True + assert response.health_error == 'health_error_value' + assert response.instructions == 'instructions_value' + + +def test_verify_kms_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 = NetAppClient( + 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 = kms.VerifyKmsConfigRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.verify_kms_config), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.verify_kms_config(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == kms.VerifyKmsConfigRequest( + name='name_value', + ) + +def test_verify_kms_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 = NetAppClient( + 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.verify_kms_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.verify_kms_config] = mock_rpc + request = {} + client.verify_kms_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.verify_kms_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_verify_kms_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 = NetAppAsyncClient( + 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.verify_kms_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.verify_kms_config] = mock_rpc + + request = {} + await client.verify_kms_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.verify_kms_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_verify_kms_config_async(transport: str = 'grpc_asyncio', request_type=kms.VerifyKmsConfigRequest): + client = NetAppAsyncClient( + 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.verify_kms_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(kms.VerifyKmsConfigResponse( + healthy=True, + health_error='health_error_value', + instructions='instructions_value', + )) + response = await client.verify_kms_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = kms.VerifyKmsConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, kms.VerifyKmsConfigResponse) + assert response.healthy is True + assert response.health_error == 'health_error_value' + assert response.instructions == 'instructions_value' + + +@pytest.mark.asyncio +async def test_verify_kms_config_async_from_dict(): + await test_verify_kms_config_async(request_type=dict) + +def test_verify_kms_config_field_headers(): + client = NetAppClient( + 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 = kms.VerifyKmsConfigRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.verify_kms_config), + '__call__') as call: + call.return_value = kms.VerifyKmsConfigResponse() + client.verify_kms_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_verify_kms_config_field_headers_async(): + client = NetAppAsyncClient( + 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 = kms.VerifyKmsConfigRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.verify_kms_config), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(kms.VerifyKmsConfigResponse()) + await client.verify_kms_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'] + + +@pytest.mark.parametrize("request_type", [ + kms.DeleteKmsConfigRequest, + dict, +]) +def test_delete_kms_config(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_kms_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_kms_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = kms.DeleteKmsConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_kms_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 = NetAppClient( + 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 = kms.DeleteKmsConfigRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_kms_config), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.delete_kms_config(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == kms.DeleteKmsConfigRequest( + name='name_value', + ) + +def test_delete_kms_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 = NetAppClient( + 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_kms_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.delete_kms_config] = mock_rpc + request = {} + client.delete_kms_config(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_kms_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_delete_kms_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 = NetAppAsyncClient( + 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_kms_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.delete_kms_config] = mock_rpc + + request = {} + await client.delete_kms_config(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_kms_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_delete_kms_config_async(transport: str = 'grpc_asyncio', request_type=kms.DeleteKmsConfigRequest): + client = NetAppAsyncClient( + 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_kms_config), + '__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_kms_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = kms.DeleteKmsConfigRequest() + 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_kms_config_async_from_dict(): + await test_delete_kms_config_async(request_type=dict) + +def test_delete_kms_config_field_headers(): + client = NetAppClient( + 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 = kms.DeleteKmsConfigRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_kms_config), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_kms_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_delete_kms_config_field_headers_async(): + client = NetAppAsyncClient( + 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 = kms.DeleteKmsConfigRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_kms_config), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_kms_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_delete_kms_config_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_kms_config), + '__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_kms_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_delete_kms_config_flattened_error(): + client = NetAppClient( + 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_kms_config( + kms.DeleteKmsConfigRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_kms_config_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_kms_config), + '__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_kms_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_delete_kms_config_flattened_error_async(): + client = NetAppAsyncClient( + 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_kms_config( + kms.DeleteKmsConfigRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + replication.ListReplicationsRequest, + dict, +]) +def test_list_replications(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_replications), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = replication.ListReplicationsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_replications(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = replication.ListReplicationsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListReplicationsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_replications_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 = NetAppClient( + 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 = replication.ListReplicationsRequest( + 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_replications), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.list_replications(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == replication.ListReplicationsRequest( + parent='parent_value', + page_token='page_token_value', + order_by='order_by_value', + filter='filter_value', + ) + +def test_list_replications_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 = NetAppClient( + 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_replications 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_replications] = mock_rpc + request = {} + client.list_replications(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_replications(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_replications_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 = NetAppAsyncClient( + 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_replications 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_replications] = mock_rpc + + request = {} + await client.list_replications(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_replications(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_replications_async(transport: str = 'grpc_asyncio', request_type=replication.ListReplicationsRequest): + client = NetAppAsyncClient( + 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_replications), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(replication.ListReplicationsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_replications(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = replication.ListReplicationsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListReplicationsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_replications_async_from_dict(): + await test_list_replications_async(request_type=dict) + +def test_list_replications_field_headers(): + client = NetAppClient( + 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 = replication.ListReplicationsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_replications), + '__call__') as call: + call.return_value = replication.ListReplicationsResponse() + client.list_replications(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_replications_field_headers_async(): + client = NetAppAsyncClient( + 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 = replication.ListReplicationsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_replications), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(replication.ListReplicationsResponse()) + await client.list_replications(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_replications_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_replications), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = replication.ListReplicationsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_replications( + 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_replications_flattened_error(): + client = NetAppClient( + 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_replications( + replication.ListReplicationsRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_replications_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_replications), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = replication.ListReplicationsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(replication.ListReplicationsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_replications( + 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_replications_flattened_error_async(): + client = NetAppAsyncClient( + 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_replications( + replication.ListReplicationsRequest(), + parent='parent_value', + ) + + +def test_list_replications_pager(transport_name: str = "grpc"): + client = NetAppClient( + 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_replications), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + replication.ListReplicationsResponse( + replications=[ + replication.Replication(), + replication.Replication(), + replication.Replication(), + ], + next_page_token='abc', + ), + replication.ListReplicationsResponse( + replications=[], + next_page_token='def', + ), + replication.ListReplicationsResponse( + replications=[ + replication.Replication(), + ], + next_page_token='ghi', + ), + replication.ListReplicationsResponse( + replications=[ + replication.Replication(), + replication.Replication(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_replications(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, replication.Replication) + for i in results) +def test_list_replications_pages(transport_name: str = "grpc"): + client = NetAppClient( + 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_replications), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + replication.ListReplicationsResponse( + replications=[ + replication.Replication(), + replication.Replication(), + replication.Replication(), + ], + next_page_token='abc', + ), + replication.ListReplicationsResponse( + replications=[], + next_page_token='def', + ), + replication.ListReplicationsResponse( + replications=[ + replication.Replication(), + ], + next_page_token='ghi', + ), + replication.ListReplicationsResponse( + replications=[ + replication.Replication(), + replication.Replication(), + ], + ), + RuntimeError, + ) + pages = list(client.list_replications(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_replications_async_pager(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_replications), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + replication.ListReplicationsResponse( + replications=[ + replication.Replication(), + replication.Replication(), + replication.Replication(), + ], + next_page_token='abc', + ), + replication.ListReplicationsResponse( + replications=[], + next_page_token='def', + ), + replication.ListReplicationsResponse( + replications=[ + replication.Replication(), + ], + next_page_token='ghi', + ), + replication.ListReplicationsResponse( + replications=[ + replication.Replication(), + replication.Replication(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_replications(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, replication.Replication) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_replications_async_pages(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_replications), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + replication.ListReplicationsResponse( + replications=[ + replication.Replication(), + replication.Replication(), + replication.Replication(), + ], + next_page_token='abc', + ), + replication.ListReplicationsResponse( + replications=[], + next_page_token='def', + ), + replication.ListReplicationsResponse( + replications=[ + replication.Replication(), + ], + next_page_token='ghi', + ), + replication.ListReplicationsResponse( + replications=[ + replication.Replication(), + replication.Replication(), + ], + ), + 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_replications(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", [ + replication.GetReplicationRequest, + dict, +]) +def test_get_replication(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_replication), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = replication.Replication( + name='name_value', + state=replication.Replication.State.CREATING, + state_details='state_details_value', + role=replication.Replication.ReplicationRole.SOURCE, + replication_schedule=replication.Replication.ReplicationSchedule.EVERY_10_MINUTES, + mirror_state=replication.Replication.MirrorState.PREPARING, + healthy=True, + destination_volume='destination_volume_value', + description='description_value', + source_volume='source_volume_value', + cluster_location='cluster_location_value', + hybrid_replication_type=replication.Replication.HybridReplicationType.MIGRATION, + ) + response = client.get_replication(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = replication.GetReplicationRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, replication.Replication) + assert response.name == 'name_value' + assert response.state == replication.Replication.State.CREATING + assert response.state_details == 'state_details_value' + assert response.role == replication.Replication.ReplicationRole.SOURCE + assert response.replication_schedule == replication.Replication.ReplicationSchedule.EVERY_10_MINUTES + assert response.mirror_state == replication.Replication.MirrorState.PREPARING + assert response.healthy is True + assert response.destination_volume == 'destination_volume_value' + assert response.description == 'description_value' + assert response.source_volume == 'source_volume_value' + assert response.cluster_location == 'cluster_location_value' + assert response.hybrid_replication_type == replication.Replication.HybridReplicationType.MIGRATION + + +def test_get_replication_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 = NetAppClient( + 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 = replication.GetReplicationRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_replication), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.get_replication(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == replication.GetReplicationRequest( + name='name_value', + ) + +def test_get_replication_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 = NetAppClient( + 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_replication 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_replication] = mock_rpc + request = {} + client.get_replication(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_replication(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_replication_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 = NetAppAsyncClient( + 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_replication 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_replication] = mock_rpc + + request = {} + await client.get_replication(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_replication(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_replication_async(transport: str = 'grpc_asyncio', request_type=replication.GetReplicationRequest): + client = NetAppAsyncClient( + 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_replication), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(replication.Replication( + name='name_value', + state=replication.Replication.State.CREATING, + state_details='state_details_value', + role=replication.Replication.ReplicationRole.SOURCE, + replication_schedule=replication.Replication.ReplicationSchedule.EVERY_10_MINUTES, + mirror_state=replication.Replication.MirrorState.PREPARING, + healthy=True, + destination_volume='destination_volume_value', + description='description_value', + source_volume='source_volume_value', + cluster_location='cluster_location_value', + hybrid_replication_type=replication.Replication.HybridReplicationType.MIGRATION, + )) + response = await client.get_replication(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = replication.GetReplicationRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, replication.Replication) + assert response.name == 'name_value' + assert response.state == replication.Replication.State.CREATING + assert response.state_details == 'state_details_value' + assert response.role == replication.Replication.ReplicationRole.SOURCE + assert response.replication_schedule == replication.Replication.ReplicationSchedule.EVERY_10_MINUTES + assert response.mirror_state == replication.Replication.MirrorState.PREPARING + assert response.healthy is True + assert response.destination_volume == 'destination_volume_value' + assert response.description == 'description_value' + assert response.source_volume == 'source_volume_value' + assert response.cluster_location == 'cluster_location_value' + assert response.hybrid_replication_type == replication.Replication.HybridReplicationType.MIGRATION + + +@pytest.mark.asyncio +async def test_get_replication_async_from_dict(): + await test_get_replication_async(request_type=dict) + +def test_get_replication_field_headers(): + client = NetAppClient( + 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 = replication.GetReplicationRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_replication), + '__call__') as call: + call.return_value = replication.Replication() + client.get_replication(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_replication_field_headers_async(): + client = NetAppAsyncClient( + 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 = replication.GetReplicationRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_replication), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(replication.Replication()) + await client.get_replication(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_replication_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_replication), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = replication.Replication() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_replication( + 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_replication_flattened_error(): + client = NetAppClient( + 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_replication( + replication.GetReplicationRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_replication_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_replication), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = replication.Replication() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(replication.Replication()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_replication( + 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_replication_flattened_error_async(): + client = NetAppAsyncClient( + 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_replication( + replication.GetReplicationRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + gcn_replication.CreateReplicationRequest, + dict, +]) +def test_create_replication(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_replication), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_replication(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gcn_replication.CreateReplicationRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_replication_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 = NetAppClient( + 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 = gcn_replication.CreateReplicationRequest( + parent='parent_value', + replication_id='replication_id_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_replication), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.create_replication(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gcn_replication.CreateReplicationRequest( + parent='parent_value', + replication_id='replication_id_value', + ) + +def test_create_replication_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 = NetAppClient( + 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_replication 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_replication] = mock_rpc + request = {} + client.create_replication(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_replication(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_replication_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 = NetAppAsyncClient( + 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_replication 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_replication] = mock_rpc + + request = {} + await client.create_replication(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_replication(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_replication_async(transport: str = 'grpc_asyncio', request_type=gcn_replication.CreateReplicationRequest): + client = NetAppAsyncClient( + 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_replication), + '__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_replication(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gcn_replication.CreateReplicationRequest() + 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_replication_async_from_dict(): + await test_create_replication_async(request_type=dict) + +def test_create_replication_field_headers(): + client = NetAppClient( + 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 = gcn_replication.CreateReplicationRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_replication), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_replication(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_replication_field_headers_async(): + client = NetAppAsyncClient( + 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 = gcn_replication.CreateReplicationRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_replication), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_replication(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_replication_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_replication), + '__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_replication( + parent='parent_value', + replication=gcn_replication.Replication(name='name_value'), + replication_id='replication_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].replication + mock_val = gcn_replication.Replication(name='name_value') + assert arg == mock_val + arg = args[0].replication_id + mock_val = 'replication_id_value' + assert arg == mock_val + + +def test_create_replication_flattened_error(): + client = NetAppClient( + 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_replication( + gcn_replication.CreateReplicationRequest(), + parent='parent_value', + replication=gcn_replication.Replication(name='name_value'), + replication_id='replication_id_value', + ) + +@pytest.mark.asyncio +async def test_create_replication_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_replication), + '__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_replication( + parent='parent_value', + replication=gcn_replication.Replication(name='name_value'), + replication_id='replication_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].replication + mock_val = gcn_replication.Replication(name='name_value') + assert arg == mock_val + arg = args[0].replication_id + mock_val = 'replication_id_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_replication_flattened_error_async(): + client = NetAppAsyncClient( + 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_replication( + gcn_replication.CreateReplicationRequest(), + parent='parent_value', + replication=gcn_replication.Replication(name='name_value'), + replication_id='replication_id_value', + ) + + +@pytest.mark.parametrize("request_type", [ + replication.DeleteReplicationRequest, + dict, +]) +def test_delete_replication(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_replication), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_replication(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = replication.DeleteReplicationRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_replication_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 = NetAppClient( + 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 = replication.DeleteReplicationRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_replication), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.delete_replication(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == replication.DeleteReplicationRequest( + name='name_value', + ) + +def test_delete_replication_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 = NetAppClient( + 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_replication 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_replication] = mock_rpc + request = {} + client.delete_replication(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_replication(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_replication_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 = NetAppAsyncClient( + 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_replication 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_replication] = mock_rpc + + request = {} + await client.delete_replication(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_replication(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_replication_async(transport: str = 'grpc_asyncio', request_type=replication.DeleteReplicationRequest): + client = NetAppAsyncClient( + 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_replication), + '__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_replication(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = replication.DeleteReplicationRequest() + 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_replication_async_from_dict(): + await test_delete_replication_async(request_type=dict) + +def test_delete_replication_field_headers(): + client = NetAppClient( + 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 = replication.DeleteReplicationRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_replication), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_replication(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_replication_field_headers_async(): + client = NetAppAsyncClient( + 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 = replication.DeleteReplicationRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_replication), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_replication(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_replication_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_replication), + '__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_replication( + 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_replication_flattened_error(): + client = NetAppClient( + 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_replication( + replication.DeleteReplicationRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_replication_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_replication), + '__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_replication( + 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_replication_flattened_error_async(): + client = NetAppAsyncClient( + 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_replication( + replication.DeleteReplicationRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + gcn_replication.UpdateReplicationRequest, + dict, +]) +def test_update_replication(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_replication), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_replication(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gcn_replication.UpdateReplicationRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_replication_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 = NetAppClient( + 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 = gcn_replication.UpdateReplicationRequest( + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_replication), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.update_replication(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gcn_replication.UpdateReplicationRequest( + ) + +def test_update_replication_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 = NetAppClient( + 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_replication 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_replication] = mock_rpc + request = {} + client.update_replication(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.update_replication(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_replication_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 = NetAppAsyncClient( + 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_replication 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_replication] = mock_rpc + + request = {} + await client.update_replication(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.update_replication(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_replication_async(transport: str = 'grpc_asyncio', request_type=gcn_replication.UpdateReplicationRequest): + client = NetAppAsyncClient( + 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_replication), + '__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.update_replication(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gcn_replication.UpdateReplicationRequest() + 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_update_replication_async_from_dict(): + await test_update_replication_async(request_type=dict) + +def test_update_replication_field_headers(): + client = NetAppClient( + 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 = gcn_replication.UpdateReplicationRequest() + + request.replication.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_replication), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_replication(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', + 'replication.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_replication_field_headers_async(): + client = NetAppAsyncClient( + 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 = gcn_replication.UpdateReplicationRequest() + + request.replication.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_replication), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_replication(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', + 'replication.name=name_value', + ) in kw['metadata'] + + +def test_update_replication_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_replication), + '__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.update_replication( + replication=gcn_replication.Replication(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].replication + mock_val = gcn_replication.Replication(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_replication_flattened_error(): + client = NetAppClient( + 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_replication( + gcn_replication.UpdateReplicationRequest(), + replication=gcn_replication.Replication(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_replication_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_replication), + '__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.update_replication( + replication=gcn_replication.Replication(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].replication + mock_val = gcn_replication.Replication(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_replication_flattened_error_async(): + client = NetAppAsyncClient( + 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_replication( + gcn_replication.UpdateReplicationRequest(), + replication=gcn_replication.Replication(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + replication.StopReplicationRequest, + dict, +]) +def test_stop_replication(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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.stop_replication), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.stop_replication(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = replication.StopReplicationRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_stop_replication_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 = NetAppClient( + 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 = replication.StopReplicationRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.stop_replication), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.stop_replication(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == replication.StopReplicationRequest( + name='name_value', + ) + +def test_stop_replication_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 = NetAppClient( + 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.stop_replication 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.stop_replication] = mock_rpc + request = {} + client.stop_replication(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.stop_replication(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_stop_replication_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 = NetAppAsyncClient( + 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.stop_replication 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.stop_replication] = mock_rpc + + request = {} + await client.stop_replication(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.stop_replication(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_stop_replication_async(transport: str = 'grpc_asyncio', request_type=replication.StopReplicationRequest): + client = NetAppAsyncClient( + 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.stop_replication), + '__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.stop_replication(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = replication.StopReplicationRequest() + 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_stop_replication_async_from_dict(): + await test_stop_replication_async(request_type=dict) + +def test_stop_replication_field_headers(): + client = NetAppClient( + 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 = replication.StopReplicationRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.stop_replication), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.stop_replication(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_stop_replication_field_headers_async(): + client = NetAppAsyncClient( + 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 = replication.StopReplicationRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.stop_replication), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.stop_replication(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'] + + +@pytest.mark.parametrize("request_type", [ + replication.ResumeReplicationRequest, + dict, +]) +def test_resume_replication(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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.resume_replication), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.resume_replication(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = replication.ResumeReplicationRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_resume_replication_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 = NetAppClient( + 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 = replication.ResumeReplicationRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.resume_replication), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.resume_replication(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == replication.ResumeReplicationRequest( + name='name_value', + ) + +def test_resume_replication_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 = NetAppClient( + 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.resume_replication 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.resume_replication] = mock_rpc + request = {} + client.resume_replication(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.resume_replication(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_resume_replication_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 = NetAppAsyncClient( + 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.resume_replication 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.resume_replication] = mock_rpc + + request = {} + await client.resume_replication(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.resume_replication(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_resume_replication_async(transport: str = 'grpc_asyncio', request_type=replication.ResumeReplicationRequest): + client = NetAppAsyncClient( + 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.resume_replication), + '__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.resume_replication(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = replication.ResumeReplicationRequest() + 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_resume_replication_async_from_dict(): + await test_resume_replication_async(request_type=dict) + +def test_resume_replication_field_headers(): + client = NetAppClient( + 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 = replication.ResumeReplicationRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.resume_replication), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.resume_replication(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_resume_replication_field_headers_async(): + client = NetAppAsyncClient( + 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 = replication.ResumeReplicationRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.resume_replication), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.resume_replication(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'] + + +@pytest.mark.parametrize("request_type", [ + replication.ReverseReplicationDirectionRequest, + dict, +]) +def test_reverse_replication_direction(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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.reverse_replication_direction), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.reverse_replication_direction(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = replication.ReverseReplicationDirectionRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_reverse_replication_direction_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 = NetAppClient( + 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 = replication.ReverseReplicationDirectionRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.reverse_replication_direction), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.reverse_replication_direction(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == replication.ReverseReplicationDirectionRequest( + name='name_value', + ) + +def test_reverse_replication_direction_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 = NetAppClient( + 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.reverse_replication_direction 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.reverse_replication_direction] = mock_rpc + request = {} + client.reverse_replication_direction(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.reverse_replication_direction(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_reverse_replication_direction_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 = NetAppAsyncClient( + 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.reverse_replication_direction 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.reverse_replication_direction] = mock_rpc + + request = {} + await client.reverse_replication_direction(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.reverse_replication_direction(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_reverse_replication_direction_async(transport: str = 'grpc_asyncio', request_type=replication.ReverseReplicationDirectionRequest): + client = NetAppAsyncClient( + 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.reverse_replication_direction), + '__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.reverse_replication_direction(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = replication.ReverseReplicationDirectionRequest() + 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_reverse_replication_direction_async_from_dict(): + await test_reverse_replication_direction_async(request_type=dict) + +def test_reverse_replication_direction_field_headers(): + client = NetAppClient( + 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 = replication.ReverseReplicationDirectionRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.reverse_replication_direction), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.reverse_replication_direction(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_reverse_replication_direction_field_headers_async(): + client = NetAppAsyncClient( + 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 = replication.ReverseReplicationDirectionRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.reverse_replication_direction), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.reverse_replication_direction(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'] + + +@pytest.mark.parametrize("request_type", [ + replication.EstablishPeeringRequest, + dict, +]) +def test_establish_peering(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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.establish_peering), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.establish_peering(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = replication.EstablishPeeringRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_establish_peering_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 = NetAppClient( + 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 = replication.EstablishPeeringRequest( + name='name_value', + peer_cluster_name='peer_cluster_name_value', + peer_svm_name='peer_svm_name_value', + peer_volume_name='peer_volume_name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.establish_peering), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.establish_peering(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == replication.EstablishPeeringRequest( + name='name_value', + peer_cluster_name='peer_cluster_name_value', + peer_svm_name='peer_svm_name_value', + peer_volume_name='peer_volume_name_value', + ) + +def test_establish_peering_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 = NetAppClient( + 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.establish_peering 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.establish_peering] = mock_rpc + request = {} + client.establish_peering(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.establish_peering(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_establish_peering_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 = NetAppAsyncClient( + 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.establish_peering 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.establish_peering] = mock_rpc + + request = {} + await client.establish_peering(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.establish_peering(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_establish_peering_async(transport: str = 'grpc_asyncio', request_type=replication.EstablishPeeringRequest): + client = NetAppAsyncClient( + 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.establish_peering), + '__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.establish_peering(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = replication.EstablishPeeringRequest() + 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_establish_peering_async_from_dict(): + await test_establish_peering_async(request_type=dict) + +def test_establish_peering_field_headers(): + client = NetAppClient( + 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 = replication.EstablishPeeringRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.establish_peering), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.establish_peering(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_establish_peering_field_headers_async(): + client = NetAppAsyncClient( + 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 = replication.EstablishPeeringRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.establish_peering), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.establish_peering(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'] + + +@pytest.mark.parametrize("request_type", [ + replication.SyncReplicationRequest, + dict, +]) +def test_sync_replication(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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.sync_replication), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.sync_replication(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = replication.SyncReplicationRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_sync_replication_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 = NetAppClient( + 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 = replication.SyncReplicationRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.sync_replication), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.sync_replication(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == replication.SyncReplicationRequest( + name='name_value', + ) + +def test_sync_replication_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 = NetAppClient( + 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.sync_replication 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.sync_replication] = mock_rpc + request = {} + client.sync_replication(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.sync_replication(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_sync_replication_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 = NetAppAsyncClient( + 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.sync_replication 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.sync_replication] = mock_rpc + + request = {} + await client.sync_replication(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.sync_replication(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_sync_replication_async(transport: str = 'grpc_asyncio', request_type=replication.SyncReplicationRequest): + client = NetAppAsyncClient( + 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.sync_replication), + '__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.sync_replication(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = replication.SyncReplicationRequest() + 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_sync_replication_async_from_dict(): + await test_sync_replication_async(request_type=dict) + +def test_sync_replication_field_headers(): + client = NetAppClient( + 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 = replication.SyncReplicationRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.sync_replication), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.sync_replication(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_sync_replication_field_headers_async(): + client = NetAppAsyncClient( + 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 = replication.SyncReplicationRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.sync_replication), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.sync_replication(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'] + + +@pytest.mark.parametrize("request_type", [ + gcn_backup_vault.CreateBackupVaultRequest, + dict, +]) +def test_create_backup_vault(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_backup_vault), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_backup_vault(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gcn_backup_vault.CreateBackupVaultRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_backup_vault_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 = NetAppClient( + 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 = gcn_backup_vault.CreateBackupVaultRequest( + parent='parent_value', + backup_vault_id='backup_vault_id_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_backup_vault), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.create_backup_vault(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gcn_backup_vault.CreateBackupVaultRequest( + parent='parent_value', + backup_vault_id='backup_vault_id_value', + ) + +def test_create_backup_vault_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 = NetAppClient( + 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_backup_vault 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_backup_vault] = mock_rpc + request = {} + client.create_backup_vault(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_backup_vault(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_backup_vault_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 = NetAppAsyncClient( + 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_backup_vault 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_backup_vault] = mock_rpc + + request = {} + await client.create_backup_vault(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_backup_vault(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_backup_vault_async(transport: str = 'grpc_asyncio', request_type=gcn_backup_vault.CreateBackupVaultRequest): + client = NetAppAsyncClient( + 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_backup_vault), + '__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_backup_vault(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gcn_backup_vault.CreateBackupVaultRequest() + 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_backup_vault_async_from_dict(): + await test_create_backup_vault_async(request_type=dict) + +def test_create_backup_vault_field_headers(): + client = NetAppClient( + 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 = gcn_backup_vault.CreateBackupVaultRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_backup_vault), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_backup_vault(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_backup_vault_field_headers_async(): + client = NetAppAsyncClient( + 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 = gcn_backup_vault.CreateBackupVaultRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_backup_vault), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_backup_vault(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_backup_vault_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_backup_vault), + '__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_backup_vault( + parent='parent_value', + backup_vault=gcn_backup_vault.BackupVault(name='name_value'), + backup_vault_id='backup_vault_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].backup_vault + mock_val = gcn_backup_vault.BackupVault(name='name_value') + assert arg == mock_val + arg = args[0].backup_vault_id + mock_val = 'backup_vault_id_value' + assert arg == mock_val + + +def test_create_backup_vault_flattened_error(): + client = NetAppClient( + 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_backup_vault( + gcn_backup_vault.CreateBackupVaultRequest(), + parent='parent_value', + backup_vault=gcn_backup_vault.BackupVault(name='name_value'), + backup_vault_id='backup_vault_id_value', + ) + +@pytest.mark.asyncio +async def test_create_backup_vault_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_backup_vault), + '__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_backup_vault( + parent='parent_value', + backup_vault=gcn_backup_vault.BackupVault(name='name_value'), + backup_vault_id='backup_vault_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].backup_vault + mock_val = gcn_backup_vault.BackupVault(name='name_value') + assert arg == mock_val + arg = args[0].backup_vault_id + mock_val = 'backup_vault_id_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_backup_vault_flattened_error_async(): + client = NetAppAsyncClient( + 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_backup_vault( + gcn_backup_vault.CreateBackupVaultRequest(), + parent='parent_value', + backup_vault=gcn_backup_vault.BackupVault(name='name_value'), + backup_vault_id='backup_vault_id_value', + ) + + +@pytest.mark.parametrize("request_type", [ + backup_vault.GetBackupVaultRequest, + dict, +]) +def test_get_backup_vault(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_backup_vault), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = backup_vault.BackupVault( + name='name_value', + state=backup_vault.BackupVault.State.CREATING, + description='description_value', + ) + response = client.get_backup_vault(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = backup_vault.GetBackupVaultRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, backup_vault.BackupVault) + assert response.name == 'name_value' + assert response.state == backup_vault.BackupVault.State.CREATING + assert response.description == 'description_value' + + +def test_get_backup_vault_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 = NetAppClient( + 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 = backup_vault.GetBackupVaultRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_backup_vault), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.get_backup_vault(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == backup_vault.GetBackupVaultRequest( + name='name_value', + ) + +def test_get_backup_vault_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 = NetAppClient( + 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_backup_vault 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_backup_vault] = mock_rpc + request = {} + client.get_backup_vault(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_backup_vault(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_backup_vault_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 = NetAppAsyncClient( + 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_backup_vault 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_backup_vault] = mock_rpc + + request = {} + await client.get_backup_vault(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_backup_vault(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_backup_vault_async(transport: str = 'grpc_asyncio', request_type=backup_vault.GetBackupVaultRequest): + client = NetAppAsyncClient( + 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_backup_vault), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(backup_vault.BackupVault( + name='name_value', + state=backup_vault.BackupVault.State.CREATING, + description='description_value', + )) + response = await client.get_backup_vault(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = backup_vault.GetBackupVaultRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, backup_vault.BackupVault) + assert response.name == 'name_value' + assert response.state == backup_vault.BackupVault.State.CREATING + assert response.description == 'description_value' + + +@pytest.mark.asyncio +async def test_get_backup_vault_async_from_dict(): + await test_get_backup_vault_async(request_type=dict) + +def test_get_backup_vault_field_headers(): + client = NetAppClient( + 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 = backup_vault.GetBackupVaultRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_backup_vault), + '__call__') as call: + call.return_value = backup_vault.BackupVault() + client.get_backup_vault(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_backup_vault_field_headers_async(): + client = NetAppAsyncClient( + 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 = backup_vault.GetBackupVaultRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_backup_vault), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_vault.BackupVault()) + await client.get_backup_vault(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_backup_vault_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_backup_vault), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = backup_vault.BackupVault() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_backup_vault( + 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_backup_vault_flattened_error(): + client = NetAppClient( + 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_backup_vault( + backup_vault.GetBackupVaultRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_backup_vault_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_backup_vault), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = backup_vault.BackupVault() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_vault.BackupVault()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_backup_vault( + 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_backup_vault_flattened_error_async(): + client = NetAppAsyncClient( + 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_backup_vault( + backup_vault.GetBackupVaultRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + backup_vault.ListBackupVaultsRequest, + dict, +]) +def test_list_backup_vaults(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_backup_vaults), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = backup_vault.ListBackupVaultsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_backup_vaults(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = backup_vault.ListBackupVaultsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListBackupVaultsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_backup_vaults_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 = NetAppClient( + 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 = backup_vault.ListBackupVaultsRequest( + 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_backup_vaults), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.list_backup_vaults(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == backup_vault.ListBackupVaultsRequest( + parent='parent_value', + page_token='page_token_value', + order_by='order_by_value', + filter='filter_value', + ) + +def test_list_backup_vaults_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 = NetAppClient( + 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_backup_vaults 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_backup_vaults] = mock_rpc + request = {} + client.list_backup_vaults(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_backup_vaults(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_backup_vaults_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 = NetAppAsyncClient( + 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_backup_vaults 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_backup_vaults] = mock_rpc + + request = {} + await client.list_backup_vaults(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_backup_vaults(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_backup_vaults_async(transport: str = 'grpc_asyncio', request_type=backup_vault.ListBackupVaultsRequest): + client = NetAppAsyncClient( + 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_backup_vaults), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(backup_vault.ListBackupVaultsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_backup_vaults(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = backup_vault.ListBackupVaultsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListBackupVaultsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_backup_vaults_async_from_dict(): + await test_list_backup_vaults_async(request_type=dict) + +def test_list_backup_vaults_field_headers(): + client = NetAppClient( + 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 = backup_vault.ListBackupVaultsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_backup_vaults), + '__call__') as call: + call.return_value = backup_vault.ListBackupVaultsResponse() + client.list_backup_vaults(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_backup_vaults_field_headers_async(): + client = NetAppAsyncClient( + 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 = backup_vault.ListBackupVaultsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_backup_vaults), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_vault.ListBackupVaultsResponse()) + await client.list_backup_vaults(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_backup_vaults_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_backup_vaults), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = backup_vault.ListBackupVaultsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_backup_vaults( + 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_backup_vaults_flattened_error(): + client = NetAppClient( + 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_backup_vaults( + backup_vault.ListBackupVaultsRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_backup_vaults_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_backup_vaults), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = backup_vault.ListBackupVaultsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_vault.ListBackupVaultsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_backup_vaults( + 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_backup_vaults_flattened_error_async(): + client = NetAppAsyncClient( + 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_backup_vaults( + backup_vault.ListBackupVaultsRequest(), + parent='parent_value', + ) + + +def test_list_backup_vaults_pager(transport_name: str = "grpc"): + client = NetAppClient( + 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_backup_vaults), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + backup_vault.ListBackupVaultsResponse( + backup_vaults=[ + backup_vault.BackupVault(), + backup_vault.BackupVault(), + backup_vault.BackupVault(), + ], + next_page_token='abc', + ), + backup_vault.ListBackupVaultsResponse( + backup_vaults=[], + next_page_token='def', + ), + backup_vault.ListBackupVaultsResponse( + backup_vaults=[ + backup_vault.BackupVault(), + ], + next_page_token='ghi', + ), + backup_vault.ListBackupVaultsResponse( + backup_vaults=[ + backup_vault.BackupVault(), + backup_vault.BackupVault(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_backup_vaults(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, backup_vault.BackupVault) + for i in results) +def test_list_backup_vaults_pages(transport_name: str = "grpc"): + client = NetAppClient( + 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_backup_vaults), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + backup_vault.ListBackupVaultsResponse( + backup_vaults=[ + backup_vault.BackupVault(), + backup_vault.BackupVault(), + backup_vault.BackupVault(), + ], + next_page_token='abc', + ), + backup_vault.ListBackupVaultsResponse( + backup_vaults=[], + next_page_token='def', + ), + backup_vault.ListBackupVaultsResponse( + backup_vaults=[ + backup_vault.BackupVault(), + ], + next_page_token='ghi', + ), + backup_vault.ListBackupVaultsResponse( + backup_vaults=[ + backup_vault.BackupVault(), + backup_vault.BackupVault(), + ], + ), + RuntimeError, + ) + pages = list(client.list_backup_vaults(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_backup_vaults_async_pager(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_backup_vaults), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + backup_vault.ListBackupVaultsResponse( + backup_vaults=[ + backup_vault.BackupVault(), + backup_vault.BackupVault(), + backup_vault.BackupVault(), + ], + next_page_token='abc', + ), + backup_vault.ListBackupVaultsResponse( + backup_vaults=[], + next_page_token='def', + ), + backup_vault.ListBackupVaultsResponse( + backup_vaults=[ + backup_vault.BackupVault(), + ], + next_page_token='ghi', + ), + backup_vault.ListBackupVaultsResponse( + backup_vaults=[ + backup_vault.BackupVault(), + backup_vault.BackupVault(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_backup_vaults(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, backup_vault.BackupVault) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_backup_vaults_async_pages(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_backup_vaults), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + backup_vault.ListBackupVaultsResponse( + backup_vaults=[ + backup_vault.BackupVault(), + backup_vault.BackupVault(), + backup_vault.BackupVault(), + ], + next_page_token='abc', + ), + backup_vault.ListBackupVaultsResponse( + backup_vaults=[], + next_page_token='def', + ), + backup_vault.ListBackupVaultsResponse( + backup_vaults=[ + backup_vault.BackupVault(), + ], + next_page_token='ghi', + ), + backup_vault.ListBackupVaultsResponse( + backup_vaults=[ + backup_vault.BackupVault(), + backup_vault.BackupVault(), + ], + ), + 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_backup_vaults(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", [ + gcn_backup_vault.UpdateBackupVaultRequest, + dict, +]) +def test_update_backup_vault(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_backup_vault), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_backup_vault(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gcn_backup_vault.UpdateBackupVaultRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_backup_vault_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 = NetAppClient( + 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 = gcn_backup_vault.UpdateBackupVaultRequest( + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_backup_vault), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.update_backup_vault(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gcn_backup_vault.UpdateBackupVaultRequest( + ) + +def test_update_backup_vault_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 = NetAppClient( + 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_backup_vault 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_backup_vault] = mock_rpc + request = {} + client.update_backup_vault(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.update_backup_vault(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_backup_vault_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 = NetAppAsyncClient( + 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_backup_vault 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_backup_vault] = mock_rpc + + request = {} + await client.update_backup_vault(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.update_backup_vault(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_backup_vault_async(transport: str = 'grpc_asyncio', request_type=gcn_backup_vault.UpdateBackupVaultRequest): + client = NetAppAsyncClient( + 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_backup_vault), + '__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.update_backup_vault(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gcn_backup_vault.UpdateBackupVaultRequest() + 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_update_backup_vault_async_from_dict(): + await test_update_backup_vault_async(request_type=dict) + +def test_update_backup_vault_field_headers(): + client = NetAppClient( + 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 = gcn_backup_vault.UpdateBackupVaultRequest() + + request.backup_vault.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_backup_vault), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_backup_vault(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', + 'backup_vault.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_backup_vault_field_headers_async(): + client = NetAppAsyncClient( + 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 = gcn_backup_vault.UpdateBackupVaultRequest() + + request.backup_vault.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_backup_vault), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_backup_vault(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', + 'backup_vault.name=name_value', + ) in kw['metadata'] + + +def test_update_backup_vault_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_backup_vault), + '__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.update_backup_vault( + backup_vault=gcn_backup_vault.BackupVault(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].backup_vault + mock_val = gcn_backup_vault.BackupVault(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_backup_vault_flattened_error(): + client = NetAppClient( + 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_backup_vault( + gcn_backup_vault.UpdateBackupVaultRequest(), + backup_vault=gcn_backup_vault.BackupVault(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_backup_vault_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_backup_vault), + '__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.update_backup_vault( + backup_vault=gcn_backup_vault.BackupVault(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].backup_vault + mock_val = gcn_backup_vault.BackupVault(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_backup_vault_flattened_error_async(): + client = NetAppAsyncClient( + 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_backup_vault( + gcn_backup_vault.UpdateBackupVaultRequest(), + backup_vault=gcn_backup_vault.BackupVault(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + backup_vault.DeleteBackupVaultRequest, + dict, +]) +def test_delete_backup_vault(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_backup_vault), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_backup_vault(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = backup_vault.DeleteBackupVaultRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_backup_vault_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 = NetAppClient( + 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 = backup_vault.DeleteBackupVaultRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup_vault), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.delete_backup_vault(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == backup_vault.DeleteBackupVaultRequest( + name='name_value', + ) + +def test_delete_backup_vault_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 = NetAppClient( + 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_backup_vault 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_backup_vault] = mock_rpc + request = {} + client.delete_backup_vault(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_backup_vault(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_backup_vault_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 = NetAppAsyncClient( + 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_backup_vault 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_backup_vault] = mock_rpc + + request = {} + await client.delete_backup_vault(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_backup_vault(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_backup_vault_async(transport: str = 'grpc_asyncio', request_type=backup_vault.DeleteBackupVaultRequest): + client = NetAppAsyncClient( + 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_backup_vault), + '__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_backup_vault(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = backup_vault.DeleteBackupVaultRequest() + 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_backup_vault_async_from_dict(): + await test_delete_backup_vault_async(request_type=dict) + +def test_delete_backup_vault_field_headers(): + client = NetAppClient( + 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 = backup_vault.DeleteBackupVaultRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup_vault), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_backup_vault(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_backup_vault_field_headers_async(): + client = NetAppAsyncClient( + 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 = backup_vault.DeleteBackupVaultRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup_vault), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_backup_vault(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_backup_vault_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup_vault), + '__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_backup_vault( + 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_backup_vault_flattened_error(): + client = NetAppClient( + 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_backup_vault( + backup_vault.DeleteBackupVaultRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_backup_vault_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup_vault), + '__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_backup_vault( + 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_backup_vault_flattened_error_async(): + client = NetAppAsyncClient( + 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_backup_vault( + backup_vault.DeleteBackupVaultRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + gcn_backup.CreateBackupRequest, + dict, +]) +def test_create_backup(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_backup), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_backup(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gcn_backup.CreateBackupRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_backup_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 = NetAppClient( + 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 = gcn_backup.CreateBackupRequest( + parent='parent_value', + backup_id='backup_id_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_backup), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.create_backup(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gcn_backup.CreateBackupRequest( + parent='parent_value', + backup_id='backup_id_value', + ) + +def test_create_backup_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 = NetAppClient( + 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_backup 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_backup] = mock_rpc + request = {} + client.create_backup(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_backup(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_backup_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 = NetAppAsyncClient( + 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_backup 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_backup] = mock_rpc + + request = {} + await client.create_backup(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_backup(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_backup_async(transport: str = 'grpc_asyncio', request_type=gcn_backup.CreateBackupRequest): + client = NetAppAsyncClient( + 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_backup), + '__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_backup(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gcn_backup.CreateBackupRequest() + 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_backup_async_from_dict(): + await test_create_backup_async(request_type=dict) + +def test_create_backup_field_headers(): + client = NetAppClient( + 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 = gcn_backup.CreateBackupRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_backup), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_backup(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_backup_field_headers_async(): + client = NetAppAsyncClient( + 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 = gcn_backup.CreateBackupRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_backup), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_backup(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_backup_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_backup), + '__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_backup( + parent='parent_value', + backup=gcn_backup.Backup(name='name_value'), + backup_id='backup_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].backup + mock_val = gcn_backup.Backup(name='name_value') + assert arg == mock_val + arg = args[0].backup_id + mock_val = 'backup_id_value' + assert arg == mock_val + + +def test_create_backup_flattened_error(): + client = NetAppClient( + 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_backup( + gcn_backup.CreateBackupRequest(), + parent='parent_value', + backup=gcn_backup.Backup(name='name_value'), + backup_id='backup_id_value', + ) + +@pytest.mark.asyncio +async def test_create_backup_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_backup), + '__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_backup( + parent='parent_value', + backup=gcn_backup.Backup(name='name_value'), + backup_id='backup_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].backup + mock_val = gcn_backup.Backup(name='name_value') + assert arg == mock_val + arg = args[0].backup_id + mock_val = 'backup_id_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_backup_flattened_error_async(): + client = NetAppAsyncClient( + 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_backup( + gcn_backup.CreateBackupRequest(), + parent='parent_value', + backup=gcn_backup.Backup(name='name_value'), + backup_id='backup_id_value', + ) + + +@pytest.mark.parametrize("request_type", [ + backup.GetBackupRequest, + dict, +]) +def test_get_backup(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_backup), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = backup.Backup( + name='name_value', + state=backup.Backup.State.CREATING, + description='description_value', + volume_usage_bytes=1938, + backup_type=backup.Backup.Type.MANUAL, + source_volume='source_volume_value', + source_snapshot='source_snapshot_value', + chain_storage_bytes=2013, + satisfies_pzs=True, + satisfies_pzi=True, + ) + response = client.get_backup(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = backup.GetBackupRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, backup.Backup) + assert response.name == 'name_value' + assert response.state == backup.Backup.State.CREATING + assert response.description == 'description_value' + assert response.volume_usage_bytes == 1938 + assert response.backup_type == backup.Backup.Type.MANUAL + assert response.source_volume == 'source_volume_value' + assert response.source_snapshot == 'source_snapshot_value' + assert response.chain_storage_bytes == 2013 + assert response.satisfies_pzs is True + assert response.satisfies_pzi is True + + +def test_get_backup_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 = NetAppClient( + 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 = backup.GetBackupRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_backup), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.get_backup(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == backup.GetBackupRequest( + name='name_value', + ) + +def test_get_backup_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 = NetAppClient( + 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_backup 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_backup] = mock_rpc + request = {} + client.get_backup(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_backup(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_backup_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 = NetAppAsyncClient( + 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_backup 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_backup] = mock_rpc + + request = {} + await client.get_backup(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_backup(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_backup_async(transport: str = 'grpc_asyncio', request_type=backup.GetBackupRequest): + client = NetAppAsyncClient( + 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_backup), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(backup.Backup( + name='name_value', + state=backup.Backup.State.CREATING, + description='description_value', + volume_usage_bytes=1938, + backup_type=backup.Backup.Type.MANUAL, + source_volume='source_volume_value', + source_snapshot='source_snapshot_value', + chain_storage_bytes=2013, + satisfies_pzs=True, + satisfies_pzi=True, + )) + response = await client.get_backup(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = backup.GetBackupRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, backup.Backup) + assert response.name == 'name_value' + assert response.state == backup.Backup.State.CREATING + assert response.description == 'description_value' + assert response.volume_usage_bytes == 1938 + assert response.backup_type == backup.Backup.Type.MANUAL + assert response.source_volume == 'source_volume_value' + assert response.source_snapshot == 'source_snapshot_value' + assert response.chain_storage_bytes == 2013 + assert response.satisfies_pzs is True + assert response.satisfies_pzi is True + + +@pytest.mark.asyncio +async def test_get_backup_async_from_dict(): + await test_get_backup_async(request_type=dict) + +def test_get_backup_field_headers(): + client = NetAppClient( + 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 = backup.GetBackupRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_backup), + '__call__') as call: + call.return_value = backup.Backup() + client.get_backup(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_backup_field_headers_async(): + client = NetAppAsyncClient( + 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 = backup.GetBackupRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_backup), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup.Backup()) + await client.get_backup(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_backup_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_backup), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = backup.Backup() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_backup( + 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_backup_flattened_error(): + client = NetAppClient( + 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_backup( + backup.GetBackupRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_backup_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_backup), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = backup.Backup() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup.Backup()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_backup( + 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_backup_flattened_error_async(): + client = NetAppAsyncClient( + 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_backup( + backup.GetBackupRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + backup.ListBackupsRequest, + dict, +]) +def test_list_backups(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_backups), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = backup.ListBackupsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_backups(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = backup.ListBackupsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListBackupsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_backups_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 = NetAppClient( + 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 = backup.ListBackupsRequest( + 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_backups), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.list_backups(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == backup.ListBackupsRequest( + parent='parent_value', + page_token='page_token_value', + order_by='order_by_value', + filter='filter_value', + ) + +def test_list_backups_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 = NetAppClient( + 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_backups 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_backups] = mock_rpc + request = {} + client.list_backups(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_backups(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_backups_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 = NetAppAsyncClient( + 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_backups 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_backups] = mock_rpc + + request = {} + await client.list_backups(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_backups(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_backups_async(transport: str = 'grpc_asyncio', request_type=backup.ListBackupsRequest): + client = NetAppAsyncClient( + 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_backups), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(backup.ListBackupsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_backups(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = backup.ListBackupsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListBackupsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_backups_async_from_dict(): + await test_list_backups_async(request_type=dict) + +def test_list_backups_field_headers(): + client = NetAppClient( + 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 = backup.ListBackupsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_backups), + '__call__') as call: + call.return_value = backup.ListBackupsResponse() + client.list_backups(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_backups_field_headers_async(): + client = NetAppAsyncClient( + 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 = backup.ListBackupsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_backups), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup.ListBackupsResponse()) + await client.list_backups(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_backups_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_backups), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = backup.ListBackupsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_backups( + 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_backups_flattened_error(): + client = NetAppClient( + 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_backups( + backup.ListBackupsRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_backups_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_backups), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = backup.ListBackupsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup.ListBackupsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_backups( + 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_backups_flattened_error_async(): + client = NetAppAsyncClient( + 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_backups( + backup.ListBackupsRequest(), + parent='parent_value', + ) + + +def test_list_backups_pager(transport_name: str = "grpc"): + client = NetAppClient( + 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_backups), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + backup.Backup(), + backup.Backup(), + ], + next_page_token='abc', + ), + backup.ListBackupsResponse( + backups=[], + next_page_token='def', + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + ], + next_page_token='ghi', + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + backup.Backup(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_backups(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, backup.Backup) + for i in results) +def test_list_backups_pages(transport_name: str = "grpc"): + client = NetAppClient( + 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_backups), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + backup.Backup(), + backup.Backup(), + ], + next_page_token='abc', + ), + backup.ListBackupsResponse( + backups=[], + next_page_token='def', + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + ], + next_page_token='ghi', + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + backup.Backup(), + ], + ), + RuntimeError, + ) + pages = list(client.list_backups(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_backups_async_pager(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_backups), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + backup.Backup(), + backup.Backup(), + ], + next_page_token='abc', + ), + backup.ListBackupsResponse( + backups=[], + next_page_token='def', + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + ], + next_page_token='ghi', + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + backup.Backup(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_backups(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, backup.Backup) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_backups_async_pages(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_backups), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + backup.Backup(), + backup.Backup(), + ], + next_page_token='abc', + ), + backup.ListBackupsResponse( + backups=[], + next_page_token='def', + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + ], + next_page_token='ghi', + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + backup.Backup(), + ], + ), + 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_backups(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", [ + backup.DeleteBackupRequest, + dict, +]) +def test_delete_backup(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_backup), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_backup(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = backup.DeleteBackupRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_backup_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 = NetAppClient( + 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 = backup.DeleteBackupRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.delete_backup(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == backup.DeleteBackupRequest( + name='name_value', + ) + +def test_delete_backup_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 = NetAppClient( + 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_backup 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_backup] = mock_rpc + request = {} + client.delete_backup(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_backup(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_backup_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 = NetAppAsyncClient( + 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_backup 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_backup] = mock_rpc + + request = {} + await client.delete_backup(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_backup(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_backup_async(transport: str = 'grpc_asyncio', request_type=backup.DeleteBackupRequest): + client = NetAppAsyncClient( + 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_backup), + '__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_backup(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = backup.DeleteBackupRequest() + 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_backup_async_from_dict(): + await test_delete_backup_async(request_type=dict) + +def test_delete_backup_field_headers(): + client = NetAppClient( + 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 = backup.DeleteBackupRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_backup(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_backup_field_headers_async(): + client = NetAppAsyncClient( + 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 = backup.DeleteBackupRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_backup(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_backup_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup), + '__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_backup( + 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_backup_flattened_error(): + client = NetAppClient( + 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_backup( + backup.DeleteBackupRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_backup_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup), + '__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_backup( + 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_backup_flattened_error_async(): + client = NetAppAsyncClient( + 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_backup( + backup.DeleteBackupRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + gcn_backup.UpdateBackupRequest, + dict, +]) +def test_update_backup(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_backup), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_backup(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gcn_backup.UpdateBackupRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_backup_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 = NetAppClient( + 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 = gcn_backup.UpdateBackupRequest( + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_backup), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.update_backup(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gcn_backup.UpdateBackupRequest( + ) + +def test_update_backup_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 = NetAppClient( + 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_backup 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_backup] = mock_rpc + request = {} + client.update_backup(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.update_backup(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_backup_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 = NetAppAsyncClient( + 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_backup 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_backup] = mock_rpc + + request = {} + await client.update_backup(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.update_backup(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_backup_async(transport: str = 'grpc_asyncio', request_type=gcn_backup.UpdateBackupRequest): + client = NetAppAsyncClient( + 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_backup), + '__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.update_backup(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gcn_backup.UpdateBackupRequest() + 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_update_backup_async_from_dict(): + await test_update_backup_async(request_type=dict) + +def test_update_backup_field_headers(): + client = NetAppClient( + 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 = gcn_backup.UpdateBackupRequest() + + request.backup.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_backup), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_backup(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', + 'backup.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_backup_field_headers_async(): + client = NetAppAsyncClient( + 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 = gcn_backup.UpdateBackupRequest() + + request.backup.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_backup), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_backup(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', + 'backup.name=name_value', + ) in kw['metadata'] + + +def test_update_backup_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_backup), + '__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.update_backup( + backup=gcn_backup.Backup(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].backup + mock_val = gcn_backup.Backup(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_backup_flattened_error(): + client = NetAppClient( + 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_backup( + gcn_backup.UpdateBackupRequest(), + backup=gcn_backup.Backup(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_backup_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_backup), + '__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.update_backup( + backup=gcn_backup.Backup(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].backup + mock_val = gcn_backup.Backup(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_backup_flattened_error_async(): + client = NetAppAsyncClient( + 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_backup( + gcn_backup.UpdateBackupRequest(), + backup=gcn_backup.Backup(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + gcn_backup_policy.CreateBackupPolicyRequest, + dict, +]) +def test_create_backup_policy(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_backup_policy), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_backup_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gcn_backup_policy.CreateBackupPolicyRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_backup_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 = NetAppClient( + 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 = gcn_backup_policy.CreateBackupPolicyRequest( + parent='parent_value', + backup_policy_id='backup_policy_id_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_backup_policy), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.create_backup_policy(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gcn_backup_policy.CreateBackupPolicyRequest( + parent='parent_value', + backup_policy_id='backup_policy_id_value', + ) + +def test_create_backup_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 = NetAppClient( + 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_backup_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.create_backup_policy] = mock_rpc + request = {} + client.create_backup_policy(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_backup_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_create_backup_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 = NetAppAsyncClient( + 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_backup_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.create_backup_policy] = mock_rpc + + request = {} + await client.create_backup_policy(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_backup_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_create_backup_policy_async(transport: str = 'grpc_asyncio', request_type=gcn_backup_policy.CreateBackupPolicyRequest): + client = NetAppAsyncClient( + 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_backup_policy), + '__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_backup_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gcn_backup_policy.CreateBackupPolicyRequest() + 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_backup_policy_async_from_dict(): + await test_create_backup_policy_async(request_type=dict) + +def test_create_backup_policy_field_headers(): + client = NetAppClient( + 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 = gcn_backup_policy.CreateBackupPolicyRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_backup_policy), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_backup_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', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_create_backup_policy_field_headers_async(): + client = NetAppAsyncClient( + 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 = gcn_backup_policy.CreateBackupPolicyRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_backup_policy), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_backup_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', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_create_backup_policy_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_backup_policy), + '__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_backup_policy( + parent='parent_value', + backup_policy=gcn_backup_policy.BackupPolicy(name='name_value'), + backup_policy_id='backup_policy_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].backup_policy + mock_val = gcn_backup_policy.BackupPolicy(name='name_value') + assert arg == mock_val + arg = args[0].backup_policy_id + mock_val = 'backup_policy_id_value' + assert arg == mock_val + + +def test_create_backup_policy_flattened_error(): + client = NetAppClient( + 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_backup_policy( + gcn_backup_policy.CreateBackupPolicyRequest(), + parent='parent_value', + backup_policy=gcn_backup_policy.BackupPolicy(name='name_value'), + backup_policy_id='backup_policy_id_value', + ) + +@pytest.mark.asyncio +async def test_create_backup_policy_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_backup_policy), + '__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_backup_policy( + parent='parent_value', + backup_policy=gcn_backup_policy.BackupPolicy(name='name_value'), + backup_policy_id='backup_policy_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].backup_policy + mock_val = gcn_backup_policy.BackupPolicy(name='name_value') + assert arg == mock_val + arg = args[0].backup_policy_id + mock_val = 'backup_policy_id_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_backup_policy_flattened_error_async(): + client = NetAppAsyncClient( + 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_backup_policy( + gcn_backup_policy.CreateBackupPolicyRequest(), + parent='parent_value', + backup_policy=gcn_backup_policy.BackupPolicy(name='name_value'), + backup_policy_id='backup_policy_id_value', + ) + + +@pytest.mark.parametrize("request_type", [ + backup_policy.GetBackupPolicyRequest, + dict, +]) +def test_get_backup_policy(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_backup_policy), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = backup_policy.BackupPolicy( + name='name_value', + daily_backup_limit=1894, + weekly_backup_limit=2020, + monthly_backup_limit=2142, + description='description_value', + enabled=True, + assigned_volume_count=2253, + state=backup_policy.BackupPolicy.State.CREATING, + ) + response = client.get_backup_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = backup_policy.GetBackupPolicyRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, backup_policy.BackupPolicy) + assert response.name == 'name_value' + assert response.daily_backup_limit == 1894 + assert response.weekly_backup_limit == 2020 + assert response.monthly_backup_limit == 2142 + assert response.description == 'description_value' + assert response.enabled is True + assert response.assigned_volume_count == 2253 + assert response.state == backup_policy.BackupPolicy.State.CREATING + + +def test_get_backup_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 = NetAppClient( + 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 = backup_policy.GetBackupPolicyRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_backup_policy), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.get_backup_policy(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == backup_policy.GetBackupPolicyRequest( + name='name_value', + ) + +def test_get_backup_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 = NetAppClient( + 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_backup_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_backup_policy] = mock_rpc + request = {} + client.get_backup_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_backup_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_backup_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 = NetAppAsyncClient( + 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_backup_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_backup_policy] = mock_rpc + + request = {} + await client.get_backup_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_backup_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_backup_policy_async(transport: str = 'grpc_asyncio', request_type=backup_policy.GetBackupPolicyRequest): + client = NetAppAsyncClient( + 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_backup_policy), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(backup_policy.BackupPolicy( + name='name_value', + daily_backup_limit=1894, + weekly_backup_limit=2020, + monthly_backup_limit=2142, + description='description_value', + enabled=True, + assigned_volume_count=2253, + state=backup_policy.BackupPolicy.State.CREATING, + )) + response = await client.get_backup_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = backup_policy.GetBackupPolicyRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, backup_policy.BackupPolicy) + assert response.name == 'name_value' + assert response.daily_backup_limit == 1894 + assert response.weekly_backup_limit == 2020 + assert response.monthly_backup_limit == 2142 + assert response.description == 'description_value' + assert response.enabled is True + assert response.assigned_volume_count == 2253 + assert response.state == backup_policy.BackupPolicy.State.CREATING + + +@pytest.mark.asyncio +async def test_get_backup_policy_async_from_dict(): + await test_get_backup_policy_async(request_type=dict) + +def test_get_backup_policy_field_headers(): + client = NetAppClient( + 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 = backup_policy.GetBackupPolicyRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_backup_policy), + '__call__') as call: + call.return_value = backup_policy.BackupPolicy() + client.get_backup_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', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_get_backup_policy_field_headers_async(): + client = NetAppAsyncClient( + 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 = backup_policy.GetBackupPolicyRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_backup_policy), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_policy.BackupPolicy()) + await client.get_backup_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', + 'name=name_value', + ) in kw['metadata'] + + +def test_get_backup_policy_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_backup_policy), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = backup_policy.BackupPolicy() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_backup_policy( + 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_backup_policy_flattened_error(): + client = NetAppClient( + 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_backup_policy( + backup_policy.GetBackupPolicyRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_backup_policy_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_backup_policy), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = backup_policy.BackupPolicy() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_policy.BackupPolicy()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_backup_policy( + 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_backup_policy_flattened_error_async(): + client = NetAppAsyncClient( + 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_backup_policy( + backup_policy.GetBackupPolicyRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + backup_policy.ListBackupPoliciesRequest, + dict, +]) +def test_list_backup_policies(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_backup_policies), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = backup_policy.ListBackupPoliciesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_backup_policies(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = backup_policy.ListBackupPoliciesRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListBackupPoliciesPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_backup_policies_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 = NetAppClient( + 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 = backup_policy.ListBackupPoliciesRequest( + 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_backup_policies), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.list_backup_policies(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == backup_policy.ListBackupPoliciesRequest( + parent='parent_value', + page_token='page_token_value', + filter='filter_value', + order_by='order_by_value', + ) + +def test_list_backup_policies_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 = NetAppClient( + 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_backup_policies 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_backup_policies] = mock_rpc + request = {} + client.list_backup_policies(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_backup_policies(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_backup_policies_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 = NetAppAsyncClient( + 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_backup_policies 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_backup_policies] = mock_rpc + + request = {} + await client.list_backup_policies(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_backup_policies(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_backup_policies_async(transport: str = 'grpc_asyncio', request_type=backup_policy.ListBackupPoliciesRequest): + client = NetAppAsyncClient( + 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_backup_policies), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(backup_policy.ListBackupPoliciesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_backup_policies(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = backup_policy.ListBackupPoliciesRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListBackupPoliciesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_backup_policies_async_from_dict(): + await test_list_backup_policies_async(request_type=dict) + +def test_list_backup_policies_field_headers(): + client = NetAppClient( + 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 = backup_policy.ListBackupPoliciesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_backup_policies), + '__call__') as call: + call.return_value = backup_policy.ListBackupPoliciesResponse() + client.list_backup_policies(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_backup_policies_field_headers_async(): + client = NetAppAsyncClient( + 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 = backup_policy.ListBackupPoliciesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_backup_policies), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_policy.ListBackupPoliciesResponse()) + await client.list_backup_policies(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_backup_policies_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_backup_policies), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = backup_policy.ListBackupPoliciesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_backup_policies( + 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_backup_policies_flattened_error(): + client = NetAppClient( + 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_backup_policies( + backup_policy.ListBackupPoliciesRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_backup_policies_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_backup_policies), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = backup_policy.ListBackupPoliciesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_policy.ListBackupPoliciesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_backup_policies( + 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_backup_policies_flattened_error_async(): + client = NetAppAsyncClient( + 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_backup_policies( + backup_policy.ListBackupPoliciesRequest(), + parent='parent_value', + ) + + +def test_list_backup_policies_pager(transport_name: str = "grpc"): + client = NetAppClient( + 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_backup_policies), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + backup_policy.ListBackupPoliciesResponse( + backup_policies=[ + backup_policy.BackupPolicy(), + backup_policy.BackupPolicy(), + backup_policy.BackupPolicy(), + ], + next_page_token='abc', + ), + backup_policy.ListBackupPoliciesResponse( + backup_policies=[], + next_page_token='def', + ), + backup_policy.ListBackupPoliciesResponse( + backup_policies=[ + backup_policy.BackupPolicy(), + ], + next_page_token='ghi', + ), + backup_policy.ListBackupPoliciesResponse( + backup_policies=[ + backup_policy.BackupPolicy(), + backup_policy.BackupPolicy(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_backup_policies(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, backup_policy.BackupPolicy) + for i in results) +def test_list_backup_policies_pages(transport_name: str = "grpc"): + client = NetAppClient( + 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_backup_policies), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + backup_policy.ListBackupPoliciesResponse( + backup_policies=[ + backup_policy.BackupPolicy(), + backup_policy.BackupPolicy(), + backup_policy.BackupPolicy(), + ], + next_page_token='abc', + ), + backup_policy.ListBackupPoliciesResponse( + backup_policies=[], + next_page_token='def', + ), + backup_policy.ListBackupPoliciesResponse( + backup_policies=[ + backup_policy.BackupPolicy(), + ], + next_page_token='ghi', + ), + backup_policy.ListBackupPoliciesResponse( + backup_policies=[ + backup_policy.BackupPolicy(), + backup_policy.BackupPolicy(), + ], + ), + RuntimeError, + ) + pages = list(client.list_backup_policies(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_backup_policies_async_pager(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_backup_policies), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + backup_policy.ListBackupPoliciesResponse( + backup_policies=[ + backup_policy.BackupPolicy(), + backup_policy.BackupPolicy(), + backup_policy.BackupPolicy(), + ], + next_page_token='abc', + ), + backup_policy.ListBackupPoliciesResponse( + backup_policies=[], + next_page_token='def', + ), + backup_policy.ListBackupPoliciesResponse( + backup_policies=[ + backup_policy.BackupPolicy(), + ], + next_page_token='ghi', + ), + backup_policy.ListBackupPoliciesResponse( + backup_policies=[ + backup_policy.BackupPolicy(), + backup_policy.BackupPolicy(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_backup_policies(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, backup_policy.BackupPolicy) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_backup_policies_async_pages(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_backup_policies), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + backup_policy.ListBackupPoliciesResponse( + backup_policies=[ + backup_policy.BackupPolicy(), + backup_policy.BackupPolicy(), + backup_policy.BackupPolicy(), + ], + next_page_token='abc', + ), + backup_policy.ListBackupPoliciesResponse( + backup_policies=[], + next_page_token='def', + ), + backup_policy.ListBackupPoliciesResponse( + backup_policies=[ + backup_policy.BackupPolicy(), + ], + next_page_token='ghi', + ), + backup_policy.ListBackupPoliciesResponse( + backup_policies=[ + backup_policy.BackupPolicy(), + backup_policy.BackupPolicy(), + ], + ), + 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_backup_policies(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", [ + gcn_backup_policy.UpdateBackupPolicyRequest, + dict, +]) +def test_update_backup_policy(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_backup_policy), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_backup_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gcn_backup_policy.UpdateBackupPolicyRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_backup_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 = NetAppClient( + 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 = gcn_backup_policy.UpdateBackupPolicyRequest( + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_backup_policy), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.update_backup_policy(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gcn_backup_policy.UpdateBackupPolicyRequest( + ) + +def test_update_backup_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 = NetAppClient( + 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_backup_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.update_backup_policy] = mock_rpc + request = {} + client.update_backup_policy(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.update_backup_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_update_backup_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 = NetAppAsyncClient( + 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_backup_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.update_backup_policy] = mock_rpc + + request = {} + await client.update_backup_policy(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.update_backup_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_update_backup_policy_async(transport: str = 'grpc_asyncio', request_type=gcn_backup_policy.UpdateBackupPolicyRequest): + client = NetAppAsyncClient( + 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_backup_policy), + '__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.update_backup_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gcn_backup_policy.UpdateBackupPolicyRequest() + 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_update_backup_policy_async_from_dict(): + await test_update_backup_policy_async(request_type=dict) + +def test_update_backup_policy_field_headers(): + client = NetAppClient( + 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 = gcn_backup_policy.UpdateBackupPolicyRequest() + + request.backup_policy.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_backup_policy), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_backup_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', + 'backup_policy.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_backup_policy_field_headers_async(): + client = NetAppAsyncClient( + 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 = gcn_backup_policy.UpdateBackupPolicyRequest() + + request.backup_policy.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_backup_policy), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_backup_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', + 'backup_policy.name=name_value', + ) in kw['metadata'] + + +def test_update_backup_policy_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_backup_policy), + '__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.update_backup_policy( + backup_policy=gcn_backup_policy.BackupPolicy(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].backup_policy + mock_val = gcn_backup_policy.BackupPolicy(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_backup_policy_flattened_error(): + client = NetAppClient( + 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_backup_policy( + gcn_backup_policy.UpdateBackupPolicyRequest(), + backup_policy=gcn_backup_policy.BackupPolicy(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_backup_policy_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_backup_policy), + '__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.update_backup_policy( + backup_policy=gcn_backup_policy.BackupPolicy(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].backup_policy + mock_val = gcn_backup_policy.BackupPolicy(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_backup_policy_flattened_error_async(): + client = NetAppAsyncClient( + 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_backup_policy( + gcn_backup_policy.UpdateBackupPolicyRequest(), + backup_policy=gcn_backup_policy.BackupPolicy(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + backup_policy.DeleteBackupPolicyRequest, + dict, +]) +def test_delete_backup_policy(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_backup_policy), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_backup_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = backup_policy.DeleteBackupPolicyRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_backup_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 = NetAppClient( + 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 = backup_policy.DeleteBackupPolicyRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup_policy), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.delete_backup_policy(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == backup_policy.DeleteBackupPolicyRequest( + name='name_value', + ) + +def test_delete_backup_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 = NetAppClient( + 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_backup_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.delete_backup_policy] = mock_rpc + request = {} + client.delete_backup_policy(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_backup_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_delete_backup_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 = NetAppAsyncClient( + 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_backup_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.delete_backup_policy] = mock_rpc + + request = {} + await client.delete_backup_policy(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_backup_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_delete_backup_policy_async(transport: str = 'grpc_asyncio', request_type=backup_policy.DeleteBackupPolicyRequest): + client = NetAppAsyncClient( + 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_backup_policy), + '__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_backup_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = backup_policy.DeleteBackupPolicyRequest() + 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_backup_policy_async_from_dict(): + await test_delete_backup_policy_async(request_type=dict) + +def test_delete_backup_policy_field_headers(): + client = NetAppClient( + 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 = backup_policy.DeleteBackupPolicyRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup_policy), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_backup_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', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_delete_backup_policy_field_headers_async(): + client = NetAppAsyncClient( + 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 = backup_policy.DeleteBackupPolicyRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup_policy), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_backup_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', + 'name=name_value', + ) in kw['metadata'] + + +def test_delete_backup_policy_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup_policy), + '__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_backup_policy( + 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_backup_policy_flattened_error(): + client = NetAppClient( + 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_backup_policy( + backup_policy.DeleteBackupPolicyRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_backup_policy_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup_policy), + '__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_backup_policy( + 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_backup_policy_flattened_error_async(): + client = NetAppAsyncClient( + 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_backup_policy( + backup_policy.DeleteBackupPolicyRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + quota_rule.ListQuotaRulesRequest, + dict, +]) +def test_list_quota_rules(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_quota_rules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = quota_rule.ListQuotaRulesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_quota_rules(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = quota_rule.ListQuotaRulesRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListQuotaRulesPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_quota_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 = NetAppClient( + 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 = quota_rule.ListQuotaRulesRequest( + 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_quota_rules), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.list_quota_rules(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == quota_rule.ListQuotaRulesRequest( + parent='parent_value', + page_token='page_token_value', + filter='filter_value', + order_by='order_by_value', + ) + +def test_list_quota_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 = NetAppClient( + 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_quota_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_quota_rules] = mock_rpc + request = {} + client.list_quota_rules(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_quota_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_quota_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 = NetAppAsyncClient( + 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_quota_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_quota_rules] = mock_rpc + + request = {} + await client.list_quota_rules(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_quota_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_quota_rules_async(transport: str = 'grpc_asyncio', request_type=quota_rule.ListQuotaRulesRequest): + client = NetAppAsyncClient( + 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_quota_rules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(quota_rule.ListQuotaRulesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_quota_rules(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = quota_rule.ListQuotaRulesRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListQuotaRulesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_quota_rules_async_from_dict(): + await test_list_quota_rules_async(request_type=dict) + +def test_list_quota_rules_field_headers(): + client = NetAppClient( + 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 = quota_rule.ListQuotaRulesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_quota_rules), + '__call__') as call: + call.return_value = quota_rule.ListQuotaRulesResponse() + client.list_quota_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_quota_rules_field_headers_async(): + client = NetAppAsyncClient( + 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 = quota_rule.ListQuotaRulesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_quota_rules), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(quota_rule.ListQuotaRulesResponse()) + await client.list_quota_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_quota_rules_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_quota_rules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = quota_rule.ListQuotaRulesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_quota_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_quota_rules_flattened_error(): + client = NetAppClient( + 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_quota_rules( + quota_rule.ListQuotaRulesRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_quota_rules_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_quota_rules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = quota_rule.ListQuotaRulesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(quota_rule.ListQuotaRulesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_quota_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_quota_rules_flattened_error_async(): + client = NetAppAsyncClient( + 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_quota_rules( + quota_rule.ListQuotaRulesRequest(), + parent='parent_value', + ) + + +def test_list_quota_rules_pager(transport_name: str = "grpc"): + client = NetAppClient( + 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_quota_rules), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + quota_rule.ListQuotaRulesResponse( + quota_rules=[ + quota_rule.QuotaRule(), + quota_rule.QuotaRule(), + quota_rule.QuotaRule(), + ], + next_page_token='abc', + ), + quota_rule.ListQuotaRulesResponse( + quota_rules=[], + next_page_token='def', + ), + quota_rule.ListQuotaRulesResponse( + quota_rules=[ + quota_rule.QuotaRule(), + ], + next_page_token='ghi', + ), + quota_rule.ListQuotaRulesResponse( + quota_rules=[ + quota_rule.QuotaRule(), + quota_rule.QuotaRule(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_quota_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, quota_rule.QuotaRule) + for i in results) +def test_list_quota_rules_pages(transport_name: str = "grpc"): + client = NetAppClient( + 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_quota_rules), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + quota_rule.ListQuotaRulesResponse( + quota_rules=[ + quota_rule.QuotaRule(), + quota_rule.QuotaRule(), + quota_rule.QuotaRule(), + ], + next_page_token='abc', + ), + quota_rule.ListQuotaRulesResponse( + quota_rules=[], + next_page_token='def', + ), + quota_rule.ListQuotaRulesResponse( + quota_rules=[ + quota_rule.QuotaRule(), + ], + next_page_token='ghi', + ), + quota_rule.ListQuotaRulesResponse( + quota_rules=[ + quota_rule.QuotaRule(), + quota_rule.QuotaRule(), + ], + ), + RuntimeError, + ) + pages = list(client.list_quota_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_quota_rules_async_pager(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_quota_rules), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + quota_rule.ListQuotaRulesResponse( + quota_rules=[ + quota_rule.QuotaRule(), + quota_rule.QuotaRule(), + quota_rule.QuotaRule(), + ], + next_page_token='abc', + ), + quota_rule.ListQuotaRulesResponse( + quota_rules=[], + next_page_token='def', + ), + quota_rule.ListQuotaRulesResponse( + quota_rules=[ + quota_rule.QuotaRule(), + ], + next_page_token='ghi', + ), + quota_rule.ListQuotaRulesResponse( + quota_rules=[ + quota_rule.QuotaRule(), + quota_rule.QuotaRule(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_quota_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, quota_rule.QuotaRule) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_quota_rules_async_pages(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_quota_rules), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + quota_rule.ListQuotaRulesResponse( + quota_rules=[ + quota_rule.QuotaRule(), + quota_rule.QuotaRule(), + quota_rule.QuotaRule(), + ], + next_page_token='abc', + ), + quota_rule.ListQuotaRulesResponse( + quota_rules=[], + next_page_token='def', + ), + quota_rule.ListQuotaRulesResponse( + quota_rules=[ + quota_rule.QuotaRule(), + ], + next_page_token='ghi', + ), + quota_rule.ListQuotaRulesResponse( + quota_rules=[ + quota_rule.QuotaRule(), + quota_rule.QuotaRule(), + ], + ), + 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_quota_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", [ + quota_rule.GetQuotaRuleRequest, + dict, +]) +def test_get_quota_rule(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_quota_rule), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = quota_rule.QuotaRule( + name='name_value', + target='target_value', + type_=quota_rule.QuotaRule.Type.INDIVIDUAL_USER_QUOTA, + disk_limit_mib=1472, + state=quota_rule.QuotaRule.State.CREATING, + state_details='state_details_value', + description='description_value', + ) + response = client.get_quota_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = quota_rule.GetQuotaRuleRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, quota_rule.QuotaRule) + assert response.name == 'name_value' + assert response.target == 'target_value' + assert response.type_ == quota_rule.QuotaRule.Type.INDIVIDUAL_USER_QUOTA + assert response.disk_limit_mib == 1472 + assert response.state == quota_rule.QuotaRule.State.CREATING + assert response.state_details == 'state_details_value' + assert response.description == 'description_value' + + +def test_get_quota_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 = NetAppClient( + 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 = quota_rule.GetQuotaRuleRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_quota_rule), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.get_quota_rule(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == quota_rule.GetQuotaRuleRequest( + name='name_value', + ) + +def test_get_quota_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 = NetAppClient( + 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_quota_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_quota_rule] = mock_rpc + request = {} + client.get_quota_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_quota_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_quota_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 = NetAppAsyncClient( + 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_quota_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_quota_rule] = mock_rpc + + request = {} + await client.get_quota_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_quota_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_quota_rule_async(transport: str = 'grpc_asyncio', request_type=quota_rule.GetQuotaRuleRequest): + client = NetAppAsyncClient( + 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_quota_rule), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(quota_rule.QuotaRule( + name='name_value', + target='target_value', + type_=quota_rule.QuotaRule.Type.INDIVIDUAL_USER_QUOTA, + disk_limit_mib=1472, + state=quota_rule.QuotaRule.State.CREATING, + state_details='state_details_value', + description='description_value', + )) + response = await client.get_quota_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = quota_rule.GetQuotaRuleRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, quota_rule.QuotaRule) + assert response.name == 'name_value' + assert response.target == 'target_value' + assert response.type_ == quota_rule.QuotaRule.Type.INDIVIDUAL_USER_QUOTA + assert response.disk_limit_mib == 1472 + assert response.state == quota_rule.QuotaRule.State.CREATING + assert response.state_details == 'state_details_value' + assert response.description == 'description_value' + + +@pytest.mark.asyncio +async def test_get_quota_rule_async_from_dict(): + await test_get_quota_rule_async(request_type=dict) + +def test_get_quota_rule_field_headers(): + client = NetAppClient( + 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 = quota_rule.GetQuotaRuleRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_quota_rule), + '__call__') as call: + call.return_value = quota_rule.QuotaRule() + client.get_quota_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_quota_rule_field_headers_async(): + client = NetAppAsyncClient( + 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 = quota_rule.GetQuotaRuleRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_quota_rule), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(quota_rule.QuotaRule()) + await client.get_quota_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_quota_rule_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_quota_rule), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = quota_rule.QuotaRule() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_quota_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_quota_rule_flattened_error(): + client = NetAppClient( + 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_quota_rule( + quota_rule.GetQuotaRuleRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_quota_rule_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_quota_rule), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = quota_rule.QuotaRule() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(quota_rule.QuotaRule()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_quota_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_quota_rule_flattened_error_async(): + client = NetAppAsyncClient( + 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_quota_rule( + quota_rule.GetQuotaRuleRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + gcn_quota_rule.CreateQuotaRuleRequest, + dict, +]) +def test_create_quota_rule(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_quota_rule), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_quota_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gcn_quota_rule.CreateQuotaRuleRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_quota_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 = NetAppClient( + 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 = gcn_quota_rule.CreateQuotaRuleRequest( + parent='parent_value', + quota_rule_id='quota_rule_id_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_quota_rule), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.create_quota_rule(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gcn_quota_rule.CreateQuotaRuleRequest( + parent='parent_value', + quota_rule_id='quota_rule_id_value', + ) + +def test_create_quota_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 = NetAppClient( + 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_quota_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_quota_rule] = mock_rpc + request = {} + client.create_quota_rule(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_quota_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_quota_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 = NetAppAsyncClient( + 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_quota_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_quota_rule] = mock_rpc + + request = {} + await client.create_quota_rule(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_quota_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_quota_rule_async(transport: str = 'grpc_asyncio', request_type=gcn_quota_rule.CreateQuotaRuleRequest): + client = NetAppAsyncClient( + 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_quota_rule), + '__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_quota_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gcn_quota_rule.CreateQuotaRuleRequest() + 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_quota_rule_async_from_dict(): + await test_create_quota_rule_async(request_type=dict) + +def test_create_quota_rule_field_headers(): + client = NetAppClient( + 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 = gcn_quota_rule.CreateQuotaRuleRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_quota_rule), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_quota_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_quota_rule_field_headers_async(): + client = NetAppAsyncClient( + 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 = gcn_quota_rule.CreateQuotaRuleRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_quota_rule), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_quota_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_quota_rule_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_quota_rule), + '__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_quota_rule( + parent='parent_value', + quota_rule=gcn_quota_rule.QuotaRule(name='name_value'), + quota_rule_id='quota_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].quota_rule + mock_val = gcn_quota_rule.QuotaRule(name='name_value') + assert arg == mock_val + arg = args[0].quota_rule_id + mock_val = 'quota_rule_id_value' + assert arg == mock_val + + +def test_create_quota_rule_flattened_error(): + client = NetAppClient( + 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_quota_rule( + gcn_quota_rule.CreateQuotaRuleRequest(), + parent='parent_value', + quota_rule=gcn_quota_rule.QuotaRule(name='name_value'), + quota_rule_id='quota_rule_id_value', + ) + +@pytest.mark.asyncio +async def test_create_quota_rule_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_quota_rule), + '__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_quota_rule( + parent='parent_value', + quota_rule=gcn_quota_rule.QuotaRule(name='name_value'), + quota_rule_id='quota_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].quota_rule + mock_val = gcn_quota_rule.QuotaRule(name='name_value') + assert arg == mock_val + arg = args[0].quota_rule_id + mock_val = 'quota_rule_id_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_quota_rule_flattened_error_async(): + client = NetAppAsyncClient( + 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_quota_rule( + gcn_quota_rule.CreateQuotaRuleRequest(), + parent='parent_value', + quota_rule=gcn_quota_rule.QuotaRule(name='name_value'), + quota_rule_id='quota_rule_id_value', + ) + + +@pytest.mark.parametrize("request_type", [ + gcn_quota_rule.UpdateQuotaRuleRequest, + dict, +]) +def test_update_quota_rule(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_quota_rule), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_quota_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gcn_quota_rule.UpdateQuotaRuleRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_quota_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 = NetAppClient( + 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 = gcn_quota_rule.UpdateQuotaRuleRequest( + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_quota_rule), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.update_quota_rule(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gcn_quota_rule.UpdateQuotaRuleRequest( + ) + +def test_update_quota_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 = NetAppClient( + 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_quota_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_quota_rule] = mock_rpc + request = {} + client.update_quota_rule(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.update_quota_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_quota_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 = NetAppAsyncClient( + 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_quota_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_quota_rule] = mock_rpc + + request = {} + await client.update_quota_rule(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.update_quota_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_quota_rule_async(transport: str = 'grpc_asyncio', request_type=gcn_quota_rule.UpdateQuotaRuleRequest): + client = NetAppAsyncClient( + 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_quota_rule), + '__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.update_quota_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gcn_quota_rule.UpdateQuotaRuleRequest() + 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_update_quota_rule_async_from_dict(): + await test_update_quota_rule_async(request_type=dict) + +def test_update_quota_rule_field_headers(): + client = NetAppClient( + 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 = gcn_quota_rule.UpdateQuotaRuleRequest() + + request.quota_rule.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_quota_rule), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_quota_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', + 'quota_rule.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_quota_rule_field_headers_async(): + client = NetAppAsyncClient( + 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 = gcn_quota_rule.UpdateQuotaRuleRequest() + + request.quota_rule.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_quota_rule), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_quota_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', + 'quota_rule.name=name_value', + ) in kw['metadata'] + + +def test_update_quota_rule_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_quota_rule), + '__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.update_quota_rule( + quota_rule=gcn_quota_rule.QuotaRule(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].quota_rule + mock_val = gcn_quota_rule.QuotaRule(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_quota_rule_flattened_error(): + client = NetAppClient( + 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_quota_rule( + gcn_quota_rule.UpdateQuotaRuleRequest(), + quota_rule=gcn_quota_rule.QuotaRule(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_quota_rule_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_quota_rule), + '__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.update_quota_rule( + quota_rule=gcn_quota_rule.QuotaRule(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].quota_rule + mock_val = gcn_quota_rule.QuotaRule(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_quota_rule_flattened_error_async(): + client = NetAppAsyncClient( + 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_quota_rule( + gcn_quota_rule.UpdateQuotaRuleRequest(), + quota_rule=gcn_quota_rule.QuotaRule(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + quota_rule.DeleteQuotaRuleRequest, + dict, +]) +def test_delete_quota_rule(request_type, transport: str = 'grpc'): + client = NetAppClient( + 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_quota_rule), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_quota_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = quota_rule.DeleteQuotaRuleRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_quota_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 = NetAppClient( + 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 = quota_rule.DeleteQuotaRuleRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_quota_rule), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.delete_quota_rule(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == quota_rule.DeleteQuotaRuleRequest( + name='name_value', + ) + +def test_delete_quota_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 = NetAppClient( + 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_quota_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_quota_rule] = mock_rpc + request = {} + client.delete_quota_rule(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_quota_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_quota_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 = NetAppAsyncClient( + 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_quota_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_quota_rule] = mock_rpc + + request = {} + await client.delete_quota_rule(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_quota_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_quota_rule_async(transport: str = 'grpc_asyncio', request_type=quota_rule.DeleteQuotaRuleRequest): + client = NetAppAsyncClient( + 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_quota_rule), + '__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_quota_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = quota_rule.DeleteQuotaRuleRequest() + 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_quota_rule_async_from_dict(): + await test_delete_quota_rule_async(request_type=dict) + +def test_delete_quota_rule_field_headers(): + client = NetAppClient( + 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 = quota_rule.DeleteQuotaRuleRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_quota_rule), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_quota_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_quota_rule_field_headers_async(): + client = NetAppAsyncClient( + 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 = quota_rule.DeleteQuotaRuleRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_quota_rule), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_quota_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_quota_rule_flattened(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_quota_rule), + '__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_quota_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_quota_rule_flattened_error(): + client = NetAppClient( + 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_quota_rule( + quota_rule.DeleteQuotaRuleRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_quota_rule_flattened_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_quota_rule), + '__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_quota_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_quota_rule_flattened_error_async(): + client = NetAppAsyncClient( + 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_quota_rule( + quota_rule.DeleteQuotaRuleRequest(), + name='name_value', + ) + + +def test_list_storage_pools_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 = NetAppClient( + 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_storage_pools 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_storage_pools] = mock_rpc + + request = {} + client.list_storage_pools(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_storage_pools(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_storage_pools_rest_required_fields(request_type=storage_pool.ListStoragePoolsRequest): + transport_class = transports.NetAppRestTransport + + 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_storage_pools._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_storage_pools._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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = storage_pool.ListStoragePoolsResponse() + # 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 = storage_pool.ListStoragePoolsResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_storage_pools(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_storage_pools_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_storage_pools._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) + + +def test_list_storage_pools_rest_flattened(): + client = NetAppClient( + 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 = storage_pool.ListStoragePoolsResponse() + + # 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 = storage_pool.ListStoragePoolsResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_storage_pools(**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/*}/storagePools" % client.transport._host, args[1]) + + +def test_list_storage_pools_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_storage_pools( + storage_pool.ListStoragePoolsRequest(), + parent='parent_value', + ) + + +def test_list_storage_pools_rest_pager(transport: str = 'rest'): + client = NetAppClient( + 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 = ( + storage_pool.ListStoragePoolsResponse( + storage_pools=[ + storage_pool.StoragePool(), + storage_pool.StoragePool(), + storage_pool.StoragePool(), + ], + next_page_token='abc', + ), + storage_pool.ListStoragePoolsResponse( + storage_pools=[], + next_page_token='def', + ), + storage_pool.ListStoragePoolsResponse( + storage_pools=[ + storage_pool.StoragePool(), + ], + next_page_token='ghi', + ), + storage_pool.ListStoragePoolsResponse( + storage_pools=[ + storage_pool.StoragePool(), + storage_pool.StoragePool(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(storage_pool.ListStoragePoolsResponse.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_storage_pools(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, storage_pool.StoragePool) + for i in results) + + pages = list(client.list_storage_pools(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +def test_create_storage_pool_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 = NetAppClient( + 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_storage_pool 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_storage_pool] = mock_rpc + + request = {} + client.create_storage_pool(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_storage_pool(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_storage_pool_rest_required_fields(request_type=gcn_storage_pool.CreateStoragePoolRequest): + transport_class = transports.NetAppRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["storage_pool_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 "storagePoolId" not in jsonified_request + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_storage_pool._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "storagePoolId" in jsonified_request + assert jsonified_request["storagePoolId"] == request_init["storage_pool_id"] + + jsonified_request["parent"] = 'parent_value' + jsonified_request["storagePoolId"] = 'storage_pool_id_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_storage_pool._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("storage_pool_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 "storagePoolId" in jsonified_request + assert jsonified_request["storagePoolId"] == 'storage_pool_id_value' + + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_storage_pool(request) + + expected_params = [ + ( + "storagePoolId", + "", + ), + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_storage_pool_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_storage_pool._get_unset_required_fields({}) + assert set(unset_fields) == (set(("storagePoolId", )) & set(("parent", "storagePoolId", "storagePool", ))) + + +def test_create_storage_pool_rest_flattened(): + client = NetAppClient( + 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', + storage_pool=gcn_storage_pool.StoragePool(name='name_value'), + storage_pool_id='storage_pool_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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_storage_pool(**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/*}/storagePools" % client.transport._host, args[1]) + + +def test_create_storage_pool_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_storage_pool( + gcn_storage_pool.CreateStoragePoolRequest(), + parent='parent_value', + storage_pool=gcn_storage_pool.StoragePool(name='name_value'), + storage_pool_id='storage_pool_id_value', + ) + + +def test_get_storage_pool_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 = NetAppClient( + 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_storage_pool 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_storage_pool] = mock_rpc + + request = {} + client.get_storage_pool(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_storage_pool(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_storage_pool_rest_required_fields(request_type=storage_pool.GetStoragePoolRequest): + transport_class = transports.NetAppRestTransport + + 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_storage_pool._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_storage_pool._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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = storage_pool.StoragePool() + # 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 = storage_pool.StoragePool.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_storage_pool(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_storage_pool_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_storage_pool._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_get_storage_pool_rest_flattened(): + client = NetAppClient( + 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 = storage_pool.StoragePool() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/storagePools/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 = storage_pool.StoragePool.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_storage_pool(**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/*/storagePools/*}" % client.transport._host, args[1]) + + +def test_get_storage_pool_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_storage_pool( + storage_pool.GetStoragePoolRequest(), + name='name_value', + ) + + +def test_update_storage_pool_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 = NetAppClient( + 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_storage_pool 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_storage_pool] = mock_rpc + + request = {} + client.update_storage_pool(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.update_storage_pool(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_storage_pool_rest_required_fields(request_type=gcn_storage_pool.UpdateStoragePoolRequest): + transport_class = transports.NetAppRestTransport + + 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_storage_pool._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_storage_pool._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 = NetAppClient( + 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': "patch", + '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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_storage_pool(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_storage_pool_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_storage_pool._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("updateMask", "storagePool", ))) + + +def test_update_storage_pool_rest_flattened(): + client = NetAppClient( + 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 = {'storage_pool': {'name': 'projects/sample1/locations/sample2/storagePools/sample3'}} + + # get truthy value for each flattened field + mock_args = dict( + storage_pool=gcn_storage_pool.StoragePool(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 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_storage_pool(**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/{storage_pool.name=projects/*/locations/*/storagePools/*}" % client.transport._host, args[1]) + + +def test_update_storage_pool_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_storage_pool( + gcn_storage_pool.UpdateStoragePoolRequest(), + storage_pool=gcn_storage_pool.StoragePool(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_delete_storage_pool_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 = NetAppClient( + 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_storage_pool 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_storage_pool] = mock_rpc + + request = {} + client.delete_storage_pool(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_storage_pool(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_storage_pool_rest_required_fields(request_type=storage_pool.DeleteStoragePoolRequest): + transport_class = transports.NetAppRestTransport + + 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_storage_pool._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_storage_pool._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 = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_storage_pool(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_storage_pool_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_storage_pool._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_delete_storage_pool_rest_flattened(): + client = NetAppClient( + 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/storagePools/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_storage_pool(**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/*/storagePools/*}" % client.transport._host, args[1]) + + +def test_delete_storage_pool_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_storage_pool( + storage_pool.DeleteStoragePoolRequest(), + name='name_value', + ) + + +def test_validate_directory_service_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 = NetAppClient( + 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.validate_directory_service 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.validate_directory_service] = mock_rpc + + request = {} + client.validate_directory_service(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.validate_directory_service(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_validate_directory_service_rest_required_fields(request_type=storage_pool.ValidateDirectoryServiceRequest): + transport_class = transports.NetAppRestTransport + + 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()).validate_directory_service._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()).validate_directory_service._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 = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.validate_directory_service(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_validate_directory_service_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.validate_directory_service._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_switch_active_replica_zone_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 = NetAppClient( + 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.switch_active_replica_zone 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.switch_active_replica_zone] = mock_rpc + + request = {} + client.switch_active_replica_zone(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.switch_active_replica_zone(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_switch_active_replica_zone_rest_required_fields(request_type=storage_pool.SwitchActiveReplicaZoneRequest): + transport_class = transports.NetAppRestTransport + + 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()).switch_active_replica_zone._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()).switch_active_replica_zone._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 = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.switch_active_replica_zone(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_switch_active_replica_zone_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.switch_active_replica_zone._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_list_volumes_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 = NetAppClient( + 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_volumes 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_volumes] = mock_rpc + + request = {} + client.list_volumes(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_volumes(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_volumes_rest_required_fields(request_type=volume.ListVolumesRequest): + transport_class = transports.NetAppRestTransport + + 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_volumes._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_volumes._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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = volume.ListVolumesResponse() + # 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 = volume.ListVolumesResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_volumes(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_volumes_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_volumes._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) + + +def test_list_volumes_rest_flattened(): + client = NetAppClient( + 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 = volume.ListVolumesResponse() + + # 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 = volume.ListVolumesResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_volumes(**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/*}/volumes" % client.transport._host, args[1]) + + +def test_list_volumes_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_volumes( + volume.ListVolumesRequest(), + parent='parent_value', + ) + + +def test_list_volumes_rest_pager(transport: str = 'rest'): + client = NetAppClient( + 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 = ( + volume.ListVolumesResponse( + volumes=[ + volume.Volume(), + volume.Volume(), + volume.Volume(), + ], + next_page_token='abc', + ), + volume.ListVolumesResponse( + volumes=[], + next_page_token='def', + ), + volume.ListVolumesResponse( + volumes=[ + volume.Volume(), + ], + next_page_token='ghi', + ), + volume.ListVolumesResponse( + volumes=[ + volume.Volume(), + volume.Volume(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(volume.ListVolumesResponse.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_volumes(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, volume.Volume) + for i in results) + + pages = list(client.list_volumes(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +def test_get_volume_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 = NetAppClient( + 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_volume 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_volume] = mock_rpc + + request = {} + client.get_volume(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_volume(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_volume_rest_required_fields(request_type=volume.GetVolumeRequest): + transport_class = transports.NetAppRestTransport + + 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_volume._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_volume._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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = volume.Volume() + # 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 = volume.Volume.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_volume(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_volume_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_volume._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_get_volume_rest_flattened(): + client = NetAppClient( + 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 = volume.Volume() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/volumes/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 = volume.Volume.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_volume(**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/*/volumes/*}" % client.transport._host, args[1]) + + +def test_get_volume_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_volume( + volume.GetVolumeRequest(), + name='name_value', + ) + + +def test_create_volume_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 = NetAppClient( + 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_volume 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_volume] = mock_rpc + + request = {} + client.create_volume(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_volume(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_volume_rest_required_fields(request_type=gcn_volume.CreateVolumeRequest): + transport_class = transports.NetAppRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["volume_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 "volumeId" not in jsonified_request + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_volume._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "volumeId" in jsonified_request + assert jsonified_request["volumeId"] == request_init["volume_id"] + + jsonified_request["parent"] = 'parent_value' + jsonified_request["volumeId"] = 'volume_id_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_volume._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("volume_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 "volumeId" in jsonified_request + assert jsonified_request["volumeId"] == 'volume_id_value' + + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_volume(request) + + expected_params = [ + ( + "volumeId", + "", + ), + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_volume_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_volume._get_unset_required_fields({}) + assert set(unset_fields) == (set(("volumeId", )) & set(("parent", "volumeId", "volume", ))) + + +def test_create_volume_rest_flattened(): + client = NetAppClient( + 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', + volume=gcn_volume.Volume(name='name_value'), + volume_id='volume_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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_volume(**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/*}/volumes" % client.transport._host, args[1]) + + +def test_create_volume_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_volume( + gcn_volume.CreateVolumeRequest(), + parent='parent_value', + volume=gcn_volume.Volume(name='name_value'), + volume_id='volume_id_value', + ) + + +def test_update_volume_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 = NetAppClient( + 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_volume 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_volume] = mock_rpc + + request = {} + client.update_volume(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.update_volume(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_volume_rest_required_fields(request_type=gcn_volume.UpdateVolumeRequest): + transport_class = transports.NetAppRestTransport + + 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_volume._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_volume._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 = NetAppClient( + 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': "patch", + '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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_volume(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_volume_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_volume._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("updateMask", "volume", ))) + + +def test_update_volume_rest_flattened(): + client = NetAppClient( + 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 = {'volume': {'name': 'projects/sample1/locations/sample2/volumes/sample3'}} + + # get truthy value for each flattened field + mock_args = dict( + volume=gcn_volume.Volume(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 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_volume(**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/{volume.name=projects/*/locations/*/volumes/*}" % client.transport._host, args[1]) + + +def test_update_volume_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_volume( + gcn_volume.UpdateVolumeRequest(), + volume=gcn_volume.Volume(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_delete_volume_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 = NetAppClient( + 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_volume 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_volume] = mock_rpc + + request = {} + client.delete_volume(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_volume(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_volume_rest_required_fields(request_type=volume.DeleteVolumeRequest): + transport_class = transports.NetAppRestTransport + + 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_volume._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_volume._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("force", )) + 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 = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_volume(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_volume_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_volume._get_unset_required_fields({}) + assert set(unset_fields) == (set(("force", )) & set(("name", ))) + + +def test_delete_volume_rest_flattened(): + client = NetAppClient( + 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/volumes/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_volume(**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/*/volumes/*}" % client.transport._host, args[1]) + + +def test_delete_volume_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_volume( + volume.DeleteVolumeRequest(), + name='name_value', + ) + + +def test_revert_volume_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 = NetAppClient( + 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.revert_volume 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.revert_volume] = mock_rpc + + request = {} + client.revert_volume(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.revert_volume(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_revert_volume_rest_required_fields(request_type=volume.RevertVolumeRequest): + transport_class = transports.NetAppRestTransport + + request_init = {} + request_init["name"] = "" + request_init["snapshot_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 + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).revert_volume._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["snapshotId"] = 'snapshot_id_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).revert_volume._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' + assert "snapshotId" in jsonified_request + assert jsonified_request["snapshotId"] == 'snapshot_id_value' + + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.revert_volume(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_revert_volume_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.revert_volume._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", "snapshotId", ))) + + +def test_list_snapshots_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 = NetAppClient( + 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_snapshots 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_snapshots] = mock_rpc + + request = {} + client.list_snapshots(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_snapshots(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_snapshots_rest_required_fields(request_type=snapshot.ListSnapshotsRequest): + transport_class = transports.NetAppRestTransport + + 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_snapshots._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_snapshots._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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = snapshot.ListSnapshotsResponse() + # 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 = snapshot.ListSnapshotsResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_snapshots(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_snapshots_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_snapshots._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) + + +def test_list_snapshots_rest_flattened(): + client = NetAppClient( + 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 = snapshot.ListSnapshotsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2/volumes/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 = snapshot.ListSnapshotsResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_snapshots(**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/*/volumes/*}/snapshots" % client.transport._host, args[1]) + + +def test_list_snapshots_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_snapshots( + snapshot.ListSnapshotsRequest(), + parent='parent_value', + ) + + +def test_list_snapshots_rest_pager(transport: str = 'rest'): + client = NetAppClient( + 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 = ( + snapshot.ListSnapshotsResponse( + snapshots=[ + snapshot.Snapshot(), + snapshot.Snapshot(), + snapshot.Snapshot(), + ], + next_page_token='abc', + ), + snapshot.ListSnapshotsResponse( + snapshots=[], + next_page_token='def', + ), + snapshot.ListSnapshotsResponse( + snapshots=[ + snapshot.Snapshot(), + ], + next_page_token='ghi', + ), + snapshot.ListSnapshotsResponse( + snapshots=[ + snapshot.Snapshot(), + snapshot.Snapshot(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(snapshot.ListSnapshotsResponse.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/volumes/sample3'} + + pager = client.list_snapshots(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, snapshot.Snapshot) + for i in results) + + pages = list(client.list_snapshots(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +def test_get_snapshot_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 = NetAppClient( + 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_snapshot 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_snapshot] = mock_rpc + + request = {} + client.get_snapshot(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_snapshot(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_snapshot_rest_required_fields(request_type=snapshot.GetSnapshotRequest): + transport_class = transports.NetAppRestTransport + + 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_snapshot._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_snapshot._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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = snapshot.Snapshot() + # 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 = snapshot.Snapshot.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_snapshot(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_snapshot_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_snapshot._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_get_snapshot_rest_flattened(): + client = NetAppClient( + 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 = snapshot.Snapshot() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/volumes/sample3/snapshots/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 = snapshot.Snapshot.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_snapshot(**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/*/volumes/*/snapshots/*}" % client.transport._host, args[1]) + + +def test_get_snapshot_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_snapshot( + snapshot.GetSnapshotRequest(), + name='name_value', + ) + + +def test_create_snapshot_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 = NetAppClient( + 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_snapshot 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_snapshot] = mock_rpc + + request = {} + client.create_snapshot(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_snapshot(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_snapshot_rest_required_fields(request_type=gcn_snapshot.CreateSnapshotRequest): + transport_class = transports.NetAppRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["snapshot_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 "snapshotId" not in jsonified_request + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_snapshot._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "snapshotId" in jsonified_request + assert jsonified_request["snapshotId"] == request_init["snapshot_id"] + + jsonified_request["parent"] = 'parent_value' + jsonified_request["snapshotId"] = 'snapshot_id_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_snapshot._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("snapshot_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 "snapshotId" in jsonified_request + assert jsonified_request["snapshotId"] == 'snapshot_id_value' + + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_snapshot(request) + + expected_params = [ + ( + "snapshotId", + "", + ), + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_snapshot_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_snapshot._get_unset_required_fields({}) + assert set(unset_fields) == (set(("snapshotId", )) & set(("parent", "snapshot", "snapshotId", ))) + + +def test_create_snapshot_rest_flattened(): + client = NetAppClient( + 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/volumes/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + snapshot=gcn_snapshot.Snapshot(name='name_value'), + snapshot_id='snapshot_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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_snapshot(**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/*/volumes/*}/snapshots" % client.transport._host, args[1]) + + +def test_create_snapshot_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_snapshot( + gcn_snapshot.CreateSnapshotRequest(), + parent='parent_value', + snapshot=gcn_snapshot.Snapshot(name='name_value'), + snapshot_id='snapshot_id_value', + ) + + +def test_delete_snapshot_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 = NetAppClient( + 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_snapshot 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_snapshot] = mock_rpc + + request = {} + client.delete_snapshot(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_snapshot(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_snapshot_rest_required_fields(request_type=snapshot.DeleteSnapshotRequest): + transport_class = transports.NetAppRestTransport + + 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_snapshot._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_snapshot._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 = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_snapshot(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_snapshot_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_snapshot._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_delete_snapshot_rest_flattened(): + client = NetAppClient( + 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/volumes/sample3/snapshots/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_snapshot(**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/*/volumes/*/snapshots/*}" % client.transport._host, args[1]) + + +def test_delete_snapshot_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_snapshot( + snapshot.DeleteSnapshotRequest(), + name='name_value', + ) + + +def test_update_snapshot_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 = NetAppClient( + 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_snapshot 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_snapshot] = mock_rpc + + request = {} + client.update_snapshot(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.update_snapshot(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_snapshot_rest_required_fields(request_type=gcn_snapshot.UpdateSnapshotRequest): + transport_class = transports.NetAppRestTransport + + 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_snapshot._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_snapshot._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 = NetAppClient( + 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': "patch", + '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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_snapshot(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_snapshot_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_snapshot._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("updateMask", "snapshot", ))) + + +def test_update_snapshot_rest_flattened(): + client = NetAppClient( + 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 = {'snapshot': {'name': 'projects/sample1/locations/sample2/volumes/sample3/snapshots/sample4'}} + + # get truthy value for each flattened field + mock_args = dict( + snapshot=gcn_snapshot.Snapshot(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 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_snapshot(**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/{snapshot.name=projects/*/locations/*/volumes/*/snapshots/*}" % client.transport._host, args[1]) + + +def test_update_snapshot_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_snapshot( + gcn_snapshot.UpdateSnapshotRequest(), + snapshot=gcn_snapshot.Snapshot(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_list_active_directories_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 = NetAppClient( + 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_active_directories 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_active_directories] = mock_rpc + + request = {} + client.list_active_directories(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_active_directories(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_active_directories_rest_required_fields(request_type=active_directory.ListActiveDirectoriesRequest): + transport_class = transports.NetAppRestTransport + + 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_active_directories._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_active_directories._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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = active_directory.ListActiveDirectoriesResponse() + # 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 = active_directory.ListActiveDirectoriesResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_active_directories(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_active_directories_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_active_directories._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) + + +def test_list_active_directories_rest_flattened(): + client = NetAppClient( + 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 = active_directory.ListActiveDirectoriesResponse() + + # 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 = active_directory.ListActiveDirectoriesResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_active_directories(**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/*}/activeDirectories" % client.transport._host, args[1]) + + +def test_list_active_directories_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_active_directories( + active_directory.ListActiveDirectoriesRequest(), + parent='parent_value', + ) + + +def test_list_active_directories_rest_pager(transport: str = 'rest'): + client = NetAppClient( + 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 = ( + active_directory.ListActiveDirectoriesResponse( + active_directories=[ + active_directory.ActiveDirectory(), + active_directory.ActiveDirectory(), + active_directory.ActiveDirectory(), + ], + next_page_token='abc', + ), + active_directory.ListActiveDirectoriesResponse( + active_directories=[], + next_page_token='def', + ), + active_directory.ListActiveDirectoriesResponse( + active_directories=[ + active_directory.ActiveDirectory(), + ], + next_page_token='ghi', + ), + active_directory.ListActiveDirectoriesResponse( + active_directories=[ + active_directory.ActiveDirectory(), + active_directory.ActiveDirectory(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(active_directory.ListActiveDirectoriesResponse.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_active_directories(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, active_directory.ActiveDirectory) + for i in results) + + pages = list(client.list_active_directories(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +def test_get_active_directory_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 = NetAppClient( + 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_active_directory 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_active_directory] = mock_rpc + + request = {} + client.get_active_directory(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_active_directory(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_active_directory_rest_required_fields(request_type=active_directory.GetActiveDirectoryRequest): + transport_class = transports.NetAppRestTransport + + 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_active_directory._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_active_directory._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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = active_directory.ActiveDirectory() + # 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 = active_directory.ActiveDirectory.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_active_directory(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_active_directory_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_active_directory._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_get_active_directory_rest_flattened(): + client = NetAppClient( + 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 = active_directory.ActiveDirectory() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/activeDirectories/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 = active_directory.ActiveDirectory.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_active_directory(**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/*/activeDirectories/*}" % client.transport._host, args[1]) + + +def test_get_active_directory_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_active_directory( + active_directory.GetActiveDirectoryRequest(), + name='name_value', + ) + + +def test_create_active_directory_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 = NetAppClient( + 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_active_directory 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_active_directory] = mock_rpc + + request = {} + client.create_active_directory(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_active_directory(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_active_directory_rest_required_fields(request_type=gcn_active_directory.CreateActiveDirectoryRequest): + transport_class = transports.NetAppRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["active_directory_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 "activeDirectoryId" not in jsonified_request + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_active_directory._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "activeDirectoryId" in jsonified_request + assert jsonified_request["activeDirectoryId"] == request_init["active_directory_id"] + + jsonified_request["parent"] = 'parent_value' + jsonified_request["activeDirectoryId"] = 'active_directory_id_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_active_directory._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("active_directory_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 "activeDirectoryId" in jsonified_request + assert jsonified_request["activeDirectoryId"] == 'active_directory_id_value' + + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_active_directory(request) + + expected_params = [ + ( + "activeDirectoryId", + "", + ), + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_active_directory_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_active_directory._get_unset_required_fields({}) + assert set(unset_fields) == (set(("activeDirectoryId", )) & set(("parent", "activeDirectory", "activeDirectoryId", ))) + + +def test_create_active_directory_rest_flattened(): + client = NetAppClient( + 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', + active_directory=gcn_active_directory.ActiveDirectory(name='name_value'), + active_directory_id='active_directory_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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_active_directory(**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/*}/activeDirectories" % client.transport._host, args[1]) + + +def test_create_active_directory_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_active_directory( + gcn_active_directory.CreateActiveDirectoryRequest(), + parent='parent_value', + active_directory=gcn_active_directory.ActiveDirectory(name='name_value'), + active_directory_id='active_directory_id_value', + ) + + +def test_update_active_directory_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 = NetAppClient( + 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_active_directory 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_active_directory] = mock_rpc + + request = {} + client.update_active_directory(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.update_active_directory(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_active_directory_rest_required_fields(request_type=gcn_active_directory.UpdateActiveDirectoryRequest): + transport_class = transports.NetAppRestTransport + + 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_active_directory._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_active_directory._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 = NetAppClient( + 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': "patch", + '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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_active_directory(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_active_directory_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_active_directory._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("updateMask", "activeDirectory", ))) + + +def test_update_active_directory_rest_flattened(): + client = NetAppClient( + 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 = {'active_directory': {'name': 'projects/sample1/locations/sample2/activeDirectories/sample3'}} + + # get truthy value for each flattened field + mock_args = dict( + active_directory=gcn_active_directory.ActiveDirectory(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 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_active_directory(**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/{active_directory.name=projects/*/locations/*/activeDirectories/*}" % client.transport._host, args[1]) + + +def test_update_active_directory_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_active_directory( + gcn_active_directory.UpdateActiveDirectoryRequest(), + active_directory=gcn_active_directory.ActiveDirectory(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_delete_active_directory_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 = NetAppClient( + 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_active_directory 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_active_directory] = mock_rpc + + request = {} + client.delete_active_directory(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_active_directory(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_active_directory_rest_required_fields(request_type=active_directory.DeleteActiveDirectoryRequest): + transport_class = transports.NetAppRestTransport + + 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_active_directory._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_active_directory._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 = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_active_directory(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_active_directory_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_active_directory._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_delete_active_directory_rest_flattened(): + client = NetAppClient( + 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/activeDirectories/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_active_directory(**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/*/activeDirectories/*}" % client.transport._host, args[1]) + + +def test_delete_active_directory_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_active_directory( + active_directory.DeleteActiveDirectoryRequest(), + name='name_value', + ) + + +def test_list_kms_configs_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 = NetAppClient( + 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_kms_configs 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_kms_configs] = mock_rpc + + request = {} + client.list_kms_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_kms_configs(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_kms_configs_rest_required_fields(request_type=kms.ListKmsConfigsRequest): + transport_class = transports.NetAppRestTransport + + 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_kms_configs._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_kms_configs._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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = kms.ListKmsConfigsResponse() + # 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 = kms.ListKmsConfigsResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_kms_configs(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_kms_configs_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_kms_configs._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) + + +def test_list_kms_configs_rest_flattened(): + client = NetAppClient( + 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 = kms.ListKmsConfigsResponse() + + # 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 = kms.ListKmsConfigsResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_kms_configs(**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/*}/kmsConfigs" % client.transport._host, args[1]) + + +def test_list_kms_configs_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_kms_configs( + kms.ListKmsConfigsRequest(), + parent='parent_value', + ) + + +def test_list_kms_configs_rest_pager(transport: str = 'rest'): + client = NetAppClient( + 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 = ( + kms.ListKmsConfigsResponse( + kms_configs=[ + kms.KmsConfig(), + kms.KmsConfig(), + kms.KmsConfig(), + ], + next_page_token='abc', + ), + kms.ListKmsConfigsResponse( + kms_configs=[], + next_page_token='def', + ), + kms.ListKmsConfigsResponse( + kms_configs=[ + kms.KmsConfig(), + ], + next_page_token='ghi', + ), + kms.ListKmsConfigsResponse( + kms_configs=[ + kms.KmsConfig(), + kms.KmsConfig(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(kms.ListKmsConfigsResponse.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_kms_configs(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, kms.KmsConfig) + for i in results) + + pages = list(client.list_kms_configs(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +def test_create_kms_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 = NetAppClient( + 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_kms_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.create_kms_config] = mock_rpc + + request = {} + client.create_kms_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.create_kms_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_create_kms_config_rest_required_fields(request_type=kms.CreateKmsConfigRequest): + transport_class = transports.NetAppRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["kms_config_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 "kmsConfigId" not in jsonified_request + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_kms_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "kmsConfigId" in jsonified_request + assert jsonified_request["kmsConfigId"] == request_init["kms_config_id"] + + jsonified_request["parent"] = 'parent_value' + jsonified_request["kmsConfigId"] = 'kms_config_id_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_kms_config._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("kms_config_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 "kmsConfigId" in jsonified_request + assert jsonified_request["kmsConfigId"] == 'kms_config_id_value' + + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_kms_config(request) + + expected_params = [ + ( + "kmsConfigId", + "", + ), + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_kms_config_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_kms_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(("kmsConfigId", )) & set(("parent", "kmsConfigId", "kmsConfig", ))) + + +def test_create_kms_config_rest_flattened(): + client = NetAppClient( + 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', + kms_config=kms.KmsConfig(name='name_value'), + kms_config_id='kms_config_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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_kms_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/{parent=projects/*/locations/*}/kmsConfigs" % client.transport._host, args[1]) + + +def test_create_kms_config_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_kms_config( + kms.CreateKmsConfigRequest(), + parent='parent_value', + kms_config=kms.KmsConfig(name='name_value'), + kms_config_id='kms_config_id_value', + ) + + +def test_get_kms_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 = NetAppClient( + 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_kms_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_kms_config] = mock_rpc + + request = {} + client.get_kms_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_kms_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_kms_config_rest_required_fields(request_type=kms.GetKmsConfigRequest): + transport_class = transports.NetAppRestTransport + + 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_kms_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_kms_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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = kms.KmsConfig() + # 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 = kms.KmsConfig.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_kms_config(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_kms_config_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_kms_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_get_kms_config_rest_flattened(): + client = NetAppClient( + 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 = kms.KmsConfig() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/kmsConfigs/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 = kms.KmsConfig.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_kms_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/*/kmsConfigs/*}" % client.transport._host, args[1]) + + +def test_get_kms_config_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_kms_config( + kms.GetKmsConfigRequest(), + name='name_value', + ) + + +def test_update_kms_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 = NetAppClient( + 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_kms_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_kms_config] = mock_rpc + + request = {} + client.update_kms_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.update_kms_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_kms_config_rest_required_fields(request_type=kms.UpdateKmsConfigRequest): + transport_class = transports.NetAppRestTransport + + 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_kms_config._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_kms_config._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 = NetAppClient( + 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': "patch", + '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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_kms_config(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_kms_config_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_kms_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("updateMask", "kmsConfig", ))) + + +def test_update_kms_config_rest_flattened(): + client = NetAppClient( + 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 = {'kms_config': {'name': 'projects/sample1/locations/sample2/kmsConfigs/sample3'}} + + # get truthy value for each flattened field + mock_args = dict( + kms_config=kms.KmsConfig(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 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_kms_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/{kms_config.name=projects/*/locations/*/kmsConfigs/*}" % client.transport._host, args[1]) + + +def test_update_kms_config_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_kms_config( + kms.UpdateKmsConfigRequest(), + kms_config=kms.KmsConfig(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_encrypt_volumes_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 = NetAppClient( + 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.encrypt_volumes 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.encrypt_volumes] = mock_rpc + + request = {} + client.encrypt_volumes(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.encrypt_volumes(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_encrypt_volumes_rest_required_fields(request_type=kms.EncryptVolumesRequest): + transport_class = transports.NetAppRestTransport + + 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()).encrypt_volumes._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()).encrypt_volumes._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 = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.encrypt_volumes(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_encrypt_volumes_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.encrypt_volumes._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_verify_kms_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 = NetAppClient( + 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.verify_kms_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.verify_kms_config] = mock_rpc + + request = {} + client.verify_kms_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.verify_kms_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_verify_kms_config_rest_required_fields(request_type=kms.VerifyKmsConfigRequest): + transport_class = transports.NetAppRestTransport + + 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()).verify_kms_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()).verify_kms_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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = kms.VerifyKmsConfigResponse() + # 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 = kms.VerifyKmsConfigResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.verify_kms_config(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_verify_kms_config_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.verify_kms_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_delete_kms_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 = NetAppClient( + 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_kms_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.delete_kms_config] = mock_rpc + + request = {} + client.delete_kms_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.delete_kms_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_delete_kms_config_rest_required_fields(request_type=kms.DeleteKmsConfigRequest): + transport_class = transports.NetAppRestTransport + + 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_kms_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()).delete_kms_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 = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_kms_config(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_kms_config_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_kms_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_delete_kms_config_rest_flattened(): + client = NetAppClient( + 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/kmsConfigs/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_kms_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/*/kmsConfigs/*}" % client.transport._host, args[1]) + + +def test_delete_kms_config_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_kms_config( + kms.DeleteKmsConfigRequest(), + name='name_value', + ) + + +def test_list_replications_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 = NetAppClient( + 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_replications 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_replications] = mock_rpc + + request = {} + client.list_replications(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_replications(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_replications_rest_required_fields(request_type=replication.ListReplicationsRequest): + transport_class = transports.NetAppRestTransport + + 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_replications._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_replications._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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = replication.ListReplicationsResponse() + # 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 = replication.ListReplicationsResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_replications(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_replications_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_replications._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) + + +def test_list_replications_rest_flattened(): + client = NetAppClient( + 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 = replication.ListReplicationsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2/volumes/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 = replication.ListReplicationsResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_replications(**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/*/volumes/*}/replications" % client.transport._host, args[1]) + + +def test_list_replications_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_replications( + replication.ListReplicationsRequest(), + parent='parent_value', + ) + + +def test_list_replications_rest_pager(transport: str = 'rest'): + client = NetAppClient( + 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 = ( + replication.ListReplicationsResponse( + replications=[ + replication.Replication(), + replication.Replication(), + replication.Replication(), + ], + next_page_token='abc', + ), + replication.ListReplicationsResponse( + replications=[], + next_page_token='def', + ), + replication.ListReplicationsResponse( + replications=[ + replication.Replication(), + ], + next_page_token='ghi', + ), + replication.ListReplicationsResponse( + replications=[ + replication.Replication(), + replication.Replication(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(replication.ListReplicationsResponse.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/volumes/sample3'} + + pager = client.list_replications(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, replication.Replication) + for i in results) + + pages = list(client.list_replications(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +def test_get_replication_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 = NetAppClient( + 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_replication 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_replication] = mock_rpc + + request = {} + client.get_replication(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_replication(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_replication_rest_required_fields(request_type=replication.GetReplicationRequest): + transport_class = transports.NetAppRestTransport + + 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_replication._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_replication._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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = replication.Replication() + # 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 = replication.Replication.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_replication(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_replication_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_replication._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_get_replication_rest_flattened(): + client = NetAppClient( + 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 = replication.Replication() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 = replication.Replication.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_replication(**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/*/volumes/*/replications/*}" % client.transport._host, args[1]) + + +def test_get_replication_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_replication( + replication.GetReplicationRequest(), + name='name_value', + ) + + +def test_create_replication_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 = NetAppClient( + 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_replication 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_replication] = mock_rpc + + request = {} + client.create_replication(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_replication(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_replication_rest_required_fields(request_type=gcn_replication.CreateReplicationRequest): + transport_class = transports.NetAppRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["replication_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 "replicationId" not in jsonified_request + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_replication._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "replicationId" in jsonified_request + assert jsonified_request["replicationId"] == request_init["replication_id"] + + jsonified_request["parent"] = 'parent_value' + jsonified_request["replicationId"] = 'replication_id_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_replication._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("replication_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 "replicationId" in jsonified_request + assert jsonified_request["replicationId"] == 'replication_id_value' + + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_replication(request) + + expected_params = [ + ( + "replicationId", + "", + ), + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_replication_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_replication._get_unset_required_fields({}) + assert set(unset_fields) == (set(("replicationId", )) & set(("parent", "replication", "replicationId", ))) + + +def test_create_replication_rest_flattened(): + client = NetAppClient( + 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/volumes/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + replication=gcn_replication.Replication(name='name_value'), + replication_id='replication_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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_replication(**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/*/volumes/*}/replications" % client.transport._host, args[1]) + + +def test_create_replication_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_replication( + gcn_replication.CreateReplicationRequest(), + parent='parent_value', + replication=gcn_replication.Replication(name='name_value'), + replication_id='replication_id_value', + ) + + +def test_delete_replication_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 = NetAppClient( + 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_replication 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_replication] = mock_rpc + + request = {} + client.delete_replication(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_replication(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_replication_rest_required_fields(request_type=replication.DeleteReplicationRequest): + transport_class = transports.NetAppRestTransport + + 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_replication._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_replication._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 = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_replication(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_replication_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_replication._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_delete_replication_rest_flattened(): + client = NetAppClient( + 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/volumes/sample3/replications/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_replication(**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/*/volumes/*/replications/*}" % client.transport._host, args[1]) + + +def test_delete_replication_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_replication( + replication.DeleteReplicationRequest(), + name='name_value', + ) + + +def test_update_replication_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 = NetAppClient( + 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_replication 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_replication] = mock_rpc + + request = {} + client.update_replication(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.update_replication(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_replication_rest_required_fields(request_type=gcn_replication.UpdateReplicationRequest): + transport_class = transports.NetAppRestTransport + + 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_replication._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_replication._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 = NetAppClient( + 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': "patch", + '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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_replication(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_replication_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_replication._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("updateMask", "replication", ))) + + +def test_update_replication_rest_flattened(): + client = NetAppClient( + 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 = {'replication': {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/sample4'}} + + # get truthy value for each flattened field + mock_args = dict( + replication=gcn_replication.Replication(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 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_replication(**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/{replication.name=projects/*/locations/*/volumes/*/replications/*}" % client.transport._host, args[1]) + + +def test_update_replication_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_replication( + gcn_replication.UpdateReplicationRequest(), + replication=gcn_replication.Replication(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_stop_replication_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 = NetAppClient( + 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.stop_replication 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.stop_replication] = mock_rpc + + request = {} + client.stop_replication(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.stop_replication(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_stop_replication_rest_required_fields(request_type=replication.StopReplicationRequest): + transport_class = transports.NetAppRestTransport + + 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()).stop_replication._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()).stop_replication._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 = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.stop_replication(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_stop_replication_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.stop_replication._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_resume_replication_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 = NetAppClient( + 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.resume_replication 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.resume_replication] = mock_rpc + + request = {} + client.resume_replication(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.resume_replication(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_resume_replication_rest_required_fields(request_type=replication.ResumeReplicationRequest): + transport_class = transports.NetAppRestTransport + + 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()).resume_replication._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()).resume_replication._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 = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.resume_replication(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_resume_replication_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.resume_replication._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_reverse_replication_direction_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 = NetAppClient( + 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.reverse_replication_direction 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.reverse_replication_direction] = mock_rpc + + request = {} + client.reverse_replication_direction(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.reverse_replication_direction(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_reverse_replication_direction_rest_required_fields(request_type=replication.ReverseReplicationDirectionRequest): + transport_class = transports.NetAppRestTransport + + 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()).reverse_replication_direction._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()).reverse_replication_direction._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 = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.reverse_replication_direction(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_reverse_replication_direction_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.reverse_replication_direction._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_establish_peering_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 = NetAppClient( + 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.establish_peering 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.establish_peering] = mock_rpc + + request = {} + client.establish_peering(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.establish_peering(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_establish_peering_rest_required_fields(request_type=replication.EstablishPeeringRequest): + transport_class = transports.NetAppRestTransport + + request_init = {} + request_init["name"] = "" + request_init["peer_cluster_name"] = "" + request_init["peer_svm_name"] = "" + request_init["peer_volume_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()).establish_peering._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["peerClusterName"] = 'peer_cluster_name_value' + jsonified_request["peerSvmName"] = 'peer_svm_name_value' + jsonified_request["peerVolumeName"] = 'peer_volume_name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).establish_peering._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' + assert "peerClusterName" in jsonified_request + assert jsonified_request["peerClusterName"] == 'peer_cluster_name_value' + assert "peerSvmName" in jsonified_request + assert jsonified_request["peerSvmName"] == 'peer_svm_name_value' + assert "peerVolumeName" in jsonified_request + assert jsonified_request["peerVolumeName"] == 'peer_volume_name_value' + + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.establish_peering(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_establish_peering_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.establish_peering._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", "peerClusterName", "peerSvmName", "peerVolumeName", ))) + + +def test_sync_replication_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 = NetAppClient( + 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.sync_replication 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.sync_replication] = mock_rpc + + request = {} + client.sync_replication(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.sync_replication(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_sync_replication_rest_required_fields(request_type=replication.SyncReplicationRequest): + transport_class = transports.NetAppRestTransport + + 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()).sync_replication._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()).sync_replication._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 = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.sync_replication(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_sync_replication_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.sync_replication._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_create_backup_vault_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 = NetAppClient( + 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_backup_vault 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_backup_vault] = mock_rpc + + request = {} + client.create_backup_vault(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_backup_vault(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_backup_vault_rest_required_fields(request_type=gcn_backup_vault.CreateBackupVaultRequest): + transport_class = transports.NetAppRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["backup_vault_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 "backupVaultId" not in jsonified_request + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_backup_vault._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "backupVaultId" in jsonified_request + assert jsonified_request["backupVaultId"] == request_init["backup_vault_id"] + + jsonified_request["parent"] = 'parent_value' + jsonified_request["backupVaultId"] = 'backup_vault_id_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_backup_vault._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("backup_vault_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 "backupVaultId" in jsonified_request + assert jsonified_request["backupVaultId"] == 'backup_vault_id_value' + + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_backup_vault(request) + + expected_params = [ + ( + "backupVaultId", + "", + ), + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_backup_vault_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_backup_vault._get_unset_required_fields({}) + assert set(unset_fields) == (set(("backupVaultId", )) & set(("parent", "backupVaultId", "backupVault", ))) + + +def test_create_backup_vault_rest_flattened(): + client = NetAppClient( + 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', + backup_vault=gcn_backup_vault.BackupVault(name='name_value'), + backup_vault_id='backup_vault_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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_backup_vault(**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/*}/backupVaults" % client.transport._host, args[1]) + + +def test_create_backup_vault_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_backup_vault( + gcn_backup_vault.CreateBackupVaultRequest(), + parent='parent_value', + backup_vault=gcn_backup_vault.BackupVault(name='name_value'), + backup_vault_id='backup_vault_id_value', + ) + + +def test_get_backup_vault_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 = NetAppClient( + 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_backup_vault 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_backup_vault] = mock_rpc + + request = {} + client.get_backup_vault(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_backup_vault(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_backup_vault_rest_required_fields(request_type=backup_vault.GetBackupVaultRequest): + transport_class = transports.NetAppRestTransport + + 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_backup_vault._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_backup_vault._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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = backup_vault.BackupVault() + # 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 = backup_vault.BackupVault.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_backup_vault(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_backup_vault_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_backup_vault._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_get_backup_vault_rest_flattened(): + client = NetAppClient( + 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 = backup_vault.BackupVault() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/backupVaults/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 = backup_vault.BackupVault.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_backup_vault(**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/*/backupVaults/*}" % client.transport._host, args[1]) + + +def test_get_backup_vault_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_backup_vault( + backup_vault.GetBackupVaultRequest(), + name='name_value', + ) + + +def test_list_backup_vaults_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 = NetAppClient( + 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_backup_vaults 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_backup_vaults] = mock_rpc + + request = {} + client.list_backup_vaults(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_backup_vaults(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_backup_vaults_rest_required_fields(request_type=backup_vault.ListBackupVaultsRequest): + transport_class = transports.NetAppRestTransport + + 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_backup_vaults._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_backup_vaults._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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = backup_vault.ListBackupVaultsResponse() + # 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 = backup_vault.ListBackupVaultsResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_backup_vaults(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_backup_vaults_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_backup_vaults._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) + + +def test_list_backup_vaults_rest_flattened(): + client = NetAppClient( + 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 = backup_vault.ListBackupVaultsResponse() + + # 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 = backup_vault.ListBackupVaultsResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_backup_vaults(**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/*}/backupVaults" % client.transport._host, args[1]) + + +def test_list_backup_vaults_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_backup_vaults( + backup_vault.ListBackupVaultsRequest(), + parent='parent_value', + ) + + +def test_list_backup_vaults_rest_pager(transport: str = 'rest'): + client = NetAppClient( + 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 = ( + backup_vault.ListBackupVaultsResponse( + backup_vaults=[ + backup_vault.BackupVault(), + backup_vault.BackupVault(), + backup_vault.BackupVault(), + ], + next_page_token='abc', + ), + backup_vault.ListBackupVaultsResponse( + backup_vaults=[], + next_page_token='def', + ), + backup_vault.ListBackupVaultsResponse( + backup_vaults=[ + backup_vault.BackupVault(), + ], + next_page_token='ghi', + ), + backup_vault.ListBackupVaultsResponse( + backup_vaults=[ + backup_vault.BackupVault(), + backup_vault.BackupVault(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(backup_vault.ListBackupVaultsResponse.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_backup_vaults(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, backup_vault.BackupVault) + for i in results) + + pages = list(client.list_backup_vaults(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +def test_update_backup_vault_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 = NetAppClient( + 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_backup_vault 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_backup_vault] = mock_rpc + + request = {} + client.update_backup_vault(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.update_backup_vault(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_backup_vault_rest_required_fields(request_type=gcn_backup_vault.UpdateBackupVaultRequest): + transport_class = transports.NetAppRestTransport + + 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_backup_vault._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_backup_vault._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 = NetAppClient( + 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': "patch", + '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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_backup_vault(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_backup_vault_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_backup_vault._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("updateMask", "backupVault", ))) + + +def test_update_backup_vault_rest_flattened(): + client = NetAppClient( + 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 = {'backup_vault': {'name': 'projects/sample1/locations/sample2/backupVaults/sample3'}} + + # get truthy value for each flattened field + mock_args = dict( + backup_vault=gcn_backup_vault.BackupVault(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 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_backup_vault(**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/{backup_vault.name=projects/*/locations/*/backupVaults/*}" % client.transport._host, args[1]) + + +def test_update_backup_vault_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_backup_vault( + gcn_backup_vault.UpdateBackupVaultRequest(), + backup_vault=gcn_backup_vault.BackupVault(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_delete_backup_vault_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 = NetAppClient( + 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_backup_vault 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_backup_vault] = mock_rpc + + request = {} + client.delete_backup_vault(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_backup_vault(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_backup_vault_rest_required_fields(request_type=backup_vault.DeleteBackupVaultRequest): + transport_class = transports.NetAppRestTransport + + 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_backup_vault._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_backup_vault._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 = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_backup_vault(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_backup_vault_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_backup_vault._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_delete_backup_vault_rest_flattened(): + client = NetAppClient( + 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/backupVaults/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_backup_vault(**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/*/backupVaults/*}" % client.transport._host, args[1]) + + +def test_delete_backup_vault_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_backup_vault( + backup_vault.DeleteBackupVaultRequest(), + name='name_value', + ) + + +def test_create_backup_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 = NetAppClient( + 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_backup 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_backup] = mock_rpc + + request = {} + client.create_backup(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_backup(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_backup_rest_required_fields(request_type=gcn_backup.CreateBackupRequest): + transport_class = transports.NetAppRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["backup_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 "backupId" not in jsonified_request + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_backup._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "backupId" in jsonified_request + assert jsonified_request["backupId"] == request_init["backup_id"] + + jsonified_request["parent"] = 'parent_value' + jsonified_request["backupId"] = 'backup_id_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_backup._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("backup_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 "backupId" in jsonified_request + assert jsonified_request["backupId"] == 'backup_id_value' + + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_backup(request) + + expected_params = [ + ( + "backupId", + "", + ), + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_backup_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_backup._get_unset_required_fields({}) + assert set(unset_fields) == (set(("backupId", )) & set(("parent", "backupId", "backup", ))) + + +def test_create_backup_rest_flattened(): + client = NetAppClient( + 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/backupVaults/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + backup=gcn_backup.Backup(name='name_value'), + backup_id='backup_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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_backup(**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/*/backupVaults/*}/backups" % client.transport._host, args[1]) + + +def test_create_backup_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_backup( + gcn_backup.CreateBackupRequest(), + parent='parent_value', + backup=gcn_backup.Backup(name='name_value'), + backup_id='backup_id_value', + ) + + +def test_get_backup_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 = NetAppClient( + 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_backup 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_backup] = mock_rpc + + request = {} + client.get_backup(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_backup(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_backup_rest_required_fields(request_type=backup.GetBackupRequest): + transport_class = transports.NetAppRestTransport + + 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_backup._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_backup._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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = backup.Backup() + # 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 = backup.Backup.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_backup(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_backup_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_backup._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_get_backup_rest_flattened(): + client = NetAppClient( + 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 = backup.Backup() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/backupVaults/sample3/backups/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 = backup.Backup.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_backup(**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/*/backupVaults/*/backups/*}" % client.transport._host, args[1]) + + +def test_get_backup_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_backup( + backup.GetBackupRequest(), + name='name_value', + ) + + +def test_list_backups_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 = NetAppClient( + 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_backups 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_backups] = mock_rpc + + request = {} + client.list_backups(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_backups(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_backups_rest_required_fields(request_type=backup.ListBackupsRequest): + transport_class = transports.NetAppRestTransport + + 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_backups._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_backups._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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = backup.ListBackupsResponse() + # 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 = backup.ListBackupsResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_backups(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_backups_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_backups._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) + + +def test_list_backups_rest_flattened(): + client = NetAppClient( + 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 = backup.ListBackupsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2/backupVaults/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 = backup.ListBackupsResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_backups(**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/*/backupVaults/*}/backups" % client.transport._host, args[1]) + + +def test_list_backups_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_backups( + backup.ListBackupsRequest(), + parent='parent_value', + ) + + +def test_list_backups_rest_pager(transport: str = 'rest'): + client = NetAppClient( + 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 = ( + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + backup.Backup(), + backup.Backup(), + ], + next_page_token='abc', + ), + backup.ListBackupsResponse( + backups=[], + next_page_token='def', + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + ], + next_page_token='ghi', + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + backup.Backup(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(backup.ListBackupsResponse.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/backupVaults/sample3'} + + pager = client.list_backups(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, backup.Backup) + for i in results) + + pages = list(client.list_backups(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +def test_delete_backup_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 = NetAppClient( + 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_backup 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_backup] = mock_rpc + + request = {} + client.delete_backup(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_backup(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_backup_rest_required_fields(request_type=backup.DeleteBackupRequest): + transport_class = transports.NetAppRestTransport + + 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_backup._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_backup._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 = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_backup(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_backup_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_backup._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_delete_backup_rest_flattened(): + client = NetAppClient( + 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/backupVaults/sample3/backups/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_backup(**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/*/backupVaults/*/backups/*}" % client.transport._host, args[1]) + + +def test_delete_backup_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_backup( + backup.DeleteBackupRequest(), + name='name_value', + ) + + +def test_update_backup_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 = NetAppClient( + 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_backup 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_backup] = mock_rpc + + request = {} + client.update_backup(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.update_backup(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_backup_rest_required_fields(request_type=gcn_backup.UpdateBackupRequest): + transport_class = transports.NetAppRestTransport + + 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_backup._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_backup._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 = NetAppClient( + 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': "patch", + '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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_backup(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_backup_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_backup._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("updateMask", "backup", ))) + + +def test_update_backup_rest_flattened(): + client = NetAppClient( + 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 = {'backup': {'name': 'projects/sample1/locations/sample2/backupVaults/sample3/backups/sample4'}} + + # get truthy value for each flattened field + mock_args = dict( + backup=gcn_backup.Backup(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 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_backup(**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/{backup.name=projects/*/locations/*/backupVaults/*/backups/*}" % client.transport._host, args[1]) + + +def test_update_backup_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_backup( + gcn_backup.UpdateBackupRequest(), + backup=gcn_backup.Backup(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_create_backup_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 = NetAppClient( + 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_backup_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.create_backup_policy] = mock_rpc + + request = {} + client.create_backup_policy(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_backup_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_create_backup_policy_rest_required_fields(request_type=gcn_backup_policy.CreateBackupPolicyRequest): + transport_class = transports.NetAppRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["backup_policy_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 "backupPolicyId" not in jsonified_request + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_backup_policy._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "backupPolicyId" in jsonified_request + assert jsonified_request["backupPolicyId"] == request_init["backup_policy_id"] + + jsonified_request["parent"] = 'parent_value' + jsonified_request["backupPolicyId"] = 'backup_policy_id_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_backup_policy._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("backup_policy_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 "backupPolicyId" in jsonified_request + assert jsonified_request["backupPolicyId"] == 'backup_policy_id_value' + + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_backup_policy(request) + + expected_params = [ + ( + "backupPolicyId", + "", + ), + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_backup_policy_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_backup_policy._get_unset_required_fields({}) + assert set(unset_fields) == (set(("backupPolicyId", )) & set(("parent", "backupPolicy", "backupPolicyId", ))) + + +def test_create_backup_policy_rest_flattened(): + client = NetAppClient( + 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', + backup_policy=gcn_backup_policy.BackupPolicy(name='name_value'), + backup_policy_id='backup_policy_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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_backup_policy(**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/*}/backupPolicies" % client.transport._host, args[1]) + + +def test_create_backup_policy_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_backup_policy( + gcn_backup_policy.CreateBackupPolicyRequest(), + parent='parent_value', + backup_policy=gcn_backup_policy.BackupPolicy(name='name_value'), + backup_policy_id='backup_policy_id_value', + ) + + +def test_get_backup_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 = NetAppClient( + 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_backup_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_backup_policy] = mock_rpc + + request = {} + client.get_backup_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_backup_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_backup_policy_rest_required_fields(request_type=backup_policy.GetBackupPolicyRequest): + transport_class = transports.NetAppRestTransport + + 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_backup_policy._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_backup_policy._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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = backup_policy.BackupPolicy() + # 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 = backup_policy.BackupPolicy.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_backup_policy(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_backup_policy_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_backup_policy._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_get_backup_policy_rest_flattened(): + client = NetAppClient( + 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 = backup_policy.BackupPolicy() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/backupPolicies/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 = backup_policy.BackupPolicy.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_backup_policy(**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/*/backupPolicies/*}" % client.transport._host, args[1]) + + +def test_get_backup_policy_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_backup_policy( + backup_policy.GetBackupPolicyRequest(), + name='name_value', + ) + + +def test_list_backup_policies_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 = NetAppClient( + 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_backup_policies 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_backup_policies] = mock_rpc + + request = {} + client.list_backup_policies(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_backup_policies(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_backup_policies_rest_required_fields(request_type=backup_policy.ListBackupPoliciesRequest): + transport_class = transports.NetAppRestTransport + + 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_backup_policies._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_backup_policies._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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = backup_policy.ListBackupPoliciesResponse() + # 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 = backup_policy.ListBackupPoliciesResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_backup_policies(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_backup_policies_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_backup_policies._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) + + +def test_list_backup_policies_rest_flattened(): + client = NetAppClient( + 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 = backup_policy.ListBackupPoliciesResponse() + + # 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 = backup_policy.ListBackupPoliciesResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_backup_policies(**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/*}/backupPolicies" % client.transport._host, args[1]) + + +def test_list_backup_policies_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_backup_policies( + backup_policy.ListBackupPoliciesRequest(), + parent='parent_value', + ) + + +def test_list_backup_policies_rest_pager(transport: str = 'rest'): + client = NetAppClient( + 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 = ( + backup_policy.ListBackupPoliciesResponse( + backup_policies=[ + backup_policy.BackupPolicy(), + backup_policy.BackupPolicy(), + backup_policy.BackupPolicy(), + ], + next_page_token='abc', + ), + backup_policy.ListBackupPoliciesResponse( + backup_policies=[], + next_page_token='def', + ), + backup_policy.ListBackupPoliciesResponse( + backup_policies=[ + backup_policy.BackupPolicy(), + ], + next_page_token='ghi', + ), + backup_policy.ListBackupPoliciesResponse( + backup_policies=[ + backup_policy.BackupPolicy(), + backup_policy.BackupPolicy(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(backup_policy.ListBackupPoliciesResponse.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_backup_policies(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, backup_policy.BackupPolicy) + for i in results) + + pages = list(client.list_backup_policies(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +def test_update_backup_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 = NetAppClient( + 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_backup_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.update_backup_policy] = mock_rpc + + request = {} + client.update_backup_policy(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.update_backup_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_update_backup_policy_rest_required_fields(request_type=gcn_backup_policy.UpdateBackupPolicyRequest): + transport_class = transports.NetAppRestTransport + + 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_backup_policy._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_backup_policy._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 = NetAppClient( + 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': "patch", + '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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_backup_policy(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_backup_policy_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_backup_policy._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("updateMask", "backupPolicy", ))) + + +def test_update_backup_policy_rest_flattened(): + client = NetAppClient( + 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 = {'backup_policy': {'name': 'projects/sample1/locations/sample2/backupPolicies/sample3'}} + + # get truthy value for each flattened field + mock_args = dict( + backup_policy=gcn_backup_policy.BackupPolicy(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 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_backup_policy(**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/{backup_policy.name=projects/*/locations/*/backupPolicies/*}" % client.transport._host, args[1]) + + +def test_update_backup_policy_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_backup_policy( + gcn_backup_policy.UpdateBackupPolicyRequest(), + backup_policy=gcn_backup_policy.BackupPolicy(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_delete_backup_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 = NetAppClient( + 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_backup_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.delete_backup_policy] = mock_rpc + + request = {} + client.delete_backup_policy(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_backup_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_delete_backup_policy_rest_required_fields(request_type=backup_policy.DeleteBackupPolicyRequest): + transport_class = transports.NetAppRestTransport + + 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_backup_policy._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_backup_policy._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 = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_backup_policy(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_backup_policy_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_backup_policy._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_delete_backup_policy_rest_flattened(): + client = NetAppClient( + 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/backupPolicies/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_backup_policy(**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/*/backupPolicies/*}" % client.transport._host, args[1]) + + +def test_delete_backup_policy_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_backup_policy( + backup_policy.DeleteBackupPolicyRequest(), + name='name_value', + ) + + +def test_list_quota_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 = NetAppClient( + 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_quota_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_quota_rules] = mock_rpc + + request = {} + client.list_quota_rules(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_quota_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_quota_rules_rest_required_fields(request_type=quota_rule.ListQuotaRulesRequest): + transport_class = transports.NetAppRestTransport + + 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_quota_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_quota_rules._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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = quota_rule.ListQuotaRulesResponse() + # 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 = quota_rule.ListQuotaRulesResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_quota_rules(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_quota_rules_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_quota_rules._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) + + +def test_list_quota_rules_rest_flattened(): + client = NetAppClient( + 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 = quota_rule.ListQuotaRulesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2/volumes/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 = quota_rule.ListQuotaRulesResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_quota_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/*/volumes/*}/quotaRules" % client.transport._host, args[1]) + + +def test_list_quota_rules_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_quota_rules( + quota_rule.ListQuotaRulesRequest(), + parent='parent_value', + ) + + +def test_list_quota_rules_rest_pager(transport: str = 'rest'): + client = NetAppClient( + 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 = ( + quota_rule.ListQuotaRulesResponse( + quota_rules=[ + quota_rule.QuotaRule(), + quota_rule.QuotaRule(), + quota_rule.QuotaRule(), + ], + next_page_token='abc', + ), + quota_rule.ListQuotaRulesResponse( + quota_rules=[], + next_page_token='def', + ), + quota_rule.ListQuotaRulesResponse( + quota_rules=[ + quota_rule.QuotaRule(), + ], + next_page_token='ghi', + ), + quota_rule.ListQuotaRulesResponse( + quota_rules=[ + quota_rule.QuotaRule(), + quota_rule.QuotaRule(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(quota_rule.ListQuotaRulesResponse.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/volumes/sample3'} + + pager = client.list_quota_rules(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, quota_rule.QuotaRule) + for i in results) + + pages = list(client.list_quota_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_quota_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 = NetAppClient( + 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_quota_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_quota_rule] = mock_rpc + + request = {} + client.get_quota_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_quota_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_quota_rule_rest_required_fields(request_type=quota_rule.GetQuotaRuleRequest): + transport_class = transports.NetAppRestTransport + + 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_quota_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_quota_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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = quota_rule.QuotaRule() + # 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 = quota_rule.QuotaRule.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_quota_rule(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_quota_rule_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_quota_rule._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_get_quota_rule_rest_flattened(): + client = NetAppClient( + 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 = quota_rule.QuotaRule() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/volumes/sample3/quotaRules/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 = quota_rule.QuotaRule.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_quota_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/*/volumes/*/quotaRules/*}" % client.transport._host, args[1]) + + +def test_get_quota_rule_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_quota_rule( + quota_rule.GetQuotaRuleRequest(), + name='name_value', + ) + + +def test_create_quota_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 = NetAppClient( + 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_quota_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_quota_rule] = mock_rpc + + request = {} + client.create_quota_rule(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_quota_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_quota_rule_rest_required_fields(request_type=gcn_quota_rule.CreateQuotaRuleRequest): + transport_class = transports.NetAppRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["quota_rule_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 "quotaRuleId" not in jsonified_request + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_quota_rule._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "quotaRuleId" in jsonified_request + assert jsonified_request["quotaRuleId"] == request_init["quota_rule_id"] + + jsonified_request["parent"] = 'parent_value' + jsonified_request["quotaRuleId"] = 'quota_rule_id_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_quota_rule._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("quota_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' + assert "quotaRuleId" in jsonified_request + assert jsonified_request["quotaRuleId"] == 'quota_rule_id_value' + + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_quota_rule(request) + + expected_params = [ + ( + "quotaRuleId", + "", + ), + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_quota_rule_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_quota_rule._get_unset_required_fields({}) + assert set(unset_fields) == (set(("quotaRuleId", )) & set(("parent", "quotaRule", "quotaRuleId", ))) + + +def test_create_quota_rule_rest_flattened(): + client = NetAppClient( + 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/volumes/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + quota_rule=gcn_quota_rule.QuotaRule(name='name_value'), + quota_rule_id='quota_rule_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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_quota_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/*/volumes/*}/quotaRules" % client.transport._host, args[1]) + + +def test_create_quota_rule_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_quota_rule( + gcn_quota_rule.CreateQuotaRuleRequest(), + parent='parent_value', + quota_rule=gcn_quota_rule.QuotaRule(name='name_value'), + quota_rule_id='quota_rule_id_value', + ) + + +def test_update_quota_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 = NetAppClient( + 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_quota_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_quota_rule] = mock_rpc + + request = {} + client.update_quota_rule(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.update_quota_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_quota_rule_rest_required_fields(request_type=gcn_quota_rule.UpdateQuotaRuleRequest): + transport_class = transports.NetAppRestTransport + + 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_quota_rule._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_quota_rule._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 = NetAppClient( + 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': "patch", + '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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_quota_rule(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_quota_rule_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_quota_rule._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("quotaRule", ))) + + +def test_update_quota_rule_rest_flattened(): + client = NetAppClient( + 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 = {'quota_rule': {'name': 'projects/sample1/locations/sample2/volumes/sample3/quotaRules/sample4'}} + + # get truthy value for each flattened field + mock_args = dict( + quota_rule=gcn_quota_rule.QuotaRule(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 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_quota_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/{quota_rule.name=projects/*/locations/*/volumes/*/quotaRules/*}" % client.transport._host, args[1]) + + +def test_update_quota_rule_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_quota_rule( + gcn_quota_rule.UpdateQuotaRuleRequest(), + quota_rule=gcn_quota_rule.QuotaRule(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_delete_quota_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 = NetAppClient( + 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_quota_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_quota_rule] = mock_rpc + + request = {} + client.delete_quota_rule(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_quota_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_quota_rule_rest_required_fields(request_type=quota_rule.DeleteQuotaRuleRequest): + transport_class = transports.NetAppRestTransport + + 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_quota_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_quota_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 = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_quota_rule(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_quota_rule_rest_unset_required_fields(): + transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_quota_rule._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_delete_quota_rule_rest_flattened(): + client = NetAppClient( + 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/volumes/sample3/quotaRules/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_quota_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/*/volumes/*/quotaRules/*}" % client.transport._host, args[1]) + + +def test_delete_quota_rule_rest_flattened_error(transport: str = 'rest'): + client = NetAppClient( + 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_quota_rule( + quota_rule.DeleteQuotaRuleRequest(), + name='name_value', + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.NetAppGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.NetAppGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = NetAppClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.NetAppGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = NetAppClient( + 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 = NetAppClient( + client_options=options, + credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.NetAppGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = NetAppClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.NetAppGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = NetAppClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.NetAppGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.NetAppGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.NetAppGrpcTransport, + transports.NetAppGrpcAsyncIOTransport, + transports.NetAppRestTransport, +]) +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 = NetAppClient.get_transport_class("grpc")( + credentials=ga_credentials.AnonymousCredentials() + ) + assert transport.kind == "grpc" + + +def test_initialize_client_w_grpc(): + client = NetAppClient( + 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_storage_pools_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_storage_pools), + '__call__') as call: + call.return_value = storage_pool.ListStoragePoolsResponse() + client.list_storage_pools(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = storage_pool.ListStoragePoolsRequest() + + assert args[0] == request_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_storage_pool_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_storage_pool), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_storage_pool(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_storage_pool.CreateStoragePoolRequest() + + assert args[0] == request_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_storage_pool_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_storage_pool), + '__call__') as call: + call.return_value = storage_pool.StoragePool() + client.get_storage_pool(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = storage_pool.GetStoragePoolRequest() + + assert args[0] == request_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_storage_pool_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_storage_pool), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_storage_pool(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_storage_pool.UpdateStoragePoolRequest() + + assert args[0] == request_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_storage_pool_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_storage_pool), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_storage_pool(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = storage_pool.DeleteStoragePoolRequest() + + assert args[0] == request_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_validate_directory_service_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.validate_directory_service), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.validate_directory_service(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = storage_pool.ValidateDirectoryServiceRequest() + + assert args[0] == request_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_switch_active_replica_zone_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.switch_active_replica_zone), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.switch_active_replica_zone(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = storage_pool.SwitchActiveReplicaZoneRequest() + + assert args[0] == request_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_volumes_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_volumes), + '__call__') as call: + call.return_value = volume.ListVolumesResponse() + client.list_volumes(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = volume.ListVolumesRequest() + + assert args[0] == request_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_volume_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_volume), + '__call__') as call: + call.return_value = volume.Volume() + client.get_volume(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = volume.GetVolumeRequest() + + assert args[0] == request_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_volume_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_volume), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_volume(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_volume.CreateVolumeRequest() + + assert args[0] == request_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_volume_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_volume), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_volume(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_volume.UpdateVolumeRequest() + + assert args[0] == request_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_volume_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_volume), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_volume(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = volume.DeleteVolumeRequest() + + assert args[0] == request_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_revert_volume_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.revert_volume), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.revert_volume(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = volume.RevertVolumeRequest() + + assert args[0] == request_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_snapshots_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_snapshots), + '__call__') as call: + call.return_value = snapshot.ListSnapshotsResponse() + client.list_snapshots(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = snapshot.ListSnapshotsRequest() + + assert args[0] == request_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_snapshot_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_snapshot), + '__call__') as call: + call.return_value = snapshot.Snapshot() + client.get_snapshot(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = snapshot.GetSnapshotRequest() + + assert args[0] == request_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_snapshot_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_snapshot), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_snapshot(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_snapshot.CreateSnapshotRequest() + + assert args[0] == request_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_snapshot_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_snapshot), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_snapshot(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = snapshot.DeleteSnapshotRequest() + + assert args[0] == request_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_snapshot_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_snapshot), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_snapshot(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_snapshot.UpdateSnapshotRequest() + + assert args[0] == request_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_active_directories_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_active_directories), + '__call__') as call: + call.return_value = active_directory.ListActiveDirectoriesResponse() + client.list_active_directories(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = active_directory.ListActiveDirectoriesRequest() + + assert args[0] == request_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_active_directory_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_active_directory), + '__call__') as call: + call.return_value = active_directory.ActiveDirectory() + client.get_active_directory(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = active_directory.GetActiveDirectoryRequest() + + assert args[0] == request_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_active_directory_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_active_directory), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_active_directory(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_active_directory.CreateActiveDirectoryRequest() + + assert args[0] == request_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_active_directory_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_active_directory), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_active_directory(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_active_directory.UpdateActiveDirectoryRequest() + + assert args[0] == request_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_active_directory_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_active_directory), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_active_directory(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = active_directory.DeleteActiveDirectoryRequest() + + assert args[0] == request_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_kms_configs_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_kms_configs), + '__call__') as call: + call.return_value = kms.ListKmsConfigsResponse() + client.list_kms_configs(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = kms.ListKmsConfigsRequest() + + assert args[0] == request_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_kms_config_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_kms_config), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_kms_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = kms.CreateKmsConfigRequest() + + assert args[0] == request_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_kms_config_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_kms_config), + '__call__') as call: + call.return_value = kms.KmsConfig() + client.get_kms_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = kms.GetKmsConfigRequest() + + assert args[0] == request_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_kms_config_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_kms_config), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_kms_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = kms.UpdateKmsConfigRequest() + + assert args[0] == request_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_encrypt_volumes_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.encrypt_volumes), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.encrypt_volumes(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = kms.EncryptVolumesRequest() + + assert args[0] == request_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_verify_kms_config_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.verify_kms_config), + '__call__') as call: + call.return_value = kms.VerifyKmsConfigResponse() + client.verify_kms_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = kms.VerifyKmsConfigRequest() + + assert args[0] == request_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_kms_config_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_kms_config), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_kms_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = kms.DeleteKmsConfigRequest() + + assert args[0] == request_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_replications_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_replications), + '__call__') as call: + call.return_value = replication.ListReplicationsResponse() + client.list_replications(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.ListReplicationsRequest() + + assert args[0] == request_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_replication_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_replication), + '__call__') as call: + call.return_value = replication.Replication() + client.get_replication(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.GetReplicationRequest() + + assert args[0] == request_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_replication_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_replication), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_replication(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_replication.CreateReplicationRequest() + + assert args[0] == request_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_replication_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_replication), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_replication(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.DeleteReplicationRequest() + + assert args[0] == request_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_replication_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_replication), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_replication(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_replication.UpdateReplicationRequest() + + assert args[0] == request_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_stop_replication_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.stop_replication), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.stop_replication(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.StopReplicationRequest() + + assert args[0] == request_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_resume_replication_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.resume_replication), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.resume_replication(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.ResumeReplicationRequest() + + assert args[0] == request_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_reverse_replication_direction_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.reverse_replication_direction), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.reverse_replication_direction(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.ReverseReplicationDirectionRequest() + + assert args[0] == request_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_establish_peering_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.establish_peering), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.establish_peering(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.EstablishPeeringRequest() + + assert args[0] == request_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_sync_replication_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.sync_replication), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.sync_replication(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.SyncReplicationRequest() + + assert args[0] == request_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_backup_vault_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_backup_vault), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_backup_vault(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_backup_vault.CreateBackupVaultRequest() + + assert args[0] == request_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_backup_vault_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_backup_vault), + '__call__') as call: + call.return_value = backup_vault.BackupVault() + client.get_backup_vault(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup_vault.GetBackupVaultRequest() + + assert args[0] == request_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_backup_vaults_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_backup_vaults), + '__call__') as call: + call.return_value = backup_vault.ListBackupVaultsResponse() + client.list_backup_vaults(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup_vault.ListBackupVaultsRequest() + + assert args[0] == request_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_backup_vault_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_backup_vault), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_backup_vault(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_backup_vault.UpdateBackupVaultRequest() + + assert args[0] == request_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_backup_vault_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup_vault), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_backup_vault(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup_vault.DeleteBackupVaultRequest() + + assert args[0] == request_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_backup_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_backup), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_backup(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_backup.CreateBackupRequest() + + assert args[0] == request_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_backup_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_backup), + '__call__') as call: + call.return_value = backup.Backup() + client.get_backup(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup.GetBackupRequest() + + assert args[0] == request_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_backups_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_backups), + '__call__') as call: + call.return_value = backup.ListBackupsResponse() + client.list_backups(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup.ListBackupsRequest() + + assert args[0] == request_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_backup_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_backup(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup.DeleteBackupRequest() + + assert args[0] == request_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_backup_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_backup), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_backup(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_backup.UpdateBackupRequest() + + assert args[0] == request_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_backup_policy_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_backup_policy), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_backup_policy(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_backup_policy.CreateBackupPolicyRequest() + + assert args[0] == request_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_backup_policy_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_backup_policy), + '__call__') as call: + call.return_value = backup_policy.BackupPolicy() + client.get_backup_policy(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup_policy.GetBackupPolicyRequest() + + assert args[0] == request_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_backup_policies_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_backup_policies), + '__call__') as call: + call.return_value = backup_policy.ListBackupPoliciesResponse() + client.list_backup_policies(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup_policy.ListBackupPoliciesRequest() + + assert args[0] == request_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_backup_policy_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_backup_policy), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_backup_policy(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_backup_policy.UpdateBackupPolicyRequest() + + assert args[0] == request_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_backup_policy_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup_policy), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_backup_policy(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup_policy.DeleteBackupPolicyRequest() + + assert args[0] == request_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_quota_rules_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_quota_rules), + '__call__') as call: + call.return_value = quota_rule.ListQuotaRulesResponse() + client.list_quota_rules(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = quota_rule.ListQuotaRulesRequest() + + assert args[0] == request_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_quota_rule_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_quota_rule), + '__call__') as call: + call.return_value = quota_rule.QuotaRule() + client.get_quota_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = quota_rule.GetQuotaRuleRequest() + + assert args[0] == request_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_quota_rule_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_quota_rule), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_quota_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_quota_rule.CreateQuotaRuleRequest() + + assert args[0] == request_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_quota_rule_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_quota_rule), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_quota_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_quota_rule.UpdateQuotaRuleRequest() + + assert args[0] == request_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_quota_rule_empty_call_grpc(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_quota_rule), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_quota_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = quota_rule.DeleteQuotaRuleRequest() + + assert args[0] == request_msg + + +def test_transport_kind_grpc_asyncio(): + transport = NetAppAsyncClient.get_transport_class("grpc_asyncio")( + credentials=async_anonymous_credentials() + ) + assert transport.kind == "grpc_asyncio" + + +def test_initialize_client_w_grpc_asyncio(): + client = NetAppAsyncClient( + 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_storage_pools_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_storage_pools), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(storage_pool.ListStoragePoolsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + await client.list_storage_pools(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = storage_pool.ListStoragePoolsRequest() + + assert args[0] == request_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_storage_pool_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_storage_pool), + '__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_storage_pool(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_storage_pool.CreateStoragePoolRequest() + + assert args[0] == request_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_storage_pool_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_storage_pool), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(storage_pool.StoragePool( + name='name_value', + service_level=common.ServiceLevel.PREMIUM, + capacity_gib=1247, + volume_capacity_gib=2006, + volume_count=1312, + state=storage_pool.StoragePool.State.READY, + state_details='state_details_value', + description='description_value', + network='network_value', + active_directory='active_directory_value', + kms_config='kms_config_value', + ldap_enabled=True, + psa_range='psa_range_value', + encryption_type=common.EncryptionType.SERVICE_MANAGED, + global_access_allowed=True, + allow_auto_tiering=True, + replica_zone='replica_zone_value', + zone='zone_value', + satisfies_pzs=True, + satisfies_pzi=True, + )) + await client.get_storage_pool(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = storage_pool.GetStoragePoolRequest() + + assert args[0] == request_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_storage_pool_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_storage_pool), + '__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.update_storage_pool(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_storage_pool.UpdateStoragePoolRequest() + + assert args[0] == request_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_storage_pool_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_storage_pool), + '__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_storage_pool(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = storage_pool.DeleteStoragePoolRequest() + + assert args[0] == request_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_validate_directory_service_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.validate_directory_service), + '__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.validate_directory_service(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = storage_pool.ValidateDirectoryServiceRequest() + + assert args[0] == request_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_switch_active_replica_zone_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.switch_active_replica_zone), + '__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.switch_active_replica_zone(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = storage_pool.SwitchActiveReplicaZoneRequest() + + assert args[0] == request_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_volumes_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_volumes), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(volume.ListVolumesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + await client.list_volumes(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = volume.ListVolumesRequest() + + assert args[0] == request_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_volume_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_volume), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(volume.Volume( + name='name_value', + state=volume.Volume.State.READY, + state_details='state_details_value', + share_name='share_name_value', + psa_range='psa_range_value', + storage_pool='storage_pool_value', + network='network_value', + service_level=common.ServiceLevel.PREMIUM, + capacity_gib=1247, + protocols=[volume.Protocols.NFSV3], + smb_settings=[volume.SMBSettings.ENCRYPT_DATA], + unix_permissions='unix_permissions_value', + description='description_value', + snap_reserve=0.1293, + snapshot_directory=True, + used_gib=834, + security_style=volume.SecurityStyle.NTFS, + kerberos_enabled=True, + ldap_enabled=True, + active_directory='active_directory_value', + kms_config='kms_config_value', + encryption_type=common.EncryptionType.SERVICE_MANAGED, + has_replication=True, + restricted_actions=[volume.RestrictedAction.DELETE], + large_capacity=True, + multiple_endpoints=True, + replica_zone='replica_zone_value', + zone='zone_value', + cold_tier_size_gib=1888, + )) + await client.get_volume(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = volume.GetVolumeRequest() + + assert args[0] == request_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_volume_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_volume), + '__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_volume(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_volume.CreateVolumeRequest() + + assert args[0] == request_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_volume_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_volume), + '__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.update_volume(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_volume.UpdateVolumeRequest() + + assert args[0] == request_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_volume_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_volume), + '__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_volume(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = volume.DeleteVolumeRequest() + + assert args[0] == request_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_revert_volume_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.revert_volume), + '__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.revert_volume(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = volume.RevertVolumeRequest() + + assert args[0] == request_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_snapshots_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_snapshots), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(snapshot.ListSnapshotsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + await client.list_snapshots(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = snapshot.ListSnapshotsRequest() + + assert args[0] == request_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_snapshot_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_snapshot), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(snapshot.Snapshot( + name='name_value', + state=snapshot.Snapshot.State.READY, + state_details='state_details_value', + description='description_value', + used_bytes=0.10790000000000001, + )) + await client.get_snapshot(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = snapshot.GetSnapshotRequest() + + assert args[0] == request_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_snapshot_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_snapshot), + '__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_snapshot(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_snapshot.CreateSnapshotRequest() + + assert args[0] == request_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_snapshot_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_snapshot), + '__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_snapshot(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = snapshot.DeleteSnapshotRequest() + + assert args[0] == request_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_snapshot_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_snapshot), + '__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.update_snapshot(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_snapshot.UpdateSnapshotRequest() + + assert args[0] == request_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_active_directories_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_active_directories), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(active_directory.ListActiveDirectoriesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + await client.list_active_directories(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = active_directory.ListActiveDirectoriesRequest() + + assert args[0] == request_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_active_directory_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_active_directory), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(active_directory.ActiveDirectory( + name='name_value', + state=active_directory.ActiveDirectory.State.CREATING, + domain='domain_value', + site='site_value', + dns='dns_value', + net_bios_prefix='net_bios_prefix_value', + organizational_unit='organizational_unit_value', + aes_encryption=True, + username='username_value', + password='password_value', + backup_operators=['backup_operators_value'], + administrators=['administrators_value'], + security_operators=['security_operators_value'], + kdc_hostname='kdc_hostname_value', + kdc_ip='kdc_ip_value', + nfs_users_with_ldap=True, + description='description_value', + ldap_signing=True, + encrypt_dc_connections=True, + state_details='state_details_value', + )) + await client.get_active_directory(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = active_directory.GetActiveDirectoryRequest() + + assert args[0] == request_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_active_directory_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_active_directory), + '__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_active_directory(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_active_directory.CreateActiveDirectoryRequest() + + assert args[0] == request_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_active_directory_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_active_directory), + '__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.update_active_directory(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_active_directory.UpdateActiveDirectoryRequest() + + assert args[0] == request_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_active_directory_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_active_directory), + '__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_active_directory(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = active_directory.DeleteActiveDirectoryRequest() + + assert args[0] == request_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_kms_configs_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_kms_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(kms.ListKmsConfigsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + await client.list_kms_configs(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = kms.ListKmsConfigsRequest() + + assert args[0] == request_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_kms_config_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_kms_config), + '__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_kms_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = kms.CreateKmsConfigRequest() + + assert args[0] == request_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_kms_config_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_kms_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(kms.KmsConfig( + name='name_value', + crypto_key_name='crypto_key_name_value', + state=kms.KmsConfig.State.READY, + state_details='state_details_value', + description='description_value', + instructions='instructions_value', + service_account='service_account_value', + )) + await client.get_kms_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = kms.GetKmsConfigRequest() + + assert args[0] == request_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_kms_config_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_kms_config), + '__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.update_kms_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = kms.UpdateKmsConfigRequest() + + assert args[0] == request_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_encrypt_volumes_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.encrypt_volumes), + '__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.encrypt_volumes(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = kms.EncryptVolumesRequest() + + assert args[0] == request_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_verify_kms_config_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.verify_kms_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(kms.VerifyKmsConfigResponse( + healthy=True, + health_error='health_error_value', + instructions='instructions_value', + )) + await client.verify_kms_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = kms.VerifyKmsConfigRequest() + + assert args[0] == request_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_kms_config_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_kms_config), + '__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_kms_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = kms.DeleteKmsConfigRequest() + + assert args[0] == request_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_replications_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_replications), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(replication.ListReplicationsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + await client.list_replications(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.ListReplicationsRequest() + + assert args[0] == request_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_replication_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_replication), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(replication.Replication( + name='name_value', + state=replication.Replication.State.CREATING, + state_details='state_details_value', + role=replication.Replication.ReplicationRole.SOURCE, + replication_schedule=replication.Replication.ReplicationSchedule.EVERY_10_MINUTES, + mirror_state=replication.Replication.MirrorState.PREPARING, + healthy=True, + destination_volume='destination_volume_value', + description='description_value', + source_volume='source_volume_value', + cluster_location='cluster_location_value', + hybrid_replication_type=replication.Replication.HybridReplicationType.MIGRATION, + )) + await client.get_replication(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.GetReplicationRequest() + + assert args[0] == request_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_replication_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_replication), + '__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_replication(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_replication.CreateReplicationRequest() + + assert args[0] == request_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_replication_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_replication), + '__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_replication(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.DeleteReplicationRequest() + + assert args[0] == request_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_replication_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_replication), + '__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.update_replication(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_replication.UpdateReplicationRequest() + + assert args[0] == request_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_stop_replication_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.stop_replication), + '__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.stop_replication(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.StopReplicationRequest() + + assert args[0] == request_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_resume_replication_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.resume_replication), + '__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.resume_replication(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.ResumeReplicationRequest() + + assert args[0] == request_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_reverse_replication_direction_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.reverse_replication_direction), + '__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.reverse_replication_direction(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.ReverseReplicationDirectionRequest() + + assert args[0] == request_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_establish_peering_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.establish_peering), + '__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.establish_peering(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.EstablishPeeringRequest() + + assert args[0] == request_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_sync_replication_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.sync_replication), + '__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.sync_replication(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.SyncReplicationRequest() + + assert args[0] == request_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_backup_vault_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_backup_vault), + '__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_backup_vault(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_backup_vault.CreateBackupVaultRequest() + + assert args[0] == request_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_backup_vault_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_backup_vault), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_vault.BackupVault( + name='name_value', + state=backup_vault.BackupVault.State.CREATING, + description='description_value', + )) + await client.get_backup_vault(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup_vault.GetBackupVaultRequest() + + assert args[0] == request_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_backup_vaults_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_backup_vaults), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_vault.ListBackupVaultsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + await client.list_backup_vaults(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup_vault.ListBackupVaultsRequest() + + assert args[0] == request_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_backup_vault_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_backup_vault), + '__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.update_backup_vault(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_backup_vault.UpdateBackupVaultRequest() + + assert args[0] == request_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_backup_vault_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup_vault), + '__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_backup_vault(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup_vault.DeleteBackupVaultRequest() + + assert args[0] == request_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_backup_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_backup), + '__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_backup(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_backup.CreateBackupRequest() + + assert args[0] == request_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_backup_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_backup), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup.Backup( + name='name_value', + state=backup.Backup.State.CREATING, + description='description_value', + volume_usage_bytes=1938, + backup_type=backup.Backup.Type.MANUAL, + source_volume='source_volume_value', + source_snapshot='source_snapshot_value', + chain_storage_bytes=2013, + satisfies_pzs=True, + satisfies_pzi=True, + )) + await client.get_backup(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup.GetBackupRequest() + + assert args[0] == request_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_backups_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_backups), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup.ListBackupsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + await client.list_backups(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup.ListBackupsRequest() + + assert args[0] == request_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_backup_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup), + '__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_backup(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup.DeleteBackupRequest() + + assert args[0] == request_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_backup_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_backup), + '__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.update_backup(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_backup.UpdateBackupRequest() + + assert args[0] == request_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_backup_policy_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_backup_policy), + '__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_backup_policy(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_backup_policy.CreateBackupPolicyRequest() + + assert args[0] == request_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_backup_policy_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_backup_policy), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_policy.BackupPolicy( + name='name_value', + daily_backup_limit=1894, + weekly_backup_limit=2020, + monthly_backup_limit=2142, + description='description_value', + enabled=True, + assigned_volume_count=2253, + state=backup_policy.BackupPolicy.State.CREATING, + )) + await client.get_backup_policy(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup_policy.GetBackupPolicyRequest() + + assert args[0] == request_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_backup_policies_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_backup_policies), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_policy.ListBackupPoliciesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + await client.list_backup_policies(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup_policy.ListBackupPoliciesRequest() + + assert args[0] == request_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_backup_policy_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_backup_policy), + '__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.update_backup_policy(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_backup_policy.UpdateBackupPolicyRequest() + + assert args[0] == request_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_backup_policy_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup_policy), + '__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_backup_policy(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup_policy.DeleteBackupPolicyRequest() + + assert args[0] == request_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_quota_rules_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_quota_rules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(quota_rule.ListQuotaRulesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + await client.list_quota_rules(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = quota_rule.ListQuotaRulesRequest() + + assert args[0] == request_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_quota_rule_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_quota_rule), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(quota_rule.QuotaRule( + name='name_value', + target='target_value', + type_=quota_rule.QuotaRule.Type.INDIVIDUAL_USER_QUOTA, + disk_limit_mib=1472, + state=quota_rule.QuotaRule.State.CREATING, + state_details='state_details_value', + description='description_value', + )) + await client.get_quota_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = quota_rule.GetQuotaRuleRequest() + + assert args[0] == request_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_quota_rule_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_quota_rule), + '__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_quota_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_quota_rule.CreateQuotaRuleRequest() + + assert args[0] == request_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_quota_rule_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_quota_rule), + '__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.update_quota_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_quota_rule.UpdateQuotaRuleRequest() + + assert args[0] == request_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_quota_rule_empty_call_grpc_asyncio(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_quota_rule), + '__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_quota_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = quota_rule.DeleteQuotaRuleRequest() + + assert args[0] == request_msg + + +def test_transport_kind_rest(): + transport = NetAppClient.get_transport_class("rest")( + credentials=ga_credentials.AnonymousCredentials() + ) + assert transport.kind == "rest" + + +def test_list_storage_pools_rest_bad_request(request_type=storage_pool.ListStoragePoolsRequest): + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_storage_pools(request) + + +@pytest.mark.parametrize("request_type", [ + storage_pool.ListStoragePoolsRequest, + dict, +]) +def test_list_storage_pools_rest_call_success(request_type): + client = NetAppClient( + 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 = storage_pool.ListStoragePoolsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_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 = storage_pool.ListStoragePoolsResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_storage_pools(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListStoragePoolsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_storage_pools_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_list_storage_pools") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_list_storage_pools_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_list_storage_pools") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = storage_pool.ListStoragePoolsRequest.pb(storage_pool.ListStoragePoolsRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = storage_pool.ListStoragePoolsResponse.to_json(storage_pool.ListStoragePoolsResponse()) + req.return_value.content = return_value + + request = storage_pool.ListStoragePoolsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = storage_pool.ListStoragePoolsResponse() + post_with_metadata.return_value = storage_pool.ListStoragePoolsResponse(), metadata + + client.list_storage_pools(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_storage_pool_rest_bad_request(request_type=gcn_storage_pool.CreateStoragePoolRequest): + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_storage_pool(request) + + +@pytest.mark.parametrize("request_type", [ + gcn_storage_pool.CreateStoragePoolRequest, + dict, +]) +def test_create_storage_pool_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["storage_pool"] = {'name': 'name_value', 'service_level': 1, 'capacity_gib': 1247, 'volume_capacity_gib': 2006, 'volume_count': 1312, 'state': 1, 'state_details': 'state_details_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'description': 'description_value', 'labels': {}, 'network': 'network_value', 'active_directory': 'active_directory_value', 'kms_config': 'kms_config_value', 'ldap_enabled': True, 'psa_range': 'psa_range_value', 'encryption_type': 1, 'global_access_allowed': True, 'allow_auto_tiering': True, 'replica_zone': 'replica_zone_value', 'zone': 'zone_value', 'satisfies_pzs': 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 = gcn_storage_pool.CreateStoragePoolRequest.meta.fields["storage_pool"] + + 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["storage_pool"].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["storage_pool"][field])): + del request_init["storage_pool"][field][i][subfield] + else: + del request_init["storage_pool"][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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_storage_pool(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_storage_pool_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_create_storage_pool") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_create_storage_pool_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_create_storage_pool") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = gcn_storage_pool.CreateStoragePoolRequest.pb(gcn_storage_pool.CreateStoragePoolRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = gcn_storage_pool.CreateStoragePoolRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_storage_pool(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_storage_pool_rest_bad_request(request_type=storage_pool.GetStoragePoolRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/storagePools/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_storage_pool(request) + + +@pytest.mark.parametrize("request_type", [ + storage_pool.GetStoragePoolRequest, + dict, +]) +def test_get_storage_pool_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/storagePools/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 = storage_pool.StoragePool( + name='name_value', + service_level=common.ServiceLevel.PREMIUM, + capacity_gib=1247, + volume_capacity_gib=2006, + volume_count=1312, + state=storage_pool.StoragePool.State.READY, + state_details='state_details_value', + description='description_value', + network='network_value', + active_directory='active_directory_value', + kms_config='kms_config_value', + ldap_enabled=True, + psa_range='psa_range_value', + encryption_type=common.EncryptionType.SERVICE_MANAGED, + global_access_allowed=True, + allow_auto_tiering=True, + replica_zone='replica_zone_value', + zone='zone_value', + satisfies_pzs=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 = storage_pool.StoragePool.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_storage_pool(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, storage_pool.StoragePool) + assert response.name == 'name_value' + assert response.service_level == common.ServiceLevel.PREMIUM + assert response.capacity_gib == 1247 + assert response.volume_capacity_gib == 2006 + assert response.volume_count == 1312 + assert response.state == storage_pool.StoragePool.State.READY + assert response.state_details == 'state_details_value' + assert response.description == 'description_value' + assert response.network == 'network_value' + assert response.active_directory == 'active_directory_value' + assert response.kms_config == 'kms_config_value' + assert response.ldap_enabled is True + assert response.psa_range == 'psa_range_value' + assert response.encryption_type == common.EncryptionType.SERVICE_MANAGED + assert response.global_access_allowed is True + assert response.allow_auto_tiering is True + assert response.replica_zone == 'replica_zone_value' + assert response.zone == 'zone_value' + assert response.satisfies_pzs is True + assert response.satisfies_pzi is True + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_storage_pool_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_get_storage_pool") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_get_storage_pool_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_get_storage_pool") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = storage_pool.GetStoragePoolRequest.pb(storage_pool.GetStoragePoolRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = storage_pool.StoragePool.to_json(storage_pool.StoragePool()) + req.return_value.content = return_value + + request = storage_pool.GetStoragePoolRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = storage_pool.StoragePool() + post_with_metadata.return_value = storage_pool.StoragePool(), metadata + + client.get_storage_pool(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_update_storage_pool_rest_bad_request(request_type=gcn_storage_pool.UpdateStoragePoolRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'storage_pool': {'name': 'projects/sample1/locations/sample2/storagePools/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_storage_pool(request) + + +@pytest.mark.parametrize("request_type", [ + gcn_storage_pool.UpdateStoragePoolRequest, + dict, +]) +def test_update_storage_pool_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'storage_pool': {'name': 'projects/sample1/locations/sample2/storagePools/sample3'}} + request_init["storage_pool"] = {'name': 'projects/sample1/locations/sample2/storagePools/sample3', 'service_level': 1, 'capacity_gib': 1247, 'volume_capacity_gib': 2006, 'volume_count': 1312, 'state': 1, 'state_details': 'state_details_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'description': 'description_value', 'labels': {}, 'network': 'network_value', 'active_directory': 'active_directory_value', 'kms_config': 'kms_config_value', 'ldap_enabled': True, 'psa_range': 'psa_range_value', 'encryption_type': 1, 'global_access_allowed': True, 'allow_auto_tiering': True, 'replica_zone': 'replica_zone_value', 'zone': 'zone_value', 'satisfies_pzs': 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 = gcn_storage_pool.UpdateStoragePoolRequest.meta.fields["storage_pool"] + + 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["storage_pool"].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["storage_pool"][field])): + del request_init["storage_pool"][field][i][subfield] + else: + del request_init["storage_pool"][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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_storage_pool(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_update_storage_pool_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_update_storage_pool") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_update_storage_pool_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_update_storage_pool") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = gcn_storage_pool.UpdateStoragePoolRequest.pb(gcn_storage_pool.UpdateStoragePoolRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = gcn_storage_pool.UpdateStoragePoolRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.update_storage_pool(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_storage_pool_rest_bad_request(request_type=storage_pool.DeleteStoragePoolRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/storagePools/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_storage_pool(request) + + +@pytest.mark.parametrize("request_type", [ + storage_pool.DeleteStoragePoolRequest, + dict, +]) +def test_delete_storage_pool_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/storagePools/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_storage_pool(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_storage_pool_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_delete_storage_pool") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_delete_storage_pool_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_delete_storage_pool") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = storage_pool.DeleteStoragePoolRequest.pb(storage_pool.DeleteStoragePoolRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = storage_pool.DeleteStoragePoolRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.delete_storage_pool(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_validate_directory_service_rest_bad_request(request_type=storage_pool.ValidateDirectoryServiceRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/storagePools/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.validate_directory_service(request) + + +@pytest.mark.parametrize("request_type", [ + storage_pool.ValidateDirectoryServiceRequest, + dict, +]) +def test_validate_directory_service_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/storagePools/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.validate_directory_service(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_validate_directory_service_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_validate_directory_service") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_validate_directory_service_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_validate_directory_service") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = storage_pool.ValidateDirectoryServiceRequest.pb(storage_pool.ValidateDirectoryServiceRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = storage_pool.ValidateDirectoryServiceRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.validate_directory_service(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_switch_active_replica_zone_rest_bad_request(request_type=storage_pool.SwitchActiveReplicaZoneRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/storagePools/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.switch_active_replica_zone(request) + + +@pytest.mark.parametrize("request_type", [ + storage_pool.SwitchActiveReplicaZoneRequest, + dict, +]) +def test_switch_active_replica_zone_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/storagePools/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.switch_active_replica_zone(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_switch_active_replica_zone_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_switch_active_replica_zone") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_switch_active_replica_zone_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_switch_active_replica_zone") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = storage_pool.SwitchActiveReplicaZoneRequest.pb(storage_pool.SwitchActiveReplicaZoneRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = storage_pool.SwitchActiveReplicaZoneRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.switch_active_replica_zone(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_volumes_rest_bad_request(request_type=volume.ListVolumesRequest): + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_volumes(request) + + +@pytest.mark.parametrize("request_type", [ + volume.ListVolumesRequest, + dict, +]) +def test_list_volumes_rest_call_success(request_type): + client = NetAppClient( + 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 = volume.ListVolumesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_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 = volume.ListVolumesResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_volumes(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListVolumesPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_volumes_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_list_volumes") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_list_volumes_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_list_volumes") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = volume.ListVolumesRequest.pb(volume.ListVolumesRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = volume.ListVolumesResponse.to_json(volume.ListVolumesResponse()) + req.return_value.content = return_value + + request = volume.ListVolumesRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = volume.ListVolumesResponse() + post_with_metadata.return_value = volume.ListVolumesResponse(), metadata + + client.list_volumes(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_volume_rest_bad_request(request_type=volume.GetVolumeRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_volume(request) + + +@pytest.mark.parametrize("request_type", [ + volume.GetVolumeRequest, + dict, +]) +def test_get_volume_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/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 = volume.Volume( + name='name_value', + state=volume.Volume.State.READY, + state_details='state_details_value', + share_name='share_name_value', + psa_range='psa_range_value', + storage_pool='storage_pool_value', + network='network_value', + service_level=common.ServiceLevel.PREMIUM, + capacity_gib=1247, + protocols=[volume.Protocols.NFSV3], + smb_settings=[volume.SMBSettings.ENCRYPT_DATA], + unix_permissions='unix_permissions_value', + description='description_value', + snap_reserve=0.1293, + snapshot_directory=True, + used_gib=834, + security_style=volume.SecurityStyle.NTFS, + kerberos_enabled=True, + ldap_enabled=True, + active_directory='active_directory_value', + kms_config='kms_config_value', + encryption_type=common.EncryptionType.SERVICE_MANAGED, + has_replication=True, + restricted_actions=[volume.RestrictedAction.DELETE], + large_capacity=True, + multiple_endpoints=True, + replica_zone='replica_zone_value', + zone='zone_value', + cold_tier_size_gib=1888, + ) + + # 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 = volume.Volume.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_volume(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, volume.Volume) + assert response.name == 'name_value' + assert response.state == volume.Volume.State.READY + assert response.state_details == 'state_details_value' + assert response.share_name == 'share_name_value' + assert response.psa_range == 'psa_range_value' + assert response.storage_pool == 'storage_pool_value' + assert response.network == 'network_value' + assert response.service_level == common.ServiceLevel.PREMIUM + assert response.capacity_gib == 1247 + assert response.protocols == [volume.Protocols.NFSV3] + assert response.smb_settings == [volume.SMBSettings.ENCRYPT_DATA] + assert response.unix_permissions == 'unix_permissions_value' + assert response.description == 'description_value' + assert math.isclose(response.snap_reserve, 0.1293, rel_tol=1e-6) + assert response.snapshot_directory is True + assert response.used_gib == 834 + assert response.security_style == volume.SecurityStyle.NTFS + assert response.kerberos_enabled is True + assert response.ldap_enabled is True + assert response.active_directory == 'active_directory_value' + assert response.kms_config == 'kms_config_value' + assert response.encryption_type == common.EncryptionType.SERVICE_MANAGED + assert response.has_replication is True + assert response.restricted_actions == [volume.RestrictedAction.DELETE] + assert response.large_capacity is True + assert response.multiple_endpoints is True + assert response.replica_zone == 'replica_zone_value' + assert response.zone == 'zone_value' + assert response.cold_tier_size_gib == 1888 + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_volume_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_get_volume") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_get_volume_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_get_volume") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = volume.GetVolumeRequest.pb(volume.GetVolumeRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = volume.Volume.to_json(volume.Volume()) + req.return_value.content = return_value + + request = volume.GetVolumeRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = volume.Volume() + post_with_metadata.return_value = volume.Volume(), metadata + + client.get_volume(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_volume_rest_bad_request(request_type=gcn_volume.CreateVolumeRequest): + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_volume(request) + + +@pytest.mark.parametrize("request_type", [ + gcn_volume.CreateVolumeRequest, + dict, +]) +def test_create_volume_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["volume"] = {'name': 'name_value', 'state': 1, 'state_details': 'state_details_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'share_name': 'share_name_value', 'psa_range': 'psa_range_value', 'storage_pool': 'storage_pool_value', 'network': 'network_value', 'service_level': 1, 'capacity_gib': 1247, 'export_policy': {'rules': [{'allowed_clients': 'allowed_clients_value', 'has_root_access': 'has_root_access_value', 'access_type': 1, 'nfsv3': True, 'nfsv4': True, 'kerberos_5_read_only': True, 'kerberos_5_read_write': True, 'kerberos_5i_read_only': True, 'kerberos_5i_read_write': True, 'kerberos_5p_read_only': True, 'kerberos_5p_read_write': True}]}, 'protocols': [1], 'smb_settings': [1], 'mount_options': [{'export': 'export_value', 'export_full': 'export_full_value', 'protocol': 1, 'instructions': 'instructions_value', 'ip_address': 'ip_address_value'}], 'unix_permissions': 'unix_permissions_value', 'labels': {}, 'description': 'description_value', 'snapshot_policy': {'enabled': True, 'hourly_schedule': {'snapshots_to_keep': 0.18330000000000002, 'minute': 0.658}, 'daily_schedule': {'snapshots_to_keep': 0.18330000000000002, 'minute': 0.658, 'hour': 0.446}, 'weekly_schedule': {'snapshots_to_keep': 0.18330000000000002, 'minute': 0.658, 'hour': 0.446, 'day': 'day_value'}, 'monthly_schedule': {'snapshots_to_keep': 0.18330000000000002, 'minute': 0.658, 'hour': 0.446, 'days_of_month': 'days_of_month_value'}}, 'snap_reserve': 0.1293, 'snapshot_directory': True, 'used_gib': 834, 'security_style': 1, 'kerberos_enabled': True, 'ldap_enabled': True, 'active_directory': 'active_directory_value', 'restore_parameters': {'source_snapshot': 'source_snapshot_value', 'source_backup': 'source_backup_value'}, 'kms_config': 'kms_config_value', 'encryption_type': 1, 'has_replication': True, 'backup_config': {'backup_policies': ['backup_policies_value1', 'backup_policies_value2'], 'backup_vault': 'backup_vault_value', 'scheduled_backup_enabled': True, 'backup_chain_bytes': 1886}, 'restricted_actions': [1], 'large_capacity': True, 'multiple_endpoints': True, 'tiering_policy': {'tier_action': 1, 'cooling_threshold_days': 2343}, 'replica_zone': 'replica_zone_value', 'zone': 'zone_value', 'cold_tier_size_gib': 1888, 'hybrid_replication_parameters': {'replication': 'replication_value', 'peer_volume_name': 'peer_volume_name_value', 'peer_cluster_name': 'peer_cluster_name_value', 'peer_svm_name': 'peer_svm_name_value', 'peer_ip_addresses': ['peer_ip_addresses_value1', 'peer_ip_addresses_value2'], 'cluster_location': 'cluster_location_value', 'description': 'description_value', 'labels': {}}} + # 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 = gcn_volume.CreateVolumeRequest.meta.fields["volume"] + + 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["volume"].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["volume"][field])): + del request_init["volume"][field][i][subfield] + else: + del request_init["volume"][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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_volume(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_volume_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_create_volume") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_create_volume_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_create_volume") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = gcn_volume.CreateVolumeRequest.pb(gcn_volume.CreateVolumeRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = gcn_volume.CreateVolumeRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_volume(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_update_volume_rest_bad_request(request_type=gcn_volume.UpdateVolumeRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'volume': {'name': 'projects/sample1/locations/sample2/volumes/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_volume(request) + + +@pytest.mark.parametrize("request_type", [ + gcn_volume.UpdateVolumeRequest, + dict, +]) +def test_update_volume_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'volume': {'name': 'projects/sample1/locations/sample2/volumes/sample3'}} + request_init["volume"] = {'name': 'projects/sample1/locations/sample2/volumes/sample3', 'state': 1, 'state_details': 'state_details_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'share_name': 'share_name_value', 'psa_range': 'psa_range_value', 'storage_pool': 'storage_pool_value', 'network': 'network_value', 'service_level': 1, 'capacity_gib': 1247, 'export_policy': {'rules': [{'allowed_clients': 'allowed_clients_value', 'has_root_access': 'has_root_access_value', 'access_type': 1, 'nfsv3': True, 'nfsv4': True, 'kerberos_5_read_only': True, 'kerberos_5_read_write': True, 'kerberos_5i_read_only': True, 'kerberos_5i_read_write': True, 'kerberos_5p_read_only': True, 'kerberos_5p_read_write': True}]}, 'protocols': [1], 'smb_settings': [1], 'mount_options': [{'export': 'export_value', 'export_full': 'export_full_value', 'protocol': 1, 'instructions': 'instructions_value', 'ip_address': 'ip_address_value'}], 'unix_permissions': 'unix_permissions_value', 'labels': {}, 'description': 'description_value', 'snapshot_policy': {'enabled': True, 'hourly_schedule': {'snapshots_to_keep': 0.18330000000000002, 'minute': 0.658}, 'daily_schedule': {'snapshots_to_keep': 0.18330000000000002, 'minute': 0.658, 'hour': 0.446}, 'weekly_schedule': {'snapshots_to_keep': 0.18330000000000002, 'minute': 0.658, 'hour': 0.446, 'day': 'day_value'}, 'monthly_schedule': {'snapshots_to_keep': 0.18330000000000002, 'minute': 0.658, 'hour': 0.446, 'days_of_month': 'days_of_month_value'}}, 'snap_reserve': 0.1293, 'snapshot_directory': True, 'used_gib': 834, 'security_style': 1, 'kerberos_enabled': True, 'ldap_enabled': True, 'active_directory': 'active_directory_value', 'restore_parameters': {'source_snapshot': 'source_snapshot_value', 'source_backup': 'source_backup_value'}, 'kms_config': 'kms_config_value', 'encryption_type': 1, 'has_replication': True, 'backup_config': {'backup_policies': ['backup_policies_value1', 'backup_policies_value2'], 'backup_vault': 'backup_vault_value', 'scheduled_backup_enabled': True, 'backup_chain_bytes': 1886}, 'restricted_actions': [1], 'large_capacity': True, 'multiple_endpoints': True, 'tiering_policy': {'tier_action': 1, 'cooling_threshold_days': 2343}, 'replica_zone': 'replica_zone_value', 'zone': 'zone_value', 'cold_tier_size_gib': 1888, 'hybrid_replication_parameters': {'replication': 'replication_value', 'peer_volume_name': 'peer_volume_name_value', 'peer_cluster_name': 'peer_cluster_name_value', 'peer_svm_name': 'peer_svm_name_value', 'peer_ip_addresses': ['peer_ip_addresses_value1', 'peer_ip_addresses_value2'], 'cluster_location': 'cluster_location_value', 'description': 'description_value', 'labels': {}}} + # 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 = gcn_volume.UpdateVolumeRequest.meta.fields["volume"] + + 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["volume"].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["volume"][field])): + del request_init["volume"][field][i][subfield] + else: + del request_init["volume"][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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_volume(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_update_volume_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_update_volume") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_update_volume_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_update_volume") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = gcn_volume.UpdateVolumeRequest.pb(gcn_volume.UpdateVolumeRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = gcn_volume.UpdateVolumeRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.update_volume(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_volume_rest_bad_request(request_type=volume.DeleteVolumeRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_volume(request) + + +@pytest.mark.parametrize("request_type", [ + volume.DeleteVolumeRequest, + dict, +]) +def test_delete_volume_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_volume(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_volume_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_delete_volume") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_delete_volume_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_delete_volume") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = volume.DeleteVolumeRequest.pb(volume.DeleteVolumeRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = volume.DeleteVolumeRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.delete_volume(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_revert_volume_rest_bad_request(request_type=volume.RevertVolumeRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.revert_volume(request) + + +@pytest.mark.parametrize("request_type", [ + volume.RevertVolumeRequest, + dict, +]) +def test_revert_volume_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.revert_volume(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_revert_volume_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_revert_volume") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_revert_volume_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_revert_volume") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = volume.RevertVolumeRequest.pb(volume.RevertVolumeRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = volume.RevertVolumeRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.revert_volume(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_snapshots_rest_bad_request(request_type=snapshot.ListSnapshotsRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/volumes/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_snapshots(request) + + +@pytest.mark.parametrize("request_type", [ + snapshot.ListSnapshotsRequest, + dict, +]) +def test_list_snapshots_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/volumes/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 = snapshot.ListSnapshotsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_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 = snapshot.ListSnapshotsResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_snapshots(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListSnapshotsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_snapshots_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_list_snapshots") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_list_snapshots_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_list_snapshots") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = snapshot.ListSnapshotsRequest.pb(snapshot.ListSnapshotsRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = snapshot.ListSnapshotsResponse.to_json(snapshot.ListSnapshotsResponse()) + req.return_value.content = return_value + + request = snapshot.ListSnapshotsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = snapshot.ListSnapshotsResponse() + post_with_metadata.return_value = snapshot.ListSnapshotsResponse(), metadata + + client.list_snapshots(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_snapshot_rest_bad_request(request_type=snapshot.GetSnapshotRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/snapshots/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_snapshot(request) + + +@pytest.mark.parametrize("request_type", [ + snapshot.GetSnapshotRequest, + dict, +]) +def test_get_snapshot_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/snapshots/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 = snapshot.Snapshot( + name='name_value', + state=snapshot.Snapshot.State.READY, + state_details='state_details_value', + description='description_value', + used_bytes=0.10790000000000001, + ) + + # 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 = snapshot.Snapshot.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_snapshot(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, snapshot.Snapshot) + assert response.name == 'name_value' + assert response.state == snapshot.Snapshot.State.READY + assert response.state_details == 'state_details_value' + assert response.description == 'description_value' + assert math.isclose(response.used_bytes, 0.10790000000000001, rel_tol=1e-6) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_snapshot_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_get_snapshot") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_get_snapshot_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_get_snapshot") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = snapshot.GetSnapshotRequest.pb(snapshot.GetSnapshotRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = snapshot.Snapshot.to_json(snapshot.Snapshot()) + req.return_value.content = return_value + + request = snapshot.GetSnapshotRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = snapshot.Snapshot() + post_with_metadata.return_value = snapshot.Snapshot(), metadata + + client.get_snapshot(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_snapshot_rest_bad_request(request_type=gcn_snapshot.CreateSnapshotRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/volumes/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_snapshot(request) + + +@pytest.mark.parametrize("request_type", [ + gcn_snapshot.CreateSnapshotRequest, + dict, +]) +def test_create_snapshot_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/volumes/sample3'} + request_init["snapshot"] = {'name': 'name_value', 'state': 1, 'state_details': 'state_details_value', 'description': 'description_value', 'used_bytes': 0.10790000000000001, 'create_time': {'seconds': 751, 'nanos': 543}, 'labels': {}} + # 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 = gcn_snapshot.CreateSnapshotRequest.meta.fields["snapshot"] + + 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["snapshot"].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["snapshot"][field])): + del request_init["snapshot"][field][i][subfield] + else: + del request_init["snapshot"][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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_snapshot(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_snapshot_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_create_snapshot") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_create_snapshot_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_create_snapshot") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = gcn_snapshot.CreateSnapshotRequest.pb(gcn_snapshot.CreateSnapshotRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = gcn_snapshot.CreateSnapshotRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_snapshot(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_snapshot_rest_bad_request(request_type=snapshot.DeleteSnapshotRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/snapshots/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_snapshot(request) + + +@pytest.mark.parametrize("request_type", [ + snapshot.DeleteSnapshotRequest, + dict, +]) +def test_delete_snapshot_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/snapshots/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_snapshot(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_snapshot_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_delete_snapshot") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_delete_snapshot_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_delete_snapshot") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = snapshot.DeleteSnapshotRequest.pb(snapshot.DeleteSnapshotRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = snapshot.DeleteSnapshotRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.delete_snapshot(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_update_snapshot_rest_bad_request(request_type=gcn_snapshot.UpdateSnapshotRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'snapshot': {'name': 'projects/sample1/locations/sample2/volumes/sample3/snapshots/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_snapshot(request) + + +@pytest.mark.parametrize("request_type", [ + gcn_snapshot.UpdateSnapshotRequest, + dict, +]) +def test_update_snapshot_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'snapshot': {'name': 'projects/sample1/locations/sample2/volumes/sample3/snapshots/sample4'}} + request_init["snapshot"] = {'name': 'projects/sample1/locations/sample2/volumes/sample3/snapshots/sample4', 'state': 1, 'state_details': 'state_details_value', 'description': 'description_value', 'used_bytes': 0.10790000000000001, 'create_time': {'seconds': 751, 'nanos': 543}, 'labels': {}} + # 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 = gcn_snapshot.UpdateSnapshotRequest.meta.fields["snapshot"] + + 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["snapshot"].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["snapshot"][field])): + del request_init["snapshot"][field][i][subfield] + else: + del request_init["snapshot"][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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_snapshot(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_update_snapshot_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_update_snapshot") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_update_snapshot_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_update_snapshot") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = gcn_snapshot.UpdateSnapshotRequest.pb(gcn_snapshot.UpdateSnapshotRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = gcn_snapshot.UpdateSnapshotRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.update_snapshot(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_active_directories_rest_bad_request(request_type=active_directory.ListActiveDirectoriesRequest): + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_active_directories(request) + + +@pytest.mark.parametrize("request_type", [ + active_directory.ListActiveDirectoriesRequest, + dict, +]) +def test_list_active_directories_rest_call_success(request_type): + client = NetAppClient( + 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 = active_directory.ListActiveDirectoriesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_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 = active_directory.ListActiveDirectoriesResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_active_directories(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListActiveDirectoriesPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_active_directories_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_list_active_directories") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_list_active_directories_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_list_active_directories") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = active_directory.ListActiveDirectoriesRequest.pb(active_directory.ListActiveDirectoriesRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = active_directory.ListActiveDirectoriesResponse.to_json(active_directory.ListActiveDirectoriesResponse()) + req.return_value.content = return_value + + request = active_directory.ListActiveDirectoriesRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = active_directory.ListActiveDirectoriesResponse() + post_with_metadata.return_value = active_directory.ListActiveDirectoriesResponse(), metadata + + client.list_active_directories(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_active_directory_rest_bad_request(request_type=active_directory.GetActiveDirectoryRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/activeDirectories/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_active_directory(request) + + +@pytest.mark.parametrize("request_type", [ + active_directory.GetActiveDirectoryRequest, + dict, +]) +def test_get_active_directory_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/activeDirectories/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 = active_directory.ActiveDirectory( + name='name_value', + state=active_directory.ActiveDirectory.State.CREATING, + domain='domain_value', + site='site_value', + dns='dns_value', + net_bios_prefix='net_bios_prefix_value', + organizational_unit='organizational_unit_value', + aes_encryption=True, + username='username_value', + password='password_value', + backup_operators=['backup_operators_value'], + administrators=['administrators_value'], + security_operators=['security_operators_value'], + kdc_hostname='kdc_hostname_value', + kdc_ip='kdc_ip_value', + nfs_users_with_ldap=True, + description='description_value', + ldap_signing=True, + encrypt_dc_connections=True, + state_details='state_details_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 = active_directory.ActiveDirectory.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_active_directory(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, active_directory.ActiveDirectory) + assert response.name == 'name_value' + assert response.state == active_directory.ActiveDirectory.State.CREATING + assert response.domain == 'domain_value' + assert response.site == 'site_value' + assert response.dns == 'dns_value' + assert response.net_bios_prefix == 'net_bios_prefix_value' + assert response.organizational_unit == 'organizational_unit_value' + assert response.aes_encryption is True + assert response.username == 'username_value' + assert response.password == 'password_value' + assert response.backup_operators == ['backup_operators_value'] + assert response.administrators == ['administrators_value'] + assert response.security_operators == ['security_operators_value'] + assert response.kdc_hostname == 'kdc_hostname_value' + assert response.kdc_ip == 'kdc_ip_value' + assert response.nfs_users_with_ldap is True + assert response.description == 'description_value' + assert response.ldap_signing is True + assert response.encrypt_dc_connections is True + assert response.state_details == 'state_details_value' + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_active_directory_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_get_active_directory") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_get_active_directory_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_get_active_directory") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = active_directory.GetActiveDirectoryRequest.pb(active_directory.GetActiveDirectoryRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = active_directory.ActiveDirectory.to_json(active_directory.ActiveDirectory()) + req.return_value.content = return_value + + request = active_directory.GetActiveDirectoryRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = active_directory.ActiveDirectory() + post_with_metadata.return_value = active_directory.ActiveDirectory(), metadata + + client.get_active_directory(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_active_directory_rest_bad_request(request_type=gcn_active_directory.CreateActiveDirectoryRequest): + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_active_directory(request) + + +@pytest.mark.parametrize("request_type", [ + gcn_active_directory.CreateActiveDirectoryRequest, + dict, +]) +def test_create_active_directory_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["active_directory"] = {'name': 'name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'state': 1, 'domain': 'domain_value', 'site': 'site_value', 'dns': 'dns_value', 'net_bios_prefix': 'net_bios_prefix_value', 'organizational_unit': 'organizational_unit_value', 'aes_encryption': True, 'username': 'username_value', 'password': 'password_value', 'backup_operators': ['backup_operators_value1', 'backup_operators_value2'], 'administrators': ['administrators_value1', 'administrators_value2'], 'security_operators': ['security_operators_value1', 'security_operators_value2'], 'kdc_hostname': 'kdc_hostname_value', 'kdc_ip': 'kdc_ip_value', 'nfs_users_with_ldap': True, 'description': 'description_value', 'ldap_signing': True, 'encrypt_dc_connections': True, 'labels': {}, 'state_details': 'state_details_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 = gcn_active_directory.CreateActiveDirectoryRequest.meta.fields["active_directory"] + + 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["active_directory"].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["active_directory"][field])): + del request_init["active_directory"][field][i][subfield] + else: + del request_init["active_directory"][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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_active_directory(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_active_directory_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_create_active_directory") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_create_active_directory_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_create_active_directory") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = gcn_active_directory.CreateActiveDirectoryRequest.pb(gcn_active_directory.CreateActiveDirectoryRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = gcn_active_directory.CreateActiveDirectoryRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_active_directory(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_update_active_directory_rest_bad_request(request_type=gcn_active_directory.UpdateActiveDirectoryRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'active_directory': {'name': 'projects/sample1/locations/sample2/activeDirectories/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_active_directory(request) + + +@pytest.mark.parametrize("request_type", [ + gcn_active_directory.UpdateActiveDirectoryRequest, + dict, +]) +def test_update_active_directory_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'active_directory': {'name': 'projects/sample1/locations/sample2/activeDirectories/sample3'}} + request_init["active_directory"] = {'name': 'projects/sample1/locations/sample2/activeDirectories/sample3', 'create_time': {'seconds': 751, 'nanos': 543}, 'state': 1, 'domain': 'domain_value', 'site': 'site_value', 'dns': 'dns_value', 'net_bios_prefix': 'net_bios_prefix_value', 'organizational_unit': 'organizational_unit_value', 'aes_encryption': True, 'username': 'username_value', 'password': 'password_value', 'backup_operators': ['backup_operators_value1', 'backup_operators_value2'], 'administrators': ['administrators_value1', 'administrators_value2'], 'security_operators': ['security_operators_value1', 'security_operators_value2'], 'kdc_hostname': 'kdc_hostname_value', 'kdc_ip': 'kdc_ip_value', 'nfs_users_with_ldap': True, 'description': 'description_value', 'ldap_signing': True, 'encrypt_dc_connections': True, 'labels': {}, 'state_details': 'state_details_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 = gcn_active_directory.UpdateActiveDirectoryRequest.meta.fields["active_directory"] + + 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["active_directory"].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["active_directory"][field])): + del request_init["active_directory"][field][i][subfield] + else: + del request_init["active_directory"][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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_active_directory(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_update_active_directory_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_update_active_directory") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_update_active_directory_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_update_active_directory") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = gcn_active_directory.UpdateActiveDirectoryRequest.pb(gcn_active_directory.UpdateActiveDirectoryRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = gcn_active_directory.UpdateActiveDirectoryRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.update_active_directory(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_active_directory_rest_bad_request(request_type=active_directory.DeleteActiveDirectoryRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/activeDirectories/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_active_directory(request) + + +@pytest.mark.parametrize("request_type", [ + active_directory.DeleteActiveDirectoryRequest, + dict, +]) +def test_delete_active_directory_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/activeDirectories/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_active_directory(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_active_directory_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_delete_active_directory") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_delete_active_directory_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_delete_active_directory") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = active_directory.DeleteActiveDirectoryRequest.pb(active_directory.DeleteActiveDirectoryRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = active_directory.DeleteActiveDirectoryRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.delete_active_directory(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_kms_configs_rest_bad_request(request_type=kms.ListKmsConfigsRequest): + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_kms_configs(request) + + +@pytest.mark.parametrize("request_type", [ + kms.ListKmsConfigsRequest, + dict, +]) +def test_list_kms_configs_rest_call_success(request_type): + client = NetAppClient( + 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 = kms.ListKmsConfigsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_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 = kms.ListKmsConfigsResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_kms_configs(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListKmsConfigsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_kms_configs_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_list_kms_configs") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_list_kms_configs_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_list_kms_configs") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = kms.ListKmsConfigsRequest.pb(kms.ListKmsConfigsRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = kms.ListKmsConfigsResponse.to_json(kms.ListKmsConfigsResponse()) + req.return_value.content = return_value + + request = kms.ListKmsConfigsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = kms.ListKmsConfigsResponse() + post_with_metadata.return_value = kms.ListKmsConfigsResponse(), metadata + + client.list_kms_configs(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_kms_config_rest_bad_request(request_type=kms.CreateKmsConfigRequest): + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_kms_config(request) + + +@pytest.mark.parametrize("request_type", [ + kms.CreateKmsConfigRequest, + dict, +]) +def test_create_kms_config_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["kms_config"] = {'name': 'name_value', 'crypto_key_name': 'crypto_key_name_value', 'state': 1, 'state_details': 'state_details_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'description': 'description_value', 'labels': {}, 'instructions': 'instructions_value', 'service_account': 'service_account_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 = kms.CreateKmsConfigRequest.meta.fields["kms_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["kms_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["kms_config"][field])): + del request_init["kms_config"][field][i][subfield] + else: + del request_init["kms_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 = 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_kms_config(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_kms_config_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_create_kms_config") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_create_kms_config_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_create_kms_config") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = kms.CreateKmsConfigRequest.pb(kms.CreateKmsConfigRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = kms.CreateKmsConfigRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_kms_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_kms_config_rest_bad_request(request_type=kms.GetKmsConfigRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/kmsConfigs/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_kms_config(request) + + +@pytest.mark.parametrize("request_type", [ + kms.GetKmsConfigRequest, + dict, +]) +def test_get_kms_config_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/kmsConfigs/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 = kms.KmsConfig( + name='name_value', + crypto_key_name='crypto_key_name_value', + state=kms.KmsConfig.State.READY, + state_details='state_details_value', + description='description_value', + instructions='instructions_value', + service_account='service_account_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 = kms.KmsConfig.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_kms_config(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, kms.KmsConfig) + assert response.name == 'name_value' + assert response.crypto_key_name == 'crypto_key_name_value' + assert response.state == kms.KmsConfig.State.READY + assert response.state_details == 'state_details_value' + assert response.description == 'description_value' + assert response.instructions == 'instructions_value' + assert response.service_account == 'service_account_value' + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_kms_config_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_get_kms_config") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_get_kms_config_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_get_kms_config") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = kms.GetKmsConfigRequest.pb(kms.GetKmsConfigRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = kms.KmsConfig.to_json(kms.KmsConfig()) + req.return_value.content = return_value + + request = kms.GetKmsConfigRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = kms.KmsConfig() + post_with_metadata.return_value = kms.KmsConfig(), metadata + + client.get_kms_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_update_kms_config_rest_bad_request(request_type=kms.UpdateKmsConfigRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'kms_config': {'name': 'projects/sample1/locations/sample2/kmsConfigs/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_kms_config(request) + + +@pytest.mark.parametrize("request_type", [ + kms.UpdateKmsConfigRequest, + dict, +]) +def test_update_kms_config_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'kms_config': {'name': 'projects/sample1/locations/sample2/kmsConfigs/sample3'}} + request_init["kms_config"] = {'name': 'projects/sample1/locations/sample2/kmsConfigs/sample3', 'crypto_key_name': 'crypto_key_name_value', 'state': 1, 'state_details': 'state_details_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'description': 'description_value', 'labels': {}, 'instructions': 'instructions_value', 'service_account': 'service_account_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 = kms.UpdateKmsConfigRequest.meta.fields["kms_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["kms_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["kms_config"][field])): + del request_init["kms_config"][field][i][subfield] + else: + del request_init["kms_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 = 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_kms_config(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_update_kms_config_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_update_kms_config") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_update_kms_config_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_update_kms_config") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = kms.UpdateKmsConfigRequest.pb(kms.UpdateKmsConfigRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = kms.UpdateKmsConfigRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.update_kms_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_encrypt_volumes_rest_bad_request(request_type=kms.EncryptVolumesRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/kmsConfigs/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.encrypt_volumes(request) + + +@pytest.mark.parametrize("request_type", [ + kms.EncryptVolumesRequest, + dict, +]) +def test_encrypt_volumes_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/kmsConfigs/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.encrypt_volumes(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_encrypt_volumes_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_encrypt_volumes") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_encrypt_volumes_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_encrypt_volumes") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = kms.EncryptVolumesRequest.pb(kms.EncryptVolumesRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = kms.EncryptVolumesRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.encrypt_volumes(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_verify_kms_config_rest_bad_request(request_type=kms.VerifyKmsConfigRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/kmsConfigs/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.verify_kms_config(request) + + +@pytest.mark.parametrize("request_type", [ + kms.VerifyKmsConfigRequest, + dict, +]) +def test_verify_kms_config_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/kmsConfigs/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 = kms.VerifyKmsConfigResponse( + healthy=True, + health_error='health_error_value', + instructions='instructions_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 = kms.VerifyKmsConfigResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.verify_kms_config(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, kms.VerifyKmsConfigResponse) + assert response.healthy is True + assert response.health_error == 'health_error_value' + assert response.instructions == 'instructions_value' + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_verify_kms_config_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_verify_kms_config") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_verify_kms_config_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_verify_kms_config") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = kms.VerifyKmsConfigRequest.pb(kms.VerifyKmsConfigRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = kms.VerifyKmsConfigResponse.to_json(kms.VerifyKmsConfigResponse()) + req.return_value.content = return_value + + request = kms.VerifyKmsConfigRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = kms.VerifyKmsConfigResponse() + post_with_metadata.return_value = kms.VerifyKmsConfigResponse(), metadata + + client.verify_kms_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_kms_config_rest_bad_request(request_type=kms.DeleteKmsConfigRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/kmsConfigs/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_kms_config(request) + + +@pytest.mark.parametrize("request_type", [ + kms.DeleteKmsConfigRequest, + dict, +]) +def test_delete_kms_config_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/kmsConfigs/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_kms_config(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_kms_config_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_delete_kms_config") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_delete_kms_config_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_delete_kms_config") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = kms.DeleteKmsConfigRequest.pb(kms.DeleteKmsConfigRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = kms.DeleteKmsConfigRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.delete_kms_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_replications_rest_bad_request(request_type=replication.ListReplicationsRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/volumes/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_replications(request) + + +@pytest.mark.parametrize("request_type", [ + replication.ListReplicationsRequest, + dict, +]) +def test_list_replications_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/volumes/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 = replication.ListReplicationsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_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 = replication.ListReplicationsResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_replications(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListReplicationsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_replications_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_list_replications") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_list_replications_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_list_replications") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = replication.ListReplicationsRequest.pb(replication.ListReplicationsRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = replication.ListReplicationsResponse.to_json(replication.ListReplicationsResponse()) + req.return_value.content = return_value + + request = replication.ListReplicationsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = replication.ListReplicationsResponse() + post_with_metadata.return_value = replication.ListReplicationsResponse(), metadata + + client.list_replications(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_replication_rest_bad_request(request_type=replication.GetReplicationRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_replication(request) + + +@pytest.mark.parametrize("request_type", [ + replication.GetReplicationRequest, + dict, +]) +def test_get_replication_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 = replication.Replication( + name='name_value', + state=replication.Replication.State.CREATING, + state_details='state_details_value', + role=replication.Replication.ReplicationRole.SOURCE, + replication_schedule=replication.Replication.ReplicationSchedule.EVERY_10_MINUTES, + mirror_state=replication.Replication.MirrorState.PREPARING, + healthy=True, + destination_volume='destination_volume_value', + description='description_value', + source_volume='source_volume_value', + cluster_location='cluster_location_value', + hybrid_replication_type=replication.Replication.HybridReplicationType.MIGRATION, + ) + + # 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 = replication.Replication.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_replication(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, replication.Replication) + assert response.name == 'name_value' + assert response.state == replication.Replication.State.CREATING + assert response.state_details == 'state_details_value' + assert response.role == replication.Replication.ReplicationRole.SOURCE + assert response.replication_schedule == replication.Replication.ReplicationSchedule.EVERY_10_MINUTES + assert response.mirror_state == replication.Replication.MirrorState.PREPARING + assert response.healthy is True + assert response.destination_volume == 'destination_volume_value' + assert response.description == 'description_value' + assert response.source_volume == 'source_volume_value' + assert response.cluster_location == 'cluster_location_value' + assert response.hybrid_replication_type == replication.Replication.HybridReplicationType.MIGRATION + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_replication_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_get_replication") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_get_replication_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_get_replication") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = replication.GetReplicationRequest.pb(replication.GetReplicationRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = replication.Replication.to_json(replication.Replication()) + req.return_value.content = return_value + + request = replication.GetReplicationRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = replication.Replication() + post_with_metadata.return_value = replication.Replication(), metadata + + client.get_replication(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_replication_rest_bad_request(request_type=gcn_replication.CreateReplicationRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/volumes/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_replication(request) + + +@pytest.mark.parametrize("request_type", [ + gcn_replication.CreateReplicationRequest, + dict, +]) +def test_create_replication_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/volumes/sample3'} + request_init["replication"] = {'name': 'name_value', 'state': 1, 'state_details': 'state_details_value', 'role': 1, 'replication_schedule': 1, 'mirror_state': 1, 'healthy': True, 'create_time': {'seconds': 751, 'nanos': 543}, 'destination_volume': 'destination_volume_value', 'transfer_stats': {'transfer_bytes': 1515, 'total_transfer_duration': {'seconds': 751, 'nanos': 543}, 'last_transfer_bytes': 2046, 'last_transfer_duration': {}, 'lag_duration': {}, 'update_time': {}, 'last_transfer_end_time': {}, 'last_transfer_error': 'last_transfer_error_value'}, 'labels': {}, 'description': 'description_value', 'destination_volume_parameters': {'storage_pool': 'storage_pool_value', 'volume_id': 'volume_id_value', 'share_name': 'share_name_value', 'description': 'description_value', 'tiering_policy': {'tier_action': 1, 'cooling_threshold_days': 2343}}, 'source_volume': 'source_volume_value', 'hybrid_peering_details': {'subnet_ip': 'subnet_ip_value', 'command': 'command_value', 'command_expiry_time': {}, 'passphrase': 'passphrase_value', 'peer_volume_name': 'peer_volume_name_value', 'peer_cluster_name': 'peer_cluster_name_value', 'peer_svm_name': 'peer_svm_name_value'}, 'cluster_location': 'cluster_location_value', 'hybrid_replication_type': 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 = gcn_replication.CreateReplicationRequest.meta.fields["replication"] + + 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["replication"].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["replication"][field])): + del request_init["replication"][field][i][subfield] + else: + del request_init["replication"][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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_replication(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_replication_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_create_replication") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_create_replication_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_create_replication") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = gcn_replication.CreateReplicationRequest.pb(gcn_replication.CreateReplicationRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = gcn_replication.CreateReplicationRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_replication(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_replication_rest_bad_request(request_type=replication.DeleteReplicationRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_replication(request) + + +@pytest.mark.parametrize("request_type", [ + replication.DeleteReplicationRequest, + dict, +]) +def test_delete_replication_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_replication(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_replication_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_delete_replication") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_delete_replication_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_delete_replication") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = replication.DeleteReplicationRequest.pb(replication.DeleteReplicationRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = replication.DeleteReplicationRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.delete_replication(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_update_replication_rest_bad_request(request_type=gcn_replication.UpdateReplicationRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'replication': {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_replication(request) + + +@pytest.mark.parametrize("request_type", [ + gcn_replication.UpdateReplicationRequest, + dict, +]) +def test_update_replication_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'replication': {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/sample4'}} + request_init["replication"] = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/sample4', 'state': 1, 'state_details': 'state_details_value', 'role': 1, 'replication_schedule': 1, 'mirror_state': 1, 'healthy': True, 'create_time': {'seconds': 751, 'nanos': 543}, 'destination_volume': 'destination_volume_value', 'transfer_stats': {'transfer_bytes': 1515, 'total_transfer_duration': {'seconds': 751, 'nanos': 543}, 'last_transfer_bytes': 2046, 'last_transfer_duration': {}, 'lag_duration': {}, 'update_time': {}, 'last_transfer_end_time': {}, 'last_transfer_error': 'last_transfer_error_value'}, 'labels': {}, 'description': 'description_value', 'destination_volume_parameters': {'storage_pool': 'storage_pool_value', 'volume_id': 'volume_id_value', 'share_name': 'share_name_value', 'description': 'description_value', 'tiering_policy': {'tier_action': 1, 'cooling_threshold_days': 2343}}, 'source_volume': 'source_volume_value', 'hybrid_peering_details': {'subnet_ip': 'subnet_ip_value', 'command': 'command_value', 'command_expiry_time': {}, 'passphrase': 'passphrase_value', 'peer_volume_name': 'peer_volume_name_value', 'peer_cluster_name': 'peer_cluster_name_value', 'peer_svm_name': 'peer_svm_name_value'}, 'cluster_location': 'cluster_location_value', 'hybrid_replication_type': 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 = gcn_replication.UpdateReplicationRequest.meta.fields["replication"] + + 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["replication"].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["replication"][field])): + del request_init["replication"][field][i][subfield] + else: + del request_init["replication"][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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_replication(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_update_replication_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_update_replication") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_update_replication_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_update_replication") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = gcn_replication.UpdateReplicationRequest.pb(gcn_replication.UpdateReplicationRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = gcn_replication.UpdateReplicationRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.update_replication(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_stop_replication_rest_bad_request(request_type=replication.StopReplicationRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.stop_replication(request) + + +@pytest.mark.parametrize("request_type", [ + replication.StopReplicationRequest, + dict, +]) +def test_stop_replication_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.stop_replication(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_stop_replication_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_stop_replication") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_stop_replication_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_stop_replication") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = replication.StopReplicationRequest.pb(replication.StopReplicationRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = replication.StopReplicationRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.stop_replication(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_resume_replication_rest_bad_request(request_type=replication.ResumeReplicationRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.resume_replication(request) + + +@pytest.mark.parametrize("request_type", [ + replication.ResumeReplicationRequest, + dict, +]) +def test_resume_replication_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.resume_replication(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_resume_replication_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_resume_replication") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_resume_replication_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_resume_replication") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = replication.ResumeReplicationRequest.pb(replication.ResumeReplicationRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = replication.ResumeReplicationRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.resume_replication(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_reverse_replication_direction_rest_bad_request(request_type=replication.ReverseReplicationDirectionRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.reverse_replication_direction(request) + + +@pytest.mark.parametrize("request_type", [ + replication.ReverseReplicationDirectionRequest, + dict, +]) +def test_reverse_replication_direction_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.reverse_replication_direction(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_reverse_replication_direction_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_reverse_replication_direction") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_reverse_replication_direction_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_reverse_replication_direction") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = replication.ReverseReplicationDirectionRequest.pb(replication.ReverseReplicationDirectionRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = replication.ReverseReplicationDirectionRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.reverse_replication_direction(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_establish_peering_rest_bad_request(request_type=replication.EstablishPeeringRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.establish_peering(request) + + +@pytest.mark.parametrize("request_type", [ + replication.EstablishPeeringRequest, + dict, +]) +def test_establish_peering_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.establish_peering(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_establish_peering_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_establish_peering") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_establish_peering_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_establish_peering") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = replication.EstablishPeeringRequest.pb(replication.EstablishPeeringRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = replication.EstablishPeeringRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.establish_peering(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_sync_replication_rest_bad_request(request_type=replication.SyncReplicationRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.sync_replication(request) + + +@pytest.mark.parametrize("request_type", [ + replication.SyncReplicationRequest, + dict, +]) +def test_sync_replication_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.sync_replication(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_sync_replication_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_sync_replication") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_sync_replication_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_sync_replication") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = replication.SyncReplicationRequest.pb(replication.SyncReplicationRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = replication.SyncReplicationRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.sync_replication(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_backup_vault_rest_bad_request(request_type=gcn_backup_vault.CreateBackupVaultRequest): + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_backup_vault(request) + + +@pytest.mark.parametrize("request_type", [ + gcn_backup_vault.CreateBackupVaultRequest, + dict, +]) +def test_create_backup_vault_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["backup_vault"] = {'name': 'name_value', 'state': 1, 'create_time': {'seconds': 751, 'nanos': 543}, 'description': 'description_value', 'labels': {}} + # 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 = gcn_backup_vault.CreateBackupVaultRequest.meta.fields["backup_vault"] + + 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["backup_vault"].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["backup_vault"][field])): + del request_init["backup_vault"][field][i][subfield] + else: + del request_init["backup_vault"][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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_backup_vault(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_backup_vault_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_create_backup_vault") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_create_backup_vault_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_create_backup_vault") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = gcn_backup_vault.CreateBackupVaultRequest.pb(gcn_backup_vault.CreateBackupVaultRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = gcn_backup_vault.CreateBackupVaultRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_backup_vault(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_backup_vault_rest_bad_request(request_type=backup_vault.GetBackupVaultRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/backupVaults/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_backup_vault(request) + + +@pytest.mark.parametrize("request_type", [ + backup_vault.GetBackupVaultRequest, + dict, +]) +def test_get_backup_vault_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/backupVaults/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 = backup_vault.BackupVault( + name='name_value', + state=backup_vault.BackupVault.State.CREATING, + 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 = backup_vault.BackupVault.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_backup_vault(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, backup_vault.BackupVault) + assert response.name == 'name_value' + assert response.state == backup_vault.BackupVault.State.CREATING + assert response.description == 'description_value' + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_backup_vault_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_get_backup_vault") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_get_backup_vault_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_get_backup_vault") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = backup_vault.GetBackupVaultRequest.pb(backup_vault.GetBackupVaultRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = backup_vault.BackupVault.to_json(backup_vault.BackupVault()) + req.return_value.content = return_value + + request = backup_vault.GetBackupVaultRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = backup_vault.BackupVault() + post_with_metadata.return_value = backup_vault.BackupVault(), metadata + + client.get_backup_vault(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_backup_vaults_rest_bad_request(request_type=backup_vault.ListBackupVaultsRequest): + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_backup_vaults(request) + + +@pytest.mark.parametrize("request_type", [ + backup_vault.ListBackupVaultsRequest, + dict, +]) +def test_list_backup_vaults_rest_call_success(request_type): + client = NetAppClient( + 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 = backup_vault.ListBackupVaultsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_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 = backup_vault.ListBackupVaultsResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_backup_vaults(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListBackupVaultsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_backup_vaults_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_list_backup_vaults") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_list_backup_vaults_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_list_backup_vaults") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = backup_vault.ListBackupVaultsRequest.pb(backup_vault.ListBackupVaultsRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = backup_vault.ListBackupVaultsResponse.to_json(backup_vault.ListBackupVaultsResponse()) + req.return_value.content = return_value + + request = backup_vault.ListBackupVaultsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = backup_vault.ListBackupVaultsResponse() + post_with_metadata.return_value = backup_vault.ListBackupVaultsResponse(), metadata + + client.list_backup_vaults(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_update_backup_vault_rest_bad_request(request_type=gcn_backup_vault.UpdateBackupVaultRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'backup_vault': {'name': 'projects/sample1/locations/sample2/backupVaults/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_backup_vault(request) + + +@pytest.mark.parametrize("request_type", [ + gcn_backup_vault.UpdateBackupVaultRequest, + dict, +]) +def test_update_backup_vault_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'backup_vault': {'name': 'projects/sample1/locations/sample2/backupVaults/sample3'}} + request_init["backup_vault"] = {'name': 'projects/sample1/locations/sample2/backupVaults/sample3', 'state': 1, 'create_time': {'seconds': 751, 'nanos': 543}, 'description': 'description_value', 'labels': {}} + # 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 = gcn_backup_vault.UpdateBackupVaultRequest.meta.fields["backup_vault"] + + 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["backup_vault"].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["backup_vault"][field])): + del request_init["backup_vault"][field][i][subfield] + else: + del request_init["backup_vault"][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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_backup_vault(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_update_backup_vault_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_update_backup_vault") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_update_backup_vault_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_update_backup_vault") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = gcn_backup_vault.UpdateBackupVaultRequest.pb(gcn_backup_vault.UpdateBackupVaultRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = gcn_backup_vault.UpdateBackupVaultRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.update_backup_vault(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_backup_vault_rest_bad_request(request_type=backup_vault.DeleteBackupVaultRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/backupVaults/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_backup_vault(request) + + +@pytest.mark.parametrize("request_type", [ + backup_vault.DeleteBackupVaultRequest, + dict, +]) +def test_delete_backup_vault_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/backupVaults/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_backup_vault(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_backup_vault_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_delete_backup_vault") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_delete_backup_vault_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_delete_backup_vault") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = backup_vault.DeleteBackupVaultRequest.pb(backup_vault.DeleteBackupVaultRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = backup_vault.DeleteBackupVaultRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.delete_backup_vault(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_backup_rest_bad_request(request_type=gcn_backup.CreateBackupRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/backupVaults/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_backup(request) + + +@pytest.mark.parametrize("request_type", [ + gcn_backup.CreateBackupRequest, + dict, +]) +def test_create_backup_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/backupVaults/sample3'} + request_init["backup"] = {'name': 'name_value', 'state': 1, 'description': 'description_value', 'volume_usage_bytes': 1938, 'backup_type': 1, 'source_volume': 'source_volume_value', 'source_snapshot': 'source_snapshot_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'labels': {}, 'chain_storage_bytes': 2013, 'satisfies_pzs': 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 = gcn_backup.CreateBackupRequest.meta.fields["backup"] + + 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["backup"].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["backup"][field])): + del request_init["backup"][field][i][subfield] + else: + del request_init["backup"][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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_backup(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_backup_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_create_backup") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_create_backup_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_create_backup") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = gcn_backup.CreateBackupRequest.pb(gcn_backup.CreateBackupRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = gcn_backup.CreateBackupRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_backup(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_backup_rest_bad_request(request_type=backup.GetBackupRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/backupVaults/sample3/backups/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_backup(request) + + +@pytest.mark.parametrize("request_type", [ + backup.GetBackupRequest, + dict, +]) +def test_get_backup_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/backupVaults/sample3/backups/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 = backup.Backup( + name='name_value', + state=backup.Backup.State.CREATING, + description='description_value', + volume_usage_bytes=1938, + backup_type=backup.Backup.Type.MANUAL, + source_volume='source_volume_value', + source_snapshot='source_snapshot_value', + chain_storage_bytes=2013, + satisfies_pzs=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 = backup.Backup.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_backup(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, backup.Backup) + assert response.name == 'name_value' + assert response.state == backup.Backup.State.CREATING + assert response.description == 'description_value' + assert response.volume_usage_bytes == 1938 + assert response.backup_type == backup.Backup.Type.MANUAL + assert response.source_volume == 'source_volume_value' + assert response.source_snapshot == 'source_snapshot_value' + assert response.chain_storage_bytes == 2013 + assert response.satisfies_pzs is True + assert response.satisfies_pzi is True + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_backup_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_get_backup") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_get_backup_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_get_backup") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = backup.GetBackupRequest.pb(backup.GetBackupRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = backup.Backup.to_json(backup.Backup()) + req.return_value.content = return_value + + request = backup.GetBackupRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = backup.Backup() + post_with_metadata.return_value = backup.Backup(), metadata + + client.get_backup(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_backups_rest_bad_request(request_type=backup.ListBackupsRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/backupVaults/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_backups(request) + + +@pytest.mark.parametrize("request_type", [ + backup.ListBackupsRequest, + dict, +]) +def test_list_backups_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/backupVaults/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 = backup.ListBackupsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_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 = backup.ListBackupsResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_backups(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListBackupsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_backups_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_list_backups") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_list_backups_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_list_backups") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = backup.ListBackupsRequest.pb(backup.ListBackupsRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = backup.ListBackupsResponse.to_json(backup.ListBackupsResponse()) + req.return_value.content = return_value + + request = backup.ListBackupsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = backup.ListBackupsResponse() + post_with_metadata.return_value = backup.ListBackupsResponse(), metadata + + client.list_backups(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_backup_rest_bad_request(request_type=backup.DeleteBackupRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/backupVaults/sample3/backups/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_backup(request) + + +@pytest.mark.parametrize("request_type", [ + backup.DeleteBackupRequest, + dict, +]) +def test_delete_backup_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/backupVaults/sample3/backups/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_backup(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_backup_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_delete_backup") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_delete_backup_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_delete_backup") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = backup.DeleteBackupRequest.pb(backup.DeleteBackupRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = backup.DeleteBackupRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.delete_backup(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_update_backup_rest_bad_request(request_type=gcn_backup.UpdateBackupRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'backup': {'name': 'projects/sample1/locations/sample2/backupVaults/sample3/backups/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_backup(request) + + +@pytest.mark.parametrize("request_type", [ + gcn_backup.UpdateBackupRequest, + dict, +]) +def test_update_backup_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'backup': {'name': 'projects/sample1/locations/sample2/backupVaults/sample3/backups/sample4'}} + request_init["backup"] = {'name': 'projects/sample1/locations/sample2/backupVaults/sample3/backups/sample4', 'state': 1, 'description': 'description_value', 'volume_usage_bytes': 1938, 'backup_type': 1, 'source_volume': 'source_volume_value', 'source_snapshot': 'source_snapshot_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'labels': {}, 'chain_storage_bytes': 2013, 'satisfies_pzs': 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 = gcn_backup.UpdateBackupRequest.meta.fields["backup"] + + 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["backup"].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["backup"][field])): + del request_init["backup"][field][i][subfield] + else: + del request_init["backup"][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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_backup(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_update_backup_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_update_backup") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_update_backup_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_update_backup") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = gcn_backup.UpdateBackupRequest.pb(gcn_backup.UpdateBackupRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = gcn_backup.UpdateBackupRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.update_backup(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_backup_policy_rest_bad_request(request_type=gcn_backup_policy.CreateBackupPolicyRequest): + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_backup_policy(request) + + +@pytest.mark.parametrize("request_type", [ + gcn_backup_policy.CreateBackupPolicyRequest, + dict, +]) +def test_create_backup_policy_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["backup_policy"] = {'name': 'name_value', 'daily_backup_limit': 1894, 'weekly_backup_limit': 2020, 'monthly_backup_limit': 2142, 'description': 'description_value', 'enabled': True, 'assigned_volume_count': 2253, 'create_time': {'seconds': 751, 'nanos': 543}, 'labels': {}, '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 = gcn_backup_policy.CreateBackupPolicyRequest.meta.fields["backup_policy"] + + 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["backup_policy"].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["backup_policy"][field])): + del request_init["backup_policy"][field][i][subfield] + else: + del request_init["backup_policy"][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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_backup_policy(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_backup_policy_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_create_backup_policy") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_create_backup_policy_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_create_backup_policy") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = gcn_backup_policy.CreateBackupPolicyRequest.pb(gcn_backup_policy.CreateBackupPolicyRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = gcn_backup_policy.CreateBackupPolicyRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_backup_policy(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_backup_policy_rest_bad_request(request_type=backup_policy.GetBackupPolicyRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/backupPolicies/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_backup_policy(request) + + +@pytest.mark.parametrize("request_type", [ + backup_policy.GetBackupPolicyRequest, + dict, +]) +def test_get_backup_policy_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/backupPolicies/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 = backup_policy.BackupPolicy( + name='name_value', + daily_backup_limit=1894, + weekly_backup_limit=2020, + monthly_backup_limit=2142, + description='description_value', + enabled=True, + assigned_volume_count=2253, + state=backup_policy.BackupPolicy.State.CREATING, + ) + + # 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 = backup_policy.BackupPolicy.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_backup_policy(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, backup_policy.BackupPolicy) + assert response.name == 'name_value' + assert response.daily_backup_limit == 1894 + assert response.weekly_backup_limit == 2020 + assert response.monthly_backup_limit == 2142 + assert response.description == 'description_value' + assert response.enabled is True + assert response.assigned_volume_count == 2253 + assert response.state == backup_policy.BackupPolicy.State.CREATING + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_backup_policy_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_get_backup_policy") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_get_backup_policy_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_get_backup_policy") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = backup_policy.GetBackupPolicyRequest.pb(backup_policy.GetBackupPolicyRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = backup_policy.BackupPolicy.to_json(backup_policy.BackupPolicy()) + req.return_value.content = return_value + + request = backup_policy.GetBackupPolicyRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = backup_policy.BackupPolicy() + post_with_metadata.return_value = backup_policy.BackupPolicy(), metadata + + client.get_backup_policy(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_backup_policies_rest_bad_request(request_type=backup_policy.ListBackupPoliciesRequest): + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_backup_policies(request) + + +@pytest.mark.parametrize("request_type", [ + backup_policy.ListBackupPoliciesRequest, + dict, +]) +def test_list_backup_policies_rest_call_success(request_type): + client = NetAppClient( + 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 = backup_policy.ListBackupPoliciesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_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 = backup_policy.ListBackupPoliciesResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_backup_policies(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListBackupPoliciesPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_backup_policies_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_list_backup_policies") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_list_backup_policies_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_list_backup_policies") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = backup_policy.ListBackupPoliciesRequest.pb(backup_policy.ListBackupPoliciesRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = backup_policy.ListBackupPoliciesResponse.to_json(backup_policy.ListBackupPoliciesResponse()) + req.return_value.content = return_value + + request = backup_policy.ListBackupPoliciesRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = backup_policy.ListBackupPoliciesResponse() + post_with_metadata.return_value = backup_policy.ListBackupPoliciesResponse(), metadata + + client.list_backup_policies(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_update_backup_policy_rest_bad_request(request_type=gcn_backup_policy.UpdateBackupPolicyRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'backup_policy': {'name': 'projects/sample1/locations/sample2/backupPolicies/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_backup_policy(request) + + +@pytest.mark.parametrize("request_type", [ + gcn_backup_policy.UpdateBackupPolicyRequest, + dict, +]) +def test_update_backup_policy_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'backup_policy': {'name': 'projects/sample1/locations/sample2/backupPolicies/sample3'}} + request_init["backup_policy"] = {'name': 'projects/sample1/locations/sample2/backupPolicies/sample3', 'daily_backup_limit': 1894, 'weekly_backup_limit': 2020, 'monthly_backup_limit': 2142, 'description': 'description_value', 'enabled': True, 'assigned_volume_count': 2253, 'create_time': {'seconds': 751, 'nanos': 543}, 'labels': {}, '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 = gcn_backup_policy.UpdateBackupPolicyRequest.meta.fields["backup_policy"] + + 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["backup_policy"].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["backup_policy"][field])): + del request_init["backup_policy"][field][i][subfield] + else: + del request_init["backup_policy"][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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_backup_policy(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_update_backup_policy_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_update_backup_policy") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_update_backup_policy_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_update_backup_policy") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = gcn_backup_policy.UpdateBackupPolicyRequest.pb(gcn_backup_policy.UpdateBackupPolicyRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = gcn_backup_policy.UpdateBackupPolicyRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.update_backup_policy(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_backup_policy_rest_bad_request(request_type=backup_policy.DeleteBackupPolicyRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/backupPolicies/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_backup_policy(request) + + +@pytest.mark.parametrize("request_type", [ + backup_policy.DeleteBackupPolicyRequest, + dict, +]) +def test_delete_backup_policy_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/backupPolicies/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_backup_policy(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_backup_policy_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_delete_backup_policy") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_delete_backup_policy_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_delete_backup_policy") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = backup_policy.DeleteBackupPolicyRequest.pb(backup_policy.DeleteBackupPolicyRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = backup_policy.DeleteBackupPolicyRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.delete_backup_policy(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_quota_rules_rest_bad_request(request_type=quota_rule.ListQuotaRulesRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/volumes/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_quota_rules(request) + + +@pytest.mark.parametrize("request_type", [ + quota_rule.ListQuotaRulesRequest, + dict, +]) +def test_list_quota_rules_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/volumes/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 = quota_rule.ListQuotaRulesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_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 = quota_rule.ListQuotaRulesResponse.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_quota_rules(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListQuotaRulesPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_quota_rules_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_list_quota_rules") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_list_quota_rules_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_list_quota_rules") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = quota_rule.ListQuotaRulesRequest.pb(quota_rule.ListQuotaRulesRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = quota_rule.ListQuotaRulesResponse.to_json(quota_rule.ListQuotaRulesResponse()) + req.return_value.content = return_value + + request = quota_rule.ListQuotaRulesRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = quota_rule.ListQuotaRulesResponse() + post_with_metadata.return_value = quota_rule.ListQuotaRulesResponse(), metadata + + client.list_quota_rules(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_quota_rule_rest_bad_request(request_type=quota_rule.GetQuotaRuleRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/quotaRules/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_quota_rule(request) + + +@pytest.mark.parametrize("request_type", [ + quota_rule.GetQuotaRuleRequest, + dict, +]) +def test_get_quota_rule_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/quotaRules/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 = quota_rule.QuotaRule( + name='name_value', + target='target_value', + type_=quota_rule.QuotaRule.Type.INDIVIDUAL_USER_QUOTA, + disk_limit_mib=1472, + state=quota_rule.QuotaRule.State.CREATING, + state_details='state_details_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 = quota_rule.QuotaRule.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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_quota_rule(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, quota_rule.QuotaRule) + assert response.name == 'name_value' + assert response.target == 'target_value' + assert response.type_ == quota_rule.QuotaRule.Type.INDIVIDUAL_USER_QUOTA + assert response.disk_limit_mib == 1472 + assert response.state == quota_rule.QuotaRule.State.CREATING + assert response.state_details == 'state_details_value' + assert response.description == 'description_value' + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_quota_rule_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_get_quota_rule") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_get_quota_rule_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_get_quota_rule") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = quota_rule.GetQuotaRuleRequest.pb(quota_rule.GetQuotaRuleRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = quota_rule.QuotaRule.to_json(quota_rule.QuotaRule()) + req.return_value.content = return_value + + request = quota_rule.GetQuotaRuleRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = quota_rule.QuotaRule() + post_with_metadata.return_value = quota_rule.QuotaRule(), metadata + + client.get_quota_rule(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_quota_rule_rest_bad_request(request_type=gcn_quota_rule.CreateQuotaRuleRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/volumes/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_quota_rule(request) + + +@pytest.mark.parametrize("request_type", [ + gcn_quota_rule.CreateQuotaRuleRequest, + dict, +]) +def test_create_quota_rule_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/volumes/sample3'} + request_init["quota_rule"] = {'name': 'name_value', 'target': 'target_value', 'type_': 1, 'disk_limit_mib': 1472, 'state': 1, 'state_details': 'state_details_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'description': 'description_value', 'labels': {}} + # 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 = gcn_quota_rule.CreateQuotaRuleRequest.meta.fields["quota_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["quota_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["quota_rule"][field])): + del request_init["quota_rule"][field][i][subfield] + else: + del request_init["quota_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') + + # 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_quota_rule(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_quota_rule_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_create_quota_rule") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_create_quota_rule_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_create_quota_rule") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = gcn_quota_rule.CreateQuotaRuleRequest.pb(gcn_quota_rule.CreateQuotaRuleRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = gcn_quota_rule.CreateQuotaRuleRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_quota_rule(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_update_quota_rule_rest_bad_request(request_type=gcn_quota_rule.UpdateQuotaRuleRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'quota_rule': {'name': 'projects/sample1/locations/sample2/volumes/sample3/quotaRules/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_quota_rule(request) + + +@pytest.mark.parametrize("request_type", [ + gcn_quota_rule.UpdateQuotaRuleRequest, + dict, +]) +def test_update_quota_rule_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'quota_rule': {'name': 'projects/sample1/locations/sample2/volumes/sample3/quotaRules/sample4'}} + request_init["quota_rule"] = {'name': 'projects/sample1/locations/sample2/volumes/sample3/quotaRules/sample4', 'target': 'target_value', 'type_': 1, 'disk_limit_mib': 1472, 'state': 1, 'state_details': 'state_details_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'description': 'description_value', 'labels': {}} + # 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 = gcn_quota_rule.UpdateQuotaRuleRequest.meta.fields["quota_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["quota_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["quota_rule"][field])): + del request_init["quota_rule"][field][i][subfield] + else: + del request_init["quota_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') + + # 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_quota_rule(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_update_quota_rule_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_update_quota_rule") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_update_quota_rule_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_update_quota_rule") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = gcn_quota_rule.UpdateQuotaRuleRequest.pb(gcn_quota_rule.UpdateQuotaRuleRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = gcn_quota_rule.UpdateQuotaRuleRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.update_quota_rule(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_quota_rule_rest_bad_request(request_type=quota_rule.DeleteQuotaRuleRequest): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/quotaRules/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_quota_rule(request) + + +@pytest.mark.parametrize("request_type", [ + quota_rule.DeleteQuotaRuleRequest, + dict, +]) +def test_delete_quota_rule_rest_call_success(request_type): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/quotaRules/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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_quota_rule(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_quota_rule_rest_interceptors(null_interceptor): + transport = transports.NetAppRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), + ) + client = NetAppClient(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.NetAppRestInterceptor, "post_delete_quota_rule") as post, \ + mock.patch.object(transports.NetAppRestInterceptor, "post_delete_quota_rule_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.NetAppRestInterceptor, "pre_delete_quota_rule") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = quota_rule.DeleteQuotaRuleRequest.pb(quota_rule.DeleteQuotaRuleRequest()) + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = quota_rule.DeleteQuotaRuleRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.delete_quota_rule(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationRequest): + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_location(request) + + +@pytest.mark.parametrize("request_type", [ + locations_pb2.GetLocationRequest, + dict, +]) +def test_get_location_rest(request_type): + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + 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 = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_locations(request) + + +@pytest.mark.parametrize("request_type", [ + locations_pb2.ListLocationsRequest, + dict, +]) +def test_list_locations_rest(request_type): + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_locations(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, locations_pb2.ListLocationsResponse) + + +def test_cancel_operation_rest_bad_request(request_type=operations_pb2.CancelOperationRequest): + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.cancel_operation(request) + + +@pytest.mark.parametrize("request_type", [ + operations_pb2.CancelOperationRequest, + dict, +]) +def test_cancel_operation_rest(request_type): + client = NetAppClient( + 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 = 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.cancel_operation(request) + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_operation_rest_bad_request(request_type=operations_pb2.DeleteOperationRequest): + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_operation(request) + + +@pytest.mark.parametrize("request_type", [ + operations_pb2.DeleteOperationRequest, + dict, +]) +def test_delete_operation_rest(request_type): + client = NetAppClient( + 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 = 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_operation(request) + + # Establish that the response is the type that we expect. + assert response is None + + +def test_get_operation_rest_bad_request(request_type=operations_pb2.GetOperationRequest): + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_operation(request) + + +@pytest.mark.parametrize("request_type", [ + operations_pb2.GetOperationRequest, + dict, +]) +def test_get_operation_rest(request_type): + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_operation(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + + +def test_list_operations_rest_bad_request(request_type=operations_pb2.ListOperationsRequest): + client = NetAppClient( + 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_operations(request) + + +@pytest.mark.parametrize("request_type", [ + operations_pb2.ListOperationsRequest, + dict, +]) +def test_list_operations_rest(request_type): + client = NetAppClient( + 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 = operations_pb2.ListOperationsResponse() + + # 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 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_operations(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.ListOperationsResponse) + +def test_initialize_client_w_rest(): + client = NetAppClient( + 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_storage_pools_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_storage_pools), + '__call__') as call: + client.list_storage_pools(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = storage_pool.ListStoragePoolsRequest() + + assert args[0] == request_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_storage_pool_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_storage_pool), + '__call__') as call: + client.create_storage_pool(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_storage_pool.CreateStoragePoolRequest() + + assert args[0] == request_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_storage_pool_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_storage_pool), + '__call__') as call: + client.get_storage_pool(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = storage_pool.GetStoragePoolRequest() + + assert args[0] == request_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_storage_pool_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_storage_pool), + '__call__') as call: + client.update_storage_pool(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_storage_pool.UpdateStoragePoolRequest() + + assert args[0] == request_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_storage_pool_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_storage_pool), + '__call__') as call: + client.delete_storage_pool(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = storage_pool.DeleteStoragePoolRequest() + + assert args[0] == request_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_validate_directory_service_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.validate_directory_service), + '__call__') as call: + client.validate_directory_service(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = storage_pool.ValidateDirectoryServiceRequest() + + assert args[0] == request_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_switch_active_replica_zone_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.switch_active_replica_zone), + '__call__') as call: + client.switch_active_replica_zone(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = storage_pool.SwitchActiveReplicaZoneRequest() + + assert args[0] == request_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_volumes_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_volumes), + '__call__') as call: + client.list_volumes(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = volume.ListVolumesRequest() + + assert args[0] == request_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_volume_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_volume), + '__call__') as call: + client.get_volume(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = volume.GetVolumeRequest() + + assert args[0] == request_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_volume_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_volume), + '__call__') as call: + client.create_volume(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_volume.CreateVolumeRequest() + + assert args[0] == request_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_volume_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_volume), + '__call__') as call: + client.update_volume(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_volume.UpdateVolumeRequest() + + assert args[0] == request_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_volume_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_volume), + '__call__') as call: + client.delete_volume(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = volume.DeleteVolumeRequest() + + assert args[0] == request_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_revert_volume_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.revert_volume), + '__call__') as call: + client.revert_volume(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = volume.RevertVolumeRequest() + + assert args[0] == request_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_snapshots_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_snapshots), + '__call__') as call: + client.list_snapshots(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = snapshot.ListSnapshotsRequest() + + assert args[0] == request_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_snapshot_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_snapshot), + '__call__') as call: + client.get_snapshot(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = snapshot.GetSnapshotRequest() + + assert args[0] == request_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_snapshot_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_snapshot), + '__call__') as call: + client.create_snapshot(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_snapshot.CreateSnapshotRequest() + + assert args[0] == request_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_snapshot_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_snapshot), + '__call__') as call: + client.delete_snapshot(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = snapshot.DeleteSnapshotRequest() + + assert args[0] == request_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_snapshot_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_snapshot), + '__call__') as call: + client.update_snapshot(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_snapshot.UpdateSnapshotRequest() + + assert args[0] == request_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_active_directories_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_active_directories), + '__call__') as call: + client.list_active_directories(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = active_directory.ListActiveDirectoriesRequest() + + assert args[0] == request_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_active_directory_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_active_directory), + '__call__') as call: + client.get_active_directory(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = active_directory.GetActiveDirectoryRequest() + + assert args[0] == request_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_active_directory_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_active_directory), + '__call__') as call: + client.create_active_directory(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_active_directory.CreateActiveDirectoryRequest() + + assert args[0] == request_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_active_directory_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_active_directory), + '__call__') as call: + client.update_active_directory(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_active_directory.UpdateActiveDirectoryRequest() + + assert args[0] == request_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_active_directory_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_active_directory), + '__call__') as call: + client.delete_active_directory(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = active_directory.DeleteActiveDirectoryRequest() + + assert args[0] == request_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_kms_configs_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_kms_configs), + '__call__') as call: + client.list_kms_configs(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = kms.ListKmsConfigsRequest() + + assert args[0] == request_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_kms_config_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_kms_config), + '__call__') as call: + client.create_kms_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = kms.CreateKmsConfigRequest() + + assert args[0] == request_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_kms_config_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_kms_config), + '__call__') as call: + client.get_kms_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = kms.GetKmsConfigRequest() + + assert args[0] == request_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_kms_config_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_kms_config), + '__call__') as call: + client.update_kms_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = kms.UpdateKmsConfigRequest() + + assert args[0] == request_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_encrypt_volumes_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.encrypt_volumes), + '__call__') as call: + client.encrypt_volumes(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = kms.EncryptVolumesRequest() + + assert args[0] == request_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_verify_kms_config_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.verify_kms_config), + '__call__') as call: + client.verify_kms_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = kms.VerifyKmsConfigRequest() + + assert args[0] == request_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_kms_config_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_kms_config), + '__call__') as call: + client.delete_kms_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = kms.DeleteKmsConfigRequest() + + assert args[0] == request_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_replications_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_replications), + '__call__') as call: + client.list_replications(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.ListReplicationsRequest() + + assert args[0] == request_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_replication_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_replication), + '__call__') as call: + client.get_replication(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.GetReplicationRequest() + + assert args[0] == request_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_replication_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_replication), + '__call__') as call: + client.create_replication(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_replication.CreateReplicationRequest() + + assert args[0] == request_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_replication_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_replication), + '__call__') as call: + client.delete_replication(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.DeleteReplicationRequest() + + assert args[0] == request_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_replication_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_replication), + '__call__') as call: + client.update_replication(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_replication.UpdateReplicationRequest() + + assert args[0] == request_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_stop_replication_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.stop_replication), + '__call__') as call: + client.stop_replication(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.StopReplicationRequest() + + assert args[0] == request_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_resume_replication_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.resume_replication), + '__call__') as call: + client.resume_replication(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.ResumeReplicationRequest() + + assert args[0] == request_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_reverse_replication_direction_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.reverse_replication_direction), + '__call__') as call: + client.reverse_replication_direction(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.ReverseReplicationDirectionRequest() + + assert args[0] == request_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_establish_peering_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.establish_peering), + '__call__') as call: + client.establish_peering(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.EstablishPeeringRequest() + + assert args[0] == request_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_sync_replication_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.sync_replication), + '__call__') as call: + client.sync_replication(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = replication.SyncReplicationRequest() + + assert args[0] == request_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_backup_vault_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_backup_vault), + '__call__') as call: + client.create_backup_vault(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_backup_vault.CreateBackupVaultRequest() + + assert args[0] == request_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_backup_vault_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_backup_vault), + '__call__') as call: + client.get_backup_vault(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup_vault.GetBackupVaultRequest() + + assert args[0] == request_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_backup_vaults_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_backup_vaults), + '__call__') as call: + client.list_backup_vaults(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup_vault.ListBackupVaultsRequest() + + assert args[0] == request_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_backup_vault_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_backup_vault), + '__call__') as call: + client.update_backup_vault(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_backup_vault.UpdateBackupVaultRequest() + + assert args[0] == request_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_backup_vault_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup_vault), + '__call__') as call: + client.delete_backup_vault(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup_vault.DeleteBackupVaultRequest() + + assert args[0] == request_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_backup_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_backup), + '__call__') as call: + client.create_backup(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_backup.CreateBackupRequest() + + assert args[0] == request_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_backup_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_backup), + '__call__') as call: + client.get_backup(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup.GetBackupRequest() + + assert args[0] == request_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_backups_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_backups), + '__call__') as call: + client.list_backups(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup.ListBackupsRequest() + + assert args[0] == request_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_backup_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup), + '__call__') as call: + client.delete_backup(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup.DeleteBackupRequest() + + assert args[0] == request_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_backup_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_backup), + '__call__') as call: + client.update_backup(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_backup.UpdateBackupRequest() + + assert args[0] == request_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_backup_policy_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_backup_policy), + '__call__') as call: + client.create_backup_policy(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_backup_policy.CreateBackupPolicyRequest() + + assert args[0] == request_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_backup_policy_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_backup_policy), + '__call__') as call: + client.get_backup_policy(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup_policy.GetBackupPolicyRequest() + + assert args[0] == request_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_backup_policies_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_backup_policies), + '__call__') as call: + client.list_backup_policies(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup_policy.ListBackupPoliciesRequest() + + assert args[0] == request_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_backup_policy_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_backup_policy), + '__call__') as call: + client.update_backup_policy(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_backup_policy.UpdateBackupPolicyRequest() + + assert args[0] == request_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_backup_policy_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_backup_policy), + '__call__') as call: + client.delete_backup_policy(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = backup_policy.DeleteBackupPolicyRequest() + + assert args[0] == request_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_quota_rules_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_quota_rules), + '__call__') as call: + client.list_quota_rules(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = quota_rule.ListQuotaRulesRequest() + + assert args[0] == request_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_quota_rule_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_quota_rule), + '__call__') as call: + client.get_quota_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = quota_rule.GetQuotaRuleRequest() + + assert args[0] == request_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_quota_rule_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_quota_rule), + '__call__') as call: + client.create_quota_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_quota_rule.CreateQuotaRuleRequest() + + assert args[0] == request_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_quota_rule_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_quota_rule), + '__call__') as call: + client.update_quota_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gcn_quota_rule.UpdateQuotaRuleRequest() + + assert args[0] == request_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_quota_rule_empty_call_rest(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_quota_rule), + '__call__') as call: + client.delete_quota_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = quota_rule.DeleteQuotaRuleRequest() + + assert args[0] == request_msg + + +def test_net_app_rest_lro_client(): + client = NetAppClient( + 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 = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.NetAppGrpcTransport, + ) + +def test_net_app_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.NetAppTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_net_app_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.netapp_v1.services.net_app.transports.NetAppTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.NetAppTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'list_storage_pools', + 'create_storage_pool', + 'get_storage_pool', + 'update_storage_pool', + 'delete_storage_pool', + 'validate_directory_service', + 'switch_active_replica_zone', + 'list_volumes', + 'get_volume', + 'create_volume', + 'update_volume', + 'delete_volume', + 'revert_volume', + 'list_snapshots', + 'get_snapshot', + 'create_snapshot', + 'delete_snapshot', + 'update_snapshot', + 'list_active_directories', + 'get_active_directory', + 'create_active_directory', + 'update_active_directory', + 'delete_active_directory', + 'list_kms_configs', + 'create_kms_config', + 'get_kms_config', + 'update_kms_config', + 'encrypt_volumes', + 'verify_kms_config', + 'delete_kms_config', + 'list_replications', + 'get_replication', + 'create_replication', + 'delete_replication', + 'update_replication', + 'stop_replication', + 'resume_replication', + 'reverse_replication_direction', + 'establish_peering', + 'sync_replication', + 'create_backup_vault', + 'get_backup_vault', + 'list_backup_vaults', + 'update_backup_vault', + 'delete_backup_vault', + 'create_backup', + 'get_backup', + 'list_backups', + 'delete_backup', + 'update_backup', + 'create_backup_policy', + 'get_backup_policy', + 'list_backup_policies', + 'update_backup_policy', + 'delete_backup_policy', + 'list_quota_rules', + 'get_quota_rule', + 'create_quota_rule', + 'update_quota_rule', + 'delete_quota_rule', + 'get_location', + 'list_locations', + 'get_operation', + 'cancel_operation', + 'delete_operation', + 'list_operations', + ) + 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_net_app_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.netapp_v1.services.net_app.transports.NetAppTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.NetAppTransport( + 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', +), + quota_project_id="octopus", + ) + + +def test_net_app_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.netapp_v1.services.net_app.transports.NetAppTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.NetAppTransport() + adc.assert_called_once() + + +def test_net_app_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) + NetAppClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id=None, + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.NetAppGrpcTransport, + transports.NetAppGrpcAsyncIOTransport, + ], +) +def test_net_app_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',), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.NetAppGrpcTransport, + transports.NetAppGrpcAsyncIOTransport, + transports.NetAppRestTransport, + ], +) +def test_net_app_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.NetAppGrpcTransport, grpc_helpers), + (transports.NetAppGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_net_app_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( + "netapp.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + scopes=["1", "2"], + default_host="netapp.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize("transport_class", [transports.NetAppGrpcTransport, transports.NetAppGrpcAsyncIOTransport]) +def test_net_app_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_net_app_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.NetAppRestTransport ( + 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_net_app_host_no_port(transport_name): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='netapp.googleapis.com'), + transport=transport_name, + ) + assert client.transport._host == ( + 'netapp.googleapis.com:443' + if transport_name in ['grpc', 'grpc_asyncio'] + else 'https://netapp.googleapis.com' + ) + +@pytest.mark.parametrize("transport_name", [ + "grpc", + "grpc_asyncio", + "rest", +]) +def test_net_app_host_with_port(transport_name): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='netapp.googleapis.com:8000'), + transport=transport_name, + ) + assert client.transport._host == ( + 'netapp.googleapis.com:8000' + if transport_name in ['grpc', 'grpc_asyncio'] + else 'https://netapp.googleapis.com:8000' + ) + +@pytest.mark.parametrize("transport_name", [ + "rest", +]) +def test_net_app_client_transport_session_collision(transport_name): + creds1 = ga_credentials.AnonymousCredentials() + creds2 = ga_credentials.AnonymousCredentials() + client1 = NetAppClient( + credentials=creds1, + transport=transport_name, + ) + client2 = NetAppClient( + credentials=creds2, + transport=transport_name, + ) + session1 = client1.transport.list_storage_pools._session + session2 = client2.transport.list_storage_pools._session + assert session1 != session2 + session1 = client1.transport.create_storage_pool._session + session2 = client2.transport.create_storage_pool._session + assert session1 != session2 + session1 = client1.transport.get_storage_pool._session + session2 = client2.transport.get_storage_pool._session + assert session1 != session2 + session1 = client1.transport.update_storage_pool._session + session2 = client2.transport.update_storage_pool._session + assert session1 != session2 + session1 = client1.transport.delete_storage_pool._session + session2 = client2.transport.delete_storage_pool._session + assert session1 != session2 + session1 = client1.transport.validate_directory_service._session + session2 = client2.transport.validate_directory_service._session + assert session1 != session2 + session1 = client1.transport.switch_active_replica_zone._session + session2 = client2.transport.switch_active_replica_zone._session + assert session1 != session2 + session1 = client1.transport.list_volumes._session + session2 = client2.transport.list_volumes._session + assert session1 != session2 + session1 = client1.transport.get_volume._session + session2 = client2.transport.get_volume._session + assert session1 != session2 + session1 = client1.transport.create_volume._session + session2 = client2.transport.create_volume._session + assert session1 != session2 + session1 = client1.transport.update_volume._session + session2 = client2.transport.update_volume._session + assert session1 != session2 + session1 = client1.transport.delete_volume._session + session2 = client2.transport.delete_volume._session + assert session1 != session2 + session1 = client1.transport.revert_volume._session + session2 = client2.transport.revert_volume._session + assert session1 != session2 + session1 = client1.transport.list_snapshots._session + session2 = client2.transport.list_snapshots._session + assert session1 != session2 + session1 = client1.transport.get_snapshot._session + session2 = client2.transport.get_snapshot._session + assert session1 != session2 + session1 = client1.transport.create_snapshot._session + session2 = client2.transport.create_snapshot._session + assert session1 != session2 + session1 = client1.transport.delete_snapshot._session + session2 = client2.transport.delete_snapshot._session + assert session1 != session2 + session1 = client1.transport.update_snapshot._session + session2 = client2.transport.update_snapshot._session + assert session1 != session2 + session1 = client1.transport.list_active_directories._session + session2 = client2.transport.list_active_directories._session + assert session1 != session2 + session1 = client1.transport.get_active_directory._session + session2 = client2.transport.get_active_directory._session + assert session1 != session2 + session1 = client1.transport.create_active_directory._session + session2 = client2.transport.create_active_directory._session + assert session1 != session2 + session1 = client1.transport.update_active_directory._session + session2 = client2.transport.update_active_directory._session + assert session1 != session2 + session1 = client1.transport.delete_active_directory._session + session2 = client2.transport.delete_active_directory._session + assert session1 != session2 + session1 = client1.transport.list_kms_configs._session + session2 = client2.transport.list_kms_configs._session + assert session1 != session2 + session1 = client1.transport.create_kms_config._session + session2 = client2.transport.create_kms_config._session + assert session1 != session2 + session1 = client1.transport.get_kms_config._session + session2 = client2.transport.get_kms_config._session + assert session1 != session2 + session1 = client1.transport.update_kms_config._session + session2 = client2.transport.update_kms_config._session + assert session1 != session2 + session1 = client1.transport.encrypt_volumes._session + session2 = client2.transport.encrypt_volumes._session + assert session1 != session2 + session1 = client1.transport.verify_kms_config._session + session2 = client2.transport.verify_kms_config._session + assert session1 != session2 + session1 = client1.transport.delete_kms_config._session + session2 = client2.transport.delete_kms_config._session + assert session1 != session2 + session1 = client1.transport.list_replications._session + session2 = client2.transport.list_replications._session + assert session1 != session2 + session1 = client1.transport.get_replication._session + session2 = client2.transport.get_replication._session + assert session1 != session2 + session1 = client1.transport.create_replication._session + session2 = client2.transport.create_replication._session + assert session1 != session2 + session1 = client1.transport.delete_replication._session + session2 = client2.transport.delete_replication._session + assert session1 != session2 + session1 = client1.transport.update_replication._session + session2 = client2.transport.update_replication._session + assert session1 != session2 + session1 = client1.transport.stop_replication._session + session2 = client2.transport.stop_replication._session + assert session1 != session2 + session1 = client1.transport.resume_replication._session + session2 = client2.transport.resume_replication._session + assert session1 != session2 + session1 = client1.transport.reverse_replication_direction._session + session2 = client2.transport.reverse_replication_direction._session + assert session1 != session2 + session1 = client1.transport.establish_peering._session + session2 = client2.transport.establish_peering._session + assert session1 != session2 + session1 = client1.transport.sync_replication._session + session2 = client2.transport.sync_replication._session + assert session1 != session2 + session1 = client1.transport.create_backup_vault._session + session2 = client2.transport.create_backup_vault._session + assert session1 != session2 + session1 = client1.transport.get_backup_vault._session + session2 = client2.transport.get_backup_vault._session + assert session1 != session2 + session1 = client1.transport.list_backup_vaults._session + session2 = client2.transport.list_backup_vaults._session + assert session1 != session2 + session1 = client1.transport.update_backup_vault._session + session2 = client2.transport.update_backup_vault._session + assert session1 != session2 + session1 = client1.transport.delete_backup_vault._session + session2 = client2.transport.delete_backup_vault._session + assert session1 != session2 + session1 = client1.transport.create_backup._session + session2 = client2.transport.create_backup._session + assert session1 != session2 + session1 = client1.transport.get_backup._session + session2 = client2.transport.get_backup._session + assert session1 != session2 + session1 = client1.transport.list_backups._session + session2 = client2.transport.list_backups._session + assert session1 != session2 + session1 = client1.transport.delete_backup._session + session2 = client2.transport.delete_backup._session + assert session1 != session2 + session1 = client1.transport.update_backup._session + session2 = client2.transport.update_backup._session + assert session1 != session2 + session1 = client1.transport.create_backup_policy._session + session2 = client2.transport.create_backup_policy._session + assert session1 != session2 + session1 = client1.transport.get_backup_policy._session + session2 = client2.transport.get_backup_policy._session + assert session1 != session2 + session1 = client1.transport.list_backup_policies._session + session2 = client2.transport.list_backup_policies._session + assert session1 != session2 + session1 = client1.transport.update_backup_policy._session + session2 = client2.transport.update_backup_policy._session + assert session1 != session2 + session1 = client1.transport.delete_backup_policy._session + session2 = client2.transport.delete_backup_policy._session + assert session1 != session2 + session1 = client1.transport.list_quota_rules._session + session2 = client2.transport.list_quota_rules._session + assert session1 != session2 + session1 = client1.transport.get_quota_rule._session + session2 = client2.transport.get_quota_rule._session + assert session1 != session2 + session1 = client1.transport.create_quota_rule._session + session2 = client2.transport.create_quota_rule._session + assert session1 != session2 + session1 = client1.transport.update_quota_rule._session + session2 = client2.transport.update_quota_rule._session + assert session1 != session2 + session1 = client1.transport.delete_quota_rule._session + session2 = client2.transport.delete_quota_rule._session + assert session1 != session2 +def test_net_app_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.NetAppGrpcTransport( + 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_net_app_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.NetAppGrpcAsyncIOTransport( + 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.NetAppGrpcTransport, transports.NetAppGrpcAsyncIOTransport]) +def test_net_app_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.NetAppGrpcTransport, transports.NetAppGrpcAsyncIOTransport]) +def test_net_app_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_net_app_grpc_lro_client(): + client = NetAppClient( + 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_net_app_grpc_lro_async_client(): + client = NetAppAsyncClient( + 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_active_directory_path(): + project = "squid" + location = "clam" + active_directory = "whelk" + expected = "projects/{project}/locations/{location}/activeDirectories/{active_directory}".format(project=project, location=location, active_directory=active_directory, ) + actual = NetAppClient.active_directory_path(project, location, active_directory) + assert expected == actual + + +def test_parse_active_directory_path(): + expected = { + "project": "octopus", + "location": "oyster", + "active_directory": "nudibranch", + } + path = NetAppClient.active_directory_path(**expected) + + # Check that the path construction is reversible. + actual = NetAppClient.parse_active_directory_path(path) + assert expected == actual + +def test_backup_path(): + project = "cuttlefish" + location = "mussel" + backup_vault = "winkle" + backup = "nautilus" + expected = "projects/{project}/locations/{location}/backupVaults/{backup_vault}/backups/{backup}".format(project=project, location=location, backup_vault=backup_vault, backup=backup, ) + actual = NetAppClient.backup_path(project, location, backup_vault, backup) + assert expected == actual + + +def test_parse_backup_path(): + expected = { + "project": "scallop", + "location": "abalone", + "backup_vault": "squid", + "backup": "clam", + } + path = NetAppClient.backup_path(**expected) + + # Check that the path construction is reversible. + actual = NetAppClient.parse_backup_path(path) + assert expected == actual + +def test_backup_policy_path(): + project = "whelk" + location = "octopus" + backup_policy = "oyster" + expected = "projects/{project}/locations/{location}/backupPolicies/{backup_policy}".format(project=project, location=location, backup_policy=backup_policy, ) + actual = NetAppClient.backup_policy_path(project, location, backup_policy) + assert expected == actual + + +def test_parse_backup_policy_path(): + expected = { + "project": "nudibranch", + "location": "cuttlefish", + "backup_policy": "mussel", + } + path = NetAppClient.backup_policy_path(**expected) + + # Check that the path construction is reversible. + actual = NetAppClient.parse_backup_policy_path(path) + assert expected == actual + +def test_backup_vault_path(): + project = "winkle" + location = "nautilus" + backup_vault = "scallop" + expected = "projects/{project}/locations/{location}/backupVaults/{backup_vault}".format(project=project, location=location, backup_vault=backup_vault, ) + actual = NetAppClient.backup_vault_path(project, location, backup_vault) + assert expected == actual + + +def test_parse_backup_vault_path(): + expected = { + "project": "abalone", + "location": "squid", + "backup_vault": "clam", + } + path = NetAppClient.backup_vault_path(**expected) + + # Check that the path construction is reversible. + actual = NetAppClient.parse_backup_vault_path(path) + assert expected == actual + +def test_kms_config_path(): + project = "whelk" + location = "octopus" + kms_config = "oyster" + expected = "projects/{project}/locations/{location}/kmsConfigs/{kms_config}".format(project=project, location=location, kms_config=kms_config, ) + actual = NetAppClient.kms_config_path(project, location, kms_config) + assert expected == actual + + +def test_parse_kms_config_path(): + expected = { + "project": "nudibranch", + "location": "cuttlefish", + "kms_config": "mussel", + } + path = NetAppClient.kms_config_path(**expected) + + # Check that the path construction is reversible. + actual = NetAppClient.parse_kms_config_path(path) + assert expected == actual + +def test_network_path(): + project = "winkle" + network = "nautilus" + expected = "projects/{project}/global/networks/{network}".format(project=project, network=network, ) + actual = NetAppClient.network_path(project, network) + assert expected == actual + + +def test_parse_network_path(): + expected = { + "project": "scallop", + "network": "abalone", + } + path = NetAppClient.network_path(**expected) + + # Check that the path construction is reversible. + actual = NetAppClient.parse_network_path(path) + assert expected == actual + +def test_quota_rule_path(): + project = "squid" + location = "clam" + volume = "whelk" + quota_rule = "octopus" + expected = "projects/{project}/locations/{location}/volumes/{volume}/quotaRules/{quota_rule}".format(project=project, location=location, volume=volume, quota_rule=quota_rule, ) + actual = NetAppClient.quota_rule_path(project, location, volume, quota_rule) + assert expected == actual + + +def test_parse_quota_rule_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + "volume": "cuttlefish", + "quota_rule": "mussel", + } + path = NetAppClient.quota_rule_path(**expected) + + # Check that the path construction is reversible. + actual = NetAppClient.parse_quota_rule_path(path) + assert expected == actual + +def test_replication_path(): + project = "winkle" + location = "nautilus" + volume = "scallop" + replication = "abalone" + expected = "projects/{project}/locations/{location}/volumes/{volume}/replications/{replication}".format(project=project, location=location, volume=volume, replication=replication, ) + actual = NetAppClient.replication_path(project, location, volume, replication) + assert expected == actual + + +def test_parse_replication_path(): + expected = { + "project": "squid", + "location": "clam", + "volume": "whelk", + "replication": "octopus", + } + path = NetAppClient.replication_path(**expected) + + # Check that the path construction is reversible. + actual = NetAppClient.parse_replication_path(path) + assert expected == actual + +def test_snapshot_path(): + project = "oyster" + location = "nudibranch" + volume = "cuttlefish" + snapshot = "mussel" + expected = "projects/{project}/locations/{location}/volumes/{volume}/snapshots/{snapshot}".format(project=project, location=location, volume=volume, snapshot=snapshot, ) + actual = NetAppClient.snapshot_path(project, location, volume, snapshot) + assert expected == actual + + +def test_parse_snapshot_path(): + expected = { + "project": "winkle", + "location": "nautilus", + "volume": "scallop", + "snapshot": "abalone", + } + path = NetAppClient.snapshot_path(**expected) + + # Check that the path construction is reversible. + actual = NetAppClient.parse_snapshot_path(path) + assert expected == actual + +def test_storage_pool_path(): + project = "squid" + location = "clam" + storage_pool = "whelk" + expected = "projects/{project}/locations/{location}/storagePools/{storage_pool}".format(project=project, location=location, storage_pool=storage_pool, ) + actual = NetAppClient.storage_pool_path(project, location, storage_pool) + assert expected == actual + + +def test_parse_storage_pool_path(): + expected = { + "project": "octopus", + "location": "oyster", + "storage_pool": "nudibranch", + } + path = NetAppClient.storage_pool_path(**expected) + + # Check that the path construction is reversible. + actual = NetAppClient.parse_storage_pool_path(path) + assert expected == actual + +def test_volume_path(): + project = "cuttlefish" + location = "mussel" + volume = "winkle" + expected = "projects/{project}/locations/{location}/volumes/{volume}".format(project=project, location=location, volume=volume, ) + actual = NetAppClient.volume_path(project, location, volume) + assert expected == actual + + +def test_parse_volume_path(): + expected = { + "project": "nautilus", + "location": "scallop", + "volume": "abalone", + } + path = NetAppClient.volume_path(**expected) + + # Check that the path construction is reversible. + actual = NetAppClient.parse_volume_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "squid" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = NetAppClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "clam", + } + path = NetAppClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = NetAppClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "whelk" + expected = "folders/{folder}".format(folder=folder, ) + actual = NetAppClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "octopus", + } + path = NetAppClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = NetAppClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "oyster" + expected = "organizations/{organization}".format(organization=organization, ) + actual = NetAppClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "nudibranch", + } + path = NetAppClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = NetAppClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "cuttlefish" + expected = "projects/{project}".format(project=project, ) + actual = NetAppClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "mussel", + } + path = NetAppClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = NetAppClient.parse_common_project_path(path) + assert expected == actual + +def test_common_location_path(): + project = "winkle" + location = "nautilus" + expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + actual = NetAppClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "scallop", + "location": "abalone", + } + path = NetAppClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = NetAppClient.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.NetAppTransport, '_prep_wrapped_messages') as prep: + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.NetAppTransport, '_prep_wrapped_messages') as prep: + transport_class = NetAppClient.get_transport_class() + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + +def test_delete_operation(transport: str = "grpc"): + client = NetAppClient( + 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.DeleteOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_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 response is None +@pytest.mark.asyncio +async def test_delete_operation_async(transport: str = "grpc_asyncio"): + client = NetAppAsyncClient( + 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.DeleteOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + None + ) + response = await client.delete_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 response is None + +def test_delete_operation_field_headers(): + client = NetAppClient( + 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.DeleteOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: + call.return_value = None + + client.delete_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_delete_operation_field_headers_async(): + client = NetAppAsyncClient( + 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.DeleteOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + None + ) + await client.delete_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_delete_operation_from_dict(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + + response = client.delete_operation( + request={ + "name": "locations", + } + ) + call.assert_called() +@pytest.mark.asyncio +async def test_delete_operation_from_dict_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + None + ) + response = await client.delete_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + +def test_cancel_operation(transport: str = "grpc"): + client = NetAppClient( + 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.CancelOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.cancel_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 response is None +@pytest.mark.asyncio +async def test_cancel_operation_async(transport: str = "grpc_asyncio"): + client = NetAppAsyncClient( + 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.CancelOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + None + ) + response = await client.cancel_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 response is None + +def test_cancel_operation_field_headers(): + client = NetAppClient( + 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.CancelOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + call.return_value = None + + client.cancel_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_cancel_operation_field_headers_async(): + client = NetAppAsyncClient( + 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.CancelOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + None + ) + await client.cancel_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_cancel_operation_from_dict(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + + response = client.cancel_operation( + request={ + "name": "locations", + } + ) + call.assert_called() +@pytest.mark.asyncio +async def test_cancel_operation_from_dict_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + None + ) + response = await client.cancel_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + +def test_get_operation(transport: str = "grpc"): + client = NetAppClient( + 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 = NetAppAsyncClient( + 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 = NetAppClient( + 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 = NetAppAsyncClient( + 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 = NetAppClient( + 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 = NetAppAsyncClient( + 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_operations(transport: str = "grpc"): + client = NetAppClient( + 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.ListOperationsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.ListOperationsResponse() + response = client.list_operations(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.ListOperationsResponse) +@pytest.mark.asyncio +async def test_list_operations_async(transport: str = "grpc_asyncio"): + client = NetAppAsyncClient( + 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.ListOperationsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.ListOperationsResponse() + ) + response = await client.list_operations(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.ListOperationsResponse) + +def test_list_operations_field_headers(): + client = NetAppClient( + 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.ListOperationsRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + call.return_value = operations_pb2.ListOperationsResponse() + + client.list_operations(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_operations_field_headers_async(): + client = NetAppAsyncClient( + 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.ListOperationsRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.ListOperationsResponse() + ) + await client.list_operations(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_operations_from_dict(): + client = NetAppClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.ListOperationsResponse() + + response = client.list_operations( + request={ + "name": "locations", + } + ) + call.assert_called() +@pytest.mark.asyncio +async def test_list_operations_from_dict_async(): + client = NetAppAsyncClient( + credentials=async_anonymous_credentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.ListOperationsResponse() + ) + response = await client.list_operations( + request={ + "name": "locations", + } + ) + call.assert_called() + + +def test_list_locations(transport: str = "grpc"): + client = NetAppClient( + 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 = NetAppAsyncClient( + 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 = NetAppClient( + 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 = NetAppAsyncClient( + 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 = NetAppClient( + 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 = NetAppAsyncClient( + 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 = NetAppClient( + 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 = NetAppAsyncClient( + 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 = NetAppClient( + 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 = NetAppAsyncClient( + 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 = NetAppClient( + 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 = NetAppAsyncClient( + 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 = NetAppClient( + 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 = NetAppAsyncClient( + 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 = NetAppClient( + 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 = NetAppClient( + 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", [ + (NetAppClient, transports.NetAppGrpcTransport), + (NetAppAsyncClient, transports.NetAppGrpcAsyncIOTransport), +]) +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, + ) From e4065d7e09bebe546dfe3a7c74991d7c455f5579 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 15 Apr 2025 23:16:37 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= 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 --- .../google-cloud-netapp/v1/.coveragerc | 13 - .../google-cloud-netapp/v1/.flake8 | 34 - .../google-cloud-netapp/v1/LICENSE | 202 - .../google-cloud-netapp/v1/MANIFEST.in | 20 - .../google-cloud-netapp/v1/README.rst | 143 - .../v1/docs/_static/custom.css | 3 - .../google-cloud-netapp/v1/docs/conf.py | 376 - .../google-cloud-netapp/v1/docs/index.rst | 7 - .../v1/docs/netapp_v1/net_app.rst | 10 - .../v1/docs/netapp_v1/services_.rst | 6 - .../v1/docs/netapp_v1/types_.rst | 6 - .../v1/google/cloud/netapp/__init__.py | 241 - .../v1/google/cloud/netapp/gapic_version.py | 16 - .../v1/google/cloud/netapp/py.typed | 2 - .../v1/google/cloud/netapp_v1/__init__.py | 242 - .../cloud/netapp_v1/gapic_metadata.json | 928 - .../google/cloud/netapp_v1/gapic_version.py | 16 - .../v1/google/cloud/netapp_v1/py.typed | 2 - .../cloud/netapp_v1/services/__init__.py | 15 - .../netapp_v1/services/net_app/__init__.py | 22 - .../services/net_app/async_client.py | 8035 --- .../netapp_v1/services/net_app/client.py | 8448 --- .../netapp_v1/services/net_app/pagers.py | 1426 - .../services/net_app/transports/README.rst | 9 - .../services/net_app/transports/__init__.py | 38 - .../services/net_app/transports/base.py | 1251 - .../services/net_app/transports/grpc.py | 2052 - .../net_app/transports/grpc_asyncio.py | 2560 - .../services/net_app/transports/rest.py | 11531 ---- .../services/net_app/transports/rest_base.py | 2786 - .../google/cloud/netapp_v1/types/__init__.py | 256 - .../cloud/netapp_v1/types/active_directory.py | 401 - .../v1/google/cloud/netapp_v1/types/backup.py | 372 - .../cloud/netapp_v1/types/backup_policy.py | 333 - .../cloud/netapp_v1/types/backup_vault.py | 274 - .../netapp_v1/types/cloud_netapp_service.py | 95 - .../v1/google/cloud/netapp_v1/types/common.py | 130 - .../v1/google/cloud/netapp_v1/types/kms.py | 381 - .../cloud/netapp_v1/types/quota_rule.py | 321 - .../cloud/netapp_v1/types/replication.py | 817 - .../google/cloud/netapp_v1/types/snapshot.py | 290 - .../cloud/netapp_v1/types/storage_pool.py | 440 - .../v1/google/cloud/netapp_v1/types/volume.py | 1322 - .../google-cloud-netapp/v1/mypy.ini | 3 - .../google-cloud-netapp/v1/noxfile.py | 591 - ...d_net_app_create_active_directory_async.py | 65 - ...ed_net_app_create_active_directory_sync.py | 65 - ...1_generated_net_app_create_backup_async.py | 57 - ...ated_net_app_create_backup_policy_async.py | 57 - ...rated_net_app_create_backup_policy_sync.py | 57 - ...v1_generated_net_app_create_backup_sync.py | 57 - ...rated_net_app_create_backup_vault_async.py | 57 - ...erated_net_app_create_backup_vault_sync.py | 57 - ...nerated_net_app_create_kms_config_async.py | 61 - ...enerated_net_app_create_kms_config_sync.py | 61 - ...nerated_net_app_create_quota_rule_async.py | 62 - ...enerated_net_app_create_quota_rule_sync.py | 62 - ...erated_net_app_create_replication_async.py | 62 - ...nerated_net_app_create_replication_sync.py | 62 - ...generated_net_app_create_snapshot_async.py | 57 - ..._generated_net_app_create_snapshot_sync.py | 57 - ...rated_net_app_create_storage_pool_async.py | 63 - ...erated_net_app_create_storage_pool_sync.py | 63 - ...1_generated_net_app_create_volume_async.py | 64 - ...v1_generated_net_app_create_volume_sync.py | 64 - ...d_net_app_delete_active_directory_async.py | 56 - ...ed_net_app_delete_active_directory_sync.py | 56 - ...1_generated_net_app_delete_backup_async.py | 56 - ...ated_net_app_delete_backup_policy_async.py | 56 - ...rated_net_app_delete_backup_policy_sync.py | 56 - ...v1_generated_net_app_delete_backup_sync.py | 56 - ...rated_net_app_delete_backup_vault_async.py | 56 - ...erated_net_app_delete_backup_vault_sync.py | 56 - ...nerated_net_app_delete_kms_config_async.py | 56 - ...enerated_net_app_delete_kms_config_sync.py | 56 - ...nerated_net_app_delete_quota_rule_async.py | 56 - ...enerated_net_app_delete_quota_rule_sync.py | 56 - ...erated_net_app_delete_replication_async.py | 56 - ...nerated_net_app_delete_replication_sync.py | 56 - ...generated_net_app_delete_snapshot_async.py | 56 - ..._generated_net_app_delete_snapshot_sync.py | 56 - ...rated_net_app_delete_storage_pool_async.py | 56 - ...erated_net_app_delete_storage_pool_sync.py | 56 - ...1_generated_net_app_delete_volume_async.py | 56 - ...v1_generated_net_app_delete_volume_sync.py | 56 - ...generated_net_app_encrypt_volumes_async.py | 56 - ..._generated_net_app_encrypt_volumes_sync.py | 56 - ...nerated_net_app_establish_peering_async.py | 59 - ...enerated_net_app_establish_peering_sync.py | 59 - ...ated_net_app_get_active_directory_async.py | 52 - ...rated_net_app_get_active_directory_sync.py | 52 - ...p_v1_generated_net_app_get_backup_async.py | 52 - ...nerated_net_app_get_backup_policy_async.py | 52 - ...enerated_net_app_get_backup_policy_sync.py | 52 - ...pp_v1_generated_net_app_get_backup_sync.py | 52 - ...enerated_net_app_get_backup_vault_async.py | 52 - ...generated_net_app_get_backup_vault_sync.py | 52 - ..._generated_net_app_get_kms_config_async.py | 52 - ...1_generated_net_app_get_kms_config_sync.py | 52 - ..._generated_net_app_get_quota_rule_async.py | 52 - ...1_generated_net_app_get_quota_rule_sync.py | 52 - ...generated_net_app_get_replication_async.py | 52 - ..._generated_net_app_get_replication_sync.py | 52 - ...v1_generated_net_app_get_snapshot_async.py | 52 - ..._v1_generated_net_app_get_snapshot_sync.py | 52 - ...enerated_net_app_get_storage_pool_async.py | 52 - ...generated_net_app_get_storage_pool_sync.py | 52 - ...p_v1_generated_net_app_get_volume_async.py | 52 - ...pp_v1_generated_net_app_get_volume_sync.py | 52 - ...d_net_app_list_active_directories_async.py | 53 - ...ed_net_app_list_active_directories_sync.py | 53 - ...ated_net_app_list_backup_policies_async.py | 53 - ...rated_net_app_list_backup_policies_sync.py | 53 - ...erated_net_app_list_backup_vaults_async.py | 53 - ...nerated_net_app_list_backup_vaults_sync.py | 53 - ...v1_generated_net_app_list_backups_async.py | 53 - ..._v1_generated_net_app_list_backups_sync.py | 53 - ...enerated_net_app_list_kms_configs_async.py | 53 - ...generated_net_app_list_kms_configs_sync.py | 53 - ...enerated_net_app_list_quota_rules_async.py | 53 - ...generated_net_app_list_quota_rules_sync.py | 53 - ...nerated_net_app_list_replications_async.py | 53 - ...enerated_net_app_list_replications_sync.py | 53 - ..._generated_net_app_list_snapshots_async.py | 53 - ...1_generated_net_app_list_snapshots_sync.py | 53 - ...erated_net_app_list_storage_pools_async.py | 53 - ...nerated_net_app_list_storage_pools_sync.py | 53 - ...v1_generated_net_app_list_volumes_async.py | 53 - ..._v1_generated_net_app_list_volumes_sync.py | 53 - ...erated_net_app_resume_replication_async.py | 56 - ...nerated_net_app_resume_replication_sync.py | 56 - ...app_reverse_replication_direction_async.py | 56 - ..._app_reverse_replication_direction_sync.py | 56 - ...1_generated_net_app_revert_volume_async.py | 57 - ...v1_generated_net_app_revert_volume_sync.py | 57 - ...enerated_net_app_stop_replication_async.py | 56 - ...generated_net_app_stop_replication_sync.py | 56 - ...et_app_switch_active_replica_zone_async.py | 56 - ...net_app_switch_active_replica_zone_sync.py | 56 - ...enerated_net_app_sync_replication_async.py | 56 - ...generated_net_app_sync_replication_sync.py | 56 - ...d_net_app_update_active_directory_async.py | 63 - ...ed_net_app_update_active_directory_sync.py | 63 - ...1_generated_net_app_update_backup_async.py | 55 - ...ated_net_app_update_backup_policy_async.py | 55 - ...rated_net_app_update_backup_policy_sync.py | 55 - ...v1_generated_net_app_update_backup_sync.py | 55 - ...rated_net_app_update_backup_vault_async.py | 55 - ...erated_net_app_update_backup_vault_sync.py | 55 - ...nerated_net_app_update_kms_config_async.py | 59 - ...enerated_net_app_update_kms_config_sync.py | 59 - ...nerated_net_app_update_quota_rule_async.py | 60 - ...enerated_net_app_update_quota_rule_sync.py | 60 - ...erated_net_app_update_replication_async.py | 60 - ...nerated_net_app_update_replication_sync.py | 60 - ...generated_net_app_update_snapshot_async.py | 55 - ..._generated_net_app_update_snapshot_sync.py | 55 - ...rated_net_app_update_storage_pool_async.py | 61 - ...erated_net_app_update_storage_pool_sync.py | 61 - ...1_generated_net_app_update_volume_async.py | 62 - ...v1_generated_net_app_update_volume_sync.py | 62 - ...et_app_validate_directory_service_async.py | 56 - ...net_app_validate_directory_service_sync.py | 56 - ...nerated_net_app_verify_kms_config_async.py | 52 - ...enerated_net_app_verify_kms_config_sync.py | 52 - ...ippet_metadata_google.cloud.netapp.v1.json | 9835 ---- .../v1/scripts/fixup_netapp_v1_keywords.py | 235 - .../google-cloud-netapp/v1/setup.py | 98 - .../v1/testing/constraints-3.10.txt | 6 - .../v1/testing/constraints-3.11.txt | 6 - .../v1/testing/constraints-3.12.txt | 6 - .../v1/testing/constraints-3.13.txt | 11 - .../v1/testing/constraints-3.7.txt | 10 - .../v1/testing/constraints-3.8.txt | 6 - .../v1/testing/constraints-3.9.txt | 6 - .../google-cloud-netapp/v1/tests/__init__.py | 16 - .../v1/tests/unit/__init__.py | 16 - .../v1/tests/unit/gapic/__init__.py | 16 - .../v1/tests/unit/gapic/netapp_v1/__init__.py | 16 - .../unit/gapic/netapp_v1/test_net_app.py | 46391 ---------------- .../google/cloud/netapp_v1/types/volume.py | 2 +- 181 files changed, 1 insertion(+), 109861 deletions(-) delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/.coveragerc delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/.flake8 delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/LICENSE delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/MANIFEST.in delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/README.rst delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/docs/_static/custom.css delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/docs/conf.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/docs/index.rst delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/net_app.rst delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/services_.rst delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/types_.rst delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/__init__.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/gapic_version.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/py.typed delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/__init__.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/gapic_version.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/py.typed delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/__init__.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/__init__.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/async_client.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/client.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/pagers.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/README.rst delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/__init__.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/base.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/grpc.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/rest.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/rest_base.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/__init__.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/active_directory.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup_policy.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup_vault.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/cloud_netapp_service.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/common.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/kms.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/quota_rule.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/replication.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/snapshot.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/storage_pool.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/volume.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/mypy.ini delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/noxfile.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_active_directory_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_active_directory_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_policy_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_policy_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_vault_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_vault_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_kms_config_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_kms_config_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_quota_rule_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_quota_rule_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_replication_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_replication_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_snapshot_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_snapshot_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_storage_pool_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_storage_pool_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_volume_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_volume_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_active_directory_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_active_directory_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_policy_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_policy_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_vault_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_vault_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_kms_config_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_kms_config_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_quota_rule_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_quota_rule_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_replication_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_replication_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_snapshot_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_snapshot_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_storage_pool_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_storage_pool_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_volume_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_volume_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_encrypt_volumes_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_encrypt_volumes_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_establish_peering_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_establish_peering_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_active_directory_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_active_directory_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_policy_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_policy_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_vault_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_vault_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_kms_config_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_kms_config_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_quota_rule_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_quota_rule_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_replication_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_replication_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_snapshot_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_snapshot_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_storage_pool_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_storage_pool_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_volume_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_volume_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_active_directories_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_active_directories_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_policies_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_policies_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_vaults_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_vaults_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backups_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backups_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_kms_configs_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_kms_configs_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_quota_rules_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_quota_rules_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_replications_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_replications_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_snapshots_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_snapshots_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_storage_pools_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_storage_pools_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_volumes_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_volumes_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_resume_replication_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_resume_replication_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_reverse_replication_direction_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_reverse_replication_direction_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_revert_volume_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_revert_volume_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_stop_replication_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_stop_replication_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_switch_active_replica_zone_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_switch_active_replica_zone_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_sync_replication_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_sync_replication_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_active_directory_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_active_directory_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_policy_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_policy_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_vault_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_vault_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_kms_config_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_kms_config_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_quota_rule_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_quota_rule_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_replication_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_replication_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_snapshot_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_snapshot_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_storage_pool_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_storage_pool_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_volume_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_volume_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_validate_directory_service_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_validate_directory_service_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_verify_kms_config_async.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_verify_kms_config_sync.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/snippet_metadata_google.cloud.netapp.v1.json delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/scripts/fixup_netapp_v1_keywords.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/setup.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.10.txt delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.11.txt delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.12.txt delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.13.txt delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.7.txt delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.8.txt delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.9.txt delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/tests/__init__.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/tests/unit/__init__.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/tests/unit/gapic/__init__.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/tests/unit/gapic/netapp_v1/__init__.py delete mode 100644 owl-bot-staging/google-cloud-netapp/v1/tests/unit/gapic/netapp_v1/test_net_app.py diff --git a/owl-bot-staging/google-cloud-netapp/v1/.coveragerc b/owl-bot-staging/google-cloud-netapp/v1/.coveragerc deleted file mode 100644 index b52a142c7e46..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/.coveragerc +++ /dev/null @@ -1,13 +0,0 @@ -[run] -branch = True - -[report] -show_missing = True -omit = - google/cloud/netapp/__init__.py - google/cloud/netapp/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-netapp/v1/.flake8 b/owl-bot-staging/google-cloud-netapp/v1/.flake8 deleted file mode 100644 index 90316de21489..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/.flake8 +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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. -# -[flake8] -# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): -# Resolve flake8 lint issues -ignore = E203, E231, E266, E501, W503 -exclude = - # TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): - # Ensure that generated code passes flake8 lint - **/gapic/** - **/services/** - **/types/** - # Exclude Protobuf gencode - *_pb2.py - - # Standard linting exemptions. - **/.nox/** - __pycache__, - .git, - *.pyc, - conf.py diff --git a/owl-bot-staging/google-cloud-netapp/v1/LICENSE b/owl-bot-staging/google-cloud-netapp/v1/LICENSE deleted file mode 100644 index d64569567334..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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-netapp/v1/MANIFEST.in b/owl-bot-staging/google-cloud-netapp/v1/MANIFEST.in deleted file mode 100644 index dae249ec8976..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/MANIFEST.in +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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. -# -include README.rst LICENSE -recursive-include google *.py *.pyi *.json *.proto py.typed -recursive-include tests * -global-exclude *.py[co] -global-exclude __pycache__ diff --git a/owl-bot-staging/google-cloud-netapp/v1/README.rst b/owl-bot-staging/google-cloud-netapp/v1/README.rst deleted file mode 100644 index 7e519a71c372..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/README.rst +++ /dev/null @@ -1,143 +0,0 @@ -Python Client for Google Cloud Netapp 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 Netapp 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 - - -Logging -------- - -This library uses the standard Python :code:`logging` functionality to log some RPC events that could be of interest for debugging and monitoring purposes. -Note the following: - -#. Logs may contain sensitive information. Take care to **restrict access to the logs** if they are saved, whether it be on local storage or on Google Cloud Logging. -#. Google may refine the occurrence, level, and content of various log messages in this library without flagging such changes as breaking. **Do not depend on immutability of the logging events**. -#. By default, the logging events from this library are not handled. You must **explicitly configure log handling** using one of the mechanisms below. - - -Simple, environment-based configuration -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -To enable logging for this library without any changes in your code, set the :code:`GOOGLE_SDK_PYTHON_LOGGING_SCOPE` environment variable to a valid Google -logging scope. This configures handling of logging events (at level :code:`logging.DEBUG` or higher) from this library in a default manner, emitting the logged -messages in a structured format. It does not currently allow customizing the logging levels captured nor the handlers, formatters, etc. used for any logging -event. - -A logging scope is a period-separated namespace that begins with :code:`google`, identifying the Python module or package to log. - -- Valid logging scopes: :code:`google`, :code:`google.cloud.asset.v1`, :code:`google.api`, :code:`google.auth`, etc. -- Invalid logging scopes: :code:`foo`, :code:`123`, etc. - -**NOTE**: If the logging scope is invalid, the library does not set up any logging handlers. - - -Examples -^^^^^^^^ - -- Enabling the default handler for all Google-based loggers - -.. code-block:: console - - export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google - -- Enabling the default handler for a specific Google module (for a client library called :code:`library_v1`): - -.. code-block:: console - - export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google.cloud.library_v1 - - -Advanced, code-based configuration -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -You can also configure a valid logging scope using Python's standard `logging` mechanism. - - -Examples -^^^^^^^^ - -- Configuring a handler for all Google-based loggers - -.. code-block:: python - - import logging - - from google.cloud.translate_v3 import translate - - base_logger = logging.getLogger("google") - base_logger.addHandler(logging.StreamHandler()) - base_logger.setLevel(logging.DEBUG) - -- Configuring a handler for a specific Google module (for a client library called :code:`library_v1`): - -.. code-block:: python - - import logging - - from google.cloud.translate_v3 import translate - - base_logger = logging.getLogger("google.cloud.library_v1") - base_logger.addHandler(logging.StreamHandler()) - base_logger.setLevel(logging.DEBUG) - - -Logging details -~~~~~~~~~~~~~~~ - -#. Regardless of which of the mechanisms above you use to configure logging for this library, by default logging events are not propagated up to the root - logger from the `google`-level logger. If you need the events to be propagated to the root logger, you must explicitly set - :code:`logging.getLogger("google").propagate = True` in your code. -#. You can mix the different logging configurations above for different Google modules. For example, you may want use a code-based logging configuration for - one library, but decide you need to also set up environment-based logging configuration for another library. - - #. If you attempt to use both code-based and environment-based configuration for the same module, the environment-based configuration will be ineffectual - if the code -based configuration gets applied first. - -#. The Google-specific logging configurations (default handlers for environment-based configuration; not propagating logging events to the root logger) get - executed the first time *any* client library is instantiated in your application, and only if the affected loggers have not been previously configured. - (This is the reason for 2.i. above.) diff --git a/owl-bot-staging/google-cloud-netapp/v1/docs/_static/custom.css b/owl-bot-staging/google-cloud-netapp/v1/docs/_static/custom.css deleted file mode 100644 index 06423be0b592..000000000000 --- a/owl-bot-staging/google-cloud-netapp/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-netapp/v1/docs/conf.py b/owl-bot-staging/google-cloud-netapp/v1/docs/conf.py deleted file mode 100644 index a8df6d383101..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/docs/conf.py +++ /dev/null @@ -1,376 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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-netapp 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-netapp" -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-netapp-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-netapp.tex", - u"google-cloud-netapp 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-netapp", - u"Google Cloud Netapp 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-netapp", - u"google-cloud-netapp Documentation", - author, - "google-cloud-netapp", - "GAPIC library for Google Cloud Netapp 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-netapp/v1/docs/index.rst b/owl-bot-staging/google-cloud-netapp/v1/docs/index.rst deleted file mode 100644 index 39a2c8ae820f..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/docs/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -API Reference -------------- -.. toctree:: - :maxdepth: 2 - - netapp_v1/services_ - netapp_v1/types_ diff --git a/owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/net_app.rst b/owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/net_app.rst deleted file mode 100644 index 03f507188fd9..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/net_app.rst +++ /dev/null @@ -1,10 +0,0 @@ -NetApp ------------------------- - -.. automodule:: google.cloud.netapp_v1.services.net_app - :members: - :inherited-members: - -.. automodule:: google.cloud.netapp_v1.services.net_app.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/services_.rst b/owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/services_.rst deleted file mode 100644 index 48180d798fdc..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/services_.rst +++ /dev/null @@ -1,6 +0,0 @@ -Services for Google Cloud Netapp v1 API -======================================= -.. toctree:: - :maxdepth: 2 - - net_app diff --git a/owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/types_.rst b/owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/types_.rst deleted file mode 100644 index dd42bfd262c5..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/docs/netapp_v1/types_.rst +++ /dev/null @@ -1,6 +0,0 @@ -Types for Google Cloud Netapp v1 API -==================================== - -.. automodule:: google.cloud.netapp_v1.types - :members: - :show-inheritance: diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/__init__.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/__init__.py deleted file mode 100644 index 59b8e3e3a6d2..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/__init__.py +++ /dev/null @@ -1,241 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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.netapp import gapic_version as package_version - -__version__ = package_version.__version__ - - -from google.cloud.netapp_v1.services.net_app.client import NetAppClient -from google.cloud.netapp_v1.services.net_app.async_client import NetAppAsyncClient - -from google.cloud.netapp_v1.types.active_directory import ActiveDirectory -from google.cloud.netapp_v1.types.active_directory import CreateActiveDirectoryRequest -from google.cloud.netapp_v1.types.active_directory import DeleteActiveDirectoryRequest -from google.cloud.netapp_v1.types.active_directory import GetActiveDirectoryRequest -from google.cloud.netapp_v1.types.active_directory import ListActiveDirectoriesRequest -from google.cloud.netapp_v1.types.active_directory import ListActiveDirectoriesResponse -from google.cloud.netapp_v1.types.active_directory import UpdateActiveDirectoryRequest -from google.cloud.netapp_v1.types.backup import Backup -from google.cloud.netapp_v1.types.backup import CreateBackupRequest -from google.cloud.netapp_v1.types.backup import DeleteBackupRequest -from google.cloud.netapp_v1.types.backup import GetBackupRequest -from google.cloud.netapp_v1.types.backup import ListBackupsRequest -from google.cloud.netapp_v1.types.backup import ListBackupsResponse -from google.cloud.netapp_v1.types.backup import UpdateBackupRequest -from google.cloud.netapp_v1.types.backup_policy import BackupPolicy -from google.cloud.netapp_v1.types.backup_policy import CreateBackupPolicyRequest -from google.cloud.netapp_v1.types.backup_policy import DeleteBackupPolicyRequest -from google.cloud.netapp_v1.types.backup_policy import GetBackupPolicyRequest -from google.cloud.netapp_v1.types.backup_policy import ListBackupPoliciesRequest -from google.cloud.netapp_v1.types.backup_policy import ListBackupPoliciesResponse -from google.cloud.netapp_v1.types.backup_policy import UpdateBackupPolicyRequest -from google.cloud.netapp_v1.types.backup_vault import BackupVault -from google.cloud.netapp_v1.types.backup_vault import CreateBackupVaultRequest -from google.cloud.netapp_v1.types.backup_vault import DeleteBackupVaultRequest -from google.cloud.netapp_v1.types.backup_vault import GetBackupVaultRequest -from google.cloud.netapp_v1.types.backup_vault import ListBackupVaultsRequest -from google.cloud.netapp_v1.types.backup_vault import ListBackupVaultsResponse -from google.cloud.netapp_v1.types.backup_vault import UpdateBackupVaultRequest -from google.cloud.netapp_v1.types.cloud_netapp_service import OperationMetadata -from google.cloud.netapp_v1.types.common import LocationMetadata -from google.cloud.netapp_v1.types.common import DirectoryServiceType -from google.cloud.netapp_v1.types.common import EncryptionType -from google.cloud.netapp_v1.types.common import FlexPerformance -from google.cloud.netapp_v1.types.common import ServiceLevel -from google.cloud.netapp_v1.types.kms import CreateKmsConfigRequest -from google.cloud.netapp_v1.types.kms import DeleteKmsConfigRequest -from google.cloud.netapp_v1.types.kms import EncryptVolumesRequest -from google.cloud.netapp_v1.types.kms import GetKmsConfigRequest -from google.cloud.netapp_v1.types.kms import KmsConfig -from google.cloud.netapp_v1.types.kms import ListKmsConfigsRequest -from google.cloud.netapp_v1.types.kms import ListKmsConfigsResponse -from google.cloud.netapp_v1.types.kms import UpdateKmsConfigRequest -from google.cloud.netapp_v1.types.kms import VerifyKmsConfigRequest -from google.cloud.netapp_v1.types.kms import VerifyKmsConfigResponse -from google.cloud.netapp_v1.types.quota_rule import CreateQuotaRuleRequest -from google.cloud.netapp_v1.types.quota_rule import DeleteQuotaRuleRequest -from google.cloud.netapp_v1.types.quota_rule import GetQuotaRuleRequest -from google.cloud.netapp_v1.types.quota_rule import ListQuotaRulesRequest -from google.cloud.netapp_v1.types.quota_rule import ListQuotaRulesResponse -from google.cloud.netapp_v1.types.quota_rule import QuotaRule -from google.cloud.netapp_v1.types.quota_rule import UpdateQuotaRuleRequest -from google.cloud.netapp_v1.types.replication import CreateReplicationRequest -from google.cloud.netapp_v1.types.replication import DeleteReplicationRequest -from google.cloud.netapp_v1.types.replication import DestinationVolumeParameters -from google.cloud.netapp_v1.types.replication import EstablishPeeringRequest -from google.cloud.netapp_v1.types.replication import GetReplicationRequest -from google.cloud.netapp_v1.types.replication import HybridPeeringDetails -from google.cloud.netapp_v1.types.replication import ListReplicationsRequest -from google.cloud.netapp_v1.types.replication import ListReplicationsResponse -from google.cloud.netapp_v1.types.replication import Replication -from google.cloud.netapp_v1.types.replication import ResumeReplicationRequest -from google.cloud.netapp_v1.types.replication import ReverseReplicationDirectionRequest -from google.cloud.netapp_v1.types.replication import StopReplicationRequest -from google.cloud.netapp_v1.types.replication import SyncReplicationRequest -from google.cloud.netapp_v1.types.replication import TransferStats -from google.cloud.netapp_v1.types.replication import UpdateReplicationRequest -from google.cloud.netapp_v1.types.snapshot import CreateSnapshotRequest -from google.cloud.netapp_v1.types.snapshot import DeleteSnapshotRequest -from google.cloud.netapp_v1.types.snapshot import GetSnapshotRequest -from google.cloud.netapp_v1.types.snapshot import ListSnapshotsRequest -from google.cloud.netapp_v1.types.snapshot import ListSnapshotsResponse -from google.cloud.netapp_v1.types.snapshot import Snapshot -from google.cloud.netapp_v1.types.snapshot import UpdateSnapshotRequest -from google.cloud.netapp_v1.types.storage_pool import CreateStoragePoolRequest -from google.cloud.netapp_v1.types.storage_pool import DeleteStoragePoolRequest -from google.cloud.netapp_v1.types.storage_pool import GetStoragePoolRequest -from google.cloud.netapp_v1.types.storage_pool import ListStoragePoolsRequest -from google.cloud.netapp_v1.types.storage_pool import ListStoragePoolsResponse -from google.cloud.netapp_v1.types.storage_pool import StoragePool -from google.cloud.netapp_v1.types.storage_pool import SwitchActiveReplicaZoneRequest -from google.cloud.netapp_v1.types.storage_pool import UpdateStoragePoolRequest -from google.cloud.netapp_v1.types.storage_pool import ValidateDirectoryServiceRequest -from google.cloud.netapp_v1.types.volume import BackupConfig -from google.cloud.netapp_v1.types.volume import CreateVolumeRequest -from google.cloud.netapp_v1.types.volume import DailySchedule -from google.cloud.netapp_v1.types.volume import DeleteVolumeRequest -from google.cloud.netapp_v1.types.volume import ExportPolicy -from google.cloud.netapp_v1.types.volume import GetVolumeRequest -from google.cloud.netapp_v1.types.volume import HourlySchedule -from google.cloud.netapp_v1.types.volume import HybridReplicationParameters -from google.cloud.netapp_v1.types.volume import ListVolumesRequest -from google.cloud.netapp_v1.types.volume import ListVolumesResponse -from google.cloud.netapp_v1.types.volume import MonthlySchedule -from google.cloud.netapp_v1.types.volume import MountOption -from google.cloud.netapp_v1.types.volume import RestoreParameters -from google.cloud.netapp_v1.types.volume import RevertVolumeRequest -from google.cloud.netapp_v1.types.volume import SimpleExportPolicyRule -from google.cloud.netapp_v1.types.volume import SnapshotPolicy -from google.cloud.netapp_v1.types.volume import TieringPolicy -from google.cloud.netapp_v1.types.volume import UpdateVolumeRequest -from google.cloud.netapp_v1.types.volume import Volume -from google.cloud.netapp_v1.types.volume import WeeklySchedule -from google.cloud.netapp_v1.types.volume import AccessType -from google.cloud.netapp_v1.types.volume import Protocols -from google.cloud.netapp_v1.types.volume import RestrictedAction -from google.cloud.netapp_v1.types.volume import SecurityStyle -from google.cloud.netapp_v1.types.volume import SMBSettings - -__all__ = ('NetAppClient', - 'NetAppAsyncClient', - 'ActiveDirectory', - 'CreateActiveDirectoryRequest', - 'DeleteActiveDirectoryRequest', - 'GetActiveDirectoryRequest', - 'ListActiveDirectoriesRequest', - 'ListActiveDirectoriesResponse', - 'UpdateActiveDirectoryRequest', - 'Backup', - 'CreateBackupRequest', - 'DeleteBackupRequest', - 'GetBackupRequest', - 'ListBackupsRequest', - 'ListBackupsResponse', - 'UpdateBackupRequest', - 'BackupPolicy', - 'CreateBackupPolicyRequest', - 'DeleteBackupPolicyRequest', - 'GetBackupPolicyRequest', - 'ListBackupPoliciesRequest', - 'ListBackupPoliciesResponse', - 'UpdateBackupPolicyRequest', - 'BackupVault', - 'CreateBackupVaultRequest', - 'DeleteBackupVaultRequest', - 'GetBackupVaultRequest', - 'ListBackupVaultsRequest', - 'ListBackupVaultsResponse', - 'UpdateBackupVaultRequest', - 'OperationMetadata', - 'LocationMetadata', - 'DirectoryServiceType', - 'EncryptionType', - 'FlexPerformance', - 'ServiceLevel', - 'CreateKmsConfigRequest', - 'DeleteKmsConfigRequest', - 'EncryptVolumesRequest', - 'GetKmsConfigRequest', - 'KmsConfig', - 'ListKmsConfigsRequest', - 'ListKmsConfigsResponse', - 'UpdateKmsConfigRequest', - 'VerifyKmsConfigRequest', - 'VerifyKmsConfigResponse', - 'CreateQuotaRuleRequest', - 'DeleteQuotaRuleRequest', - 'GetQuotaRuleRequest', - 'ListQuotaRulesRequest', - 'ListQuotaRulesResponse', - 'QuotaRule', - 'UpdateQuotaRuleRequest', - 'CreateReplicationRequest', - 'DeleteReplicationRequest', - 'DestinationVolumeParameters', - 'EstablishPeeringRequest', - 'GetReplicationRequest', - 'HybridPeeringDetails', - 'ListReplicationsRequest', - 'ListReplicationsResponse', - 'Replication', - 'ResumeReplicationRequest', - 'ReverseReplicationDirectionRequest', - 'StopReplicationRequest', - 'SyncReplicationRequest', - 'TransferStats', - 'UpdateReplicationRequest', - 'CreateSnapshotRequest', - 'DeleteSnapshotRequest', - 'GetSnapshotRequest', - 'ListSnapshotsRequest', - 'ListSnapshotsResponse', - 'Snapshot', - 'UpdateSnapshotRequest', - 'CreateStoragePoolRequest', - 'DeleteStoragePoolRequest', - 'GetStoragePoolRequest', - 'ListStoragePoolsRequest', - 'ListStoragePoolsResponse', - 'StoragePool', - 'SwitchActiveReplicaZoneRequest', - 'UpdateStoragePoolRequest', - 'ValidateDirectoryServiceRequest', - 'BackupConfig', - 'CreateVolumeRequest', - 'DailySchedule', - 'DeleteVolumeRequest', - 'ExportPolicy', - 'GetVolumeRequest', - 'HourlySchedule', - 'HybridReplicationParameters', - 'ListVolumesRequest', - 'ListVolumesResponse', - 'MonthlySchedule', - 'MountOption', - 'RestoreParameters', - 'RevertVolumeRequest', - 'SimpleExportPolicyRule', - 'SnapshotPolicy', - 'TieringPolicy', - 'UpdateVolumeRequest', - 'Volume', - 'WeeklySchedule', - 'AccessType', - 'Protocols', - 'RestrictedAction', - 'SecurityStyle', - 'SMBSettings', -) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/gapic_version.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/gapic_version.py deleted file mode 100644 index 20a9cd975b02..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/gapic_version.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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-netapp/v1/google/cloud/netapp/py.typed b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/py.typed deleted file mode 100644 index 7d2f4c53406d..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-netapp package uses inline types. diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/__init__.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/__init__.py deleted file mode 100644 index 9fbe7ba71c5b..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/__init__.py +++ /dev/null @@ -1,242 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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.netapp_v1 import gapic_version as package_version - -__version__ = package_version.__version__ - - -from .services.net_app import NetAppClient -from .services.net_app import NetAppAsyncClient - -from .types.active_directory import ActiveDirectory -from .types.active_directory import CreateActiveDirectoryRequest -from .types.active_directory import DeleteActiveDirectoryRequest -from .types.active_directory import GetActiveDirectoryRequest -from .types.active_directory import ListActiveDirectoriesRequest -from .types.active_directory import ListActiveDirectoriesResponse -from .types.active_directory import UpdateActiveDirectoryRequest -from .types.backup import Backup -from .types.backup import CreateBackupRequest -from .types.backup import DeleteBackupRequest -from .types.backup import GetBackupRequest -from .types.backup import ListBackupsRequest -from .types.backup import ListBackupsResponse -from .types.backup import UpdateBackupRequest -from .types.backup_policy import BackupPolicy -from .types.backup_policy import CreateBackupPolicyRequest -from .types.backup_policy import DeleteBackupPolicyRequest -from .types.backup_policy import GetBackupPolicyRequest -from .types.backup_policy import ListBackupPoliciesRequest -from .types.backup_policy import ListBackupPoliciesResponse -from .types.backup_policy import UpdateBackupPolicyRequest -from .types.backup_vault import BackupVault -from .types.backup_vault import CreateBackupVaultRequest -from .types.backup_vault import DeleteBackupVaultRequest -from .types.backup_vault import GetBackupVaultRequest -from .types.backup_vault import ListBackupVaultsRequest -from .types.backup_vault import ListBackupVaultsResponse -from .types.backup_vault import UpdateBackupVaultRequest -from .types.cloud_netapp_service import OperationMetadata -from .types.common import LocationMetadata -from .types.common import DirectoryServiceType -from .types.common import EncryptionType -from .types.common import FlexPerformance -from .types.common import ServiceLevel -from .types.kms import CreateKmsConfigRequest -from .types.kms import DeleteKmsConfigRequest -from .types.kms import EncryptVolumesRequest -from .types.kms import GetKmsConfigRequest -from .types.kms import KmsConfig -from .types.kms import ListKmsConfigsRequest -from .types.kms import ListKmsConfigsResponse -from .types.kms import UpdateKmsConfigRequest -from .types.kms import VerifyKmsConfigRequest -from .types.kms import VerifyKmsConfigResponse -from .types.quota_rule import CreateQuotaRuleRequest -from .types.quota_rule import DeleteQuotaRuleRequest -from .types.quota_rule import GetQuotaRuleRequest -from .types.quota_rule import ListQuotaRulesRequest -from .types.quota_rule import ListQuotaRulesResponse -from .types.quota_rule import QuotaRule -from .types.quota_rule import UpdateQuotaRuleRequest -from .types.replication import CreateReplicationRequest -from .types.replication import DeleteReplicationRequest -from .types.replication import DestinationVolumeParameters -from .types.replication import EstablishPeeringRequest -from .types.replication import GetReplicationRequest -from .types.replication import HybridPeeringDetails -from .types.replication import ListReplicationsRequest -from .types.replication import ListReplicationsResponse -from .types.replication import Replication -from .types.replication import ResumeReplicationRequest -from .types.replication import ReverseReplicationDirectionRequest -from .types.replication import StopReplicationRequest -from .types.replication import SyncReplicationRequest -from .types.replication import TransferStats -from .types.replication import UpdateReplicationRequest -from .types.snapshot import CreateSnapshotRequest -from .types.snapshot import DeleteSnapshotRequest -from .types.snapshot import GetSnapshotRequest -from .types.snapshot import ListSnapshotsRequest -from .types.snapshot import ListSnapshotsResponse -from .types.snapshot import Snapshot -from .types.snapshot import UpdateSnapshotRequest -from .types.storage_pool import CreateStoragePoolRequest -from .types.storage_pool import DeleteStoragePoolRequest -from .types.storage_pool import GetStoragePoolRequest -from .types.storage_pool import ListStoragePoolsRequest -from .types.storage_pool import ListStoragePoolsResponse -from .types.storage_pool import StoragePool -from .types.storage_pool import SwitchActiveReplicaZoneRequest -from .types.storage_pool import UpdateStoragePoolRequest -from .types.storage_pool import ValidateDirectoryServiceRequest -from .types.volume import BackupConfig -from .types.volume import CreateVolumeRequest -from .types.volume import DailySchedule -from .types.volume import DeleteVolumeRequest -from .types.volume import ExportPolicy -from .types.volume import GetVolumeRequest -from .types.volume import HourlySchedule -from .types.volume import HybridReplicationParameters -from .types.volume import ListVolumesRequest -from .types.volume import ListVolumesResponse -from .types.volume import MonthlySchedule -from .types.volume import MountOption -from .types.volume import RestoreParameters -from .types.volume import RevertVolumeRequest -from .types.volume import SimpleExportPolicyRule -from .types.volume import SnapshotPolicy -from .types.volume import TieringPolicy -from .types.volume import UpdateVolumeRequest -from .types.volume import Volume -from .types.volume import WeeklySchedule -from .types.volume import AccessType -from .types.volume import Protocols -from .types.volume import RestrictedAction -from .types.volume import SecurityStyle -from .types.volume import SMBSettings - -__all__ = ( - 'NetAppAsyncClient', -'AccessType', -'ActiveDirectory', -'Backup', -'BackupConfig', -'BackupPolicy', -'BackupVault', -'CreateActiveDirectoryRequest', -'CreateBackupPolicyRequest', -'CreateBackupRequest', -'CreateBackupVaultRequest', -'CreateKmsConfigRequest', -'CreateQuotaRuleRequest', -'CreateReplicationRequest', -'CreateSnapshotRequest', -'CreateStoragePoolRequest', -'CreateVolumeRequest', -'DailySchedule', -'DeleteActiveDirectoryRequest', -'DeleteBackupPolicyRequest', -'DeleteBackupRequest', -'DeleteBackupVaultRequest', -'DeleteKmsConfigRequest', -'DeleteQuotaRuleRequest', -'DeleteReplicationRequest', -'DeleteSnapshotRequest', -'DeleteStoragePoolRequest', -'DeleteVolumeRequest', -'DestinationVolumeParameters', -'DirectoryServiceType', -'EncryptVolumesRequest', -'EncryptionType', -'EstablishPeeringRequest', -'ExportPolicy', -'FlexPerformance', -'GetActiveDirectoryRequest', -'GetBackupPolicyRequest', -'GetBackupRequest', -'GetBackupVaultRequest', -'GetKmsConfigRequest', -'GetQuotaRuleRequest', -'GetReplicationRequest', -'GetSnapshotRequest', -'GetStoragePoolRequest', -'GetVolumeRequest', -'HourlySchedule', -'HybridPeeringDetails', -'HybridReplicationParameters', -'KmsConfig', -'ListActiveDirectoriesRequest', -'ListActiveDirectoriesResponse', -'ListBackupPoliciesRequest', -'ListBackupPoliciesResponse', -'ListBackupVaultsRequest', -'ListBackupVaultsResponse', -'ListBackupsRequest', -'ListBackupsResponse', -'ListKmsConfigsRequest', -'ListKmsConfigsResponse', -'ListQuotaRulesRequest', -'ListQuotaRulesResponse', -'ListReplicationsRequest', -'ListReplicationsResponse', -'ListSnapshotsRequest', -'ListSnapshotsResponse', -'ListStoragePoolsRequest', -'ListStoragePoolsResponse', -'ListVolumesRequest', -'ListVolumesResponse', -'LocationMetadata', -'MonthlySchedule', -'MountOption', -'NetAppClient', -'OperationMetadata', -'Protocols', -'QuotaRule', -'Replication', -'RestoreParameters', -'RestrictedAction', -'ResumeReplicationRequest', -'ReverseReplicationDirectionRequest', -'RevertVolumeRequest', -'SMBSettings', -'SecurityStyle', -'ServiceLevel', -'SimpleExportPolicyRule', -'Snapshot', -'SnapshotPolicy', -'StopReplicationRequest', -'StoragePool', -'SwitchActiveReplicaZoneRequest', -'SyncReplicationRequest', -'TieringPolicy', -'TransferStats', -'UpdateActiveDirectoryRequest', -'UpdateBackupPolicyRequest', -'UpdateBackupRequest', -'UpdateBackupVaultRequest', -'UpdateKmsConfigRequest', -'UpdateQuotaRuleRequest', -'UpdateReplicationRequest', -'UpdateSnapshotRequest', -'UpdateStoragePoolRequest', -'UpdateVolumeRequest', -'ValidateDirectoryServiceRequest', -'VerifyKmsConfigRequest', -'VerifyKmsConfigResponse', -'Volume', -'WeeklySchedule', -) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/gapic_metadata.json b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/gapic_metadata.json deleted file mode 100644 index c06767c5fa9a..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/gapic_metadata.json +++ /dev/null @@ -1,928 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.netapp_v1", - "protoPackage": "google.cloud.netapp.v1", - "schema": "1.0", - "services": { - "NetApp": { - "clients": { - "grpc": { - "libraryClient": "NetAppClient", - "rpcs": { - "CreateActiveDirectory": { - "methods": [ - "create_active_directory" - ] - }, - "CreateBackup": { - "methods": [ - "create_backup" - ] - }, - "CreateBackupPolicy": { - "methods": [ - "create_backup_policy" - ] - }, - "CreateBackupVault": { - "methods": [ - "create_backup_vault" - ] - }, - "CreateKmsConfig": { - "methods": [ - "create_kms_config" - ] - }, - "CreateQuotaRule": { - "methods": [ - "create_quota_rule" - ] - }, - "CreateReplication": { - "methods": [ - "create_replication" - ] - }, - "CreateSnapshot": { - "methods": [ - "create_snapshot" - ] - }, - "CreateStoragePool": { - "methods": [ - "create_storage_pool" - ] - }, - "CreateVolume": { - "methods": [ - "create_volume" - ] - }, - "DeleteActiveDirectory": { - "methods": [ - "delete_active_directory" - ] - }, - "DeleteBackup": { - "methods": [ - "delete_backup" - ] - }, - "DeleteBackupPolicy": { - "methods": [ - "delete_backup_policy" - ] - }, - "DeleteBackupVault": { - "methods": [ - "delete_backup_vault" - ] - }, - "DeleteKmsConfig": { - "methods": [ - "delete_kms_config" - ] - }, - "DeleteQuotaRule": { - "methods": [ - "delete_quota_rule" - ] - }, - "DeleteReplication": { - "methods": [ - "delete_replication" - ] - }, - "DeleteSnapshot": { - "methods": [ - "delete_snapshot" - ] - }, - "DeleteStoragePool": { - "methods": [ - "delete_storage_pool" - ] - }, - "DeleteVolume": { - "methods": [ - "delete_volume" - ] - }, - "EncryptVolumes": { - "methods": [ - "encrypt_volumes" - ] - }, - "EstablishPeering": { - "methods": [ - "establish_peering" - ] - }, - "GetActiveDirectory": { - "methods": [ - "get_active_directory" - ] - }, - "GetBackup": { - "methods": [ - "get_backup" - ] - }, - "GetBackupPolicy": { - "methods": [ - "get_backup_policy" - ] - }, - "GetBackupVault": { - "methods": [ - "get_backup_vault" - ] - }, - "GetKmsConfig": { - "methods": [ - "get_kms_config" - ] - }, - "GetQuotaRule": { - "methods": [ - "get_quota_rule" - ] - }, - "GetReplication": { - "methods": [ - "get_replication" - ] - }, - "GetSnapshot": { - "methods": [ - "get_snapshot" - ] - }, - "GetStoragePool": { - "methods": [ - "get_storage_pool" - ] - }, - "GetVolume": { - "methods": [ - "get_volume" - ] - }, - "ListActiveDirectories": { - "methods": [ - "list_active_directories" - ] - }, - "ListBackupPolicies": { - "methods": [ - "list_backup_policies" - ] - }, - "ListBackupVaults": { - "methods": [ - "list_backup_vaults" - ] - }, - "ListBackups": { - "methods": [ - "list_backups" - ] - }, - "ListKmsConfigs": { - "methods": [ - "list_kms_configs" - ] - }, - "ListQuotaRules": { - "methods": [ - "list_quota_rules" - ] - }, - "ListReplications": { - "methods": [ - "list_replications" - ] - }, - "ListSnapshots": { - "methods": [ - "list_snapshots" - ] - }, - "ListStoragePools": { - "methods": [ - "list_storage_pools" - ] - }, - "ListVolumes": { - "methods": [ - "list_volumes" - ] - }, - "ResumeReplication": { - "methods": [ - "resume_replication" - ] - }, - "ReverseReplicationDirection": { - "methods": [ - "reverse_replication_direction" - ] - }, - "RevertVolume": { - "methods": [ - "revert_volume" - ] - }, - "StopReplication": { - "methods": [ - "stop_replication" - ] - }, - "SwitchActiveReplicaZone": { - "methods": [ - "switch_active_replica_zone" - ] - }, - "SyncReplication": { - "methods": [ - "sync_replication" - ] - }, - "UpdateActiveDirectory": { - "methods": [ - "update_active_directory" - ] - }, - "UpdateBackup": { - "methods": [ - "update_backup" - ] - }, - "UpdateBackupPolicy": { - "methods": [ - "update_backup_policy" - ] - }, - "UpdateBackupVault": { - "methods": [ - "update_backup_vault" - ] - }, - "UpdateKmsConfig": { - "methods": [ - "update_kms_config" - ] - }, - "UpdateQuotaRule": { - "methods": [ - "update_quota_rule" - ] - }, - "UpdateReplication": { - "methods": [ - "update_replication" - ] - }, - "UpdateSnapshot": { - "methods": [ - "update_snapshot" - ] - }, - "UpdateStoragePool": { - "methods": [ - "update_storage_pool" - ] - }, - "UpdateVolume": { - "methods": [ - "update_volume" - ] - }, - "ValidateDirectoryService": { - "methods": [ - "validate_directory_service" - ] - }, - "VerifyKmsConfig": { - "methods": [ - "verify_kms_config" - ] - } - } - }, - "grpc-async": { - "libraryClient": "NetAppAsyncClient", - "rpcs": { - "CreateActiveDirectory": { - "methods": [ - "create_active_directory" - ] - }, - "CreateBackup": { - "methods": [ - "create_backup" - ] - }, - "CreateBackupPolicy": { - "methods": [ - "create_backup_policy" - ] - }, - "CreateBackupVault": { - "methods": [ - "create_backup_vault" - ] - }, - "CreateKmsConfig": { - "methods": [ - "create_kms_config" - ] - }, - "CreateQuotaRule": { - "methods": [ - "create_quota_rule" - ] - }, - "CreateReplication": { - "methods": [ - "create_replication" - ] - }, - "CreateSnapshot": { - "methods": [ - "create_snapshot" - ] - }, - "CreateStoragePool": { - "methods": [ - "create_storage_pool" - ] - }, - "CreateVolume": { - "methods": [ - "create_volume" - ] - }, - "DeleteActiveDirectory": { - "methods": [ - "delete_active_directory" - ] - }, - "DeleteBackup": { - "methods": [ - "delete_backup" - ] - }, - "DeleteBackupPolicy": { - "methods": [ - "delete_backup_policy" - ] - }, - "DeleteBackupVault": { - "methods": [ - "delete_backup_vault" - ] - }, - "DeleteKmsConfig": { - "methods": [ - "delete_kms_config" - ] - }, - "DeleteQuotaRule": { - "methods": [ - "delete_quota_rule" - ] - }, - "DeleteReplication": { - "methods": [ - "delete_replication" - ] - }, - "DeleteSnapshot": { - "methods": [ - "delete_snapshot" - ] - }, - "DeleteStoragePool": { - "methods": [ - "delete_storage_pool" - ] - }, - "DeleteVolume": { - "methods": [ - "delete_volume" - ] - }, - "EncryptVolumes": { - "methods": [ - "encrypt_volumes" - ] - }, - "EstablishPeering": { - "methods": [ - "establish_peering" - ] - }, - "GetActiveDirectory": { - "methods": [ - "get_active_directory" - ] - }, - "GetBackup": { - "methods": [ - "get_backup" - ] - }, - "GetBackupPolicy": { - "methods": [ - "get_backup_policy" - ] - }, - "GetBackupVault": { - "methods": [ - "get_backup_vault" - ] - }, - "GetKmsConfig": { - "methods": [ - "get_kms_config" - ] - }, - "GetQuotaRule": { - "methods": [ - "get_quota_rule" - ] - }, - "GetReplication": { - "methods": [ - "get_replication" - ] - }, - "GetSnapshot": { - "methods": [ - "get_snapshot" - ] - }, - "GetStoragePool": { - "methods": [ - "get_storage_pool" - ] - }, - "GetVolume": { - "methods": [ - "get_volume" - ] - }, - "ListActiveDirectories": { - "methods": [ - "list_active_directories" - ] - }, - "ListBackupPolicies": { - "methods": [ - "list_backup_policies" - ] - }, - "ListBackupVaults": { - "methods": [ - "list_backup_vaults" - ] - }, - "ListBackups": { - "methods": [ - "list_backups" - ] - }, - "ListKmsConfigs": { - "methods": [ - "list_kms_configs" - ] - }, - "ListQuotaRules": { - "methods": [ - "list_quota_rules" - ] - }, - "ListReplications": { - "methods": [ - "list_replications" - ] - }, - "ListSnapshots": { - "methods": [ - "list_snapshots" - ] - }, - "ListStoragePools": { - "methods": [ - "list_storage_pools" - ] - }, - "ListVolumes": { - "methods": [ - "list_volumes" - ] - }, - "ResumeReplication": { - "methods": [ - "resume_replication" - ] - }, - "ReverseReplicationDirection": { - "methods": [ - "reverse_replication_direction" - ] - }, - "RevertVolume": { - "methods": [ - "revert_volume" - ] - }, - "StopReplication": { - "methods": [ - "stop_replication" - ] - }, - "SwitchActiveReplicaZone": { - "methods": [ - "switch_active_replica_zone" - ] - }, - "SyncReplication": { - "methods": [ - "sync_replication" - ] - }, - "UpdateActiveDirectory": { - "methods": [ - "update_active_directory" - ] - }, - "UpdateBackup": { - "methods": [ - "update_backup" - ] - }, - "UpdateBackupPolicy": { - "methods": [ - "update_backup_policy" - ] - }, - "UpdateBackupVault": { - "methods": [ - "update_backup_vault" - ] - }, - "UpdateKmsConfig": { - "methods": [ - "update_kms_config" - ] - }, - "UpdateQuotaRule": { - "methods": [ - "update_quota_rule" - ] - }, - "UpdateReplication": { - "methods": [ - "update_replication" - ] - }, - "UpdateSnapshot": { - "methods": [ - "update_snapshot" - ] - }, - "UpdateStoragePool": { - "methods": [ - "update_storage_pool" - ] - }, - "UpdateVolume": { - "methods": [ - "update_volume" - ] - }, - "ValidateDirectoryService": { - "methods": [ - "validate_directory_service" - ] - }, - "VerifyKmsConfig": { - "methods": [ - "verify_kms_config" - ] - } - } - }, - "rest": { - "libraryClient": "NetAppClient", - "rpcs": { - "CreateActiveDirectory": { - "methods": [ - "create_active_directory" - ] - }, - "CreateBackup": { - "methods": [ - "create_backup" - ] - }, - "CreateBackupPolicy": { - "methods": [ - "create_backup_policy" - ] - }, - "CreateBackupVault": { - "methods": [ - "create_backup_vault" - ] - }, - "CreateKmsConfig": { - "methods": [ - "create_kms_config" - ] - }, - "CreateQuotaRule": { - "methods": [ - "create_quota_rule" - ] - }, - "CreateReplication": { - "methods": [ - "create_replication" - ] - }, - "CreateSnapshot": { - "methods": [ - "create_snapshot" - ] - }, - "CreateStoragePool": { - "methods": [ - "create_storage_pool" - ] - }, - "CreateVolume": { - "methods": [ - "create_volume" - ] - }, - "DeleteActiveDirectory": { - "methods": [ - "delete_active_directory" - ] - }, - "DeleteBackup": { - "methods": [ - "delete_backup" - ] - }, - "DeleteBackupPolicy": { - "methods": [ - "delete_backup_policy" - ] - }, - "DeleteBackupVault": { - "methods": [ - "delete_backup_vault" - ] - }, - "DeleteKmsConfig": { - "methods": [ - "delete_kms_config" - ] - }, - "DeleteQuotaRule": { - "methods": [ - "delete_quota_rule" - ] - }, - "DeleteReplication": { - "methods": [ - "delete_replication" - ] - }, - "DeleteSnapshot": { - "methods": [ - "delete_snapshot" - ] - }, - "DeleteStoragePool": { - "methods": [ - "delete_storage_pool" - ] - }, - "DeleteVolume": { - "methods": [ - "delete_volume" - ] - }, - "EncryptVolumes": { - "methods": [ - "encrypt_volumes" - ] - }, - "EstablishPeering": { - "methods": [ - "establish_peering" - ] - }, - "GetActiveDirectory": { - "methods": [ - "get_active_directory" - ] - }, - "GetBackup": { - "methods": [ - "get_backup" - ] - }, - "GetBackupPolicy": { - "methods": [ - "get_backup_policy" - ] - }, - "GetBackupVault": { - "methods": [ - "get_backup_vault" - ] - }, - "GetKmsConfig": { - "methods": [ - "get_kms_config" - ] - }, - "GetQuotaRule": { - "methods": [ - "get_quota_rule" - ] - }, - "GetReplication": { - "methods": [ - "get_replication" - ] - }, - "GetSnapshot": { - "methods": [ - "get_snapshot" - ] - }, - "GetStoragePool": { - "methods": [ - "get_storage_pool" - ] - }, - "GetVolume": { - "methods": [ - "get_volume" - ] - }, - "ListActiveDirectories": { - "methods": [ - "list_active_directories" - ] - }, - "ListBackupPolicies": { - "methods": [ - "list_backup_policies" - ] - }, - "ListBackupVaults": { - "methods": [ - "list_backup_vaults" - ] - }, - "ListBackups": { - "methods": [ - "list_backups" - ] - }, - "ListKmsConfigs": { - "methods": [ - "list_kms_configs" - ] - }, - "ListQuotaRules": { - "methods": [ - "list_quota_rules" - ] - }, - "ListReplications": { - "methods": [ - "list_replications" - ] - }, - "ListSnapshots": { - "methods": [ - "list_snapshots" - ] - }, - "ListStoragePools": { - "methods": [ - "list_storage_pools" - ] - }, - "ListVolumes": { - "methods": [ - "list_volumes" - ] - }, - "ResumeReplication": { - "methods": [ - "resume_replication" - ] - }, - "ReverseReplicationDirection": { - "methods": [ - "reverse_replication_direction" - ] - }, - "RevertVolume": { - "methods": [ - "revert_volume" - ] - }, - "StopReplication": { - "methods": [ - "stop_replication" - ] - }, - "SwitchActiveReplicaZone": { - "methods": [ - "switch_active_replica_zone" - ] - }, - "SyncReplication": { - "methods": [ - "sync_replication" - ] - }, - "UpdateActiveDirectory": { - "methods": [ - "update_active_directory" - ] - }, - "UpdateBackup": { - "methods": [ - "update_backup" - ] - }, - "UpdateBackupPolicy": { - "methods": [ - "update_backup_policy" - ] - }, - "UpdateBackupVault": { - "methods": [ - "update_backup_vault" - ] - }, - "UpdateKmsConfig": { - "methods": [ - "update_kms_config" - ] - }, - "UpdateQuotaRule": { - "methods": [ - "update_quota_rule" - ] - }, - "UpdateReplication": { - "methods": [ - "update_replication" - ] - }, - "UpdateSnapshot": { - "methods": [ - "update_snapshot" - ] - }, - "UpdateStoragePool": { - "methods": [ - "update_storage_pool" - ] - }, - "UpdateVolume": { - "methods": [ - "update_volume" - ] - }, - "ValidateDirectoryService": { - "methods": [ - "validate_directory_service" - ] - }, - "VerifyKmsConfig": { - "methods": [ - "verify_kms_config" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/gapic_version.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/gapic_version.py deleted file mode 100644 index 20a9cd975b02..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/gapic_version.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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-netapp/v1/google/cloud/netapp_v1/py.typed b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/py.typed deleted file mode 100644 index 7d2f4c53406d..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-netapp package uses inline types. diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/__init__.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/__init__.py deleted file mode 100644 index cbf94b283c70..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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-netapp/v1/google/cloud/netapp_v1/services/net_app/__init__.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/__init__.py deleted file mode 100644 index c2e08c12629f..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 NetAppClient -from .async_client import NetAppAsyncClient - -__all__ = ( - 'NetAppClient', - 'NetAppAsyncClient', -) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/async_client.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/async_client.py deleted file mode 100644 index b544c5e288de..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/async_client.py +++ /dev/null @@ -1,8035 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 logging as std_logging -from collections import OrderedDict -import re -from typing import Dict, Callable, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union - -from google.cloud.netapp_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.location import locations_pb2 # type: ignore -from google.cloud.netapp_v1.services.net_app import pagers -from google.cloud.netapp_v1.types import active_directory -from google.cloud.netapp_v1.types import active_directory as gcn_active_directory -from google.cloud.netapp_v1.types import backup -from google.cloud.netapp_v1.types import backup as gcn_backup -from google.cloud.netapp_v1.types import backup_policy -from google.cloud.netapp_v1.types import backup_policy as gcn_backup_policy -from google.cloud.netapp_v1.types import backup_vault -from google.cloud.netapp_v1.types import backup_vault as gcn_backup_vault -from google.cloud.netapp_v1.types import cloud_netapp_service -from google.cloud.netapp_v1.types import common -from google.cloud.netapp_v1.types import kms -from google.cloud.netapp_v1.types import quota_rule -from google.cloud.netapp_v1.types import quota_rule as gcn_quota_rule -from google.cloud.netapp_v1.types import replication -from google.cloud.netapp_v1.types import replication as gcn_replication -from google.cloud.netapp_v1.types import snapshot -from google.cloud.netapp_v1.types import snapshot as gcn_snapshot -from google.cloud.netapp_v1.types import storage_pool -from google.cloud.netapp_v1.types import storage_pool as gcn_storage_pool -from google.cloud.netapp_v1.types import volume -from google.cloud.netapp_v1.types import volume as gcn_volume -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 timestamp_pb2 # type: ignore -from .transports.base import NetAppTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import NetAppGrpcAsyncIOTransport -from .client import NetAppClient - -try: - from google.api_core import client_logging # type: ignore - CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER -except ImportError: # pragma: NO COVER - CLIENT_LOGGING_SUPPORTED = False - -_LOGGER = std_logging.getLogger(__name__) - -class NetAppAsyncClient: - """NetApp Files Google Cloud Service""" - - _client: NetAppClient - - # Copy defaults from the synchronous client for use here. - # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead. - DEFAULT_ENDPOINT = NetAppClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = NetAppClient.DEFAULT_MTLS_ENDPOINT - _DEFAULT_ENDPOINT_TEMPLATE = NetAppClient._DEFAULT_ENDPOINT_TEMPLATE - _DEFAULT_UNIVERSE = NetAppClient._DEFAULT_UNIVERSE - - active_directory_path = staticmethod(NetAppClient.active_directory_path) - parse_active_directory_path = staticmethod(NetAppClient.parse_active_directory_path) - backup_path = staticmethod(NetAppClient.backup_path) - parse_backup_path = staticmethod(NetAppClient.parse_backup_path) - backup_policy_path = staticmethod(NetAppClient.backup_policy_path) - parse_backup_policy_path = staticmethod(NetAppClient.parse_backup_policy_path) - backup_vault_path = staticmethod(NetAppClient.backup_vault_path) - parse_backup_vault_path = staticmethod(NetAppClient.parse_backup_vault_path) - kms_config_path = staticmethod(NetAppClient.kms_config_path) - parse_kms_config_path = staticmethod(NetAppClient.parse_kms_config_path) - network_path = staticmethod(NetAppClient.network_path) - parse_network_path = staticmethod(NetAppClient.parse_network_path) - quota_rule_path = staticmethod(NetAppClient.quota_rule_path) - parse_quota_rule_path = staticmethod(NetAppClient.parse_quota_rule_path) - replication_path = staticmethod(NetAppClient.replication_path) - parse_replication_path = staticmethod(NetAppClient.parse_replication_path) - snapshot_path = staticmethod(NetAppClient.snapshot_path) - parse_snapshot_path = staticmethod(NetAppClient.parse_snapshot_path) - storage_pool_path = staticmethod(NetAppClient.storage_pool_path) - parse_storage_pool_path = staticmethod(NetAppClient.parse_storage_pool_path) - volume_path = staticmethod(NetAppClient.volume_path) - parse_volume_path = staticmethod(NetAppClient.parse_volume_path) - common_billing_account_path = staticmethod(NetAppClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(NetAppClient.parse_common_billing_account_path) - common_folder_path = staticmethod(NetAppClient.common_folder_path) - parse_common_folder_path = staticmethod(NetAppClient.parse_common_folder_path) - common_organization_path = staticmethod(NetAppClient.common_organization_path) - parse_common_organization_path = staticmethod(NetAppClient.parse_common_organization_path) - common_project_path = staticmethod(NetAppClient.common_project_path) - parse_common_project_path = staticmethod(NetAppClient.parse_common_project_path) - common_location_path = staticmethod(NetAppClient.common_location_path) - parse_common_location_path = staticmethod(NetAppClient.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: - NetAppAsyncClient: The constructed client. - """ - return NetAppClient.from_service_account_info.__func__(NetAppAsyncClient, 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: - NetAppAsyncClient: The constructed client. - """ - return NetAppClient.from_service_account_file.__func__(NetAppAsyncClient, 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 NetAppClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> NetAppTransport: - """Returns the transport used by the client instance. - - Returns: - NetAppTransport: 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 = NetAppClient.get_transport_class - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Optional[Union[str, NetAppTransport, Callable[..., NetAppTransport]]] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the net app 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,NetAppTransport,Callable[..., NetAppTransport]]]): - 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 NetAppTransport 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 = NetAppClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG): # pragma: NO COVER - _LOGGER.debug( - "Created client `google.cloud.netapp_v1.NetAppAsyncClient`.", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "universeDomain": getattr(self._client._transport._credentials, "universe_domain", ""), - "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}", - "credentialsInfo": getattr(self.transport._credentials, "get_cred_info", lambda: None)(), - } if hasattr(self._client._transport, "_credentials") else { - "serviceName": "google.cloud.netapp.v1.NetApp", - "credentialsType": None, - } - ) - - async def list_storage_pools(self, - request: Optional[Union[storage_pool.ListStoragePoolsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListStoragePoolsAsyncPager: - r"""Returns descriptions of all storage pools owned by - the caller. - - .. 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 netapp_v1 - - async def sample_list_storage_pools(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ListStoragePoolsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_storage_pools(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.ListStoragePoolsRequest, dict]]): - The request object. ListStoragePoolsRequest lists Storage - Pools. - parent (:class:`str`): - Required. Parent value - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.services.net_app.pagers.ListStoragePoolsAsyncPager: - ListStoragePoolsResponse is the - response to a ListStoragePoolsRequest. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, storage_pool.ListStoragePoolsRequest): - request = storage_pool.ListStoragePoolsRequest(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_storage_pools] - - # 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.ListStoragePoolsAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_storage_pool(self, - request: Optional[Union[gcn_storage_pool.CreateStoragePoolRequest, dict]] = None, - *, - parent: Optional[str] = None, - storage_pool: Optional[gcn_storage_pool.StoragePool] = None, - storage_pool_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Creates a new storage pool. - - .. 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 netapp_v1 - - async def sample_create_storage_pool(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - storage_pool = netapp_v1.StoragePool() - storage_pool.service_level = "FLEX" - storage_pool.capacity_gib = 1247 - storage_pool.network = "network_value" - - request = netapp_v1.CreateStoragePoolRequest( - parent="parent_value", - storage_pool_id="storage_pool_id_value", - storage_pool=storage_pool, - ) - - # Make the request - operation = client.create_storage_pool(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.CreateStoragePoolRequest, dict]]): - The request object. CreateStoragePoolRequest creates a - Storage Pool. - parent (:class:`str`): - Required. Value for parent. - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - storage_pool (:class:`google.cloud.netapp_v1.types.StoragePool`): - Required. The required parameters to - create a new storage pool. - - This corresponds to the ``storage_pool`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - storage_pool_id (:class:`str`): - Required. Id of the requesting - storage pool. Must be unique within the - parent resource. Must contain only - letters, numbers and hyphen, with the - first character a letter, the last a - letter or a number, and a 63 character - maximum. - - This corresponds to the ``storage_pool_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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.StoragePool` StoragePool is a container for volumes with a service level and capacity. - Volumes can be created in a pool of sufficient - available capacity. StoragePool capacity is what you - are billed for. - - """ - # 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. - flattened_params = [parent, storage_pool, storage_pool_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_storage_pool.CreateStoragePoolRequest): - request = gcn_storage_pool.CreateStoragePoolRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if storage_pool is not None: - request.storage_pool = storage_pool - if storage_pool_id is not None: - request.storage_pool_id = storage_pool_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_storage_pool] - - # 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, - gcn_storage_pool.StoragePool, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def get_storage_pool(self, - request: Optional[Union[storage_pool.GetStoragePoolRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> storage_pool.StoragePool: - r"""Returns the description of the specified storage pool - by poolId. - - .. 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 netapp_v1 - - async def sample_get_storage_pool(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.GetStoragePoolRequest( - name="name_value", - ) - - # Make the request - response = await client.get_storage_pool(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.GetStoragePoolRequest, dict]]): - The request object. GetStoragePoolRequest gets a Storage - Pool. - name (:class:`str`): - Required. Name of the storage pool - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.StoragePool: - StoragePool is a container for - volumes with a service level and - capacity. Volumes can be created in a - pool of sufficient available capacity. - StoragePool capacity is what you are - billed for. - - """ - # 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, storage_pool.GetStoragePoolRequest): - request = storage_pool.GetStoragePoolRequest(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_storage_pool] - - # 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_storage_pool(self, - request: Optional[Union[gcn_storage_pool.UpdateStoragePoolRequest, dict]] = None, - *, - storage_pool: Optional[gcn_storage_pool.StoragePool] = 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, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates the storage pool properties with the full - spec - - .. 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 netapp_v1 - - async def sample_update_storage_pool(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - storage_pool = netapp_v1.StoragePool() - storage_pool.service_level = "FLEX" - storage_pool.capacity_gib = 1247 - storage_pool.network = "network_value" - - request = netapp_v1.UpdateStoragePoolRequest( - storage_pool=storage_pool, - ) - - # Make the request - operation = client.update_storage_pool(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.UpdateStoragePoolRequest, dict]]): - The request object. UpdateStoragePoolRequest updates a - Storage Pool. - storage_pool (:class:`google.cloud.netapp_v1.types.StoragePool`): - Required. The pool being updated - This corresponds to the ``storage_pool`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. Field mask is used to specify the fields to be - overwritten in the StoragePool resource by the update. - The fields specified in the update_mask are relative to - the resource, not the full request. A field will be - overwritten if it is in the mask. If the user does not - provide a mask then all fields will be overwritten. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.StoragePool` StoragePool is a container for volumes with a service level and capacity. - Volumes can be created in a pool of sufficient - available capacity. StoragePool capacity is what you - are billed for. - - """ - # 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. - flattened_params = [storage_pool, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_storage_pool.UpdateStoragePoolRequest): - request = gcn_storage_pool.UpdateStoragePoolRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if storage_pool is not None: - request.storage_pool = storage_pool - 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_storage_pool] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("storage_pool.name", request.storage_pool.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, - gcn_storage_pool.StoragePool, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_storage_pool(self, - request: Optional[Union[storage_pool.DeleteStoragePoolRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Warning! This operation will permanently delete the - storage pool. - - .. 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 netapp_v1 - - async def sample_delete_storage_pool(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteStoragePoolRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_storage_pool(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.DeleteStoragePoolRequest, dict]]): - The request object. DeleteStoragePoolRequest deletes a - Storage Pool. - name (:class:`str`): - Required. Name of the storage pool - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, storage_pool.DeleteStoragePoolRequest): - request = storage_pool.DeleteStoragePoolRequest(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_storage_pool] - - # 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=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def validate_directory_service(self, - request: Optional[Union[storage_pool.ValidateDirectoryServiceRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""ValidateDirectoryService does a connectivity check - for a directory service policy attached to the storage - pool. - - .. 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 netapp_v1 - - async def sample_validate_directory_service(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ValidateDirectoryServiceRequest( - name="name_value", - ) - - # Make the request - operation = client.validate_directory_service(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.ValidateDirectoryServiceRequest, dict]]): - The request object. ValidateDirectoryServiceRequest - validates the directory service policy - attached to the storage pool. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - # - 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, storage_pool.ValidateDirectoryServiceRequest): - request = storage_pool.ValidateDirectoryServiceRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.validate_directory_service] - - # 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=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def switch_active_replica_zone(self, - request: Optional[Union[storage_pool.SwitchActiveReplicaZoneRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""This operation will switch the active/replica zone - for a regional storagePool. - - .. 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 netapp_v1 - - async def sample_switch_active_replica_zone(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.SwitchActiveReplicaZoneRequest( - name="name_value", - ) - - # Make the request - operation = client.switch_active_replica_zone(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.SwitchActiveReplicaZoneRequest, dict]]): - The request object. SwitchActiveReplicaZoneRequest switch - the active/replica zone for a regional - storagePool. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.StoragePool` StoragePool is a container for volumes with a service level and capacity. - Volumes can be created in a pool of sufficient - available capacity. StoragePool capacity is what you - are billed for. - - """ - # 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, storage_pool.SwitchActiveReplicaZoneRequest): - request = storage_pool.SwitchActiveReplicaZoneRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.switch_active_replica_zone] - - # 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, - storage_pool.StoragePool, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_volumes(self, - request: Optional[Union[volume.ListVolumesRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListVolumesAsyncPager: - r"""Lists Volumes in a given 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 netapp_v1 - - async def sample_list_volumes(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ListVolumesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_volumes(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.ListVolumesRequest, dict]]): - The request object. Message for requesting list of - Volumes - parent (:class:`str`): - Required. Parent value for - ListVolumesRequest - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.services.net_app.pagers.ListVolumesAsyncPager: - Message for response to listing - Volumes - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, volume.ListVolumesRequest): - request = volume.ListVolumesRequest(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_volumes] - - # 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.ListVolumesAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_volume(self, - request: Optional[Union[volume.GetVolumeRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> volume.Volume: - r"""Gets details of a single Volume. - - .. 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 netapp_v1 - - async def sample_get_volume(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.GetVolumeRequest( - name="name_value", - ) - - # Make the request - response = await client.get_volume(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.GetVolumeRequest, dict]]): - The request object. Message for getting a Volume - name (:class:`str`): - Required. Name of the volume - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.Volume: - Volume provides a filesystem that you - can mount. - - """ - # 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, volume.GetVolumeRequest): - request = volume.GetVolumeRequest(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_volume] - - # 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_volume(self, - request: Optional[Union[gcn_volume.CreateVolumeRequest, dict]] = None, - *, - parent: Optional[str] = None, - volume: Optional[gcn_volume.Volume] = None, - volume_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Creates a new Volume in a given project and location. - - .. 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 netapp_v1 - - async def sample_create_volume(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - volume = netapp_v1.Volume() - volume.share_name = "share_name_value" - volume.storage_pool = "storage_pool_value" - volume.capacity_gib = 1247 - volume.protocols = ['SMB'] - - request = netapp_v1.CreateVolumeRequest( - parent="parent_value", - volume_id="volume_id_value", - volume=volume, - ) - - # Make the request - operation = client.create_volume(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.CreateVolumeRequest, dict]]): - The request object. Message for creating a Volume - parent (:class:`str`): - Required. Value for parent. - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - volume (:class:`google.cloud.netapp_v1.types.Volume`): - Required. The volume being created. - This corresponds to the ``volume`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - volume_id (:class:`str`): - Required. Id of the requesting - volume. Must be unique within the parent - resource. Must contain only letters, - numbers and hyphen, with the first - character a letter, the last a letter or - a number, and a 63 character maximum. - - This corresponds to the ``volume_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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.Volume` Volume - provides a filesystem that you can mount. - - """ - # 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. - flattened_params = [parent, volume, volume_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_volume.CreateVolumeRequest): - request = gcn_volume.CreateVolumeRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if volume is not None: - request.volume = volume - if volume_id is not None: - request.volume_id = volume_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_volume] - - # 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, - gcn_volume.Volume, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_volume(self, - request: Optional[Union[gcn_volume.UpdateVolumeRequest, dict]] = None, - *, - volume: Optional[gcn_volume.Volume] = 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, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates the parameters of a single Volume. - - .. 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 netapp_v1 - - async def sample_update_volume(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - volume = netapp_v1.Volume() - volume.share_name = "share_name_value" - volume.storage_pool = "storage_pool_value" - volume.capacity_gib = 1247 - volume.protocols = ['SMB'] - - request = netapp_v1.UpdateVolumeRequest( - volume=volume, - ) - - # Make the request - operation = client.update_volume(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.UpdateVolumeRequest, dict]]): - The request object. Message for updating a Volume - volume (:class:`google.cloud.netapp_v1.types.Volume`): - Required. The volume being updated - This corresponds to the ``volume`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. Field mask is used to specify the fields to be - overwritten in the Volume resource by the update. The - fields specified in the update_mask are relative to the - resource, not the full request. A field will be - overwritten if it is in the mask. If the user does not - provide a mask then all fields will be overwritten. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.Volume` Volume - provides a filesystem that you can mount. - - """ - # 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. - flattened_params = [volume, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_volume.UpdateVolumeRequest): - request = gcn_volume.UpdateVolumeRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if volume is not None: - request.volume = volume - 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_volume] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("volume.name", request.volume.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, - gcn_volume.Volume, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_volume(self, - request: Optional[Union[volume.DeleteVolumeRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes a single Volume. - - .. 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 netapp_v1 - - async def sample_delete_volume(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteVolumeRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_volume(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.DeleteVolumeRequest, dict]]): - The request object. Message for deleting a Volume - name (:class:`str`): - Required. Name of the volume - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, volume.DeleteVolumeRequest): - request = volume.DeleteVolumeRequest(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_volume] - - # 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=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def revert_volume(self, - request: Optional[Union[volume.RevertVolumeRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Revert an existing volume to a specified snapshot. - Warning! This operation will permanently revert all - changes made after the snapshot was created. - - .. 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 netapp_v1 - - async def sample_revert_volume(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.RevertVolumeRequest( - name="name_value", - snapshot_id="snapshot_id_value", - ) - - # Make the request - operation = client.revert_volume(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.RevertVolumeRequest, dict]]): - The request object. RevertVolumeRequest reverts the given - volume to the specified snapshot. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.Volume` Volume - provides a filesystem that you can mount. - - """ - # 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, volume.RevertVolumeRequest): - request = volume.RevertVolumeRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.revert_volume] - - # 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, - volume.Volume, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_snapshots(self, - request: Optional[Union[snapshot.ListSnapshotsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListSnapshotsAsyncPager: - r"""Returns descriptions of all snapshots for a volume. - - .. 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 netapp_v1 - - async def sample_list_snapshots(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ListSnapshotsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_snapshots(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.ListSnapshotsRequest, dict]]): - The request object. ListSnapshotsRequest lists snapshots. - parent (:class:`str`): - Required. The volume for which to retrieve snapshot - information, in the format - ``projects/{project_id}/locations/{location}/volumes/{volume_id}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.services.net_app.pagers.ListSnapshotsAsyncPager: - ListSnapshotsResponse is the result - of ListSnapshotsRequest. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, snapshot.ListSnapshotsRequest): - request = snapshot.ListSnapshotsRequest(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_snapshots] - - # 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.ListSnapshotsAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_snapshot(self, - request: Optional[Union[snapshot.GetSnapshotRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> snapshot.Snapshot: - r"""Describe a snapshot for a volume. - - .. 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 netapp_v1 - - async def sample_get_snapshot(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.GetSnapshotRequest( - name="name_value", - ) - - # Make the request - response = await client.get_snapshot(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.GetSnapshotRequest, dict]]): - The request object. GetSnapshotRequest gets the state of - a snapshot. - name (:class:`str`): - Required. The snapshot resource name, in the format - ``projects/{project_id}/locations/{location}/volumes/{volume_id}/snapshots/{snapshot_id}`` - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.Snapshot: - Snapshot is a point-in-time version - of a Volume's content. - - """ - # 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, snapshot.GetSnapshotRequest): - request = snapshot.GetSnapshotRequest(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_snapshot] - - # 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_snapshot(self, - request: Optional[Union[gcn_snapshot.CreateSnapshotRequest, dict]] = None, - *, - parent: Optional[str] = None, - snapshot: Optional[gcn_snapshot.Snapshot] = None, - snapshot_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Create a new snapshot for a volume. - - .. 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 netapp_v1 - - async def sample_create_snapshot(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.CreateSnapshotRequest( - parent="parent_value", - snapshot_id="snapshot_id_value", - ) - - # Make the request - operation = client.create_snapshot(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.CreateSnapshotRequest, dict]]): - The request object. CreateSnapshotRequest creates a - snapshot. - parent (:class:`str`): - Required. The NetApp volume to create the snapshots of, - in the format - ``projects/{project_id}/locations/{location}/volumes/{volume_id}`` - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - snapshot (:class:`google.cloud.netapp_v1.types.Snapshot`): - Required. A snapshot resource - This corresponds to the ``snapshot`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - snapshot_id (:class:`str`): - Required. ID of the snapshot to - create. Must be unique within the parent - resource. Must contain only letters, - numbers and hyphen, with the first - character a letter, the last a letter or - a number, and a 63 character maximum. - - This corresponds to the ``snapshot_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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.Snapshot` Snapshot - is a point-in-time version of a Volume's content. - - """ - # 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. - flattened_params = [parent, snapshot, snapshot_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_snapshot.CreateSnapshotRequest): - request = gcn_snapshot.CreateSnapshotRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if snapshot is not None: - request.snapshot = snapshot - if snapshot_id is not None: - request.snapshot_id = snapshot_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_snapshot] - - # 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, - gcn_snapshot.Snapshot, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_snapshot(self, - request: Optional[Union[snapshot.DeleteSnapshotRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes a snapshot. - - .. 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 netapp_v1 - - async def sample_delete_snapshot(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteSnapshotRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_snapshot(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.DeleteSnapshotRequest, dict]]): - The request object. DeleteSnapshotRequest deletes a - snapshot. - name (:class:`str`): - Required. The snapshot resource name, in the format - ``projects/*/locations/*/volumes/*/snapshots/{snapshot_id}`` - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, snapshot.DeleteSnapshotRequest): - request = snapshot.DeleteSnapshotRequest(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_snapshot] - - # 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=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_snapshot(self, - request: Optional[Union[gcn_snapshot.UpdateSnapshotRequest, dict]] = None, - *, - snapshot: Optional[gcn_snapshot.Snapshot] = 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, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates the settings of a specific snapshot. - - .. 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 netapp_v1 - - async def sample_update_snapshot(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.UpdateSnapshotRequest( - ) - - # Make the request - operation = client.update_snapshot(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.UpdateSnapshotRequest, dict]]): - The request object. UpdateSnapshotRequest updates - description and/or labels for a - snapshot. - snapshot (:class:`google.cloud.netapp_v1.types.Snapshot`): - Required. A snapshot resource - This corresponds to the ``snapshot`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. Mask of fields to update. - At least one path must be supplied in - this field. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.Snapshot` Snapshot - is a point-in-time version of a Volume's content. - - """ - # 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. - flattened_params = [snapshot, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_snapshot.UpdateSnapshotRequest): - request = gcn_snapshot.UpdateSnapshotRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if snapshot is not None: - request.snapshot = snapshot - 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_snapshot] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("snapshot.name", request.snapshot.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, - gcn_snapshot.Snapshot, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_active_directories(self, - request: Optional[Union[active_directory.ListActiveDirectoriesRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListActiveDirectoriesAsyncPager: - r"""Lists active directories. - - .. 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 netapp_v1 - - async def sample_list_active_directories(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ListActiveDirectoriesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_active_directories(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.ListActiveDirectoriesRequest, dict]]): - The request object. ListActiveDirectoriesRequest for - requesting multiple active directories. - parent (:class:`str`): - Required. Parent value for - ListActiveDirectoriesRequest - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.services.net_app.pagers.ListActiveDirectoriesAsyncPager: - ListActiveDirectoriesResponse - contains all the active directories - requested. 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, active_directory.ListActiveDirectoriesRequest): - request = active_directory.ListActiveDirectoriesRequest(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_active_directories] - - # 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.ListActiveDirectoriesAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_active_directory(self, - request: Optional[Union[active_directory.GetActiveDirectoryRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> active_directory.ActiveDirectory: - r"""Describes a specified active directory. - - .. 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 netapp_v1 - - async def sample_get_active_directory(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.GetActiveDirectoryRequest( - name="name_value", - ) - - # Make the request - response = await client.get_active_directory(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.GetActiveDirectoryRequest, dict]]): - The request object. GetActiveDirectory for getting a - single active directory. - name (:class:`str`): - Required. Name of the active - directory. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.ActiveDirectory: - ActiveDirectory is the public - representation of the active directory - config. - - """ - # 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, active_directory.GetActiveDirectoryRequest): - request = active_directory.GetActiveDirectoryRequest(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_active_directory] - - # 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_active_directory(self, - request: Optional[Union[gcn_active_directory.CreateActiveDirectoryRequest, dict]] = None, - *, - parent: Optional[str] = None, - active_directory: Optional[gcn_active_directory.ActiveDirectory] = None, - active_directory_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""CreateActiveDirectory - Creates the active directory specified in the request. - - .. 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 netapp_v1 - - async def sample_create_active_directory(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - active_directory = netapp_v1.ActiveDirectory() - active_directory.domain = "domain_value" - active_directory.dns = "dns_value" - active_directory.net_bios_prefix = "net_bios_prefix_value" - active_directory.username = "username_value" - active_directory.password = "password_value" - - request = netapp_v1.CreateActiveDirectoryRequest( - parent="parent_value", - active_directory=active_directory, - active_directory_id="active_directory_id_value", - ) - - # Make the request - operation = client.create_active_directory(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.CreateActiveDirectoryRequest, dict]]): - The request object. CreateActiveDirectoryRequest for - creating an active directory. - parent (:class:`str`): - Required. Value for parent. - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - active_directory (:class:`google.cloud.netapp_v1.types.ActiveDirectory`): - Required. Fields of the to be created - active directory. - - This corresponds to the ``active_directory`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - active_directory_id (:class:`str`): - Required. ID of the active directory - to create. Must be unique within the - parent resource. Must contain only - letters, numbers and hyphen, with the - first character a letter , the last a - letter or a number, and a 63 character - maximum. - - This corresponds to the ``active_directory_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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.ActiveDirectory` - ActiveDirectory is the public representation of the - active directory config. - - """ - # 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. - flattened_params = [parent, active_directory, active_directory_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_active_directory.CreateActiveDirectoryRequest): - request = gcn_active_directory.CreateActiveDirectoryRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if active_directory is not None: - request.active_directory = active_directory - if active_directory_id is not None: - request.active_directory_id = active_directory_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_active_directory] - - # 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, - gcn_active_directory.ActiveDirectory, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_active_directory(self, - request: Optional[Union[gcn_active_directory.UpdateActiveDirectoryRequest, dict]] = None, - *, - active_directory: Optional[gcn_active_directory.ActiveDirectory] = 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, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Update the parameters of an active directories. - - .. 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 netapp_v1 - - async def sample_update_active_directory(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - active_directory = netapp_v1.ActiveDirectory() - active_directory.domain = "domain_value" - active_directory.dns = "dns_value" - active_directory.net_bios_prefix = "net_bios_prefix_value" - active_directory.username = "username_value" - active_directory.password = "password_value" - - request = netapp_v1.UpdateActiveDirectoryRequest( - active_directory=active_directory, - ) - - # Make the request - operation = client.update_active_directory(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.UpdateActiveDirectoryRequest, dict]]): - The request object. UpdateActiveDirectoryRequest for - updating an active directory. - active_directory (:class:`google.cloud.netapp_v1.types.ActiveDirectory`): - Required. The volume being updated - This corresponds to the ``active_directory`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. Field mask is used to specify the fields to be - overwritten in the Active Directory resource by the - update. The fields specified in the update_mask are - relative to the resource, not the full request. A field - will be overwritten if it is in the mask. If the user - does not provide a mask then all fields will be - overwritten. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.ActiveDirectory` - ActiveDirectory is the public representation of the - active directory config. - - """ - # 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. - flattened_params = [active_directory, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_active_directory.UpdateActiveDirectoryRequest): - request = gcn_active_directory.UpdateActiveDirectoryRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if active_directory is not None: - request.active_directory = active_directory - 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_active_directory] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("active_directory.name", request.active_directory.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, - gcn_active_directory.ActiveDirectory, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_active_directory(self, - request: Optional[Union[active_directory.DeleteActiveDirectoryRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Delete the active directory specified in the request. - - .. 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 netapp_v1 - - async def sample_delete_active_directory(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteActiveDirectoryRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_active_directory(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.DeleteActiveDirectoryRequest, dict]]): - The request object. DeleteActiveDirectoryRequest for - deleting a single active directory. - name (:class:`str`): - Required. Name of the active - directory. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, active_directory.DeleteActiveDirectoryRequest): - request = active_directory.DeleteActiveDirectoryRequest(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_active_directory] - - # 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=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_kms_configs(self, - request: Optional[Union[kms.ListKmsConfigsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListKmsConfigsAsyncPager: - r"""Returns descriptions of all KMS configs owned by the - caller. - - .. 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 netapp_v1 - - async def sample_list_kms_configs(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ListKmsConfigsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_kms_configs(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.ListKmsConfigsRequest, dict]]): - The request object. ListKmsConfigsRequest lists KMS - Configs. - parent (:class:`str`): - Required. Parent value - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.services.net_app.pagers.ListKmsConfigsAsyncPager: - ListKmsConfigsResponse is the - response to a ListKmsConfigsRequest. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, kms.ListKmsConfigsRequest): - request = kms.ListKmsConfigsRequest(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_kms_configs] - - # 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.ListKmsConfigsAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_kms_config(self, - request: Optional[Union[kms.CreateKmsConfigRequest, dict]] = None, - *, - parent: Optional[str] = None, - kms_config: Optional[kms.KmsConfig] = None, - kms_config_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Creates a new KMS config. - - .. 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 netapp_v1 - - async def sample_create_kms_config(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - kms_config = netapp_v1.KmsConfig() - kms_config.crypto_key_name = "crypto_key_name_value" - - request = netapp_v1.CreateKmsConfigRequest( - parent="parent_value", - kms_config_id="kms_config_id_value", - kms_config=kms_config, - ) - - # Make the request - operation = client.create_kms_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.CreateKmsConfigRequest, dict]]): - The request object. CreateKmsConfigRequest creates a KMS - Config. - parent (:class:`str`): - Required. Value for parent. - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - kms_config (:class:`google.cloud.netapp_v1.types.KmsConfig`): - Required. The required parameters to - create a new KmsConfig. - - This corresponds to the ``kms_config`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - kms_config_id (:class:`str`): - Required. Id of the requesting - KmsConfig. Must be unique within the - parent resource. Must contain only - letters, numbers and hyphen, with the - first character a letter, the last a - letter or a number, and a 63 character - maximum. - - This corresponds to the ``kms_config_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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.KmsConfig` - KmsConfig is the customer managed encryption key(CMEK) - configuration. - - """ - # 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. - flattened_params = [parent, kms_config, kms_config_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, kms.CreateKmsConfigRequest): - request = kms.CreateKmsConfigRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if kms_config is not None: - request.kms_config = kms_config - if kms_config_id is not None: - request.kms_config_id = kms_config_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_kms_config] - - # 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, - kms.KmsConfig, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def get_kms_config(self, - request: Optional[Union[kms.GetKmsConfigRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> kms.KmsConfig: - r"""Returns the description of the specified KMS config by - kms_config_id. - - .. 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 netapp_v1 - - async def sample_get_kms_config(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.GetKmsConfigRequest( - name="name_value", - ) - - # Make the request - response = await client.get_kms_config(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.GetKmsConfigRequest, dict]]): - The request object. GetKmsConfigRequest gets a KMS - Config. - name (:class:`str`): - Required. Name of the KmsConfig - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.KmsConfig: - KmsConfig is the customer managed - encryption key(CMEK) configuration. - - """ - # 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, kms.GetKmsConfigRequest): - request = kms.GetKmsConfigRequest(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_kms_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_kms_config(self, - request: Optional[Union[kms.UpdateKmsConfigRequest, dict]] = None, - *, - kms_config: Optional[kms.KmsConfig] = 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, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates the Kms config properties with the full spec - - .. 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 netapp_v1 - - async def sample_update_kms_config(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - kms_config = netapp_v1.KmsConfig() - kms_config.crypto_key_name = "crypto_key_name_value" - - request = netapp_v1.UpdateKmsConfigRequest( - kms_config=kms_config, - ) - - # Make the request - operation = client.update_kms_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.UpdateKmsConfigRequest, dict]]): - The request object. UpdateKmsConfigRequest updates a KMS - Config. - kms_config (:class:`google.cloud.netapp_v1.types.KmsConfig`): - Required. The KmsConfig being updated - This corresponds to the ``kms_config`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. Field mask is used to specify the fields to be - overwritten in the KmsConfig resource by the update. The - fields specified in the update_mask are relative to the - resource, not the full request. A field will be - overwritten if it is in the mask. If the user does not - provide a mask then all fields will be overwritten. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.KmsConfig` - KmsConfig is the customer managed encryption key(CMEK) - configuration. - - """ - # 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. - flattened_params = [kms_config, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, kms.UpdateKmsConfigRequest): - request = kms.UpdateKmsConfigRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if kms_config is not None: - request.kms_config = kms_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_kms_config] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("kms_config.name", request.kms_config.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, - kms.KmsConfig, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def encrypt_volumes(self, - request: Optional[Union[kms.EncryptVolumesRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Encrypt the existing volumes without CMEK encryption - with the desired the KMS config for the whole region. - - .. 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 netapp_v1 - - async def sample_encrypt_volumes(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.EncryptVolumesRequest( - name="name_value", - ) - - # Make the request - operation = client.encrypt_volumes(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.EncryptVolumesRequest, dict]]): - The request object. EncryptVolumesRequest specifies the - KMS config to encrypt existing volumes. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.KmsConfig` - KmsConfig is the customer managed encryption key(CMEK) - configuration. - - """ - # 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, kms.EncryptVolumesRequest): - request = kms.EncryptVolumesRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.encrypt_volumes] - - # 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, - kms.KmsConfig, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def verify_kms_config(self, - request: Optional[Union[kms.VerifyKmsConfigRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> kms.VerifyKmsConfigResponse: - r"""Verifies KMS config reachability. - - .. 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 netapp_v1 - - async def sample_verify_kms_config(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.VerifyKmsConfigRequest( - name="name_value", - ) - - # Make the request - response = await client.verify_kms_config(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.VerifyKmsConfigRequest, dict]]): - The request object. VerifyKmsConfigRequest specifies the - KMS config to be validated. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.VerifyKmsConfigResponse: - VerifyKmsConfigResponse contains the - information if the config is correctly - and error message. - - """ - # 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, kms.VerifyKmsConfigRequest): - request = kms.VerifyKmsConfigRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.verify_kms_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 delete_kms_config(self, - request: Optional[Union[kms.DeleteKmsConfigRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Warning! This operation will permanently delete the - Kms config. - - .. 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 netapp_v1 - - async def sample_delete_kms_config(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteKmsConfigRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_kms_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.DeleteKmsConfigRequest, dict]]): - The request object. DeleteKmsConfigRequest deletes a KMS - Config. - name (:class:`str`): - Required. Name of the KmsConfig. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, kms.DeleteKmsConfigRequest): - request = kms.DeleteKmsConfigRequest(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_kms_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, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_replications(self, - request: Optional[Union[replication.ListReplicationsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListReplicationsAsyncPager: - r"""Returns descriptions of all replications for a - volume. - - .. 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 netapp_v1 - - async def sample_list_replications(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ListReplicationsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_replications(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.ListReplicationsRequest, dict]]): - The request object. ListReplications lists replications. - parent (:class:`str`): - Required. The volume for which to retrieve replication - information, in the format - ``projects/{project_id}/locations/{location}/volumes/{volume_id}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.services.net_app.pagers.ListReplicationsAsyncPager: - ListReplicationsResponse is the - result of ListReplicationsRequest. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, replication.ListReplicationsRequest): - request = replication.ListReplicationsRequest(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_replications] - - # 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.ListReplicationsAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_replication(self, - request: Optional[Union[replication.GetReplicationRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> replication.Replication: - r"""Describe a replication for a volume. - - .. 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 netapp_v1 - - async def sample_get_replication(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.GetReplicationRequest( - name="name_value", - ) - - # Make the request - response = await client.get_replication(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.GetReplicationRequest, dict]]): - The request object. GetReplicationRequest gets the state - of a replication. - name (:class:`str`): - Required. The replication resource name, in the format - ``projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}`` - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.Replication: - Replication is a nested resource - under Volume, that describes a - cross-region replication relationship - between 2 volumes in different regions. - - """ - # 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, replication.GetReplicationRequest): - request = replication.GetReplicationRequest(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_replication] - - # 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_replication(self, - request: Optional[Union[gcn_replication.CreateReplicationRequest, dict]] = None, - *, - parent: Optional[str] = None, - replication: Optional[gcn_replication.Replication] = None, - replication_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Create a new replication for a volume. - - .. 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 netapp_v1 - - async def sample_create_replication(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - replication = netapp_v1.Replication() - replication.replication_schedule = "DAILY" - replication.destination_volume_parameters.storage_pool = "storage_pool_value" - - request = netapp_v1.CreateReplicationRequest( - parent="parent_value", - replication=replication, - replication_id="replication_id_value", - ) - - # Make the request - operation = client.create_replication(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.CreateReplicationRequest, dict]]): - The request object. CreateReplicationRequest creates a - replication. - parent (:class:`str`): - Required. The NetApp volume to create the replications - of, in the format - ``projects/{project_id}/locations/{location}/volumes/{volume_id}`` - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - replication (:class:`google.cloud.netapp_v1.types.Replication`): - Required. A replication resource - This corresponds to the ``replication`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - replication_id (:class:`str`): - Required. ID of the replication to - create. Must be unique within the parent - resource. Must contain only letters, - numbers and hyphen, with the first - character a letter, the last a letter or - a number, and a 63 character maximum. - - This corresponds to the ``replication_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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a - cross-region replication relationship between 2 - volumes in different regions. - - """ - # 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. - flattened_params = [parent, replication, replication_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_replication.CreateReplicationRequest): - request = gcn_replication.CreateReplicationRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if replication is not None: - request.replication = replication - if replication_id is not None: - request.replication_id = replication_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_replication] - - # 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, - gcn_replication.Replication, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_replication(self, - request: Optional[Union[replication.DeleteReplicationRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes a replication. - - .. 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 netapp_v1 - - async def sample_delete_replication(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteReplicationRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_replication(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.DeleteReplicationRequest, dict]]): - The request object. DeleteReplicationRequest deletes a - replication. - name (:class:`str`): - Required. The replication resource name, in the format - ``projects/*/locations/*/volumes/*/replications/{replication_id}`` - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, replication.DeleteReplicationRequest): - request = replication.DeleteReplicationRequest(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_replication] - - # 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=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_replication(self, - request: Optional[Union[gcn_replication.UpdateReplicationRequest, dict]] = None, - *, - replication: Optional[gcn_replication.Replication] = 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, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates the settings of a specific replication. - - .. 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 netapp_v1 - - async def sample_update_replication(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - replication = netapp_v1.Replication() - replication.replication_schedule = "DAILY" - replication.destination_volume_parameters.storage_pool = "storage_pool_value" - - request = netapp_v1.UpdateReplicationRequest( - replication=replication, - ) - - # Make the request - operation = client.update_replication(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.UpdateReplicationRequest, dict]]): - The request object. UpdateReplicationRequest updates - description and/or labels for a - replication. - replication (:class:`google.cloud.netapp_v1.types.Replication`): - Required. A replication resource - This corresponds to the ``replication`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. Mask of fields to update. - At least one path must be supplied in - this field. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a - cross-region replication relationship between 2 - volumes in different regions. - - """ - # 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. - flattened_params = [replication, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_replication.UpdateReplicationRequest): - request = gcn_replication.UpdateReplicationRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if replication is not None: - request.replication = replication - 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_replication] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("replication.name", request.replication.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, - gcn_replication.Replication, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def stop_replication(self, - request: Optional[Union[replication.StopReplicationRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Stop Cross Region Replication. - - .. 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 netapp_v1 - - async def sample_stop_replication(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.StopReplicationRequest( - name="name_value", - ) - - # Make the request - operation = client.stop_replication(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.StopReplicationRequest, dict]]): - The request object. StopReplicationRequest stops a - replication until resumed. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a - cross-region replication relationship between 2 - volumes in different regions. - - """ - # 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, replication.StopReplicationRequest): - request = replication.StopReplicationRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.stop_replication] - - # 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, - replication.Replication, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def resume_replication(self, - request: Optional[Union[replication.ResumeReplicationRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Resume Cross Region Replication. - - .. 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 netapp_v1 - - async def sample_resume_replication(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ResumeReplicationRequest( - name="name_value", - ) - - # Make the request - operation = client.resume_replication(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.ResumeReplicationRequest, dict]]): - The request object. ResumeReplicationRequest resumes a - stopped replication. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a - cross-region replication relationship between 2 - volumes in different regions. - - """ - # 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, replication.ResumeReplicationRequest): - request = replication.ResumeReplicationRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.resume_replication] - - # 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, - replication.Replication, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def reverse_replication_direction(self, - request: Optional[Union[replication.ReverseReplicationDirectionRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Reverses direction of replication. Source becomes - destination and destination becomes source. - - .. 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 netapp_v1 - - async def sample_reverse_replication_direction(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ReverseReplicationDirectionRequest( - name="name_value", - ) - - # Make the request - operation = client.reverse_replication_direction(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.ReverseReplicationDirectionRequest, dict]]): - The request object. ReverseReplicationDirectionRequest - reverses direction of replication. - Source becomes destination and - destination becomes source. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a - cross-region replication relationship between 2 - volumes in different regions. - - """ - # 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, replication.ReverseReplicationDirectionRequest): - request = replication.ReverseReplicationDirectionRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.reverse_replication_direction] - - # 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, - replication.Replication, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def establish_peering(self, - request: Optional[Union[replication.EstablishPeeringRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Establish replication peering. - - .. 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 netapp_v1 - - async def sample_establish_peering(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.EstablishPeeringRequest( - name="name_value", - peer_cluster_name="peer_cluster_name_value", - peer_svm_name="peer_svm_name_value", - peer_volume_name="peer_volume_name_value", - ) - - # Make the request - operation = client.establish_peering(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.EstablishPeeringRequest, dict]]): - The request object. EstablishPeeringRequest establishes - cluster and svm peerings between the - source and the destination replications. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a - cross-region replication relationship between 2 - volumes in different regions. - - """ - # 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, replication.EstablishPeeringRequest): - request = replication.EstablishPeeringRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.establish_peering] - - # 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, - replication.Replication, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def sync_replication(self, - request: Optional[Union[replication.SyncReplicationRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Syncs the replication. This will invoke one time - volume data transfer from source to destination. - - .. 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 netapp_v1 - - async def sample_sync_replication(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.SyncReplicationRequest( - name="name_value", - ) - - # Make the request - operation = client.sync_replication(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.SyncReplicationRequest, dict]]): - The request object. SyncReplicationRequest syncs the - replication from source to destination. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a - cross-region replication relationship between 2 - volumes in different regions. - - """ - # 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, replication.SyncReplicationRequest): - request = replication.SyncReplicationRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.sync_replication] - - # 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, - replication.Replication, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def create_backup_vault(self, - request: Optional[Union[gcn_backup_vault.CreateBackupVaultRequest, dict]] = None, - *, - parent: Optional[str] = None, - backup_vault: Optional[gcn_backup_vault.BackupVault] = None, - backup_vault_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Creates new backup vault - - .. 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 netapp_v1 - - async def sample_create_backup_vault(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.CreateBackupVaultRequest( - parent="parent_value", - backup_vault_id="backup_vault_id_value", - ) - - # Make the request - operation = client.create_backup_vault(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.CreateBackupVaultRequest, dict]]): - The request object. CreateBackupVaultRequest creates a - backup vault. - parent (:class:`str`): - Required. The location to create the backup vaults, in - the format - ``projects/{project_id}/locations/{location}`` - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - backup_vault (:class:`google.cloud.netapp_v1.types.BackupVault`): - Required. A backupVault resource - This corresponds to the ``backup_vault`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - backup_vault_id (:class:`str`): - Required. The ID to use for the - backupVault. The ID must be unique - within the specified location. Must - contain only letters, numbers and - hyphen, with the first character a - letter, the last a letter or a number, - and a 63 character maximum. - - This corresponds to the ``backup_vault_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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.BackupVault` A - NetApp BackupVault. - - """ - # 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. - flattened_params = [parent, backup_vault, backup_vault_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_backup_vault.CreateBackupVaultRequest): - request = gcn_backup_vault.CreateBackupVaultRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if backup_vault is not None: - request.backup_vault = backup_vault - if backup_vault_id is not None: - request.backup_vault_id = backup_vault_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_backup_vault] - - # 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, - gcn_backup_vault.BackupVault, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def get_backup_vault(self, - request: Optional[Union[backup_vault.GetBackupVaultRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> backup_vault.BackupVault: - r"""Returns the description of the specified backup vault - - .. 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 netapp_v1 - - async def sample_get_backup_vault(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.GetBackupVaultRequest( - name="name_value", - ) - - # Make the request - response = await client.get_backup_vault(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.GetBackupVaultRequest, dict]]): - The request object. GetBackupVaultRequest gets the state - of a backupVault. - name (:class:`str`): - Required. The backupVault resource name, in the format - ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}`` - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.BackupVault: - A NetApp BackupVault. - """ - # 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, backup_vault.GetBackupVaultRequest): - request = backup_vault.GetBackupVaultRequest(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_backup_vault] - - # 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_backup_vaults(self, - request: Optional[Union[backup_vault.ListBackupVaultsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListBackupVaultsAsyncPager: - r"""Returns list of all available backup vaults. - - .. 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 netapp_v1 - - async def sample_list_backup_vaults(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ListBackupVaultsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_backup_vaults(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.ListBackupVaultsRequest, dict]]): - The request object. ListBackupVaultsRequest lists - backupVaults. - parent (:class:`str`): - Required. The location for which to retrieve backupVault - information, in the format - ``projects/{project_id}/locations/{location}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.services.net_app.pagers.ListBackupVaultsAsyncPager: - ListBackupVaultsResponse is the - result of ListBackupVaultsRequest. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, backup_vault.ListBackupVaultsRequest): - request = backup_vault.ListBackupVaultsRequest(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_backup_vaults] - - # 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.ListBackupVaultsAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_backup_vault(self, - request: Optional[Union[gcn_backup_vault.UpdateBackupVaultRequest, dict]] = None, - *, - backup_vault: Optional[gcn_backup_vault.BackupVault] = 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, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates the settings of a specific backup vault. - - .. 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 netapp_v1 - - async def sample_update_backup_vault(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.UpdateBackupVaultRequest( - ) - - # Make the request - operation = client.update_backup_vault(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.UpdateBackupVaultRequest, dict]]): - The request object. UpdateBackupVaultRequest updates - description and/or labels for a - backupVault. - backup_vault (:class:`google.cloud.netapp_v1.types.BackupVault`): - Required. The backupVault being - updated - - This corresponds to the ``backup_vault`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. Field mask is used to specify the fields to be - overwritten in the Backup resource to be updated. The - fields specified in the update_mask are relative to the - resource, not the full request. A field will be - overwritten if it is in the mask. If the user does not - provide a mask then all fields will be overwritten. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.BackupVault` A - NetApp BackupVault. - - """ - # 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. - flattened_params = [backup_vault, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_backup_vault.UpdateBackupVaultRequest): - request = gcn_backup_vault.UpdateBackupVaultRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if backup_vault is not None: - request.backup_vault = backup_vault - 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_backup_vault] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("backup_vault.name", request.backup_vault.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, - gcn_backup_vault.BackupVault, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_backup_vault(self, - request: Optional[Union[backup_vault.DeleteBackupVaultRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Warning! This operation will permanently delete the - backup vault. - - .. 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 netapp_v1 - - async def sample_delete_backup_vault(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteBackupVaultRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_backup_vault(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.DeleteBackupVaultRequest, dict]]): - The request object. DeleteBackupVaultRequest deletes a - backupVault. - name (:class:`str`): - Required. The backupVault resource name, in the format - ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}`` - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, backup_vault.DeleteBackupVaultRequest): - request = backup_vault.DeleteBackupVaultRequest(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_backup_vault] - - # 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=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def create_backup(self, - request: Optional[Union[gcn_backup.CreateBackupRequest, dict]] = None, - *, - parent: Optional[str] = None, - backup: Optional[gcn_backup.Backup] = None, - backup_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Creates a backup from the volume specified in the - request The backup can be created from the given - snapshot if specified in the request. If no snapshot - specified, there'll be a new snapshot taken to initiate - the backup creation. - - .. 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 netapp_v1 - - async def sample_create_backup(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.CreateBackupRequest( - parent="parent_value", - backup_id="backup_id_value", - ) - - # Make the request - operation = client.create_backup(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.CreateBackupRequest, dict]]): - The request object. CreateBackupRequest creates a backup. - parent (:class:`str`): - Required. The NetApp backupVault to create the backups - of, in the format - ``projects/*/locations/*/backupVaults/{backup_vault_id}`` - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - backup (:class:`google.cloud.netapp_v1.types.Backup`): - Required. A backup resource - This corresponds to the ``backup`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - backup_id (:class:`str`): - Required. The ID to use for the - backup. The ID must be unique within the - specified backupVault. Must contain only - letters, numbers and hyphen, with the - first character a letter, the last a - letter or a number, and a 63 character - maximum. - - This corresponds to the ``backup_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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.Backup` A NetApp - Backup. - - """ - # 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. - flattened_params = [parent, backup, backup_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_backup.CreateBackupRequest): - request = gcn_backup.CreateBackupRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if backup is not None: - request.backup = backup - if backup_id is not None: - request.backup_id = backup_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_backup] - - # 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, - gcn_backup.Backup, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def get_backup(self, - request: Optional[Union[backup.GetBackupRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> backup.Backup: - r"""Returns the description of the specified backup - - .. 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 netapp_v1 - - async def sample_get_backup(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.GetBackupRequest( - name="name_value", - ) - - # Make the request - response = await client.get_backup(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.GetBackupRequest, dict]]): - The request object. GetBackupRequest gets the state of a - backup. - name (:class:`str`): - Required. The backup resource name, in the format - ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id}`` - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.Backup: - A NetApp Backup. - """ - # 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, backup.GetBackupRequest): - request = backup.GetBackupRequest(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_backup] - - # 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_backups(self, - request: Optional[Union[backup.ListBackupsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListBackupsAsyncPager: - r"""Returns descriptions of all backups for a - backupVault. - - .. 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 netapp_v1 - - async def sample_list_backups(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ListBackupsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_backups(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.ListBackupsRequest, dict]]): - The request object. ListBackupsRequest lists backups. - parent (:class:`str`): - Required. The backupVault for which to retrieve backup - information, in the format - ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}``. - To retrieve backup information for all locations, use - "-" for the ``{location}`` value. To retrieve backup - information for all backupVaults, use "-" for the - ``{backup_vault_id}`` value. To retrieve backup - information for a volume, use "-" for the - ``{backup_vault_id}`` value and specify volume full name - with the filter. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.services.net_app.pagers.ListBackupsAsyncPager: - ListBackupsResponse is the result of - ListBackupsRequest. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, backup.ListBackupsRequest): - request = backup.ListBackupsRequest(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_backups] - - # 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.ListBackupsAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_backup(self, - request: Optional[Union[backup.DeleteBackupRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Warning! This operation will permanently delete the - backup. - - .. 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 netapp_v1 - - async def sample_delete_backup(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteBackupRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_backup(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.DeleteBackupRequest, dict]]): - The request object. DeleteBackupRequest deletes a backup. - name (:class:`str`): - Required. The backup resource name, in the format - ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id}`` - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, backup.DeleteBackupRequest): - request = backup.DeleteBackupRequest(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_backup] - - # 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=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_backup(self, - request: Optional[Union[gcn_backup.UpdateBackupRequest, dict]] = None, - *, - backup: Optional[gcn_backup.Backup] = 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, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Update backup with full spec. - - .. 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 netapp_v1 - - async def sample_update_backup(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.UpdateBackupRequest( - ) - - # Make the request - operation = client.update_backup(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.UpdateBackupRequest, dict]]): - The request object. UpdateBackupRequest updates - description and/or labels for a backup. - backup (:class:`google.cloud.netapp_v1.types.Backup`): - Required. The backup being updated - This corresponds to the ``backup`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. Field mask is used to specify the fields to be - overwritten in the Backup resource to be updated. The - fields specified in the update_mask are relative to the - resource, not the full request. A field will be - overwritten if it is in the mask. If the user does not - provide a mask then all fields will be overwritten. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.Backup` A NetApp - Backup. - - """ - # 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. - flattened_params = [backup, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_backup.UpdateBackupRequest): - request = gcn_backup.UpdateBackupRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if backup is not None: - request.backup = backup - 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_backup] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("backup.name", request.backup.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, - gcn_backup.Backup, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def create_backup_policy(self, - request: Optional[Union[gcn_backup_policy.CreateBackupPolicyRequest, dict]] = None, - *, - parent: Optional[str] = None, - backup_policy: Optional[gcn_backup_policy.BackupPolicy] = None, - backup_policy_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Creates new backup policy - - .. 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 netapp_v1 - - async def sample_create_backup_policy(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.CreateBackupPolicyRequest( - parent="parent_value", - backup_policy_id="backup_policy_id_value", - ) - - # Make the request - operation = client.create_backup_policy(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.CreateBackupPolicyRequest, dict]]): - The request object. CreateBackupPolicyRequest creates a - backupPolicy. - parent (:class:`str`): - Required. The location to create the backup policies of, - in the format - ``projects/{project_id}/locations/{location}`` - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - backup_policy (:class:`google.cloud.netapp_v1.types.BackupPolicy`): - Required. A backupPolicy resource - This corresponds to the ``backup_policy`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - backup_policy_id (:class:`str`): - Required. The ID to use for the - backup policy. The ID must be unique - within the specified location. Must - contain only letters, numbers and - hyphen, with the first character a - letter, the last a letter or a number, - and a 63 character maximum. - - This corresponds to the ``backup_policy_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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.BackupPolicy` - Backup Policy. - - """ - # 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. - flattened_params = [parent, backup_policy, backup_policy_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_backup_policy.CreateBackupPolicyRequest): - request = gcn_backup_policy.CreateBackupPolicyRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if backup_policy is not None: - request.backup_policy = backup_policy - if backup_policy_id is not None: - request.backup_policy_id = backup_policy_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_backup_policy] - - # 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, - gcn_backup_policy.BackupPolicy, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def get_backup_policy(self, - request: Optional[Union[backup_policy.GetBackupPolicyRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> backup_policy.BackupPolicy: - r"""Returns the description of the specified backup policy by - backup_policy_id. - - .. 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 netapp_v1 - - async def sample_get_backup_policy(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.GetBackupPolicyRequest( - name="name_value", - ) - - # Make the request - response = await client.get_backup_policy(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.GetBackupPolicyRequest, dict]]): - The request object. GetBackupPolicyRequest gets the state - of a backupPolicy. - name (:class:`str`): - Required. The backupPolicy resource name, in the format - ``projects/{project_id}/locations/{location}/backupPolicies/{backup_policy_id}`` - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.BackupPolicy: - Backup Policy. - """ - # 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, backup_policy.GetBackupPolicyRequest): - request = backup_policy.GetBackupPolicyRequest(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_backup_policy] - - # 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_backup_policies(self, - request: Optional[Union[backup_policy.ListBackupPoliciesRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListBackupPoliciesAsyncPager: - r"""Returns list of all available backup policies. - - .. 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 netapp_v1 - - async def sample_list_backup_policies(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ListBackupPoliciesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_backup_policies(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.ListBackupPoliciesRequest, dict]]): - The request object. ListBackupPoliciesRequest for - requesting multiple backup policies. - parent (:class:`str`): - Required. Parent value for - ListBackupPoliciesRequest - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.services.net_app.pagers.ListBackupPoliciesAsyncPager: - ListBackupPoliciesResponse contains - all the backup policies requested. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, backup_policy.ListBackupPoliciesRequest): - request = backup_policy.ListBackupPoliciesRequest(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_backup_policies] - - # 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.ListBackupPoliciesAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_backup_policy(self, - request: Optional[Union[gcn_backup_policy.UpdateBackupPolicyRequest, dict]] = None, - *, - backup_policy: Optional[gcn_backup_policy.BackupPolicy] = 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, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates settings of a specific backup policy. - - .. 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 netapp_v1 - - async def sample_update_backup_policy(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.UpdateBackupPolicyRequest( - ) - - # Make the request - operation = client.update_backup_policy(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.UpdateBackupPolicyRequest, dict]]): - The request object. UpdateBackupPolicyRequest for - updating a backup policy. - backup_policy (:class:`google.cloud.netapp_v1.types.BackupPolicy`): - Required. The backup policy being - updated - - This corresponds to the ``backup_policy`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. Field mask is used to specify the fields to be - overwritten in the Backup Policy resource by the update. - The fields specified in the update_mask are relative to - the resource, not the full request. A field will be - overwritten if it is in the mask. If the user does not - provide a mask then all fields will be overwritten. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.BackupPolicy` - Backup Policy. - - """ - # 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. - flattened_params = [backup_policy, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_backup_policy.UpdateBackupPolicyRequest): - request = gcn_backup_policy.UpdateBackupPolicyRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if backup_policy is not None: - request.backup_policy = backup_policy - 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_backup_policy] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("backup_policy.name", request.backup_policy.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, - gcn_backup_policy.BackupPolicy, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_backup_policy(self, - request: Optional[Union[backup_policy.DeleteBackupPolicyRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Warning! This operation will permanently delete the - backup policy. - - .. 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 netapp_v1 - - async def sample_delete_backup_policy(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteBackupPolicyRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_backup_policy(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.DeleteBackupPolicyRequest, dict]]): - The request object. DeleteBackupPolicyRequest deletes a - backup policy. - name (:class:`str`): - Required. The backup policy resource name, in the format - ``projects/{project_id}/locations/{location}/backupPolicies/{backup_policy_id}`` - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, backup_policy.DeleteBackupPolicyRequest): - request = backup_policy.DeleteBackupPolicyRequest(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_backup_policy] - - # 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=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_quota_rules(self, - request: Optional[Union[quota_rule.ListQuotaRulesRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListQuotaRulesAsyncPager: - r"""Returns list of all quota rules in a location. - - .. 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 netapp_v1 - - async def sample_list_quota_rules(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ListQuotaRulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_quota_rules(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.ListQuotaRulesRequest, dict]]): - The request object. ListQuotaRulesRequest for listing - quota rules. - parent (:class:`str`): - Required. Parent value for - ListQuotaRulesRequest - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.services.net_app.pagers.ListQuotaRulesAsyncPager: - ListQuotaRulesResponse is the - response to a ListQuotaRulesRequest. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, quota_rule.ListQuotaRulesRequest): - request = quota_rule.ListQuotaRulesRequest(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_quota_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.ListQuotaRulesAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_quota_rule(self, - request: Optional[Union[quota_rule.GetQuotaRuleRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> quota_rule.QuotaRule: - r"""Returns details of the specified quota 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 netapp_v1 - - async def sample_get_quota_rule(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.GetQuotaRuleRequest( - name="name_value", - ) - - # Make the request - response = await client.get_quota_rule(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.GetQuotaRuleRequest, dict]]): - The request object. GetQuotaRuleRequest for getting a - quota rule. - name (:class:`str`): - Required. Name of the quota rule - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.QuotaRule: - QuotaRule specifies the maximum disk - space a user or group can use within a - volume. They can be used for creating - default and individual quota rules. - - """ - # 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, quota_rule.GetQuotaRuleRequest): - request = quota_rule.GetQuotaRuleRequest(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_quota_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 create_quota_rule(self, - request: Optional[Union[gcn_quota_rule.CreateQuotaRuleRequest, dict]] = None, - *, - parent: Optional[str] = None, - quota_rule: Optional[gcn_quota_rule.QuotaRule] = None, - quota_rule_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Creates a new quota 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 netapp_v1 - - async def sample_create_quota_rule(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - quota_rule = netapp_v1.QuotaRule() - quota_rule.type_ = "DEFAULT_GROUP_QUOTA" - quota_rule.disk_limit_mib = 1472 - - request = netapp_v1.CreateQuotaRuleRequest( - parent="parent_value", - quota_rule=quota_rule, - quota_rule_id="quota_rule_id_value", - ) - - # Make the request - operation = client.create_quota_rule(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.CreateQuotaRuleRequest, dict]]): - The request object. CreateQuotaRuleRequest for creating a - quota rule. - parent (:class:`str`): - Required. Parent value for - CreateQuotaRuleRequest - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - quota_rule (:class:`google.cloud.netapp_v1.types.QuotaRule`): - Required. Fields of the to be created - quota rule. - - This corresponds to the ``quota_rule`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - quota_rule_id (:class:`str`): - Required. ID of the quota rule to - create. Must be unique within the parent - resource. Must contain only letters, - numbers, underscore and hyphen, with the - first character a letter or underscore, - the last a letter or underscore or a - number, and a 63 character maximum. - - This corresponds to the ``quota_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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.QuotaRule` QuotaRule specifies the maximum disk space a user or group can use within a - volume. They can be used for creating default and - individual quota rules. - - """ - # 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. - flattened_params = [parent, quota_rule, quota_rule_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_quota_rule.CreateQuotaRuleRequest): - request = gcn_quota_rule.CreateQuotaRuleRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if quota_rule is not None: - request.quota_rule = quota_rule - if quota_rule_id is not None: - request.quota_rule_id = quota_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_quota_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, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - gcn_quota_rule.QuotaRule, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_quota_rule(self, - request: Optional[Union[gcn_quota_rule.UpdateQuotaRuleRequest, dict]] = None, - *, - quota_rule: Optional[gcn_quota_rule.QuotaRule] = 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, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates a quota 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 netapp_v1 - - async def sample_update_quota_rule(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - quota_rule = netapp_v1.QuotaRule() - quota_rule.type_ = "DEFAULT_GROUP_QUOTA" - quota_rule.disk_limit_mib = 1472 - - request = netapp_v1.UpdateQuotaRuleRequest( - quota_rule=quota_rule, - ) - - # Make the request - operation = client.update_quota_rule(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.UpdateQuotaRuleRequest, dict]]): - The request object. UpdateQuotaRuleRequest for updating a - quota rule. - quota_rule (:class:`google.cloud.netapp_v1.types.QuotaRule`): - Required. The quota rule being - updated - - This corresponds to the ``quota_rule`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Optional. Field mask is used to specify the fields to be - overwritten in the Quota Rule resource by the update. - The fields specified in the update_mask are relative to - the resource, not the full request. A field will be - overwritten if it is in the mask. If the user does not - provide a mask then all fields will be overwritten. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.netapp_v1.types.QuotaRule` QuotaRule specifies the maximum disk space a user or group can use within a - volume. They can be used for creating default and - individual quota rules. - - """ - # 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. - flattened_params = [quota_rule, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_quota_rule.UpdateQuotaRuleRequest): - request = gcn_quota_rule.UpdateQuotaRuleRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if quota_rule is not None: - request.quota_rule = quota_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_quota_rule] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("quota_rule.name", request.quota_rule.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, - gcn_quota_rule.QuotaRule, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_quota_rule(self, - request: Optional[Union[quota_rule.DeleteQuotaRuleRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes a quota 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 netapp_v1 - - async def sample_delete_quota_rule(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteQuotaRuleRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_quota_rule(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.netapp_v1.types.DeleteQuotaRuleRequest, dict]]): - The request object. DeleteQuotaRuleRequest for deleting a - single quota rule. - name (:class:`str`): - Required. Name of the quota rule. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, quota_rule.DeleteQuotaRuleRequest): - request = quota_rule.DeleteQuotaRuleRequest(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_quota_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, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_operations( - self, - request: Optional[operations_pb2.ListOperationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operations_pb2.ListOperationsResponse: - r"""Lists operations that match the specified filter in the request. - - Args: - request (:class:`~.operations_pb2.ListOperationsRequest`): - The request object. Request message for - `ListOperations` 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - Returns: - ~.operations_pb2.ListOperationsResponse: - Response message for ``ListOperations`` 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 = operations_pb2.ListOperationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self.transport._wrapped_methods[self._client._transport.list_operations] - - # 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_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, Union[str, bytes]]] = (), - ) -> 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - 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 delete_operation( - self, - request: Optional[operations_pb2.DeleteOperationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> None: - r"""Deletes a long-running operation. - - This method indicates that the client is no longer interested - in the operation result. It does not cancel the operation. - If the server doesn't support this method, it returns - `google.rpc.Code.UNIMPLEMENTED`. - - Args: - request (:class:`~.operations_pb2.DeleteOperationRequest`): - The request object. Request message for - `DeleteOperation` 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - Returns: - None - """ - # 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.DeleteOperationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self.transport._wrapped_methods[self._client._transport.delete_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. - await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - async def cancel_operation( - self, - request: Optional[operations_pb2.CancelOperationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> None: - r"""Starts asynchronous cancellation on a long-running operation. - - The server makes a best effort to cancel the operation, but success - is not guaranteed. If the server doesn't support this method, it returns - `google.rpc.Code.UNIMPLEMENTED`. - - Args: - request (:class:`~.operations_pb2.CancelOperationRequest`): - The request object. Request message for - `CancelOperation` 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - Returns: - None - """ - # 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.CancelOperationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self.transport._wrapped_methods[self._client._transport.cancel_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. - await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - 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, Union[str, bytes]]] = (), - ) -> 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - 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, Union[str, bytes]]] = (), - ) -> 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - 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) -> "NetAppAsyncClient": - 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__ = ( - "NetAppAsyncClient", -) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/client.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/client.py deleted file mode 100644 index 22fe61682ad4..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/client.py +++ /dev/null @@ -1,8448 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 http import HTTPStatus -import json -import logging as std_logging -import os -import re -from typing import Dict, Callable, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union, cast -import warnings - -from google.cloud.netapp_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 - -try: - from google.api_core import client_logging # type: ignore - CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER -except ImportError: # pragma: NO COVER - CLIENT_LOGGING_SUPPORTED = False - -_LOGGER = std_logging.getLogger(__name__) - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.location import locations_pb2 # type: ignore -from google.cloud.netapp_v1.services.net_app import pagers -from google.cloud.netapp_v1.types import active_directory -from google.cloud.netapp_v1.types import active_directory as gcn_active_directory -from google.cloud.netapp_v1.types import backup -from google.cloud.netapp_v1.types import backup as gcn_backup -from google.cloud.netapp_v1.types import backup_policy -from google.cloud.netapp_v1.types import backup_policy as gcn_backup_policy -from google.cloud.netapp_v1.types import backup_vault -from google.cloud.netapp_v1.types import backup_vault as gcn_backup_vault -from google.cloud.netapp_v1.types import cloud_netapp_service -from google.cloud.netapp_v1.types import common -from google.cloud.netapp_v1.types import kms -from google.cloud.netapp_v1.types import quota_rule -from google.cloud.netapp_v1.types import quota_rule as gcn_quota_rule -from google.cloud.netapp_v1.types import replication -from google.cloud.netapp_v1.types import replication as gcn_replication -from google.cloud.netapp_v1.types import snapshot -from google.cloud.netapp_v1.types import snapshot as gcn_snapshot -from google.cloud.netapp_v1.types import storage_pool -from google.cloud.netapp_v1.types import storage_pool as gcn_storage_pool -from google.cloud.netapp_v1.types import volume -from google.cloud.netapp_v1.types import volume as gcn_volume -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 timestamp_pb2 # type: ignore -from .transports.base import NetAppTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import NetAppGrpcTransport -from .transports.grpc_asyncio import NetAppGrpcAsyncIOTransport -from .transports.rest import NetAppRestTransport - - -class NetAppClientMeta(type): - """Metaclass for the NetApp 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[NetAppTransport]] - _transport_registry["grpc"] = NetAppGrpcTransport - _transport_registry["grpc_asyncio"] = NetAppGrpcAsyncIOTransport - _transport_registry["rest"] = NetAppRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[NetAppTransport]: - """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 NetAppClient(metaclass=NetAppClientMeta): - """NetApp Files Google Cloud Service""" - - @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 = "netapp.googleapis.com" - DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore - DEFAULT_ENDPOINT - ) - - _DEFAULT_ENDPOINT_TEMPLATE = "netapp.{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: - NetAppClient: 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: - NetAppClient: 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) -> NetAppTransport: - """Returns the transport used by the client instance. - - Returns: - NetAppTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def active_directory_path(project: str,location: str,active_directory: str,) -> str: - """Returns a fully-qualified active_directory string.""" - return "projects/{project}/locations/{location}/activeDirectories/{active_directory}".format(project=project, location=location, active_directory=active_directory, ) - - @staticmethod - def parse_active_directory_path(path: str) -> Dict[str,str]: - """Parses a active_directory path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/activeDirectories/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def backup_path(project: str,location: str,backup_vault: str,backup: str,) -> str: - """Returns a fully-qualified backup string.""" - return "projects/{project}/locations/{location}/backupVaults/{backup_vault}/backups/{backup}".format(project=project, location=location, backup_vault=backup_vault, backup=backup, ) - - @staticmethod - def parse_backup_path(path: str) -> Dict[str,str]: - """Parses a backup path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/backupVaults/(?P.+?)/backups/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def backup_policy_path(project: str,location: str,backup_policy: str,) -> str: - """Returns a fully-qualified backup_policy string.""" - return "projects/{project}/locations/{location}/backupPolicies/{backup_policy}".format(project=project, location=location, backup_policy=backup_policy, ) - - @staticmethod - def parse_backup_policy_path(path: str) -> Dict[str,str]: - """Parses a backup_policy path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/backupPolicies/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def backup_vault_path(project: str,location: str,backup_vault: str,) -> str: - """Returns a fully-qualified backup_vault string.""" - return "projects/{project}/locations/{location}/backupVaults/{backup_vault}".format(project=project, location=location, backup_vault=backup_vault, ) - - @staticmethod - def parse_backup_vault_path(path: str) -> Dict[str,str]: - """Parses a backup_vault path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/backupVaults/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def kms_config_path(project: str,location: str,kms_config: str,) -> str: - """Returns a fully-qualified kms_config string.""" - return "projects/{project}/locations/{location}/kmsConfigs/{kms_config}".format(project=project, location=location, kms_config=kms_config, ) - - @staticmethod - def parse_kms_config_path(path: str) -> Dict[str,str]: - """Parses a kms_config path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/kmsConfigs/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def network_path(project: str,network: str,) -> str: - """Returns a fully-qualified network string.""" - return "projects/{project}/global/networks/{network}".format(project=project, network=network, ) - - @staticmethod - def parse_network_path(path: str) -> Dict[str,str]: - """Parses a network path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/global/networks/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def quota_rule_path(project: str,location: str,volume: str,quota_rule: str,) -> str: - """Returns a fully-qualified quota_rule string.""" - return "projects/{project}/locations/{location}/volumes/{volume}/quotaRules/{quota_rule}".format(project=project, location=location, volume=volume, quota_rule=quota_rule, ) - - @staticmethod - def parse_quota_rule_path(path: str) -> Dict[str,str]: - """Parses a quota_rule path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/volumes/(?P.+?)/quotaRules/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def replication_path(project: str,location: str,volume: str,replication: str,) -> str: - """Returns a fully-qualified replication string.""" - return "projects/{project}/locations/{location}/volumes/{volume}/replications/{replication}".format(project=project, location=location, volume=volume, replication=replication, ) - - @staticmethod - def parse_replication_path(path: str) -> Dict[str,str]: - """Parses a replication path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/volumes/(?P.+?)/replications/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def snapshot_path(project: str,location: str,volume: str,snapshot: str,) -> str: - """Returns a fully-qualified snapshot string.""" - return "projects/{project}/locations/{location}/volumes/{volume}/snapshots/{snapshot}".format(project=project, location=location, volume=volume, snapshot=snapshot, ) - - @staticmethod - def parse_snapshot_path(path: str) -> Dict[str,str]: - """Parses a snapshot path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/volumes/(?P.+?)/snapshots/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def storage_pool_path(project: str,location: str,storage_pool: str,) -> str: - """Returns a fully-qualified storage_pool string.""" - return "projects/{project}/locations/{location}/storagePools/{storage_pool}".format(project=project, location=location, storage_pool=storage_pool, ) - - @staticmethod - def parse_storage_pool_path(path: str) -> Dict[str,str]: - """Parses a storage_pool path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/storagePools/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def volume_path(project: str,location: str,volume: str,) -> str: - """Returns a fully-qualified volume string.""" - return "projects/{project}/locations/{location}/volumes/{volume}".format(project=project, location=location, volume=volume, ) - - @staticmethod - def parse_volume_path(path: str) -> Dict[str,str]: - """Parses a volume path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/volumes/(?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 = NetAppClient._DEFAULT_UNIVERSE - if universe_domain != _default_universe: - raise MutualTLSChannelError(f"mTLS is not supported in any universe other than {_default_universe}.") - api_endpoint = NetAppClient.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = NetAppClient._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 = NetAppClient._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 - - 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. - """ - - # NOTE (b/349488459): universe validation is disabled until further notice. - return True - - def _add_cred_info_for_auth_errors( - self, - error: core_exceptions.GoogleAPICallError - ) -> None: - """Adds credential info string to error details for 401/403/404 errors. - - Args: - error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info. - """ - if error.code not in [HTTPStatus.UNAUTHORIZED, HTTPStatus.FORBIDDEN, HTTPStatus.NOT_FOUND]: - return - - cred = self._transport._credentials - - # get_cred_info is only available in google-auth>=2.35.0 - if not hasattr(cred, "get_cred_info"): - return - - # ignore the type check since pypy test fails when get_cred_info - # is not available - cred_info = cred.get_cred_info() # type: ignore - if cred_info and hasattr(error._details, "append"): - error._details.append(json.dumps(cred_info)) - - @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, NetAppTransport, Callable[..., NetAppTransport]]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the net app 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,NetAppTransport,Callable[..., NetAppTransport]]]): - 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 NetAppTransport 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 = NetAppClient._read_environment_variables() - self._client_cert_source = NetAppClient._get_client_cert_source(self._client_options.client_cert_source, self._use_client_cert) - self._universe_domain = NetAppClient._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 - - if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER - # Setup logging. - client_logging.initialize_logging() - - 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, NetAppTransport) - if transport_provided: - # transport is a NetAppTransport 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(NetAppTransport, transport) - self._api_endpoint = self._transport.host - - self._api_endpoint = (self._api_endpoint or - NetAppClient._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[NetAppTransport], Callable[..., NetAppTransport]] = ( - NetAppClient.get_transport_class(transport) - if isinstance(transport, str) or transport is None - else cast(Callable[..., NetAppTransport], 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, - ) - - if "async" not in str(self._transport): - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG): # pragma: NO COVER - _LOGGER.debug( - "Created client `google.cloud.netapp_v1.NetAppClient`.", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "universeDomain": getattr(self._transport._credentials, "universe_domain", ""), - "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}", - "credentialsInfo": getattr(self.transport._credentials, "get_cred_info", lambda: None)(), - } if hasattr(self._transport, "_credentials") else { - "serviceName": "google.cloud.netapp.v1.NetApp", - "credentialsType": None, - } - ) - - def list_storage_pools(self, - request: Optional[Union[storage_pool.ListStoragePoolsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListStoragePoolsPager: - r"""Returns descriptions of all storage pools owned by - the caller. - - .. 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 netapp_v1 - - def sample_list_storage_pools(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ListStoragePoolsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_storage_pools(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.ListStoragePoolsRequest, dict]): - The request object. ListStoragePoolsRequest lists Storage - Pools. - parent (str): - Required. Parent value - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.services.net_app.pagers.ListStoragePoolsPager: - ListStoragePoolsResponse is the - response to a ListStoragePoolsRequest. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, storage_pool.ListStoragePoolsRequest): - request = storage_pool.ListStoragePoolsRequest(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_storage_pools] - - # 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.ListStoragePoolsPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_storage_pool(self, - request: Optional[Union[gcn_storage_pool.CreateStoragePoolRequest, dict]] = None, - *, - parent: Optional[str] = None, - storage_pool: Optional[gcn_storage_pool.StoragePool] = None, - storage_pool_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Creates a new storage pool. - - .. 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 netapp_v1 - - def sample_create_storage_pool(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - storage_pool = netapp_v1.StoragePool() - storage_pool.service_level = "FLEX" - storage_pool.capacity_gib = 1247 - storage_pool.network = "network_value" - - request = netapp_v1.CreateStoragePoolRequest( - parent="parent_value", - storage_pool_id="storage_pool_id_value", - storage_pool=storage_pool, - ) - - # Make the request - operation = client.create_storage_pool(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.CreateStoragePoolRequest, dict]): - The request object. CreateStoragePoolRequest creates a - Storage Pool. - parent (str): - Required. Value for parent. - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - storage_pool (google.cloud.netapp_v1.types.StoragePool): - Required. The required parameters to - create a new storage pool. - - This corresponds to the ``storage_pool`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - storage_pool_id (str): - Required. Id of the requesting - storage pool. Must be unique within the - parent resource. Must contain only - letters, numbers and hyphen, with the - first character a letter, the last a - letter or a number, and a 63 character - maximum. - - This corresponds to the ``storage_pool_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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.netapp_v1.types.StoragePool` StoragePool is a container for volumes with a service level and capacity. - Volumes can be created in a pool of sufficient - available capacity. StoragePool capacity is what you - are billed for. - - """ - # 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. - flattened_params = [parent, storage_pool, storage_pool_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_storage_pool.CreateStoragePoolRequest): - request = gcn_storage_pool.CreateStoragePoolRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if storage_pool is not None: - request.storage_pool = storage_pool - if storage_pool_id is not None: - request.storage_pool_id = storage_pool_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_storage_pool] - - # 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, - gcn_storage_pool.StoragePool, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def get_storage_pool(self, - request: Optional[Union[storage_pool.GetStoragePoolRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> storage_pool.StoragePool: - r"""Returns the description of the specified storage pool - by poolId. - - .. 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 netapp_v1 - - def sample_get_storage_pool(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.GetStoragePoolRequest( - name="name_value", - ) - - # Make the request - response = client.get_storage_pool(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.GetStoragePoolRequest, dict]): - The request object. GetStoragePoolRequest gets a Storage - Pool. - name (str): - Required. Name of the storage pool - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.StoragePool: - StoragePool is a container for - volumes with a service level and - capacity. Volumes can be created in a - pool of sufficient available capacity. - StoragePool capacity is what you are - billed for. - - """ - # 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, storage_pool.GetStoragePoolRequest): - request = storage_pool.GetStoragePoolRequest(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_storage_pool] - - # 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_storage_pool(self, - request: Optional[Union[gcn_storage_pool.UpdateStoragePoolRequest, dict]] = None, - *, - storage_pool: Optional[gcn_storage_pool.StoragePool] = 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, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Updates the storage pool properties with the full - spec - - .. 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 netapp_v1 - - def sample_update_storage_pool(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - storage_pool = netapp_v1.StoragePool() - storage_pool.service_level = "FLEX" - storage_pool.capacity_gib = 1247 - storage_pool.network = "network_value" - - request = netapp_v1.UpdateStoragePoolRequest( - storage_pool=storage_pool, - ) - - # Make the request - operation = client.update_storage_pool(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.UpdateStoragePoolRequest, dict]): - The request object. UpdateStoragePoolRequest updates a - Storage Pool. - storage_pool (google.cloud.netapp_v1.types.StoragePool): - Required. The pool being updated - This corresponds to the ``storage_pool`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the StoragePool resource by the update. - The fields specified in the update_mask are relative to - the resource, not the full request. A field will be - overwritten if it is in the mask. If the user does not - provide a mask then all fields will be overwritten. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.netapp_v1.types.StoragePool` StoragePool is a container for volumes with a service level and capacity. - Volumes can be created in a pool of sufficient - available capacity. StoragePool capacity is what you - are billed for. - - """ - # 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. - flattened_params = [storage_pool, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_storage_pool.UpdateStoragePoolRequest): - request = gcn_storage_pool.UpdateStoragePoolRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if storage_pool is not None: - request.storage_pool = storage_pool - 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_storage_pool] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("storage_pool.name", request.storage_pool.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, - gcn_storage_pool.StoragePool, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_storage_pool(self, - request: Optional[Union[storage_pool.DeleteStoragePoolRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Warning! This operation will permanently delete the - storage pool. - - .. 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 netapp_v1 - - def sample_delete_storage_pool(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteStoragePoolRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_storage_pool(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.DeleteStoragePoolRequest, dict]): - The request object. DeleteStoragePoolRequest deletes a - Storage Pool. - name (str): - Required. Name of the storage pool - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, storage_pool.DeleteStoragePoolRequest): - request = storage_pool.DeleteStoragePoolRequest(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_storage_pool] - - # 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=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def validate_directory_service(self, - request: Optional[Union[storage_pool.ValidateDirectoryServiceRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""ValidateDirectoryService does a connectivity check - for a directory service policy attached to the storage - pool. - - .. 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 netapp_v1 - - def sample_validate_directory_service(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ValidateDirectoryServiceRequest( - name="name_value", - ) - - # Make the request - operation = client.validate_directory_service(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.ValidateDirectoryServiceRequest, dict]): - The request object. ValidateDirectoryServiceRequest - validates the directory service policy - attached to the storage pool. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - # - 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, storage_pool.ValidateDirectoryServiceRequest): - request = storage_pool.ValidateDirectoryServiceRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.validate_directory_service] - - # 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=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def switch_active_replica_zone(self, - request: Optional[Union[storage_pool.SwitchActiveReplicaZoneRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""This operation will switch the active/replica zone - for a regional storagePool. - - .. 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 netapp_v1 - - def sample_switch_active_replica_zone(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.SwitchActiveReplicaZoneRequest( - name="name_value", - ) - - # Make the request - operation = client.switch_active_replica_zone(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.SwitchActiveReplicaZoneRequest, dict]): - The request object. SwitchActiveReplicaZoneRequest switch - the active/replica zone for a regional - storagePool. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.netapp_v1.types.StoragePool` StoragePool is a container for volumes with a service level and capacity. - Volumes can be created in a pool of sufficient - available capacity. StoragePool capacity is what you - are billed for. - - """ - # 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, storage_pool.SwitchActiveReplicaZoneRequest): - request = storage_pool.SwitchActiveReplicaZoneRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.switch_active_replica_zone] - - # 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, - storage_pool.StoragePool, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def list_volumes(self, - request: Optional[Union[volume.ListVolumesRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListVolumesPager: - r"""Lists Volumes in a given 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 netapp_v1 - - def sample_list_volumes(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ListVolumesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_volumes(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.ListVolumesRequest, dict]): - The request object. Message for requesting list of - Volumes - parent (str): - Required. Parent value for - ListVolumesRequest - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.services.net_app.pagers.ListVolumesPager: - Message for response to listing - Volumes - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, volume.ListVolumesRequest): - request = volume.ListVolumesRequest(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_volumes] - - # 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.ListVolumesPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_volume(self, - request: Optional[Union[volume.GetVolumeRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> volume.Volume: - r"""Gets details of a single Volume. - - .. 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 netapp_v1 - - def sample_get_volume(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.GetVolumeRequest( - name="name_value", - ) - - # Make the request - response = client.get_volume(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.GetVolumeRequest, dict]): - The request object. Message for getting a Volume - name (str): - Required. Name of the volume - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.Volume: - Volume provides a filesystem that you - can mount. - - """ - # 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, volume.GetVolumeRequest): - request = volume.GetVolumeRequest(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_volume] - - # 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_volume(self, - request: Optional[Union[gcn_volume.CreateVolumeRequest, dict]] = None, - *, - parent: Optional[str] = None, - volume: Optional[gcn_volume.Volume] = None, - volume_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Creates a new Volume in a given project and location. - - .. 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 netapp_v1 - - def sample_create_volume(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - volume = netapp_v1.Volume() - volume.share_name = "share_name_value" - volume.storage_pool = "storage_pool_value" - volume.capacity_gib = 1247 - volume.protocols = ['SMB'] - - request = netapp_v1.CreateVolumeRequest( - parent="parent_value", - volume_id="volume_id_value", - volume=volume, - ) - - # Make the request - operation = client.create_volume(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.CreateVolumeRequest, dict]): - The request object. Message for creating a Volume - parent (str): - Required. Value for parent. - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - volume (google.cloud.netapp_v1.types.Volume): - Required. The volume being created. - This corresponds to the ``volume`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - volume_id (str): - Required. Id of the requesting - volume. Must be unique within the parent - resource. Must contain only letters, - numbers and hyphen, with the first - character a letter, the last a letter or - a number, and a 63 character maximum. - - This corresponds to the ``volume_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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.netapp_v1.types.Volume` Volume - provides a filesystem that you can mount. - - """ - # 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. - flattened_params = [parent, volume, volume_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_volume.CreateVolumeRequest): - request = gcn_volume.CreateVolumeRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if volume is not None: - request.volume = volume - if volume_id is not None: - request.volume_id = volume_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_volume] - - # 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, - gcn_volume.Volume, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_volume(self, - request: Optional[Union[gcn_volume.UpdateVolumeRequest, dict]] = None, - *, - volume: Optional[gcn_volume.Volume] = 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, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Updates the parameters of a single Volume. - - .. 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 netapp_v1 - - def sample_update_volume(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - volume = netapp_v1.Volume() - volume.share_name = "share_name_value" - volume.storage_pool = "storage_pool_value" - volume.capacity_gib = 1247 - volume.protocols = ['SMB'] - - request = netapp_v1.UpdateVolumeRequest( - volume=volume, - ) - - # Make the request - operation = client.update_volume(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.UpdateVolumeRequest, dict]): - The request object. Message for updating a Volume - volume (google.cloud.netapp_v1.types.Volume): - Required. The volume being updated - This corresponds to the ``volume`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the Volume resource by the update. The - fields specified in the update_mask are relative to the - resource, not the full request. A field will be - overwritten if it is in the mask. If the user does not - provide a mask then all fields will be overwritten. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.netapp_v1.types.Volume` Volume - provides a filesystem that you can mount. - - """ - # 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. - flattened_params = [volume, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_volume.UpdateVolumeRequest): - request = gcn_volume.UpdateVolumeRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if volume is not None: - request.volume = volume - 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_volume] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("volume.name", request.volume.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, - gcn_volume.Volume, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_volume(self, - request: Optional[Union[volume.DeleteVolumeRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Deletes a single Volume. - - .. 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 netapp_v1 - - def sample_delete_volume(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteVolumeRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_volume(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.DeleteVolumeRequest, dict]): - The request object. Message for deleting a Volume - name (str): - Required. Name of the volume - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, volume.DeleteVolumeRequest): - request = volume.DeleteVolumeRequest(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_volume] - - # 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=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def revert_volume(self, - request: Optional[Union[volume.RevertVolumeRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Revert an existing volume to a specified snapshot. - Warning! This operation will permanently revert all - changes made after the snapshot was created. - - .. 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 netapp_v1 - - def sample_revert_volume(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.RevertVolumeRequest( - name="name_value", - snapshot_id="snapshot_id_value", - ) - - # Make the request - operation = client.revert_volume(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.RevertVolumeRequest, dict]): - The request object. RevertVolumeRequest reverts the given - volume to the specified snapshot. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.netapp_v1.types.Volume` Volume - provides a filesystem that you can mount. - - """ - # 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, volume.RevertVolumeRequest): - request = volume.RevertVolumeRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.revert_volume] - - # 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, - volume.Volume, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def list_snapshots(self, - request: Optional[Union[snapshot.ListSnapshotsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListSnapshotsPager: - r"""Returns descriptions of all snapshots for a volume. - - .. 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 netapp_v1 - - def sample_list_snapshots(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ListSnapshotsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_snapshots(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.ListSnapshotsRequest, dict]): - The request object. ListSnapshotsRequest lists snapshots. - parent (str): - Required. The volume for which to retrieve snapshot - information, in the format - ``projects/{project_id}/locations/{location}/volumes/{volume_id}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.services.net_app.pagers.ListSnapshotsPager: - ListSnapshotsResponse is the result - of ListSnapshotsRequest. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, snapshot.ListSnapshotsRequest): - request = snapshot.ListSnapshotsRequest(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_snapshots] - - # 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.ListSnapshotsPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_snapshot(self, - request: Optional[Union[snapshot.GetSnapshotRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> snapshot.Snapshot: - r"""Describe a snapshot for a volume. - - .. 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 netapp_v1 - - def sample_get_snapshot(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.GetSnapshotRequest( - name="name_value", - ) - - # Make the request - response = client.get_snapshot(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.GetSnapshotRequest, dict]): - The request object. GetSnapshotRequest gets the state of - a snapshot. - name (str): - Required. The snapshot resource name, in the format - ``projects/{project_id}/locations/{location}/volumes/{volume_id}/snapshots/{snapshot_id}`` - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.Snapshot: - Snapshot is a point-in-time version - of a Volume's content. - - """ - # 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, snapshot.GetSnapshotRequest): - request = snapshot.GetSnapshotRequest(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_snapshot] - - # 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_snapshot(self, - request: Optional[Union[gcn_snapshot.CreateSnapshotRequest, dict]] = None, - *, - parent: Optional[str] = None, - snapshot: Optional[gcn_snapshot.Snapshot] = None, - snapshot_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Create a new snapshot for a volume. - - .. 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 netapp_v1 - - def sample_create_snapshot(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.CreateSnapshotRequest( - parent="parent_value", - snapshot_id="snapshot_id_value", - ) - - # Make the request - operation = client.create_snapshot(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.CreateSnapshotRequest, dict]): - The request object. CreateSnapshotRequest creates a - snapshot. - parent (str): - Required. The NetApp volume to create the snapshots of, - in the format - ``projects/{project_id}/locations/{location}/volumes/{volume_id}`` - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - snapshot (google.cloud.netapp_v1.types.Snapshot): - Required. A snapshot resource - This corresponds to the ``snapshot`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - snapshot_id (str): - Required. ID of the snapshot to - create. Must be unique within the parent - resource. Must contain only letters, - numbers and hyphen, with the first - character a letter, the last a letter or - a number, and a 63 character maximum. - - This corresponds to the ``snapshot_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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.netapp_v1.types.Snapshot` Snapshot - is a point-in-time version of a Volume's content. - - """ - # 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. - flattened_params = [parent, snapshot, snapshot_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_snapshot.CreateSnapshotRequest): - request = gcn_snapshot.CreateSnapshotRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if snapshot is not None: - request.snapshot = snapshot - if snapshot_id is not None: - request.snapshot_id = snapshot_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_snapshot] - - # 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, - gcn_snapshot.Snapshot, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_snapshot(self, - request: Optional[Union[snapshot.DeleteSnapshotRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Deletes a snapshot. - - .. 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 netapp_v1 - - def sample_delete_snapshot(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteSnapshotRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_snapshot(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.DeleteSnapshotRequest, dict]): - The request object. DeleteSnapshotRequest deletes a - snapshot. - name (str): - Required. The snapshot resource name, in the format - ``projects/*/locations/*/volumes/*/snapshots/{snapshot_id}`` - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, snapshot.DeleteSnapshotRequest): - request = snapshot.DeleteSnapshotRequest(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_snapshot] - - # 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=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_snapshot(self, - request: Optional[Union[gcn_snapshot.UpdateSnapshotRequest, dict]] = None, - *, - snapshot: Optional[gcn_snapshot.Snapshot] = 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, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Updates the settings of a specific snapshot. - - .. 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 netapp_v1 - - def sample_update_snapshot(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.UpdateSnapshotRequest( - ) - - # Make the request - operation = client.update_snapshot(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.UpdateSnapshotRequest, dict]): - The request object. UpdateSnapshotRequest updates - description and/or labels for a - snapshot. - snapshot (google.cloud.netapp_v1.types.Snapshot): - Required. A snapshot resource - This corresponds to the ``snapshot`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Mask of fields to update. - At least one path must be supplied in - this field. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.netapp_v1.types.Snapshot` Snapshot - is a point-in-time version of a Volume's content. - - """ - # 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. - flattened_params = [snapshot, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_snapshot.UpdateSnapshotRequest): - request = gcn_snapshot.UpdateSnapshotRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if snapshot is not None: - request.snapshot = snapshot - 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_snapshot] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("snapshot.name", request.snapshot.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, - gcn_snapshot.Snapshot, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def list_active_directories(self, - request: Optional[Union[active_directory.ListActiveDirectoriesRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListActiveDirectoriesPager: - r"""Lists active directories. - - .. 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 netapp_v1 - - def sample_list_active_directories(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ListActiveDirectoriesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_active_directories(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.ListActiveDirectoriesRequest, dict]): - The request object. ListActiveDirectoriesRequest for - requesting multiple active directories. - parent (str): - Required. Parent value for - ListActiveDirectoriesRequest - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.services.net_app.pagers.ListActiveDirectoriesPager: - ListActiveDirectoriesResponse - contains all the active directories - requested. 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, active_directory.ListActiveDirectoriesRequest): - request = active_directory.ListActiveDirectoriesRequest(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_active_directories] - - # 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.ListActiveDirectoriesPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_active_directory(self, - request: Optional[Union[active_directory.GetActiveDirectoryRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> active_directory.ActiveDirectory: - r"""Describes a specified active directory. - - .. 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 netapp_v1 - - def sample_get_active_directory(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.GetActiveDirectoryRequest( - name="name_value", - ) - - # Make the request - response = client.get_active_directory(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.GetActiveDirectoryRequest, dict]): - The request object. GetActiveDirectory for getting a - single active directory. - name (str): - Required. Name of the active - directory. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.ActiveDirectory: - ActiveDirectory is the public - representation of the active directory - config. - - """ - # 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, active_directory.GetActiveDirectoryRequest): - request = active_directory.GetActiveDirectoryRequest(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_active_directory] - - # 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_active_directory(self, - request: Optional[Union[gcn_active_directory.CreateActiveDirectoryRequest, dict]] = None, - *, - parent: Optional[str] = None, - active_directory: Optional[gcn_active_directory.ActiveDirectory] = None, - active_directory_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""CreateActiveDirectory - Creates the active directory specified in the request. - - .. 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 netapp_v1 - - def sample_create_active_directory(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - active_directory = netapp_v1.ActiveDirectory() - active_directory.domain = "domain_value" - active_directory.dns = "dns_value" - active_directory.net_bios_prefix = "net_bios_prefix_value" - active_directory.username = "username_value" - active_directory.password = "password_value" - - request = netapp_v1.CreateActiveDirectoryRequest( - parent="parent_value", - active_directory=active_directory, - active_directory_id="active_directory_id_value", - ) - - # Make the request - operation = client.create_active_directory(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.CreateActiveDirectoryRequest, dict]): - The request object. CreateActiveDirectoryRequest for - creating an active directory. - parent (str): - Required. Value for parent. - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - active_directory (google.cloud.netapp_v1.types.ActiveDirectory): - Required. Fields of the to be created - active directory. - - This corresponds to the ``active_directory`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - active_directory_id (str): - Required. ID of the active directory - to create. Must be unique within the - parent resource. Must contain only - letters, numbers and hyphen, with the - first character a letter , the last a - letter or a number, and a 63 character - maximum. - - This corresponds to the ``active_directory_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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.netapp_v1.types.ActiveDirectory` - ActiveDirectory is the public representation of the - active directory config. - - """ - # 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. - flattened_params = [parent, active_directory, active_directory_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_active_directory.CreateActiveDirectoryRequest): - request = gcn_active_directory.CreateActiveDirectoryRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if active_directory is not None: - request.active_directory = active_directory - if active_directory_id is not None: - request.active_directory_id = active_directory_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_active_directory] - - # 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, - gcn_active_directory.ActiveDirectory, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_active_directory(self, - request: Optional[Union[gcn_active_directory.UpdateActiveDirectoryRequest, dict]] = None, - *, - active_directory: Optional[gcn_active_directory.ActiveDirectory] = 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, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Update the parameters of an active directories. - - .. 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 netapp_v1 - - def sample_update_active_directory(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - active_directory = netapp_v1.ActiveDirectory() - active_directory.domain = "domain_value" - active_directory.dns = "dns_value" - active_directory.net_bios_prefix = "net_bios_prefix_value" - active_directory.username = "username_value" - active_directory.password = "password_value" - - request = netapp_v1.UpdateActiveDirectoryRequest( - active_directory=active_directory, - ) - - # Make the request - operation = client.update_active_directory(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.UpdateActiveDirectoryRequest, dict]): - The request object. UpdateActiveDirectoryRequest for - updating an active directory. - active_directory (google.cloud.netapp_v1.types.ActiveDirectory): - Required. The volume being updated - This corresponds to the ``active_directory`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the Active Directory resource by the - update. The fields specified in the update_mask are - relative to the resource, not the full request. A field - will be overwritten if it is in the mask. If the user - does not provide a mask then all fields will be - overwritten. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.netapp_v1.types.ActiveDirectory` - ActiveDirectory is the public representation of the - active directory config. - - """ - # 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. - flattened_params = [active_directory, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_active_directory.UpdateActiveDirectoryRequest): - request = gcn_active_directory.UpdateActiveDirectoryRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if active_directory is not None: - request.active_directory = active_directory - 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_active_directory] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("active_directory.name", request.active_directory.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, - gcn_active_directory.ActiveDirectory, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_active_directory(self, - request: Optional[Union[active_directory.DeleteActiveDirectoryRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Delete the active directory specified in the request. - - .. 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 netapp_v1 - - def sample_delete_active_directory(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteActiveDirectoryRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_active_directory(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.DeleteActiveDirectoryRequest, dict]): - The request object. DeleteActiveDirectoryRequest for - deleting a single active directory. - name (str): - Required. Name of the active - directory. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, active_directory.DeleteActiveDirectoryRequest): - request = active_directory.DeleteActiveDirectoryRequest(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_active_directory] - - # 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=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def list_kms_configs(self, - request: Optional[Union[kms.ListKmsConfigsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListKmsConfigsPager: - r"""Returns descriptions of all KMS configs owned by the - caller. - - .. 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 netapp_v1 - - def sample_list_kms_configs(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ListKmsConfigsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_kms_configs(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.ListKmsConfigsRequest, dict]): - The request object. ListKmsConfigsRequest lists KMS - Configs. - parent (str): - Required. Parent value - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.services.net_app.pagers.ListKmsConfigsPager: - ListKmsConfigsResponse is the - response to a ListKmsConfigsRequest. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, kms.ListKmsConfigsRequest): - request = kms.ListKmsConfigsRequest(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_kms_configs] - - # 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.ListKmsConfigsPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_kms_config(self, - request: Optional[Union[kms.CreateKmsConfigRequest, dict]] = None, - *, - parent: Optional[str] = None, - kms_config: Optional[kms.KmsConfig] = None, - kms_config_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Creates a new KMS config. - - .. 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 netapp_v1 - - def sample_create_kms_config(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - kms_config = netapp_v1.KmsConfig() - kms_config.crypto_key_name = "crypto_key_name_value" - - request = netapp_v1.CreateKmsConfigRequest( - parent="parent_value", - kms_config_id="kms_config_id_value", - kms_config=kms_config, - ) - - # Make the request - operation = client.create_kms_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.CreateKmsConfigRequest, dict]): - The request object. CreateKmsConfigRequest creates a KMS - Config. - parent (str): - Required. Value for parent. - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - kms_config (google.cloud.netapp_v1.types.KmsConfig): - Required. The required parameters to - create a new KmsConfig. - - This corresponds to the ``kms_config`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - kms_config_id (str): - Required. Id of the requesting - KmsConfig. Must be unique within the - parent resource. Must contain only - letters, numbers and hyphen, with the - first character a letter, the last a - letter or a number, and a 63 character - maximum. - - This corresponds to the ``kms_config_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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.netapp_v1.types.KmsConfig` - KmsConfig is the customer managed encryption key(CMEK) - configuration. - - """ - # 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. - flattened_params = [parent, kms_config, kms_config_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, kms.CreateKmsConfigRequest): - request = kms.CreateKmsConfigRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if kms_config is not None: - request.kms_config = kms_config - if kms_config_id is not None: - request.kms_config_id = kms_config_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_kms_config] - - # 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, - kms.KmsConfig, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def get_kms_config(self, - request: Optional[Union[kms.GetKmsConfigRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> kms.KmsConfig: - r"""Returns the description of the specified KMS config by - kms_config_id. - - .. 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 netapp_v1 - - def sample_get_kms_config(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.GetKmsConfigRequest( - name="name_value", - ) - - # Make the request - response = client.get_kms_config(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.GetKmsConfigRequest, dict]): - The request object. GetKmsConfigRequest gets a KMS - Config. - name (str): - Required. Name of the KmsConfig - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.KmsConfig: - KmsConfig is the customer managed - encryption key(CMEK) configuration. - - """ - # 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, kms.GetKmsConfigRequest): - request = kms.GetKmsConfigRequest(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_kms_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_kms_config(self, - request: Optional[Union[kms.UpdateKmsConfigRequest, dict]] = None, - *, - kms_config: Optional[kms.KmsConfig] = 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, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Updates the Kms config properties with the full spec - - .. 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 netapp_v1 - - def sample_update_kms_config(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - kms_config = netapp_v1.KmsConfig() - kms_config.crypto_key_name = "crypto_key_name_value" - - request = netapp_v1.UpdateKmsConfigRequest( - kms_config=kms_config, - ) - - # Make the request - operation = client.update_kms_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.UpdateKmsConfigRequest, dict]): - The request object. UpdateKmsConfigRequest updates a KMS - Config. - kms_config (google.cloud.netapp_v1.types.KmsConfig): - Required. The KmsConfig being updated - This corresponds to the ``kms_config`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the KmsConfig resource by the update. The - fields specified in the update_mask are relative to the - resource, not the full request. A field will be - overwritten if it is in the mask. If the user does not - provide a mask then all fields will be overwritten. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.netapp_v1.types.KmsConfig` - KmsConfig is the customer managed encryption key(CMEK) - configuration. - - """ - # 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. - flattened_params = [kms_config, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, kms.UpdateKmsConfigRequest): - request = kms.UpdateKmsConfigRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if kms_config is not None: - request.kms_config = kms_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_kms_config] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("kms_config.name", request.kms_config.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, - kms.KmsConfig, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def encrypt_volumes(self, - request: Optional[Union[kms.EncryptVolumesRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Encrypt the existing volumes without CMEK encryption - with the desired the KMS config for the whole region. - - .. 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 netapp_v1 - - def sample_encrypt_volumes(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.EncryptVolumesRequest( - name="name_value", - ) - - # Make the request - operation = client.encrypt_volumes(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.EncryptVolumesRequest, dict]): - The request object. EncryptVolumesRequest specifies the - KMS config to encrypt existing volumes. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.netapp_v1.types.KmsConfig` - KmsConfig is the customer managed encryption key(CMEK) - configuration. - - """ - # 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, kms.EncryptVolumesRequest): - request = kms.EncryptVolumesRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.encrypt_volumes] - - # 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, - kms.KmsConfig, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def verify_kms_config(self, - request: Optional[Union[kms.VerifyKmsConfigRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> kms.VerifyKmsConfigResponse: - r"""Verifies KMS config reachability. - - .. 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 netapp_v1 - - def sample_verify_kms_config(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.VerifyKmsConfigRequest( - name="name_value", - ) - - # Make the request - response = client.verify_kms_config(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.VerifyKmsConfigRequest, dict]): - The request object. VerifyKmsConfigRequest specifies the - KMS config to be validated. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.VerifyKmsConfigResponse: - VerifyKmsConfigResponse contains the - information if the config is correctly - and error message. - - """ - # 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, kms.VerifyKmsConfigRequest): - request = kms.VerifyKmsConfigRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.verify_kms_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 delete_kms_config(self, - request: Optional[Union[kms.DeleteKmsConfigRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Warning! This operation will permanently delete the - Kms config. - - .. 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 netapp_v1 - - def sample_delete_kms_config(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteKmsConfigRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_kms_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.DeleteKmsConfigRequest, dict]): - The request object. DeleteKmsConfigRequest deletes a KMS - Config. - name (str): - Required. Name of the KmsConfig. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, kms.DeleteKmsConfigRequest): - request = kms.DeleteKmsConfigRequest(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_kms_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, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - empty_pb2.Empty, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def list_replications(self, - request: Optional[Union[replication.ListReplicationsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListReplicationsPager: - r"""Returns descriptions of all replications for a - volume. - - .. 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 netapp_v1 - - def sample_list_replications(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ListReplicationsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_replications(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.ListReplicationsRequest, dict]): - The request object. ListReplications lists replications. - parent (str): - Required. The volume for which to retrieve replication - information, in the format - ``projects/{project_id}/locations/{location}/volumes/{volume_id}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.services.net_app.pagers.ListReplicationsPager: - ListReplicationsResponse is the - result of ListReplicationsRequest. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, replication.ListReplicationsRequest): - request = replication.ListReplicationsRequest(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_replications] - - # 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.ListReplicationsPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_replication(self, - request: Optional[Union[replication.GetReplicationRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> replication.Replication: - r"""Describe a replication for a volume. - - .. 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 netapp_v1 - - def sample_get_replication(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.GetReplicationRequest( - name="name_value", - ) - - # Make the request - response = client.get_replication(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.GetReplicationRequest, dict]): - The request object. GetReplicationRequest gets the state - of a replication. - name (str): - Required. The replication resource name, in the format - ``projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}`` - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.Replication: - Replication is a nested resource - under Volume, that describes a - cross-region replication relationship - between 2 volumes in different regions. - - """ - # 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, replication.GetReplicationRequest): - request = replication.GetReplicationRequest(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_replication] - - # 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_replication(self, - request: Optional[Union[gcn_replication.CreateReplicationRequest, dict]] = None, - *, - parent: Optional[str] = None, - replication: Optional[gcn_replication.Replication] = None, - replication_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Create a new replication for a volume. - - .. 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 netapp_v1 - - def sample_create_replication(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - replication = netapp_v1.Replication() - replication.replication_schedule = "DAILY" - replication.destination_volume_parameters.storage_pool = "storage_pool_value" - - request = netapp_v1.CreateReplicationRequest( - parent="parent_value", - replication=replication, - replication_id="replication_id_value", - ) - - # Make the request - operation = client.create_replication(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.CreateReplicationRequest, dict]): - The request object. CreateReplicationRequest creates a - replication. - parent (str): - Required. The NetApp volume to create the replications - of, in the format - ``projects/{project_id}/locations/{location}/volumes/{volume_id}`` - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - replication (google.cloud.netapp_v1.types.Replication): - Required. A replication resource - This corresponds to the ``replication`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - replication_id (str): - Required. ID of the replication to - create. Must be unique within the parent - resource. Must contain only letters, - numbers and hyphen, with the first - character a letter, the last a letter or - a number, and a 63 character maximum. - - This corresponds to the ``replication_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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a - cross-region replication relationship between 2 - volumes in different regions. - - """ - # 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. - flattened_params = [parent, replication, replication_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_replication.CreateReplicationRequest): - request = gcn_replication.CreateReplicationRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if replication is not None: - request.replication = replication - if replication_id is not None: - request.replication_id = replication_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_replication] - - # 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, - gcn_replication.Replication, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_replication(self, - request: Optional[Union[replication.DeleteReplicationRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Deletes a replication. - - .. 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 netapp_v1 - - def sample_delete_replication(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteReplicationRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_replication(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.DeleteReplicationRequest, dict]): - The request object. DeleteReplicationRequest deletes a - replication. - name (str): - Required. The replication resource name, in the format - ``projects/*/locations/*/volumes/*/replications/{replication_id}`` - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, replication.DeleteReplicationRequest): - request = replication.DeleteReplicationRequest(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_replication] - - # 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=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_replication(self, - request: Optional[Union[gcn_replication.UpdateReplicationRequest, dict]] = None, - *, - replication: Optional[gcn_replication.Replication] = 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, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Updates the settings of a specific replication. - - .. 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 netapp_v1 - - def sample_update_replication(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - replication = netapp_v1.Replication() - replication.replication_schedule = "DAILY" - replication.destination_volume_parameters.storage_pool = "storage_pool_value" - - request = netapp_v1.UpdateReplicationRequest( - replication=replication, - ) - - # Make the request - operation = client.update_replication(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.UpdateReplicationRequest, dict]): - The request object. UpdateReplicationRequest updates - description and/or labels for a - replication. - replication (google.cloud.netapp_v1.types.Replication): - Required. A replication resource - This corresponds to the ``replication`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Mask of fields to update. - At least one path must be supplied in - this field. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a - cross-region replication relationship between 2 - volumes in different regions. - - """ - # 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. - flattened_params = [replication, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_replication.UpdateReplicationRequest): - request = gcn_replication.UpdateReplicationRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if replication is not None: - request.replication = replication - 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_replication] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("replication.name", request.replication.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, - gcn_replication.Replication, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def stop_replication(self, - request: Optional[Union[replication.StopReplicationRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Stop Cross Region Replication. - - .. 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 netapp_v1 - - def sample_stop_replication(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.StopReplicationRequest( - name="name_value", - ) - - # Make the request - operation = client.stop_replication(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.StopReplicationRequest, dict]): - The request object. StopReplicationRequest stops a - replication until resumed. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a - cross-region replication relationship between 2 - volumes in different regions. - - """ - # 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, replication.StopReplicationRequest): - request = replication.StopReplicationRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.stop_replication] - - # 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, - replication.Replication, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def resume_replication(self, - request: Optional[Union[replication.ResumeReplicationRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Resume Cross Region Replication. - - .. 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 netapp_v1 - - def sample_resume_replication(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ResumeReplicationRequest( - name="name_value", - ) - - # Make the request - operation = client.resume_replication(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.ResumeReplicationRequest, dict]): - The request object. ResumeReplicationRequest resumes a - stopped replication. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a - cross-region replication relationship between 2 - volumes in different regions. - - """ - # 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, replication.ResumeReplicationRequest): - request = replication.ResumeReplicationRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.resume_replication] - - # 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, - replication.Replication, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def reverse_replication_direction(self, - request: Optional[Union[replication.ReverseReplicationDirectionRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Reverses direction of replication. Source becomes - destination and destination becomes source. - - .. 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 netapp_v1 - - def sample_reverse_replication_direction(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ReverseReplicationDirectionRequest( - name="name_value", - ) - - # Make the request - operation = client.reverse_replication_direction(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.ReverseReplicationDirectionRequest, dict]): - The request object. ReverseReplicationDirectionRequest - reverses direction of replication. - Source becomes destination and - destination becomes source. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a - cross-region replication relationship between 2 - volumes in different regions. - - """ - # 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, replication.ReverseReplicationDirectionRequest): - request = replication.ReverseReplicationDirectionRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.reverse_replication_direction] - - # 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, - replication.Replication, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def establish_peering(self, - request: Optional[Union[replication.EstablishPeeringRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Establish replication peering. - - .. 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 netapp_v1 - - def sample_establish_peering(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.EstablishPeeringRequest( - name="name_value", - peer_cluster_name="peer_cluster_name_value", - peer_svm_name="peer_svm_name_value", - peer_volume_name="peer_volume_name_value", - ) - - # Make the request - operation = client.establish_peering(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.EstablishPeeringRequest, dict]): - The request object. EstablishPeeringRequest establishes - cluster and svm peerings between the - source and the destination replications. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a - cross-region replication relationship between 2 - volumes in different regions. - - """ - # 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, replication.EstablishPeeringRequest): - request = replication.EstablishPeeringRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.establish_peering] - - # 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, - replication.Replication, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def sync_replication(self, - request: Optional[Union[replication.SyncReplicationRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Syncs the replication. This will invoke one time - volume data transfer from source to destination. - - .. 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 netapp_v1 - - def sample_sync_replication(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.SyncReplicationRequest( - name="name_value", - ) - - # Make the request - operation = client.sync_replication(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.SyncReplicationRequest, dict]): - The request object. SyncReplicationRequest syncs the - replication from source to destination. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.netapp_v1.types.Replication` Replication is a nested resource under Volume, that describes a - cross-region replication relationship between 2 - volumes in different regions. - - """ - # 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, replication.SyncReplicationRequest): - request = replication.SyncReplicationRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.sync_replication] - - # 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, - replication.Replication, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def create_backup_vault(self, - request: Optional[Union[gcn_backup_vault.CreateBackupVaultRequest, dict]] = None, - *, - parent: Optional[str] = None, - backup_vault: Optional[gcn_backup_vault.BackupVault] = None, - backup_vault_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Creates new backup vault - - .. 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 netapp_v1 - - def sample_create_backup_vault(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.CreateBackupVaultRequest( - parent="parent_value", - backup_vault_id="backup_vault_id_value", - ) - - # Make the request - operation = client.create_backup_vault(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.CreateBackupVaultRequest, dict]): - The request object. CreateBackupVaultRequest creates a - backup vault. - parent (str): - Required. The location to create the backup vaults, in - the format - ``projects/{project_id}/locations/{location}`` - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - backup_vault (google.cloud.netapp_v1.types.BackupVault): - Required. A backupVault resource - This corresponds to the ``backup_vault`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - backup_vault_id (str): - Required. The ID to use for the - backupVault. The ID must be unique - within the specified location. Must - contain only letters, numbers and - hyphen, with the first character a - letter, the last a letter or a number, - and a 63 character maximum. - - This corresponds to the ``backup_vault_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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.netapp_v1.types.BackupVault` A - NetApp BackupVault. - - """ - # 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. - flattened_params = [parent, backup_vault, backup_vault_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_backup_vault.CreateBackupVaultRequest): - request = gcn_backup_vault.CreateBackupVaultRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if backup_vault is not None: - request.backup_vault = backup_vault - if backup_vault_id is not None: - request.backup_vault_id = backup_vault_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_backup_vault] - - # 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, - gcn_backup_vault.BackupVault, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def get_backup_vault(self, - request: Optional[Union[backup_vault.GetBackupVaultRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> backup_vault.BackupVault: - r"""Returns the description of the specified backup vault - - .. 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 netapp_v1 - - def sample_get_backup_vault(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.GetBackupVaultRequest( - name="name_value", - ) - - # Make the request - response = client.get_backup_vault(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.GetBackupVaultRequest, dict]): - The request object. GetBackupVaultRequest gets the state - of a backupVault. - name (str): - Required. The backupVault resource name, in the format - ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}`` - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.BackupVault: - A NetApp BackupVault. - """ - # 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, backup_vault.GetBackupVaultRequest): - request = backup_vault.GetBackupVaultRequest(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_backup_vault] - - # 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_backup_vaults(self, - request: Optional[Union[backup_vault.ListBackupVaultsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListBackupVaultsPager: - r"""Returns list of all available backup vaults. - - .. 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 netapp_v1 - - def sample_list_backup_vaults(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ListBackupVaultsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_backup_vaults(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.ListBackupVaultsRequest, dict]): - The request object. ListBackupVaultsRequest lists - backupVaults. - parent (str): - Required. The location for which to retrieve backupVault - information, in the format - ``projects/{project_id}/locations/{location}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.services.net_app.pagers.ListBackupVaultsPager: - ListBackupVaultsResponse is the - result of ListBackupVaultsRequest. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, backup_vault.ListBackupVaultsRequest): - request = backup_vault.ListBackupVaultsRequest(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_backup_vaults] - - # 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.ListBackupVaultsPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_backup_vault(self, - request: Optional[Union[gcn_backup_vault.UpdateBackupVaultRequest, dict]] = None, - *, - backup_vault: Optional[gcn_backup_vault.BackupVault] = 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, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Updates the settings of a specific backup vault. - - .. 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 netapp_v1 - - def sample_update_backup_vault(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.UpdateBackupVaultRequest( - ) - - # Make the request - operation = client.update_backup_vault(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.UpdateBackupVaultRequest, dict]): - The request object. UpdateBackupVaultRequest updates - description and/or labels for a - backupVault. - backup_vault (google.cloud.netapp_v1.types.BackupVault): - Required. The backupVault being - updated - - This corresponds to the ``backup_vault`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the Backup resource to be updated. The - fields specified in the update_mask are relative to the - resource, not the full request. A field will be - overwritten if it is in the mask. If the user does not - provide a mask then all fields will be overwritten. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.netapp_v1.types.BackupVault` A - NetApp BackupVault. - - """ - # 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. - flattened_params = [backup_vault, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_backup_vault.UpdateBackupVaultRequest): - request = gcn_backup_vault.UpdateBackupVaultRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if backup_vault is not None: - request.backup_vault = backup_vault - 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_backup_vault] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("backup_vault.name", request.backup_vault.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, - gcn_backup_vault.BackupVault, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_backup_vault(self, - request: Optional[Union[backup_vault.DeleteBackupVaultRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Warning! This operation will permanently delete the - backup vault. - - .. 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 netapp_v1 - - def sample_delete_backup_vault(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteBackupVaultRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_backup_vault(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.DeleteBackupVaultRequest, dict]): - The request object. DeleteBackupVaultRequest deletes a - backupVault. - name (str): - Required. The backupVault resource name, in the format - ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}`` - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, backup_vault.DeleteBackupVaultRequest): - request = backup_vault.DeleteBackupVaultRequest(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_backup_vault] - - # 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=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def create_backup(self, - request: Optional[Union[gcn_backup.CreateBackupRequest, dict]] = None, - *, - parent: Optional[str] = None, - backup: Optional[gcn_backup.Backup] = None, - backup_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Creates a backup from the volume specified in the - request The backup can be created from the given - snapshot if specified in the request. If no snapshot - specified, there'll be a new snapshot taken to initiate - the backup creation. - - .. 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 netapp_v1 - - def sample_create_backup(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.CreateBackupRequest( - parent="parent_value", - backup_id="backup_id_value", - ) - - # Make the request - operation = client.create_backup(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.CreateBackupRequest, dict]): - The request object. CreateBackupRequest creates a backup. - parent (str): - Required. The NetApp backupVault to create the backups - of, in the format - ``projects/*/locations/*/backupVaults/{backup_vault_id}`` - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - backup (google.cloud.netapp_v1.types.Backup): - Required. A backup resource - This corresponds to the ``backup`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - backup_id (str): - Required. The ID to use for the - backup. The ID must be unique within the - specified backupVault. Must contain only - letters, numbers and hyphen, with the - first character a letter, the last a - letter or a number, and a 63 character - maximum. - - This corresponds to the ``backup_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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.netapp_v1.types.Backup` A NetApp - Backup. - - """ - # 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. - flattened_params = [parent, backup, backup_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_backup.CreateBackupRequest): - request = gcn_backup.CreateBackupRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if backup is not None: - request.backup = backup - if backup_id is not None: - request.backup_id = backup_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_backup] - - # 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, - gcn_backup.Backup, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def get_backup(self, - request: Optional[Union[backup.GetBackupRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> backup.Backup: - r"""Returns the description of the specified backup - - .. 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 netapp_v1 - - def sample_get_backup(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.GetBackupRequest( - name="name_value", - ) - - # Make the request - response = client.get_backup(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.GetBackupRequest, dict]): - The request object. GetBackupRequest gets the state of a - backup. - name (str): - Required. The backup resource name, in the format - ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id}`` - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.Backup: - A NetApp Backup. - """ - # 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, backup.GetBackupRequest): - request = backup.GetBackupRequest(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_backup] - - # 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_backups(self, - request: Optional[Union[backup.ListBackupsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListBackupsPager: - r"""Returns descriptions of all backups for a - backupVault. - - .. 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 netapp_v1 - - def sample_list_backups(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ListBackupsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_backups(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.ListBackupsRequest, dict]): - The request object. ListBackupsRequest lists backups. - parent (str): - Required. The backupVault for which to retrieve backup - information, in the format - ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}``. - To retrieve backup information for all locations, use - "-" for the ``{location}`` value. To retrieve backup - information for all backupVaults, use "-" for the - ``{backup_vault_id}`` value. To retrieve backup - information for a volume, use "-" for the - ``{backup_vault_id}`` value and specify volume full name - with the filter. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.services.net_app.pagers.ListBackupsPager: - ListBackupsResponse is the result of - ListBackupsRequest. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, backup.ListBackupsRequest): - request = backup.ListBackupsRequest(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_backups] - - # 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.ListBackupsPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_backup(self, - request: Optional[Union[backup.DeleteBackupRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Warning! This operation will permanently delete the - backup. - - .. 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 netapp_v1 - - def sample_delete_backup(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteBackupRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_backup(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.DeleteBackupRequest, dict]): - The request object. DeleteBackupRequest deletes a backup. - name (str): - Required. The backup resource name, in the format - ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id}`` - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, backup.DeleteBackupRequest): - request = backup.DeleteBackupRequest(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_backup] - - # 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=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_backup(self, - request: Optional[Union[gcn_backup.UpdateBackupRequest, dict]] = None, - *, - backup: Optional[gcn_backup.Backup] = 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, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Update backup with full spec. - - .. 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 netapp_v1 - - def sample_update_backup(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.UpdateBackupRequest( - ) - - # Make the request - operation = client.update_backup(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.UpdateBackupRequest, dict]): - The request object. UpdateBackupRequest updates - description and/or labels for a backup. - backup (google.cloud.netapp_v1.types.Backup): - Required. The backup being updated - This corresponds to the ``backup`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the Backup resource to be updated. The - fields specified in the update_mask are relative to the - resource, not the full request. A field will be - overwritten if it is in the mask. If the user does not - provide a mask then all fields will be overwritten. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.netapp_v1.types.Backup` A NetApp - Backup. - - """ - # 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. - flattened_params = [backup, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_backup.UpdateBackupRequest): - request = gcn_backup.UpdateBackupRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if backup is not None: - request.backup = backup - 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_backup] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("backup.name", request.backup.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, - gcn_backup.Backup, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def create_backup_policy(self, - request: Optional[Union[gcn_backup_policy.CreateBackupPolicyRequest, dict]] = None, - *, - parent: Optional[str] = None, - backup_policy: Optional[gcn_backup_policy.BackupPolicy] = None, - backup_policy_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Creates new backup policy - - .. 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 netapp_v1 - - def sample_create_backup_policy(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.CreateBackupPolicyRequest( - parent="parent_value", - backup_policy_id="backup_policy_id_value", - ) - - # Make the request - operation = client.create_backup_policy(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.CreateBackupPolicyRequest, dict]): - The request object. CreateBackupPolicyRequest creates a - backupPolicy. - parent (str): - Required. The location to create the backup policies of, - in the format - ``projects/{project_id}/locations/{location}`` - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - backup_policy (google.cloud.netapp_v1.types.BackupPolicy): - Required. A backupPolicy resource - This corresponds to the ``backup_policy`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - backup_policy_id (str): - Required. The ID to use for the - backup policy. The ID must be unique - within the specified location. Must - contain only letters, numbers and - hyphen, with the first character a - letter, the last a letter or a number, - and a 63 character maximum. - - This corresponds to the ``backup_policy_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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.netapp_v1.types.BackupPolicy` - Backup Policy. - - """ - # 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. - flattened_params = [parent, backup_policy, backup_policy_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_backup_policy.CreateBackupPolicyRequest): - request = gcn_backup_policy.CreateBackupPolicyRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if backup_policy is not None: - request.backup_policy = backup_policy - if backup_policy_id is not None: - request.backup_policy_id = backup_policy_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_backup_policy] - - # 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, - gcn_backup_policy.BackupPolicy, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def get_backup_policy(self, - request: Optional[Union[backup_policy.GetBackupPolicyRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> backup_policy.BackupPolicy: - r"""Returns the description of the specified backup policy by - backup_policy_id. - - .. 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 netapp_v1 - - def sample_get_backup_policy(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.GetBackupPolicyRequest( - name="name_value", - ) - - # Make the request - response = client.get_backup_policy(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.GetBackupPolicyRequest, dict]): - The request object. GetBackupPolicyRequest gets the state - of a backupPolicy. - name (str): - Required. The backupPolicy resource name, in the format - ``projects/{project_id}/locations/{location}/backupPolicies/{backup_policy_id}`` - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.BackupPolicy: - Backup Policy. - """ - # 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, backup_policy.GetBackupPolicyRequest): - request = backup_policy.GetBackupPolicyRequest(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_backup_policy] - - # 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_backup_policies(self, - request: Optional[Union[backup_policy.ListBackupPoliciesRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListBackupPoliciesPager: - r"""Returns list of all available backup policies. - - .. 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 netapp_v1 - - def sample_list_backup_policies(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ListBackupPoliciesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_backup_policies(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.ListBackupPoliciesRequest, dict]): - The request object. ListBackupPoliciesRequest for - requesting multiple backup policies. - parent (str): - Required. Parent value for - ListBackupPoliciesRequest - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.services.net_app.pagers.ListBackupPoliciesPager: - ListBackupPoliciesResponse contains - all the backup policies requested. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, backup_policy.ListBackupPoliciesRequest): - request = backup_policy.ListBackupPoliciesRequest(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_backup_policies] - - # 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.ListBackupPoliciesPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_backup_policy(self, - request: Optional[Union[gcn_backup_policy.UpdateBackupPolicyRequest, dict]] = None, - *, - backup_policy: Optional[gcn_backup_policy.BackupPolicy] = 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, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Updates settings of a specific backup policy. - - .. 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 netapp_v1 - - def sample_update_backup_policy(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.UpdateBackupPolicyRequest( - ) - - # Make the request - operation = client.update_backup_policy(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.UpdateBackupPolicyRequest, dict]): - The request object. UpdateBackupPolicyRequest for - updating a backup policy. - backup_policy (google.cloud.netapp_v1.types.BackupPolicy): - Required. The backup policy being - updated - - This corresponds to the ``backup_policy`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the Backup Policy resource by the update. - The fields specified in the update_mask are relative to - the resource, not the full request. A field will be - overwritten if it is in the mask. If the user does not - provide a mask then all fields will be overwritten. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.netapp_v1.types.BackupPolicy` - Backup Policy. - - """ - # 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. - flattened_params = [backup_policy, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_backup_policy.UpdateBackupPolicyRequest): - request = gcn_backup_policy.UpdateBackupPolicyRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if backup_policy is not None: - request.backup_policy = backup_policy - 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_backup_policy] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("backup_policy.name", request.backup_policy.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, - gcn_backup_policy.BackupPolicy, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_backup_policy(self, - request: Optional[Union[backup_policy.DeleteBackupPolicyRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Warning! This operation will permanently delete the - backup policy. - - .. 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 netapp_v1 - - def sample_delete_backup_policy(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteBackupPolicyRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_backup_policy(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.DeleteBackupPolicyRequest, dict]): - The request object. DeleteBackupPolicyRequest deletes a - backup policy. - name (str): - Required. The backup policy resource name, in the format - ``projects/{project_id}/locations/{location}/backupPolicies/{backup_policy_id}`` - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, backup_policy.DeleteBackupPolicyRequest): - request = backup_policy.DeleteBackupPolicyRequest(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_backup_policy] - - # 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=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def list_quota_rules(self, - request: Optional[Union[quota_rule.ListQuotaRulesRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListQuotaRulesPager: - r"""Returns list of all quota rules in a location. - - .. 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 netapp_v1 - - def sample_list_quota_rules(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ListQuotaRulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_quota_rules(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.ListQuotaRulesRequest, dict]): - The request object. ListQuotaRulesRequest for listing - quota rules. - parent (str): - Required. Parent value for - ListQuotaRulesRequest - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.services.net_app.pagers.ListQuotaRulesPager: - ListQuotaRulesResponse is the - response to a ListQuotaRulesRequest. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, quota_rule.ListQuotaRulesRequest): - request = quota_rule.ListQuotaRulesRequest(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_quota_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.ListQuotaRulesPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_quota_rule(self, - request: Optional[Union[quota_rule.GetQuotaRuleRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> quota_rule.QuotaRule: - r"""Returns details of the specified quota 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 netapp_v1 - - def sample_get_quota_rule(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.GetQuotaRuleRequest( - name="name_value", - ) - - # Make the request - response = client.get_quota_rule(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.GetQuotaRuleRequest, dict]): - The request object. GetQuotaRuleRequest for getting a - quota rule. - name (str): - Required. Name of the quota rule - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.netapp_v1.types.QuotaRule: - QuotaRule specifies the maximum disk - space a user or group can use within a - volume. They can be used for creating - default and individual quota rules. - - """ - # 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, quota_rule.GetQuotaRuleRequest): - request = quota_rule.GetQuotaRuleRequest(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_quota_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 create_quota_rule(self, - request: Optional[Union[gcn_quota_rule.CreateQuotaRuleRequest, dict]] = None, - *, - parent: Optional[str] = None, - quota_rule: Optional[gcn_quota_rule.QuotaRule] = None, - quota_rule_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Creates a new quota 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 netapp_v1 - - def sample_create_quota_rule(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - quota_rule = netapp_v1.QuotaRule() - quota_rule.type_ = "DEFAULT_GROUP_QUOTA" - quota_rule.disk_limit_mib = 1472 - - request = netapp_v1.CreateQuotaRuleRequest( - parent="parent_value", - quota_rule=quota_rule, - quota_rule_id="quota_rule_id_value", - ) - - # Make the request - operation = client.create_quota_rule(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.CreateQuotaRuleRequest, dict]): - The request object. CreateQuotaRuleRequest for creating a - quota rule. - parent (str): - Required. Parent value for - CreateQuotaRuleRequest - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - quota_rule (google.cloud.netapp_v1.types.QuotaRule): - Required. Fields of the to be created - quota rule. - - This corresponds to the ``quota_rule`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - quota_rule_id (str): - Required. ID of the quota rule to - create. Must be unique within the parent - resource. Must contain only letters, - numbers, underscore and hyphen, with the - first character a letter or underscore, - the last a letter or underscore or a - number, and a 63 character maximum. - - This corresponds to the ``quota_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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.netapp_v1.types.QuotaRule` QuotaRule specifies the maximum disk space a user or group can use within a - volume. They can be used for creating default and - individual quota rules. - - """ - # 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. - flattened_params = [parent, quota_rule, quota_rule_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_quota_rule.CreateQuotaRuleRequest): - request = gcn_quota_rule.CreateQuotaRuleRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if quota_rule is not None: - request.quota_rule = quota_rule - if quota_rule_id is not None: - request.quota_rule_id = quota_rule_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_quota_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, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - gcn_quota_rule.QuotaRule, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_quota_rule(self, - request: Optional[Union[gcn_quota_rule.UpdateQuotaRuleRequest, dict]] = None, - *, - quota_rule: Optional[gcn_quota_rule.QuotaRule] = 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, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Updates a quota 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 netapp_v1 - - def sample_update_quota_rule(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - quota_rule = netapp_v1.QuotaRule() - quota_rule.type_ = "DEFAULT_GROUP_QUOTA" - quota_rule.disk_limit_mib = 1472 - - request = netapp_v1.UpdateQuotaRuleRequest( - quota_rule=quota_rule, - ) - - # Make the request - operation = client.update_quota_rule(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.UpdateQuotaRuleRequest, dict]): - The request object. UpdateQuotaRuleRequest for updating a - quota rule. - quota_rule (google.cloud.netapp_v1.types.QuotaRule): - Required. The quota rule being - updated - - This corresponds to the ``quota_rule`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Optional. Field mask is used to specify the fields to be - overwritten in the Quota Rule resource by the update. - The fields specified in the update_mask are relative to - the resource, not the full request. A field will be - overwritten if it is in the mask. If the user does not - provide a mask then all fields will be overwritten. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.netapp_v1.types.QuotaRule` QuotaRule specifies the maximum disk space a user or group can use within a - volume. They can be used for creating default and - individual quota rules. - - """ - # 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. - flattened_params = [quota_rule, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, gcn_quota_rule.UpdateQuotaRuleRequest): - request = gcn_quota_rule.UpdateQuotaRuleRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if quota_rule is not None: - request.quota_rule = quota_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_quota_rule] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("quota_rule.name", request.quota_rule.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, - gcn_quota_rule.QuotaRule, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_quota_rule(self, - request: Optional[Union[quota_rule.DeleteQuotaRuleRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Deletes a quota 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 netapp_v1 - - def sample_delete_quota_rule(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteQuotaRuleRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_quota_rule(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.netapp_v1.types.DeleteQuotaRuleRequest, dict]): - The request object. DeleteQuotaRuleRequest for deleting a - single quota rule. - name (str): - Required. Name of the quota rule. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - 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, quota_rule.DeleteQuotaRuleRequest): - request = quota_rule.DeleteQuotaRuleRequest(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_quota_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, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - empty_pb2.Empty, - metadata_type=cloud_netapp_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def __enter__(self) -> "NetAppClient": - 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 list_operations( - self, - request: Optional[operations_pb2.ListOperationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operations_pb2.ListOperationsResponse: - r"""Lists operations that match the specified filter in the request. - - Args: - request (:class:`~.operations_pb2.ListOperationsRequest`): - The request object. Request message for - `ListOperations` 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - Returns: - ~.operations_pb2.ListOperationsResponse: - Response message for ``ListOperations`` 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 = operations_pb2.ListOperationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_operations] - - # 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() - - try: - # Send the request. - response = rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - except core_exceptions.GoogleAPICallError as e: - self._add_cred_info_for_auth_errors(e) - raise e - - 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, Union[str, bytes]]] = (), - ) -> 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - 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() - - try: - # Send the request. - response = rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - except core_exceptions.GoogleAPICallError as e: - self._add_cred_info_for_auth_errors(e) - raise e - - def delete_operation( - self, - request: Optional[operations_pb2.DeleteOperationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> None: - r"""Deletes a long-running operation. - - This method indicates that the client is no longer interested - in the operation result. It does not cancel the operation. - If the server doesn't support this method, it returns - `google.rpc.Code.UNIMPLEMENTED`. - - Args: - request (:class:`~.operations_pb2.DeleteOperationRequest`): - The request object. Request message for - `DeleteOperation` 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - Returns: - None - """ - # 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.DeleteOperationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.delete_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. - rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - def cancel_operation( - self, - request: Optional[operations_pb2.CancelOperationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> None: - r"""Starts asynchronous cancellation on a long-running operation. - - The server makes a best effort to cancel the operation, but success - is not guaranteed. If the server doesn't support this method, it returns - `google.rpc.Code.UNIMPLEMENTED`. - - Args: - request (:class:`~.operations_pb2.CancelOperationRequest`): - The request object. Request message for - `CancelOperation` 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - Returns: - None - """ - # 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.CancelOperationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.cancel_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. - rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - 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, Union[str, bytes]]] = (), - ) -> 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - 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() - - try: - # Send the request. - response = rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - except core_exceptions.GoogleAPICallError as e: - self._add_cred_info_for_auth_errors(e) - raise e - - 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, Union[str, bytes]]] = (), - ) -> 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - 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() - - try: - # Send the request. - response = rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - except core_exceptions.GoogleAPICallError as e: - self._add_cred_info_for_auth_errors(e) - raise e - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "NetAppClient", -) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/pagers.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/pagers.py deleted file mode 100644 index adbdb24c09a4..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/pagers.py +++ /dev/null @@ -1,1426 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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.netapp_v1.types import active_directory -from google.cloud.netapp_v1.types import backup -from google.cloud.netapp_v1.types import backup_policy -from google.cloud.netapp_v1.types import backup_vault -from google.cloud.netapp_v1.types import kms -from google.cloud.netapp_v1.types import quota_rule -from google.cloud.netapp_v1.types import replication -from google.cloud.netapp_v1.types import snapshot -from google.cloud.netapp_v1.types import storage_pool -from google.cloud.netapp_v1.types import volume - - -class ListStoragePoolsPager: - """A pager for iterating through ``list_storage_pools`` requests. - - This class thinly wraps an initial - :class:`google.cloud.netapp_v1.types.ListStoragePoolsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``storage_pools`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListStoragePools`` requests and continue to iterate - through the ``storage_pools`` field on the - corresponding responses. - - All the usual :class:`google.cloud.netapp_v1.types.ListStoragePoolsResponse` - 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[..., storage_pool.ListStoragePoolsResponse], - request: storage_pool.ListStoragePoolsRequest, - response: storage_pool.ListStoragePoolsResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.netapp_v1.types.ListStoragePoolsRequest): - The initial request object. - response (google.cloud.netapp_v1.types.ListStoragePoolsResponse): - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = storage_pool.ListStoragePoolsRequest(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[storage_pool.ListStoragePoolsResponse]: - 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[storage_pool.StoragePool]: - for page in self.pages: - yield from page.storage_pools - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListStoragePoolsAsyncPager: - """A pager for iterating through ``list_storage_pools`` requests. - - This class thinly wraps an initial - :class:`google.cloud.netapp_v1.types.ListStoragePoolsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``storage_pools`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListStoragePools`` requests and continue to iterate - through the ``storage_pools`` field on the - corresponding responses. - - All the usual :class:`google.cloud.netapp_v1.types.ListStoragePoolsResponse` - 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[storage_pool.ListStoragePoolsResponse]], - request: storage_pool.ListStoragePoolsRequest, - response: storage_pool.ListStoragePoolsResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.netapp_v1.types.ListStoragePoolsRequest): - The initial request object. - response (google.cloud.netapp_v1.types.ListStoragePoolsResponse): - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = storage_pool.ListStoragePoolsRequest(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[storage_pool.ListStoragePoolsResponse]: - 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[storage_pool.StoragePool]: - async def async_generator(): - async for page in self.pages: - for response in page.storage_pools: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListVolumesPager: - """A pager for iterating through ``list_volumes`` requests. - - This class thinly wraps an initial - :class:`google.cloud.netapp_v1.types.ListVolumesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``volumes`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListVolumes`` requests and continue to iterate - through the ``volumes`` field on the - corresponding responses. - - All the usual :class:`google.cloud.netapp_v1.types.ListVolumesResponse` - 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[..., volume.ListVolumesResponse], - request: volume.ListVolumesRequest, - response: volume.ListVolumesResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.netapp_v1.types.ListVolumesRequest): - The initial request object. - response (google.cloud.netapp_v1.types.ListVolumesResponse): - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = volume.ListVolumesRequest(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[volume.ListVolumesResponse]: - 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[volume.Volume]: - for page in self.pages: - yield from page.volumes - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListVolumesAsyncPager: - """A pager for iterating through ``list_volumes`` requests. - - This class thinly wraps an initial - :class:`google.cloud.netapp_v1.types.ListVolumesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``volumes`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListVolumes`` requests and continue to iterate - through the ``volumes`` field on the - corresponding responses. - - All the usual :class:`google.cloud.netapp_v1.types.ListVolumesResponse` - 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[volume.ListVolumesResponse]], - request: volume.ListVolumesRequest, - response: volume.ListVolumesResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.netapp_v1.types.ListVolumesRequest): - The initial request object. - response (google.cloud.netapp_v1.types.ListVolumesResponse): - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = volume.ListVolumesRequest(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[volume.ListVolumesResponse]: - 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[volume.Volume]: - async def async_generator(): - async for page in self.pages: - for response in page.volumes: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListSnapshotsPager: - """A pager for iterating through ``list_snapshots`` requests. - - This class thinly wraps an initial - :class:`google.cloud.netapp_v1.types.ListSnapshotsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``snapshots`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListSnapshots`` requests and continue to iterate - through the ``snapshots`` field on the - corresponding responses. - - All the usual :class:`google.cloud.netapp_v1.types.ListSnapshotsResponse` - 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[..., snapshot.ListSnapshotsResponse], - request: snapshot.ListSnapshotsRequest, - response: snapshot.ListSnapshotsResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.netapp_v1.types.ListSnapshotsRequest): - The initial request object. - response (google.cloud.netapp_v1.types.ListSnapshotsResponse): - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = snapshot.ListSnapshotsRequest(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[snapshot.ListSnapshotsResponse]: - 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[snapshot.Snapshot]: - for page in self.pages: - yield from page.snapshots - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListSnapshotsAsyncPager: - """A pager for iterating through ``list_snapshots`` requests. - - This class thinly wraps an initial - :class:`google.cloud.netapp_v1.types.ListSnapshotsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``snapshots`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListSnapshots`` requests and continue to iterate - through the ``snapshots`` field on the - corresponding responses. - - All the usual :class:`google.cloud.netapp_v1.types.ListSnapshotsResponse` - 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[snapshot.ListSnapshotsResponse]], - request: snapshot.ListSnapshotsRequest, - response: snapshot.ListSnapshotsResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.netapp_v1.types.ListSnapshotsRequest): - The initial request object. - response (google.cloud.netapp_v1.types.ListSnapshotsResponse): - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = snapshot.ListSnapshotsRequest(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[snapshot.ListSnapshotsResponse]: - 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[snapshot.Snapshot]: - async def async_generator(): - async for page in self.pages: - for response in page.snapshots: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListActiveDirectoriesPager: - """A pager for iterating through ``list_active_directories`` requests. - - This class thinly wraps an initial - :class:`google.cloud.netapp_v1.types.ListActiveDirectoriesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``active_directories`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListActiveDirectories`` requests and continue to iterate - through the ``active_directories`` field on the - corresponding responses. - - All the usual :class:`google.cloud.netapp_v1.types.ListActiveDirectoriesResponse` - 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[..., active_directory.ListActiveDirectoriesResponse], - request: active_directory.ListActiveDirectoriesRequest, - response: active_directory.ListActiveDirectoriesResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.netapp_v1.types.ListActiveDirectoriesRequest): - The initial request object. - response (google.cloud.netapp_v1.types.ListActiveDirectoriesResponse): - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = active_directory.ListActiveDirectoriesRequest(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[active_directory.ListActiveDirectoriesResponse]: - 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[active_directory.ActiveDirectory]: - for page in self.pages: - yield from page.active_directories - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListActiveDirectoriesAsyncPager: - """A pager for iterating through ``list_active_directories`` requests. - - This class thinly wraps an initial - :class:`google.cloud.netapp_v1.types.ListActiveDirectoriesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``active_directories`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListActiveDirectories`` requests and continue to iterate - through the ``active_directories`` field on the - corresponding responses. - - All the usual :class:`google.cloud.netapp_v1.types.ListActiveDirectoriesResponse` - 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[active_directory.ListActiveDirectoriesResponse]], - request: active_directory.ListActiveDirectoriesRequest, - response: active_directory.ListActiveDirectoriesResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.netapp_v1.types.ListActiveDirectoriesRequest): - The initial request object. - response (google.cloud.netapp_v1.types.ListActiveDirectoriesResponse): - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = active_directory.ListActiveDirectoriesRequest(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[active_directory.ListActiveDirectoriesResponse]: - 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[active_directory.ActiveDirectory]: - async def async_generator(): - async for page in self.pages: - for response in page.active_directories: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListKmsConfigsPager: - """A pager for iterating through ``list_kms_configs`` requests. - - This class thinly wraps an initial - :class:`google.cloud.netapp_v1.types.ListKmsConfigsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``kms_configs`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListKmsConfigs`` requests and continue to iterate - through the ``kms_configs`` field on the - corresponding responses. - - All the usual :class:`google.cloud.netapp_v1.types.ListKmsConfigsResponse` - 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[..., kms.ListKmsConfigsResponse], - request: kms.ListKmsConfigsRequest, - response: kms.ListKmsConfigsResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.netapp_v1.types.ListKmsConfigsRequest): - The initial request object. - response (google.cloud.netapp_v1.types.ListKmsConfigsResponse): - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = kms.ListKmsConfigsRequest(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[kms.ListKmsConfigsResponse]: - 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[kms.KmsConfig]: - for page in self.pages: - yield from page.kms_configs - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListKmsConfigsAsyncPager: - """A pager for iterating through ``list_kms_configs`` requests. - - This class thinly wraps an initial - :class:`google.cloud.netapp_v1.types.ListKmsConfigsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``kms_configs`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListKmsConfigs`` requests and continue to iterate - through the ``kms_configs`` field on the - corresponding responses. - - All the usual :class:`google.cloud.netapp_v1.types.ListKmsConfigsResponse` - 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[kms.ListKmsConfigsResponse]], - request: kms.ListKmsConfigsRequest, - response: kms.ListKmsConfigsResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.netapp_v1.types.ListKmsConfigsRequest): - The initial request object. - response (google.cloud.netapp_v1.types.ListKmsConfigsResponse): - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = kms.ListKmsConfigsRequest(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[kms.ListKmsConfigsResponse]: - 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[kms.KmsConfig]: - async def async_generator(): - async for page in self.pages: - for response in page.kms_configs: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListReplicationsPager: - """A pager for iterating through ``list_replications`` requests. - - This class thinly wraps an initial - :class:`google.cloud.netapp_v1.types.ListReplicationsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``replications`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListReplications`` requests and continue to iterate - through the ``replications`` field on the - corresponding responses. - - All the usual :class:`google.cloud.netapp_v1.types.ListReplicationsResponse` - 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[..., replication.ListReplicationsResponse], - request: replication.ListReplicationsRequest, - response: replication.ListReplicationsResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.netapp_v1.types.ListReplicationsRequest): - The initial request object. - response (google.cloud.netapp_v1.types.ListReplicationsResponse): - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = replication.ListReplicationsRequest(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[replication.ListReplicationsResponse]: - 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[replication.Replication]: - for page in self.pages: - yield from page.replications - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListReplicationsAsyncPager: - """A pager for iterating through ``list_replications`` requests. - - This class thinly wraps an initial - :class:`google.cloud.netapp_v1.types.ListReplicationsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``replications`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListReplications`` requests and continue to iterate - through the ``replications`` field on the - corresponding responses. - - All the usual :class:`google.cloud.netapp_v1.types.ListReplicationsResponse` - 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[replication.ListReplicationsResponse]], - request: replication.ListReplicationsRequest, - response: replication.ListReplicationsResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.netapp_v1.types.ListReplicationsRequest): - The initial request object. - response (google.cloud.netapp_v1.types.ListReplicationsResponse): - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = replication.ListReplicationsRequest(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[replication.ListReplicationsResponse]: - 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[replication.Replication]: - async def async_generator(): - async for page in self.pages: - for response in page.replications: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListBackupVaultsPager: - """A pager for iterating through ``list_backup_vaults`` requests. - - This class thinly wraps an initial - :class:`google.cloud.netapp_v1.types.ListBackupVaultsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``backup_vaults`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListBackupVaults`` requests and continue to iterate - through the ``backup_vaults`` field on the - corresponding responses. - - All the usual :class:`google.cloud.netapp_v1.types.ListBackupVaultsResponse` - 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[..., backup_vault.ListBackupVaultsResponse], - request: backup_vault.ListBackupVaultsRequest, - response: backup_vault.ListBackupVaultsResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.netapp_v1.types.ListBackupVaultsRequest): - The initial request object. - response (google.cloud.netapp_v1.types.ListBackupVaultsResponse): - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = backup_vault.ListBackupVaultsRequest(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[backup_vault.ListBackupVaultsResponse]: - 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[backup_vault.BackupVault]: - for page in self.pages: - yield from page.backup_vaults - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListBackupVaultsAsyncPager: - """A pager for iterating through ``list_backup_vaults`` requests. - - This class thinly wraps an initial - :class:`google.cloud.netapp_v1.types.ListBackupVaultsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``backup_vaults`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListBackupVaults`` requests and continue to iterate - through the ``backup_vaults`` field on the - corresponding responses. - - All the usual :class:`google.cloud.netapp_v1.types.ListBackupVaultsResponse` - 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[backup_vault.ListBackupVaultsResponse]], - request: backup_vault.ListBackupVaultsRequest, - response: backup_vault.ListBackupVaultsResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.netapp_v1.types.ListBackupVaultsRequest): - The initial request object. - response (google.cloud.netapp_v1.types.ListBackupVaultsResponse): - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = backup_vault.ListBackupVaultsRequest(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[backup_vault.ListBackupVaultsResponse]: - 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[backup_vault.BackupVault]: - async def async_generator(): - async for page in self.pages: - for response in page.backup_vaults: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListBackupsPager: - """A pager for iterating through ``list_backups`` requests. - - This class thinly wraps an initial - :class:`google.cloud.netapp_v1.types.ListBackupsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``backups`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListBackups`` requests and continue to iterate - through the ``backups`` field on the - corresponding responses. - - All the usual :class:`google.cloud.netapp_v1.types.ListBackupsResponse` - 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[..., backup.ListBackupsResponse], - request: backup.ListBackupsRequest, - response: backup.ListBackupsResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.netapp_v1.types.ListBackupsRequest): - The initial request object. - response (google.cloud.netapp_v1.types.ListBackupsResponse): - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = backup.ListBackupsRequest(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[backup.ListBackupsResponse]: - 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[backup.Backup]: - for page in self.pages: - yield from page.backups - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListBackupsAsyncPager: - """A pager for iterating through ``list_backups`` requests. - - This class thinly wraps an initial - :class:`google.cloud.netapp_v1.types.ListBackupsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``backups`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListBackups`` requests and continue to iterate - through the ``backups`` field on the - corresponding responses. - - All the usual :class:`google.cloud.netapp_v1.types.ListBackupsResponse` - 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[backup.ListBackupsResponse]], - request: backup.ListBackupsRequest, - response: backup.ListBackupsResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.netapp_v1.types.ListBackupsRequest): - The initial request object. - response (google.cloud.netapp_v1.types.ListBackupsResponse): - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = backup.ListBackupsRequest(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[backup.ListBackupsResponse]: - 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[backup.Backup]: - async def async_generator(): - async for page in self.pages: - for response in page.backups: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListBackupPoliciesPager: - """A pager for iterating through ``list_backup_policies`` requests. - - This class thinly wraps an initial - :class:`google.cloud.netapp_v1.types.ListBackupPoliciesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``backup_policies`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListBackupPolicies`` requests and continue to iterate - through the ``backup_policies`` field on the - corresponding responses. - - All the usual :class:`google.cloud.netapp_v1.types.ListBackupPoliciesResponse` - 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[..., backup_policy.ListBackupPoliciesResponse], - request: backup_policy.ListBackupPoliciesRequest, - response: backup_policy.ListBackupPoliciesResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.netapp_v1.types.ListBackupPoliciesRequest): - The initial request object. - response (google.cloud.netapp_v1.types.ListBackupPoliciesResponse): - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = backup_policy.ListBackupPoliciesRequest(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[backup_policy.ListBackupPoliciesResponse]: - 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[backup_policy.BackupPolicy]: - for page in self.pages: - yield from page.backup_policies - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListBackupPoliciesAsyncPager: - """A pager for iterating through ``list_backup_policies`` requests. - - This class thinly wraps an initial - :class:`google.cloud.netapp_v1.types.ListBackupPoliciesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``backup_policies`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListBackupPolicies`` requests and continue to iterate - through the ``backup_policies`` field on the - corresponding responses. - - All the usual :class:`google.cloud.netapp_v1.types.ListBackupPoliciesResponse` - 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[backup_policy.ListBackupPoliciesResponse]], - request: backup_policy.ListBackupPoliciesRequest, - response: backup_policy.ListBackupPoliciesResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.netapp_v1.types.ListBackupPoliciesRequest): - The initial request object. - response (google.cloud.netapp_v1.types.ListBackupPoliciesResponse): - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = backup_policy.ListBackupPoliciesRequest(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[backup_policy.ListBackupPoliciesResponse]: - 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[backup_policy.BackupPolicy]: - async def async_generator(): - async for page in self.pages: - for response in page.backup_policies: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListQuotaRulesPager: - """A pager for iterating through ``list_quota_rules`` requests. - - This class thinly wraps an initial - :class:`google.cloud.netapp_v1.types.ListQuotaRulesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``quota_rules`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListQuotaRules`` requests and continue to iterate - through the ``quota_rules`` field on the - corresponding responses. - - All the usual :class:`google.cloud.netapp_v1.types.ListQuotaRulesResponse` - 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[..., quota_rule.ListQuotaRulesResponse], - request: quota_rule.ListQuotaRulesRequest, - response: quota_rule.ListQuotaRulesResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.netapp_v1.types.ListQuotaRulesRequest): - The initial request object. - response (google.cloud.netapp_v1.types.ListQuotaRulesResponse): - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = quota_rule.ListQuotaRulesRequest(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[quota_rule.ListQuotaRulesResponse]: - 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[quota_rule.QuotaRule]: - for page in self.pages: - yield from page.quota_rules - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListQuotaRulesAsyncPager: - """A pager for iterating through ``list_quota_rules`` requests. - - This class thinly wraps an initial - :class:`google.cloud.netapp_v1.types.ListQuotaRulesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``quota_rules`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListQuotaRules`` requests and continue to iterate - through the ``quota_rules`` field on the - corresponding responses. - - All the usual :class:`google.cloud.netapp_v1.types.ListQuotaRulesResponse` - 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[quota_rule.ListQuotaRulesResponse]], - request: quota_rule.ListQuotaRulesRequest, - response: quota_rule.ListQuotaRulesResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.netapp_v1.types.ListQuotaRulesRequest): - The initial request object. - response (google.cloud.netapp_v1.types.ListQuotaRulesResponse): - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = quota_rule.ListQuotaRulesRequest(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[quota_rule.ListQuotaRulesResponse]: - 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[quota_rule.QuotaRule]: - async def async_generator(): - async for page in self.pages: - for response in page.quota_rules: - 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-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/README.rst b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/README.rst deleted file mode 100644 index 16bd00900281..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/README.rst +++ /dev/null @@ -1,9 +0,0 @@ - -transport inheritance structure -_______________________________ - -`NetAppTransport` is the ABC for all transports. -- public child `NetAppGrpcTransport` for sync gRPC transport (defined in `grpc.py`). -- public child `NetAppGrpcAsyncIOTransport` for async gRPC transport (defined in `grpc_asyncio.py`). -- private child `_BaseNetAppRestTransport` for base REST transport with inner classes `_BaseMETHOD` (defined in `rest_base.py`). -- public child `NetAppRestTransport` 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-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/__init__.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/__init__.py deleted file mode 100644 index 4e551ab78d20..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/__init__.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 NetAppTransport -from .grpc import NetAppGrpcTransport -from .grpc_asyncio import NetAppGrpcAsyncIOTransport -from .rest import NetAppRestTransport -from .rest import NetAppRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[NetAppTransport]] -_transport_registry['grpc'] = NetAppGrpcTransport -_transport_registry['grpc_asyncio'] = NetAppGrpcAsyncIOTransport -_transport_registry['rest'] = NetAppRestTransport - -__all__ = ( - 'NetAppTransport', - 'NetAppGrpcTransport', - 'NetAppGrpcAsyncIOTransport', - 'NetAppRestTransport', - 'NetAppRestInterceptor', -) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/base.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/base.py deleted file mode 100644 index bd582c4a0b82..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/base.py +++ /dev/null @@ -1,1251 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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.netapp_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.location import locations_pb2 # type: ignore -from google.cloud.netapp_v1.types import active_directory -from google.cloud.netapp_v1.types import active_directory as gcn_active_directory -from google.cloud.netapp_v1.types import backup -from google.cloud.netapp_v1.types import backup as gcn_backup -from google.cloud.netapp_v1.types import backup_policy -from google.cloud.netapp_v1.types import backup_policy as gcn_backup_policy -from google.cloud.netapp_v1.types import backup_vault -from google.cloud.netapp_v1.types import backup_vault as gcn_backup_vault -from google.cloud.netapp_v1.types import kms -from google.cloud.netapp_v1.types import quota_rule -from google.cloud.netapp_v1.types import quota_rule as gcn_quota_rule -from google.cloud.netapp_v1.types import replication -from google.cloud.netapp_v1.types import replication as gcn_replication -from google.cloud.netapp_v1.types import snapshot -from google.cloud.netapp_v1.types import snapshot as gcn_snapshot -from google.cloud.netapp_v1.types import storage_pool -from google.cloud.netapp_v1.types import storage_pool as gcn_storage_pool -from google.cloud.netapp_v1.types import volume -from google.cloud.netapp_v1.types import volume as gcn_volume -from google.longrunning import operations_pb2 # type: ignore - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -class NetAppTransport(abc.ABC): - """Abstract transport class for NetApp.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - ) - - DEFAULT_HOST: str = 'netapp.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: 'netapp.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_storage_pools: gapic_v1.method.wrap_method( - self.list_storage_pools, - default_retry=retries.Retry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.create_storage_pool: gapic_v1.method.wrap_method( - self.create_storage_pool, - default_timeout=60.0, - client_info=client_info, - ), - self.get_storage_pool: gapic_v1.method.wrap_method( - self.get_storage_pool, - default_retry=retries.Retry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.update_storage_pool: gapic_v1.method.wrap_method( - self.update_storage_pool, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_storage_pool: gapic_v1.method.wrap_method( - self.delete_storage_pool, - default_timeout=60.0, - client_info=client_info, - ), - self.validate_directory_service: gapic_v1.method.wrap_method( - self.validate_directory_service, - default_timeout=None, - client_info=client_info, - ), - self.switch_active_replica_zone: gapic_v1.method.wrap_method( - self.switch_active_replica_zone, - default_timeout=None, - client_info=client_info, - ), - self.list_volumes: gapic_v1.method.wrap_method( - self.list_volumes, - default_retry=retries.Retry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.get_volume: gapic_v1.method.wrap_method( - self.get_volume, - default_retry=retries.Retry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.create_volume: gapic_v1.method.wrap_method( - self.create_volume, - default_timeout=60.0, - client_info=client_info, - ), - self.update_volume: gapic_v1.method.wrap_method( - self.update_volume, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_volume: gapic_v1.method.wrap_method( - self.delete_volume, - default_timeout=60.0, - client_info=client_info, - ), - self.revert_volume: gapic_v1.method.wrap_method( - self.revert_volume, - default_timeout=60.0, - client_info=client_info, - ), - self.list_snapshots: gapic_v1.method.wrap_method( - self.list_snapshots, - default_retry=retries.Retry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.get_snapshot: gapic_v1.method.wrap_method( - self.get_snapshot, - default_retry=retries.Retry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.create_snapshot: gapic_v1.method.wrap_method( - self.create_snapshot, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_snapshot: gapic_v1.method.wrap_method( - self.delete_snapshot, - default_timeout=60.0, - client_info=client_info, - ), - self.update_snapshot: gapic_v1.method.wrap_method( - self.update_snapshot, - default_timeout=60.0, - client_info=client_info, - ), - self.list_active_directories: gapic_v1.method.wrap_method( - self.list_active_directories, - default_retry=retries.Retry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.get_active_directory: gapic_v1.method.wrap_method( - self.get_active_directory, - default_retry=retries.Retry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.create_active_directory: gapic_v1.method.wrap_method( - self.create_active_directory, - default_timeout=60.0, - client_info=client_info, - ), - self.update_active_directory: gapic_v1.method.wrap_method( - self.update_active_directory, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_active_directory: gapic_v1.method.wrap_method( - self.delete_active_directory, - default_timeout=60.0, - client_info=client_info, - ), - self.list_kms_configs: gapic_v1.method.wrap_method( - self.list_kms_configs, - default_retry=retries.Retry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.create_kms_config: gapic_v1.method.wrap_method( - self.create_kms_config, - default_timeout=60.0, - client_info=client_info, - ), - self.get_kms_config: gapic_v1.method.wrap_method( - self.get_kms_config, - default_retry=retries.Retry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.update_kms_config: gapic_v1.method.wrap_method( - self.update_kms_config, - default_timeout=60.0, - client_info=client_info, - ), - self.encrypt_volumes: gapic_v1.method.wrap_method( - self.encrypt_volumes, - default_timeout=60.0, - client_info=client_info, - ), - self.verify_kms_config: gapic_v1.method.wrap_method( - self.verify_kms_config, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_kms_config: gapic_v1.method.wrap_method( - self.delete_kms_config, - default_timeout=60.0, - client_info=client_info, - ), - self.list_replications: gapic_v1.method.wrap_method( - self.list_replications, - default_retry=retries.Retry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.get_replication: gapic_v1.method.wrap_method( - self.get_replication, - default_retry=retries.Retry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.create_replication: gapic_v1.method.wrap_method( - self.create_replication, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_replication: gapic_v1.method.wrap_method( - self.delete_replication, - default_timeout=60.0, - client_info=client_info, - ), - self.update_replication: gapic_v1.method.wrap_method( - self.update_replication, - default_timeout=60.0, - client_info=client_info, - ), - self.stop_replication: gapic_v1.method.wrap_method( - self.stop_replication, - default_timeout=60.0, - client_info=client_info, - ), - self.resume_replication: gapic_v1.method.wrap_method( - self.resume_replication, - default_timeout=60.0, - client_info=client_info, - ), - self.reverse_replication_direction: gapic_v1.method.wrap_method( - self.reverse_replication_direction, - default_timeout=60.0, - client_info=client_info, - ), - self.establish_peering: gapic_v1.method.wrap_method( - self.establish_peering, - default_timeout=None, - client_info=client_info, - ), - self.sync_replication: gapic_v1.method.wrap_method( - self.sync_replication, - default_timeout=None, - client_info=client_info, - ), - self.create_backup_vault: gapic_v1.method.wrap_method( - self.create_backup_vault, - default_timeout=60.0, - client_info=client_info, - ), - self.get_backup_vault: gapic_v1.method.wrap_method( - self.get_backup_vault, - default_retry=retries.Retry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.list_backup_vaults: gapic_v1.method.wrap_method( - self.list_backup_vaults, - default_retry=retries.Retry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.update_backup_vault: gapic_v1.method.wrap_method( - self.update_backup_vault, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_backup_vault: gapic_v1.method.wrap_method( - self.delete_backup_vault, - default_timeout=60.0, - client_info=client_info, - ), - self.create_backup: gapic_v1.method.wrap_method( - self.create_backup, - default_timeout=60.0, - client_info=client_info, - ), - self.get_backup: gapic_v1.method.wrap_method( - self.get_backup, - default_retry=retries.Retry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.list_backups: gapic_v1.method.wrap_method( - self.list_backups, - default_retry=retries.Retry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.delete_backup: gapic_v1.method.wrap_method( - self.delete_backup, - default_timeout=60.0, - client_info=client_info, - ), - self.update_backup: gapic_v1.method.wrap_method( - self.update_backup, - default_timeout=60.0, - client_info=client_info, - ), - self.create_backup_policy: gapic_v1.method.wrap_method( - self.create_backup_policy, - default_timeout=60.0, - client_info=client_info, - ), - self.get_backup_policy: gapic_v1.method.wrap_method( - self.get_backup_policy, - default_retry=retries.Retry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.list_backup_policies: gapic_v1.method.wrap_method( - self.list_backup_policies, - default_retry=retries.Retry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.update_backup_policy: gapic_v1.method.wrap_method( - self.update_backup_policy, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_backup_policy: gapic_v1.method.wrap_method( - self.delete_backup_policy, - default_timeout=60.0, - client_info=client_info, - ), - self.list_quota_rules: gapic_v1.method.wrap_method( - self.list_quota_rules, - default_timeout=None, - client_info=client_info, - ), - self.get_quota_rule: gapic_v1.method.wrap_method( - self.get_quota_rule, - default_timeout=None, - client_info=client_info, - ), - self.create_quota_rule: gapic_v1.method.wrap_method( - self.create_quota_rule, - default_timeout=None, - client_info=client_info, - ), - self.update_quota_rule: gapic_v1.method.wrap_method( - self.update_quota_rule, - default_timeout=None, - client_info=client_info, - ), - self.delete_quota_rule: gapic_v1.method.wrap_method( - self.delete_quota_rule, - 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.cancel_operation: gapic_v1.method.wrap_method( - self.cancel_operation, - default_timeout=None, - client_info=client_info, - ), - self.delete_operation: gapic_v1.method.wrap_method( - self.delete_operation, - 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, - ), - self.list_operations: gapic_v1.method.wrap_method( - self.list_operations, - 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_storage_pools(self) -> Callable[ - [storage_pool.ListStoragePoolsRequest], - Union[ - storage_pool.ListStoragePoolsResponse, - Awaitable[storage_pool.ListStoragePoolsResponse] - ]]: - raise NotImplementedError() - - @property - def create_storage_pool(self) -> Callable[ - [gcn_storage_pool.CreateStoragePoolRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def get_storage_pool(self) -> Callable[ - [storage_pool.GetStoragePoolRequest], - Union[ - storage_pool.StoragePool, - Awaitable[storage_pool.StoragePool] - ]]: - raise NotImplementedError() - - @property - def update_storage_pool(self) -> Callable[ - [gcn_storage_pool.UpdateStoragePoolRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_storage_pool(self) -> Callable[ - [storage_pool.DeleteStoragePoolRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def validate_directory_service(self) -> Callable[ - [storage_pool.ValidateDirectoryServiceRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def switch_active_replica_zone(self) -> Callable[ - [storage_pool.SwitchActiveReplicaZoneRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_volumes(self) -> Callable[ - [volume.ListVolumesRequest], - Union[ - volume.ListVolumesResponse, - Awaitable[volume.ListVolumesResponse] - ]]: - raise NotImplementedError() - - @property - def get_volume(self) -> Callable[ - [volume.GetVolumeRequest], - Union[ - volume.Volume, - Awaitable[volume.Volume] - ]]: - raise NotImplementedError() - - @property - def create_volume(self) -> Callable[ - [gcn_volume.CreateVolumeRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_volume(self) -> Callable[ - [gcn_volume.UpdateVolumeRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_volume(self) -> Callable[ - [volume.DeleteVolumeRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def revert_volume(self) -> Callable[ - [volume.RevertVolumeRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_snapshots(self) -> Callable[ - [snapshot.ListSnapshotsRequest], - Union[ - snapshot.ListSnapshotsResponse, - Awaitable[snapshot.ListSnapshotsResponse] - ]]: - raise NotImplementedError() - - @property - def get_snapshot(self) -> Callable[ - [snapshot.GetSnapshotRequest], - Union[ - snapshot.Snapshot, - Awaitable[snapshot.Snapshot] - ]]: - raise NotImplementedError() - - @property - def create_snapshot(self) -> Callable[ - [gcn_snapshot.CreateSnapshotRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_snapshot(self) -> Callable[ - [snapshot.DeleteSnapshotRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_snapshot(self) -> Callable[ - [gcn_snapshot.UpdateSnapshotRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_active_directories(self) -> Callable[ - [active_directory.ListActiveDirectoriesRequest], - Union[ - active_directory.ListActiveDirectoriesResponse, - Awaitable[active_directory.ListActiveDirectoriesResponse] - ]]: - raise NotImplementedError() - - @property - def get_active_directory(self) -> Callable[ - [active_directory.GetActiveDirectoryRequest], - Union[ - active_directory.ActiveDirectory, - Awaitable[active_directory.ActiveDirectory] - ]]: - raise NotImplementedError() - - @property - def create_active_directory(self) -> Callable[ - [gcn_active_directory.CreateActiveDirectoryRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_active_directory(self) -> Callable[ - [gcn_active_directory.UpdateActiveDirectoryRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_active_directory(self) -> Callable[ - [active_directory.DeleteActiveDirectoryRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_kms_configs(self) -> Callable[ - [kms.ListKmsConfigsRequest], - Union[ - kms.ListKmsConfigsResponse, - Awaitable[kms.ListKmsConfigsResponse] - ]]: - raise NotImplementedError() - - @property - def create_kms_config(self) -> Callable[ - [kms.CreateKmsConfigRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def get_kms_config(self) -> Callable[ - [kms.GetKmsConfigRequest], - Union[ - kms.KmsConfig, - Awaitable[kms.KmsConfig] - ]]: - raise NotImplementedError() - - @property - def update_kms_config(self) -> Callable[ - [kms.UpdateKmsConfigRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def encrypt_volumes(self) -> Callable[ - [kms.EncryptVolumesRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def verify_kms_config(self) -> Callable[ - [kms.VerifyKmsConfigRequest], - Union[ - kms.VerifyKmsConfigResponse, - Awaitable[kms.VerifyKmsConfigResponse] - ]]: - raise NotImplementedError() - - @property - def delete_kms_config(self) -> Callable[ - [kms.DeleteKmsConfigRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_replications(self) -> Callable[ - [replication.ListReplicationsRequest], - Union[ - replication.ListReplicationsResponse, - Awaitable[replication.ListReplicationsResponse] - ]]: - raise NotImplementedError() - - @property - def get_replication(self) -> Callable[ - [replication.GetReplicationRequest], - Union[ - replication.Replication, - Awaitable[replication.Replication] - ]]: - raise NotImplementedError() - - @property - def create_replication(self) -> Callable[ - [gcn_replication.CreateReplicationRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_replication(self) -> Callable[ - [replication.DeleteReplicationRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_replication(self) -> Callable[ - [gcn_replication.UpdateReplicationRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def stop_replication(self) -> Callable[ - [replication.StopReplicationRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def resume_replication(self) -> Callable[ - [replication.ResumeReplicationRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def reverse_replication_direction(self) -> Callable[ - [replication.ReverseReplicationDirectionRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def establish_peering(self) -> Callable[ - [replication.EstablishPeeringRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def sync_replication(self) -> Callable[ - [replication.SyncReplicationRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def create_backup_vault(self) -> Callable[ - [gcn_backup_vault.CreateBackupVaultRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def get_backup_vault(self) -> Callable[ - [backup_vault.GetBackupVaultRequest], - Union[ - backup_vault.BackupVault, - Awaitable[backup_vault.BackupVault] - ]]: - raise NotImplementedError() - - @property - def list_backup_vaults(self) -> Callable[ - [backup_vault.ListBackupVaultsRequest], - Union[ - backup_vault.ListBackupVaultsResponse, - Awaitable[backup_vault.ListBackupVaultsResponse] - ]]: - raise NotImplementedError() - - @property - def update_backup_vault(self) -> Callable[ - [gcn_backup_vault.UpdateBackupVaultRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_backup_vault(self) -> Callable[ - [backup_vault.DeleteBackupVaultRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def create_backup(self) -> Callable[ - [gcn_backup.CreateBackupRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def get_backup(self) -> Callable[ - [backup.GetBackupRequest], - Union[ - backup.Backup, - Awaitable[backup.Backup] - ]]: - raise NotImplementedError() - - @property - def list_backups(self) -> Callable[ - [backup.ListBackupsRequest], - Union[ - backup.ListBackupsResponse, - Awaitable[backup.ListBackupsResponse] - ]]: - raise NotImplementedError() - - @property - def delete_backup(self) -> Callable[ - [backup.DeleteBackupRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_backup(self) -> Callable[ - [gcn_backup.UpdateBackupRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def create_backup_policy(self) -> Callable[ - [gcn_backup_policy.CreateBackupPolicyRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def get_backup_policy(self) -> Callable[ - [backup_policy.GetBackupPolicyRequest], - Union[ - backup_policy.BackupPolicy, - Awaitable[backup_policy.BackupPolicy] - ]]: - raise NotImplementedError() - - @property - def list_backup_policies(self) -> Callable[ - [backup_policy.ListBackupPoliciesRequest], - Union[ - backup_policy.ListBackupPoliciesResponse, - Awaitable[backup_policy.ListBackupPoliciesResponse] - ]]: - raise NotImplementedError() - - @property - def update_backup_policy(self) -> Callable[ - [gcn_backup_policy.UpdateBackupPolicyRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_backup_policy(self) -> Callable[ - [backup_policy.DeleteBackupPolicyRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_quota_rules(self) -> Callable[ - [quota_rule.ListQuotaRulesRequest], - Union[ - quota_rule.ListQuotaRulesResponse, - Awaitable[quota_rule.ListQuotaRulesResponse] - ]]: - raise NotImplementedError() - - @property - def get_quota_rule(self) -> Callable[ - [quota_rule.GetQuotaRuleRequest], - Union[ - quota_rule.QuotaRule, - Awaitable[quota_rule.QuotaRule] - ]]: - raise NotImplementedError() - - @property - def create_quota_rule(self) -> Callable[ - [gcn_quota_rule.CreateQuotaRuleRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_quota_rule(self) -> Callable[ - [gcn_quota_rule.UpdateQuotaRuleRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_quota_rule(self) -> Callable[ - [quota_rule.DeleteQuotaRuleRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_operations( - self, - ) -> Callable[ - [operations_pb2.ListOperationsRequest], - Union[operations_pb2.ListOperationsResponse, Awaitable[operations_pb2.ListOperationsResponse]], - ]: - raise NotImplementedError() - - @property - def get_operation( - self, - ) -> Callable[ - [operations_pb2.GetOperationRequest], - Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], - ]: - raise NotImplementedError() - - @property - def cancel_operation( - self, - ) -> Callable[ - [operations_pb2.CancelOperationRequest], - None, - ]: - raise NotImplementedError() - - @property - def delete_operation( - self, - ) -> Callable[ - [operations_pb2.DeleteOperationRequest], - None, - ]: - 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__ = ( - 'NetAppTransport', -) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/grpc.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/grpc.py deleted file mode 100644 index 0030b7b37801..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/grpc.py +++ /dev/null @@ -1,2052 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 -import logging as std_logging -import pickle -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 -from google.protobuf.json_format import MessageToJson -import google.protobuf.message - -import grpc # type: ignore -import proto # type: ignore - -from google.cloud.location import locations_pb2 # type: ignore -from google.cloud.netapp_v1.types import active_directory -from google.cloud.netapp_v1.types import active_directory as gcn_active_directory -from google.cloud.netapp_v1.types import backup -from google.cloud.netapp_v1.types import backup as gcn_backup -from google.cloud.netapp_v1.types import backup_policy -from google.cloud.netapp_v1.types import backup_policy as gcn_backup_policy -from google.cloud.netapp_v1.types import backup_vault -from google.cloud.netapp_v1.types import backup_vault as gcn_backup_vault -from google.cloud.netapp_v1.types import kms -from google.cloud.netapp_v1.types import quota_rule -from google.cloud.netapp_v1.types import quota_rule as gcn_quota_rule -from google.cloud.netapp_v1.types import replication -from google.cloud.netapp_v1.types import replication as gcn_replication -from google.cloud.netapp_v1.types import snapshot -from google.cloud.netapp_v1.types import snapshot as gcn_snapshot -from google.cloud.netapp_v1.types import storage_pool -from google.cloud.netapp_v1.types import storage_pool as gcn_storage_pool -from google.cloud.netapp_v1.types import volume -from google.cloud.netapp_v1.types import volume as gcn_volume -from google.longrunning import operations_pb2 # type: ignore -from .base import NetAppTransport, DEFAULT_CLIENT_INFO - -try: - from google.api_core import client_logging # type: ignore - CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER -except ImportError: # pragma: NO COVER - CLIENT_LOGGING_SUPPORTED = False - -_LOGGER = std_logging.getLogger(__name__) - - -class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER - def intercept_unary_unary(self, continuation, client_call_details, request): - logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG) - if logging_enabled: # pragma: NO COVER - request_metadata = client_call_details.metadata - if isinstance(request, proto.Message): - request_payload = type(request).to_json(request) - elif isinstance(request, google.protobuf.message.Message): - request_payload = MessageToJson(request) - else: - request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" - - request_metadata = { - key: value.decode("utf-8") if isinstance(value, bytes) else value - for key, value in request_metadata - } - grpc_request = { - "payload": request_payload, - "requestMethod": "grpc", - "metadata": dict(request_metadata), - } - _LOGGER.debug( - f"Sending request for {client_call_details.method}", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": str(client_call_details.method), - "request": grpc_request, - "metadata": grpc_request["metadata"], - }, - ) - response = continuation(client_call_details, request) - if logging_enabled: # pragma: NO COVER - response_metadata = response.trailing_metadata() - # Convert gRPC metadata `` to list of tuples - metadata = dict([(k, str(v)) for k, v in response_metadata]) if response_metadata else None - result = response.result() - if isinstance(result, proto.Message): - response_payload = type(result).to_json(result) - elif isinstance(result, google.protobuf.message.Message): - response_payload = MessageToJson(result) - else: - response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" - grpc_response = { - "payload": response_payload, - "metadata": metadata, - "status": "OK", - } - _LOGGER.debug( - f"Received response for {client_call_details.method}.", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": client_call_details.method, - "response": grpc_response, - "metadata": grpc_response["metadata"], - }, - ) - return response - - -class NetAppGrpcTransport(NetAppTransport): - """gRPC backend transport for NetApp. - - NetApp Files Google Cloud Service - - 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 = 'netapp.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: 'netapp.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), - ], - ) - - self._interceptor = _LoggingClientInterceptor() - self._logged_channel = grpc.intercept_channel(self._grpc_channel, self._interceptor) - - # Wrap messages. This must be done after self._logged_channel exists - self._prep_wrapped_messages(client_info) - - @classmethod - def create_channel(cls, - host: str = 'netapp.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._logged_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def list_storage_pools(self) -> Callable[ - [storage_pool.ListStoragePoolsRequest], - storage_pool.ListStoragePoolsResponse]: - r"""Return a callable for the list storage pools method over gRPC. - - Returns descriptions of all storage pools owned by - the caller. - - Returns: - Callable[[~.ListStoragePoolsRequest], - ~.ListStoragePoolsResponse]: - 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_storage_pools' not in self._stubs: - self._stubs['list_storage_pools'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ListStoragePools', - request_serializer=storage_pool.ListStoragePoolsRequest.serialize, - response_deserializer=storage_pool.ListStoragePoolsResponse.deserialize, - ) - return self._stubs['list_storage_pools'] - - @property - def create_storage_pool(self) -> Callable[ - [gcn_storage_pool.CreateStoragePoolRequest], - operations_pb2.Operation]: - r"""Return a callable for the create storage pool method over gRPC. - - Creates a new storage pool. - - Returns: - Callable[[~.CreateStoragePoolRequest], - ~.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_storage_pool' not in self._stubs: - self._stubs['create_storage_pool'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/CreateStoragePool', - request_serializer=gcn_storage_pool.CreateStoragePoolRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_storage_pool'] - - @property - def get_storage_pool(self) -> Callable[ - [storage_pool.GetStoragePoolRequest], - storage_pool.StoragePool]: - r"""Return a callable for the get storage pool method over gRPC. - - Returns the description of the specified storage pool - by poolId. - - Returns: - Callable[[~.GetStoragePoolRequest], - ~.StoragePool]: - 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_storage_pool' not in self._stubs: - self._stubs['get_storage_pool'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/GetStoragePool', - request_serializer=storage_pool.GetStoragePoolRequest.serialize, - response_deserializer=storage_pool.StoragePool.deserialize, - ) - return self._stubs['get_storage_pool'] - - @property - def update_storage_pool(self) -> Callable[ - [gcn_storage_pool.UpdateStoragePoolRequest], - operations_pb2.Operation]: - r"""Return a callable for the update storage pool method over gRPC. - - Updates the storage pool properties with the full - spec - - Returns: - Callable[[~.UpdateStoragePoolRequest], - ~.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 'update_storage_pool' not in self._stubs: - self._stubs['update_storage_pool'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/UpdateStoragePool', - request_serializer=gcn_storage_pool.UpdateStoragePoolRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_storage_pool'] - - @property - def delete_storage_pool(self) -> Callable[ - [storage_pool.DeleteStoragePoolRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete storage pool method over gRPC. - - Warning! This operation will permanently delete the - storage pool. - - Returns: - Callable[[~.DeleteStoragePoolRequest], - ~.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_storage_pool' not in self._stubs: - self._stubs['delete_storage_pool'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/DeleteStoragePool', - request_serializer=storage_pool.DeleteStoragePoolRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_storage_pool'] - - @property - def validate_directory_service(self) -> Callable[ - [storage_pool.ValidateDirectoryServiceRequest], - operations_pb2.Operation]: - r"""Return a callable for the validate directory service method over gRPC. - - ValidateDirectoryService does a connectivity check - for a directory service policy attached to the storage - pool. - - Returns: - Callable[[~.ValidateDirectoryServiceRequest], - ~.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 'validate_directory_service' not in self._stubs: - self._stubs['validate_directory_service'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ValidateDirectoryService', - request_serializer=storage_pool.ValidateDirectoryServiceRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['validate_directory_service'] - - @property - def switch_active_replica_zone(self) -> Callable[ - [storage_pool.SwitchActiveReplicaZoneRequest], - operations_pb2.Operation]: - r"""Return a callable for the switch active replica zone method over gRPC. - - This operation will switch the active/replica zone - for a regional storagePool. - - Returns: - Callable[[~.SwitchActiveReplicaZoneRequest], - ~.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 'switch_active_replica_zone' not in self._stubs: - self._stubs['switch_active_replica_zone'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/SwitchActiveReplicaZone', - request_serializer=storage_pool.SwitchActiveReplicaZoneRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['switch_active_replica_zone'] - - @property - def list_volumes(self) -> Callable[ - [volume.ListVolumesRequest], - volume.ListVolumesResponse]: - r"""Return a callable for the list volumes method over gRPC. - - Lists Volumes in a given project. - - Returns: - Callable[[~.ListVolumesRequest], - ~.ListVolumesResponse]: - 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_volumes' not in self._stubs: - self._stubs['list_volumes'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ListVolumes', - request_serializer=volume.ListVolumesRequest.serialize, - response_deserializer=volume.ListVolumesResponse.deserialize, - ) - return self._stubs['list_volumes'] - - @property - def get_volume(self) -> Callable[ - [volume.GetVolumeRequest], - volume.Volume]: - r"""Return a callable for the get volume method over gRPC. - - Gets details of a single Volume. - - Returns: - Callable[[~.GetVolumeRequest], - ~.Volume]: - 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_volume' not in self._stubs: - self._stubs['get_volume'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/GetVolume', - request_serializer=volume.GetVolumeRequest.serialize, - response_deserializer=volume.Volume.deserialize, - ) - return self._stubs['get_volume'] - - @property - def create_volume(self) -> Callable[ - [gcn_volume.CreateVolumeRequest], - operations_pb2.Operation]: - r"""Return a callable for the create volume method over gRPC. - - Creates a new Volume in a given project and location. - - Returns: - Callable[[~.CreateVolumeRequest], - ~.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_volume' not in self._stubs: - self._stubs['create_volume'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/CreateVolume', - request_serializer=gcn_volume.CreateVolumeRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_volume'] - - @property - def update_volume(self) -> Callable[ - [gcn_volume.UpdateVolumeRequest], - operations_pb2.Operation]: - r"""Return a callable for the update volume method over gRPC. - - Updates the parameters of a single Volume. - - Returns: - Callable[[~.UpdateVolumeRequest], - ~.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 'update_volume' not in self._stubs: - self._stubs['update_volume'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/UpdateVolume', - request_serializer=gcn_volume.UpdateVolumeRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_volume'] - - @property - def delete_volume(self) -> Callable[ - [volume.DeleteVolumeRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete volume method over gRPC. - - Deletes a single Volume. - - Returns: - Callable[[~.DeleteVolumeRequest], - ~.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_volume' not in self._stubs: - self._stubs['delete_volume'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/DeleteVolume', - request_serializer=volume.DeleteVolumeRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_volume'] - - @property - def revert_volume(self) -> Callable[ - [volume.RevertVolumeRequest], - operations_pb2.Operation]: - r"""Return a callable for the revert volume method over gRPC. - - Revert an existing volume to a specified snapshot. - Warning! This operation will permanently revert all - changes made after the snapshot was created. - - Returns: - Callable[[~.RevertVolumeRequest], - ~.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 'revert_volume' not in self._stubs: - self._stubs['revert_volume'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/RevertVolume', - request_serializer=volume.RevertVolumeRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['revert_volume'] - - @property - def list_snapshots(self) -> Callable[ - [snapshot.ListSnapshotsRequest], - snapshot.ListSnapshotsResponse]: - r"""Return a callable for the list snapshots method over gRPC. - - Returns descriptions of all snapshots for a volume. - - Returns: - Callable[[~.ListSnapshotsRequest], - ~.ListSnapshotsResponse]: - 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_snapshots' not in self._stubs: - self._stubs['list_snapshots'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ListSnapshots', - request_serializer=snapshot.ListSnapshotsRequest.serialize, - response_deserializer=snapshot.ListSnapshotsResponse.deserialize, - ) - return self._stubs['list_snapshots'] - - @property - def get_snapshot(self) -> Callable[ - [snapshot.GetSnapshotRequest], - snapshot.Snapshot]: - r"""Return a callable for the get snapshot method over gRPC. - - Describe a snapshot for a volume. - - Returns: - Callable[[~.GetSnapshotRequest], - ~.Snapshot]: - 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_snapshot' not in self._stubs: - self._stubs['get_snapshot'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/GetSnapshot', - request_serializer=snapshot.GetSnapshotRequest.serialize, - response_deserializer=snapshot.Snapshot.deserialize, - ) - return self._stubs['get_snapshot'] - - @property - def create_snapshot(self) -> Callable[ - [gcn_snapshot.CreateSnapshotRequest], - operations_pb2.Operation]: - r"""Return a callable for the create snapshot method over gRPC. - - Create a new snapshot for a volume. - - Returns: - Callable[[~.CreateSnapshotRequest], - ~.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_snapshot' not in self._stubs: - self._stubs['create_snapshot'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/CreateSnapshot', - request_serializer=gcn_snapshot.CreateSnapshotRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_snapshot'] - - @property - def delete_snapshot(self) -> Callable[ - [snapshot.DeleteSnapshotRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete snapshot method over gRPC. - - Deletes a snapshot. - - Returns: - Callable[[~.DeleteSnapshotRequest], - ~.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_snapshot' not in self._stubs: - self._stubs['delete_snapshot'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/DeleteSnapshot', - request_serializer=snapshot.DeleteSnapshotRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_snapshot'] - - @property - def update_snapshot(self) -> Callable[ - [gcn_snapshot.UpdateSnapshotRequest], - operations_pb2.Operation]: - r"""Return a callable for the update snapshot method over gRPC. - - Updates the settings of a specific snapshot. - - Returns: - Callable[[~.UpdateSnapshotRequest], - ~.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 'update_snapshot' not in self._stubs: - self._stubs['update_snapshot'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/UpdateSnapshot', - request_serializer=gcn_snapshot.UpdateSnapshotRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_snapshot'] - - @property - def list_active_directories(self) -> Callable[ - [active_directory.ListActiveDirectoriesRequest], - active_directory.ListActiveDirectoriesResponse]: - r"""Return a callable for the list active directories method over gRPC. - - Lists active directories. - - Returns: - Callable[[~.ListActiveDirectoriesRequest], - ~.ListActiveDirectoriesResponse]: - 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_active_directories' not in self._stubs: - self._stubs['list_active_directories'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ListActiveDirectories', - request_serializer=active_directory.ListActiveDirectoriesRequest.serialize, - response_deserializer=active_directory.ListActiveDirectoriesResponse.deserialize, - ) - return self._stubs['list_active_directories'] - - @property - def get_active_directory(self) -> Callable[ - [active_directory.GetActiveDirectoryRequest], - active_directory.ActiveDirectory]: - r"""Return a callable for the get active directory method over gRPC. - - Describes a specified active directory. - - Returns: - Callable[[~.GetActiveDirectoryRequest], - ~.ActiveDirectory]: - 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_active_directory' not in self._stubs: - self._stubs['get_active_directory'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/GetActiveDirectory', - request_serializer=active_directory.GetActiveDirectoryRequest.serialize, - response_deserializer=active_directory.ActiveDirectory.deserialize, - ) - return self._stubs['get_active_directory'] - - @property - def create_active_directory(self) -> Callable[ - [gcn_active_directory.CreateActiveDirectoryRequest], - operations_pb2.Operation]: - r"""Return a callable for the create active directory method over gRPC. - - CreateActiveDirectory - Creates the active directory specified in the request. - - Returns: - Callable[[~.CreateActiveDirectoryRequest], - ~.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_active_directory' not in self._stubs: - self._stubs['create_active_directory'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/CreateActiveDirectory', - request_serializer=gcn_active_directory.CreateActiveDirectoryRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_active_directory'] - - @property - def update_active_directory(self) -> Callable[ - [gcn_active_directory.UpdateActiveDirectoryRequest], - operations_pb2.Operation]: - r"""Return a callable for the update active directory method over gRPC. - - Update the parameters of an active directories. - - Returns: - Callable[[~.UpdateActiveDirectoryRequest], - ~.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 'update_active_directory' not in self._stubs: - self._stubs['update_active_directory'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/UpdateActiveDirectory', - request_serializer=gcn_active_directory.UpdateActiveDirectoryRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_active_directory'] - - @property - def delete_active_directory(self) -> Callable[ - [active_directory.DeleteActiveDirectoryRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete active directory method over gRPC. - - Delete the active directory specified in the request. - - Returns: - Callable[[~.DeleteActiveDirectoryRequest], - ~.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_active_directory' not in self._stubs: - self._stubs['delete_active_directory'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/DeleteActiveDirectory', - request_serializer=active_directory.DeleteActiveDirectoryRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_active_directory'] - - @property - def list_kms_configs(self) -> Callable[ - [kms.ListKmsConfigsRequest], - kms.ListKmsConfigsResponse]: - r"""Return a callable for the list kms configs method over gRPC. - - Returns descriptions of all KMS configs owned by the - caller. - - Returns: - Callable[[~.ListKmsConfigsRequest], - ~.ListKmsConfigsResponse]: - 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_kms_configs' not in self._stubs: - self._stubs['list_kms_configs'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ListKmsConfigs', - request_serializer=kms.ListKmsConfigsRequest.serialize, - response_deserializer=kms.ListKmsConfigsResponse.deserialize, - ) - return self._stubs['list_kms_configs'] - - @property - def create_kms_config(self) -> Callable[ - [kms.CreateKmsConfigRequest], - operations_pb2.Operation]: - r"""Return a callable for the create kms config method over gRPC. - - Creates a new KMS config. - - Returns: - Callable[[~.CreateKmsConfigRequest], - ~.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_kms_config' not in self._stubs: - self._stubs['create_kms_config'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/CreateKmsConfig', - request_serializer=kms.CreateKmsConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_kms_config'] - - @property - def get_kms_config(self) -> Callable[ - [kms.GetKmsConfigRequest], - kms.KmsConfig]: - r"""Return a callable for the get kms config method over gRPC. - - Returns the description of the specified KMS config by - kms_config_id. - - Returns: - Callable[[~.GetKmsConfigRequest], - ~.KmsConfig]: - 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_kms_config' not in self._stubs: - self._stubs['get_kms_config'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/GetKmsConfig', - request_serializer=kms.GetKmsConfigRequest.serialize, - response_deserializer=kms.KmsConfig.deserialize, - ) - return self._stubs['get_kms_config'] - - @property - def update_kms_config(self) -> Callable[ - [kms.UpdateKmsConfigRequest], - operations_pb2.Operation]: - r"""Return a callable for the update kms config method over gRPC. - - Updates the Kms config properties with the full spec - - Returns: - Callable[[~.UpdateKmsConfigRequest], - ~.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 'update_kms_config' not in self._stubs: - self._stubs['update_kms_config'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/UpdateKmsConfig', - request_serializer=kms.UpdateKmsConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_kms_config'] - - @property - def encrypt_volumes(self) -> Callable[ - [kms.EncryptVolumesRequest], - operations_pb2.Operation]: - r"""Return a callable for the encrypt volumes method over gRPC. - - Encrypt the existing volumes without CMEK encryption - with the desired the KMS config for the whole region. - - Returns: - Callable[[~.EncryptVolumesRequest], - ~.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 'encrypt_volumes' not in self._stubs: - self._stubs['encrypt_volumes'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/EncryptVolumes', - request_serializer=kms.EncryptVolumesRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['encrypt_volumes'] - - @property - def verify_kms_config(self) -> Callable[ - [kms.VerifyKmsConfigRequest], - kms.VerifyKmsConfigResponse]: - r"""Return a callable for the verify kms config method over gRPC. - - Verifies KMS config reachability. - - Returns: - Callable[[~.VerifyKmsConfigRequest], - ~.VerifyKmsConfigResponse]: - 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 'verify_kms_config' not in self._stubs: - self._stubs['verify_kms_config'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/VerifyKmsConfig', - request_serializer=kms.VerifyKmsConfigRequest.serialize, - response_deserializer=kms.VerifyKmsConfigResponse.deserialize, - ) - return self._stubs['verify_kms_config'] - - @property - def delete_kms_config(self) -> Callable[ - [kms.DeleteKmsConfigRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete kms config method over gRPC. - - Warning! This operation will permanently delete the - Kms config. - - Returns: - Callable[[~.DeleteKmsConfigRequest], - ~.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_kms_config' not in self._stubs: - self._stubs['delete_kms_config'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/DeleteKmsConfig', - request_serializer=kms.DeleteKmsConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_kms_config'] - - @property - def list_replications(self) -> Callable[ - [replication.ListReplicationsRequest], - replication.ListReplicationsResponse]: - r"""Return a callable for the list replications method over gRPC. - - Returns descriptions of all replications for a - volume. - - Returns: - Callable[[~.ListReplicationsRequest], - ~.ListReplicationsResponse]: - 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_replications' not in self._stubs: - self._stubs['list_replications'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ListReplications', - request_serializer=replication.ListReplicationsRequest.serialize, - response_deserializer=replication.ListReplicationsResponse.deserialize, - ) - return self._stubs['list_replications'] - - @property - def get_replication(self) -> Callable[ - [replication.GetReplicationRequest], - replication.Replication]: - r"""Return a callable for the get replication method over gRPC. - - Describe a replication for a volume. - - Returns: - Callable[[~.GetReplicationRequest], - ~.Replication]: - 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_replication' not in self._stubs: - self._stubs['get_replication'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/GetReplication', - request_serializer=replication.GetReplicationRequest.serialize, - response_deserializer=replication.Replication.deserialize, - ) - return self._stubs['get_replication'] - - @property - def create_replication(self) -> Callable[ - [gcn_replication.CreateReplicationRequest], - operations_pb2.Operation]: - r"""Return a callable for the create replication method over gRPC. - - Create a new replication for a volume. - - Returns: - Callable[[~.CreateReplicationRequest], - ~.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_replication' not in self._stubs: - self._stubs['create_replication'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/CreateReplication', - request_serializer=gcn_replication.CreateReplicationRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_replication'] - - @property - def delete_replication(self) -> Callable[ - [replication.DeleteReplicationRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete replication method over gRPC. - - Deletes a replication. - - Returns: - Callable[[~.DeleteReplicationRequest], - ~.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_replication' not in self._stubs: - self._stubs['delete_replication'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/DeleteReplication', - request_serializer=replication.DeleteReplicationRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_replication'] - - @property - def update_replication(self) -> Callable[ - [gcn_replication.UpdateReplicationRequest], - operations_pb2.Operation]: - r"""Return a callable for the update replication method over gRPC. - - Updates the settings of a specific replication. - - Returns: - Callable[[~.UpdateReplicationRequest], - ~.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 'update_replication' not in self._stubs: - self._stubs['update_replication'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/UpdateReplication', - request_serializer=gcn_replication.UpdateReplicationRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_replication'] - - @property - def stop_replication(self) -> Callable[ - [replication.StopReplicationRequest], - operations_pb2.Operation]: - r"""Return a callable for the stop replication method over gRPC. - - Stop Cross Region Replication. - - Returns: - Callable[[~.StopReplicationRequest], - ~.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 'stop_replication' not in self._stubs: - self._stubs['stop_replication'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/StopReplication', - request_serializer=replication.StopReplicationRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['stop_replication'] - - @property - def resume_replication(self) -> Callable[ - [replication.ResumeReplicationRequest], - operations_pb2.Operation]: - r"""Return a callable for the resume replication method over gRPC. - - Resume Cross Region Replication. - - Returns: - Callable[[~.ResumeReplicationRequest], - ~.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 'resume_replication' not in self._stubs: - self._stubs['resume_replication'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ResumeReplication', - request_serializer=replication.ResumeReplicationRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['resume_replication'] - - @property - def reverse_replication_direction(self) -> Callable[ - [replication.ReverseReplicationDirectionRequest], - operations_pb2.Operation]: - r"""Return a callable for the reverse replication direction method over gRPC. - - Reverses direction of replication. Source becomes - destination and destination becomes source. - - Returns: - Callable[[~.ReverseReplicationDirectionRequest], - ~.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 'reverse_replication_direction' not in self._stubs: - self._stubs['reverse_replication_direction'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ReverseReplicationDirection', - request_serializer=replication.ReverseReplicationDirectionRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['reverse_replication_direction'] - - @property - def establish_peering(self) -> Callable[ - [replication.EstablishPeeringRequest], - operations_pb2.Operation]: - r"""Return a callable for the establish peering method over gRPC. - - Establish replication peering. - - Returns: - Callable[[~.EstablishPeeringRequest], - ~.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 'establish_peering' not in self._stubs: - self._stubs['establish_peering'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/EstablishPeering', - request_serializer=replication.EstablishPeeringRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['establish_peering'] - - @property - def sync_replication(self) -> Callable[ - [replication.SyncReplicationRequest], - operations_pb2.Operation]: - r"""Return a callable for the sync replication method over gRPC. - - Syncs the replication. This will invoke one time - volume data transfer from source to destination. - - Returns: - Callable[[~.SyncReplicationRequest], - ~.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 'sync_replication' not in self._stubs: - self._stubs['sync_replication'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/SyncReplication', - request_serializer=replication.SyncReplicationRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['sync_replication'] - - @property - def create_backup_vault(self) -> Callable[ - [gcn_backup_vault.CreateBackupVaultRequest], - operations_pb2.Operation]: - r"""Return a callable for the create backup vault method over gRPC. - - Creates new backup vault - - Returns: - Callable[[~.CreateBackupVaultRequest], - ~.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_backup_vault' not in self._stubs: - self._stubs['create_backup_vault'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/CreateBackupVault', - request_serializer=gcn_backup_vault.CreateBackupVaultRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_backup_vault'] - - @property - def get_backup_vault(self) -> Callable[ - [backup_vault.GetBackupVaultRequest], - backup_vault.BackupVault]: - r"""Return a callable for the get backup vault method over gRPC. - - Returns the description of the specified backup vault - - Returns: - Callable[[~.GetBackupVaultRequest], - ~.BackupVault]: - 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_backup_vault' not in self._stubs: - self._stubs['get_backup_vault'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/GetBackupVault', - request_serializer=backup_vault.GetBackupVaultRequest.serialize, - response_deserializer=backup_vault.BackupVault.deserialize, - ) - return self._stubs['get_backup_vault'] - - @property - def list_backup_vaults(self) -> Callable[ - [backup_vault.ListBackupVaultsRequest], - backup_vault.ListBackupVaultsResponse]: - r"""Return a callable for the list backup vaults method over gRPC. - - Returns list of all available backup vaults. - - Returns: - Callable[[~.ListBackupVaultsRequest], - ~.ListBackupVaultsResponse]: - 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_backup_vaults' not in self._stubs: - self._stubs['list_backup_vaults'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ListBackupVaults', - request_serializer=backup_vault.ListBackupVaultsRequest.serialize, - response_deserializer=backup_vault.ListBackupVaultsResponse.deserialize, - ) - return self._stubs['list_backup_vaults'] - - @property - def update_backup_vault(self) -> Callable[ - [gcn_backup_vault.UpdateBackupVaultRequest], - operations_pb2.Operation]: - r"""Return a callable for the update backup vault method over gRPC. - - Updates the settings of a specific backup vault. - - Returns: - Callable[[~.UpdateBackupVaultRequest], - ~.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 'update_backup_vault' not in self._stubs: - self._stubs['update_backup_vault'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/UpdateBackupVault', - request_serializer=gcn_backup_vault.UpdateBackupVaultRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_backup_vault'] - - @property - def delete_backup_vault(self) -> Callable[ - [backup_vault.DeleteBackupVaultRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete backup vault method over gRPC. - - Warning! This operation will permanently delete the - backup vault. - - Returns: - Callable[[~.DeleteBackupVaultRequest], - ~.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_backup_vault' not in self._stubs: - self._stubs['delete_backup_vault'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/DeleteBackupVault', - request_serializer=backup_vault.DeleteBackupVaultRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_backup_vault'] - - @property - def create_backup(self) -> Callable[ - [gcn_backup.CreateBackupRequest], - operations_pb2.Operation]: - r"""Return a callable for the create backup method over gRPC. - - Creates a backup from the volume specified in the - request The backup can be created from the given - snapshot if specified in the request. If no snapshot - specified, there'll be a new snapshot taken to initiate - the backup creation. - - Returns: - Callable[[~.CreateBackupRequest], - ~.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_backup' not in self._stubs: - self._stubs['create_backup'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/CreateBackup', - request_serializer=gcn_backup.CreateBackupRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_backup'] - - @property - def get_backup(self) -> Callable[ - [backup.GetBackupRequest], - backup.Backup]: - r"""Return a callable for the get backup method over gRPC. - - Returns the description of the specified backup - - Returns: - Callable[[~.GetBackupRequest], - ~.Backup]: - 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_backup' not in self._stubs: - self._stubs['get_backup'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/GetBackup', - request_serializer=backup.GetBackupRequest.serialize, - response_deserializer=backup.Backup.deserialize, - ) - return self._stubs['get_backup'] - - @property - def list_backups(self) -> Callable[ - [backup.ListBackupsRequest], - backup.ListBackupsResponse]: - r"""Return a callable for the list backups method over gRPC. - - Returns descriptions of all backups for a - backupVault. - - Returns: - Callable[[~.ListBackupsRequest], - ~.ListBackupsResponse]: - 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_backups' not in self._stubs: - self._stubs['list_backups'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ListBackups', - request_serializer=backup.ListBackupsRequest.serialize, - response_deserializer=backup.ListBackupsResponse.deserialize, - ) - return self._stubs['list_backups'] - - @property - def delete_backup(self) -> Callable[ - [backup.DeleteBackupRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete backup method over gRPC. - - Warning! This operation will permanently delete the - backup. - - Returns: - Callable[[~.DeleteBackupRequest], - ~.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_backup' not in self._stubs: - self._stubs['delete_backup'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/DeleteBackup', - request_serializer=backup.DeleteBackupRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_backup'] - - @property - def update_backup(self) -> Callable[ - [gcn_backup.UpdateBackupRequest], - operations_pb2.Operation]: - r"""Return a callable for the update backup method over gRPC. - - Update backup with full spec. - - Returns: - Callable[[~.UpdateBackupRequest], - ~.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 'update_backup' not in self._stubs: - self._stubs['update_backup'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/UpdateBackup', - request_serializer=gcn_backup.UpdateBackupRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_backup'] - - @property - def create_backup_policy(self) -> Callable[ - [gcn_backup_policy.CreateBackupPolicyRequest], - operations_pb2.Operation]: - r"""Return a callable for the create backup policy method over gRPC. - - Creates new backup policy - - Returns: - Callable[[~.CreateBackupPolicyRequest], - ~.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_backup_policy' not in self._stubs: - self._stubs['create_backup_policy'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/CreateBackupPolicy', - request_serializer=gcn_backup_policy.CreateBackupPolicyRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_backup_policy'] - - @property - def get_backup_policy(self) -> Callable[ - [backup_policy.GetBackupPolicyRequest], - backup_policy.BackupPolicy]: - r"""Return a callable for the get backup policy method over gRPC. - - Returns the description of the specified backup policy by - backup_policy_id. - - Returns: - Callable[[~.GetBackupPolicyRequest], - ~.BackupPolicy]: - 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_backup_policy' not in self._stubs: - self._stubs['get_backup_policy'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/GetBackupPolicy', - request_serializer=backup_policy.GetBackupPolicyRequest.serialize, - response_deserializer=backup_policy.BackupPolicy.deserialize, - ) - return self._stubs['get_backup_policy'] - - @property - def list_backup_policies(self) -> Callable[ - [backup_policy.ListBackupPoliciesRequest], - backup_policy.ListBackupPoliciesResponse]: - r"""Return a callable for the list backup policies method over gRPC. - - Returns list of all available backup policies. - - Returns: - Callable[[~.ListBackupPoliciesRequest], - ~.ListBackupPoliciesResponse]: - 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_backup_policies' not in self._stubs: - self._stubs['list_backup_policies'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ListBackupPolicies', - request_serializer=backup_policy.ListBackupPoliciesRequest.serialize, - response_deserializer=backup_policy.ListBackupPoliciesResponse.deserialize, - ) - return self._stubs['list_backup_policies'] - - @property - def update_backup_policy(self) -> Callable[ - [gcn_backup_policy.UpdateBackupPolicyRequest], - operations_pb2.Operation]: - r"""Return a callable for the update backup policy method over gRPC. - - Updates settings of a specific backup policy. - - Returns: - Callable[[~.UpdateBackupPolicyRequest], - ~.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 'update_backup_policy' not in self._stubs: - self._stubs['update_backup_policy'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/UpdateBackupPolicy', - request_serializer=gcn_backup_policy.UpdateBackupPolicyRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_backup_policy'] - - @property - def delete_backup_policy(self) -> Callable[ - [backup_policy.DeleteBackupPolicyRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete backup policy method over gRPC. - - Warning! This operation will permanently delete the - backup policy. - - Returns: - Callable[[~.DeleteBackupPolicyRequest], - ~.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_backup_policy' not in self._stubs: - self._stubs['delete_backup_policy'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/DeleteBackupPolicy', - request_serializer=backup_policy.DeleteBackupPolicyRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_backup_policy'] - - @property - def list_quota_rules(self) -> Callable[ - [quota_rule.ListQuotaRulesRequest], - quota_rule.ListQuotaRulesResponse]: - r"""Return a callable for the list quota rules method over gRPC. - - Returns list of all quota rules in a location. - - Returns: - Callable[[~.ListQuotaRulesRequest], - ~.ListQuotaRulesResponse]: - 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_quota_rules' not in self._stubs: - self._stubs['list_quota_rules'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ListQuotaRules', - request_serializer=quota_rule.ListQuotaRulesRequest.serialize, - response_deserializer=quota_rule.ListQuotaRulesResponse.deserialize, - ) - return self._stubs['list_quota_rules'] - - @property - def get_quota_rule(self) -> Callable[ - [quota_rule.GetQuotaRuleRequest], - quota_rule.QuotaRule]: - r"""Return a callable for the get quota rule method over gRPC. - - Returns details of the specified quota rule. - - Returns: - Callable[[~.GetQuotaRuleRequest], - ~.QuotaRule]: - 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_quota_rule' not in self._stubs: - self._stubs['get_quota_rule'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/GetQuotaRule', - request_serializer=quota_rule.GetQuotaRuleRequest.serialize, - response_deserializer=quota_rule.QuotaRule.deserialize, - ) - return self._stubs['get_quota_rule'] - - @property - def create_quota_rule(self) -> Callable[ - [gcn_quota_rule.CreateQuotaRuleRequest], - operations_pb2.Operation]: - r"""Return a callable for the create quota rule method over gRPC. - - Creates a new quota rule. - - Returns: - Callable[[~.CreateQuotaRuleRequest], - ~.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_quota_rule' not in self._stubs: - self._stubs['create_quota_rule'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/CreateQuotaRule', - request_serializer=gcn_quota_rule.CreateQuotaRuleRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_quota_rule'] - - @property - def update_quota_rule(self) -> Callable[ - [gcn_quota_rule.UpdateQuotaRuleRequest], - operations_pb2.Operation]: - r"""Return a callable for the update quota rule method over gRPC. - - Updates a quota rule. - - Returns: - Callable[[~.UpdateQuotaRuleRequest], - ~.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 'update_quota_rule' not in self._stubs: - self._stubs['update_quota_rule'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/UpdateQuotaRule', - request_serializer=gcn_quota_rule.UpdateQuotaRuleRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_quota_rule'] - - @property - def delete_quota_rule(self) -> Callable[ - [quota_rule.DeleteQuotaRuleRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete quota rule method over gRPC. - - Deletes a quota rule. - - Returns: - Callable[[~.DeleteQuotaRuleRequest], - ~.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_quota_rule' not in self._stubs: - self._stubs['delete_quota_rule'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/DeleteQuotaRule', - request_serializer=quota_rule.DeleteQuotaRuleRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_quota_rule'] - - def close(self): - self._logged_channel.close() - - @property - def delete_operation( - self, - ) -> Callable[[operations_pb2.DeleteOperationRequest], None]: - r"""Return a callable for the delete_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 "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self._logged_channel.unary_unary( - "/google.longrunning.Operations/DeleteOperation", - request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, - response_deserializer=None, - ) - return self._stubs["delete_operation"] - - @property - def cancel_operation( - self, - ) -> Callable[[operations_pb2.CancelOperationRequest], None]: - r"""Return a callable for the cancel_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 "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self._logged_channel.unary_unary( - "/google.longrunning.Operations/CancelOperation", - request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, - response_deserializer=None, - ) - return self._stubs["cancel_operation"] - - @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._logged_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_operations( - self, - ) -> Callable[[operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse]: - r"""Return a callable for the list_operations 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_operations" not in self._stubs: - self._stubs["list_operations"] = self._logged_channel.unary_unary( - "/google.longrunning.Operations/ListOperations", - request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, - response_deserializer=operations_pb2.ListOperationsResponse.FromString, - ) - return self._stubs["list_operations"] - - @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._logged_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._logged_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__ = ( - 'NetAppGrpcTransport', -) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/grpc_asyncio.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/grpc_asyncio.py deleted file mode 100644 index 9669115ac22a..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/grpc_asyncio.py +++ /dev/null @@ -1,2560 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 json -import pickle -import logging as std_logging -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 -from google.protobuf.json_format import MessageToJson -import google.protobuf.message - -import grpc # type: ignore -import proto # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.location import locations_pb2 # type: ignore -from google.cloud.netapp_v1.types import active_directory -from google.cloud.netapp_v1.types import active_directory as gcn_active_directory -from google.cloud.netapp_v1.types import backup -from google.cloud.netapp_v1.types import backup as gcn_backup -from google.cloud.netapp_v1.types import backup_policy -from google.cloud.netapp_v1.types import backup_policy as gcn_backup_policy -from google.cloud.netapp_v1.types import backup_vault -from google.cloud.netapp_v1.types import backup_vault as gcn_backup_vault -from google.cloud.netapp_v1.types import kms -from google.cloud.netapp_v1.types import quota_rule -from google.cloud.netapp_v1.types import quota_rule as gcn_quota_rule -from google.cloud.netapp_v1.types import replication -from google.cloud.netapp_v1.types import replication as gcn_replication -from google.cloud.netapp_v1.types import snapshot -from google.cloud.netapp_v1.types import snapshot as gcn_snapshot -from google.cloud.netapp_v1.types import storage_pool -from google.cloud.netapp_v1.types import storage_pool as gcn_storage_pool -from google.cloud.netapp_v1.types import volume -from google.cloud.netapp_v1.types import volume as gcn_volume -from google.longrunning import operations_pb2 # type: ignore -from .base import NetAppTransport, DEFAULT_CLIENT_INFO -from .grpc import NetAppGrpcTransport - -try: - from google.api_core import client_logging # type: ignore - CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER -except ImportError: # pragma: NO COVER - CLIENT_LOGGING_SUPPORTED = False - -_LOGGER = std_logging.getLogger(__name__) - - -class _LoggingClientAIOInterceptor(grpc.aio.UnaryUnaryClientInterceptor): # pragma: NO COVER - async def intercept_unary_unary(self, continuation, client_call_details, request): - logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG) - if logging_enabled: # pragma: NO COVER - request_metadata = client_call_details.metadata - if isinstance(request, proto.Message): - request_payload = type(request).to_json(request) - elif isinstance(request, google.protobuf.message.Message): - request_payload = MessageToJson(request) - else: - request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" - - request_metadata = { - key: value.decode("utf-8") if isinstance(value, bytes) else value - for key, value in request_metadata - } - grpc_request = { - "payload": request_payload, - "requestMethod": "grpc", - "metadata": dict(request_metadata), - } - _LOGGER.debug( - f"Sending request for {client_call_details.method}", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": str(client_call_details.method), - "request": grpc_request, - "metadata": grpc_request["metadata"], - }, - ) - response = await continuation(client_call_details, request) - if logging_enabled: # pragma: NO COVER - response_metadata = await response.trailing_metadata() - # Convert gRPC metadata `` to list of tuples - metadata = dict([(k, str(v)) for k, v in response_metadata]) if response_metadata else None - result = await response - if isinstance(result, proto.Message): - response_payload = type(result).to_json(result) - elif isinstance(result, google.protobuf.message.Message): - response_payload = MessageToJson(result) - else: - response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" - grpc_response = { - "payload": response_payload, - "metadata": metadata, - "status": "OK", - } - _LOGGER.debug( - f"Received response to rpc {client_call_details.method}.", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": str(client_call_details.method), - "response": grpc_response, - "metadata": grpc_response["metadata"], - }, - ) - return response - - -class NetAppGrpcAsyncIOTransport(NetAppTransport): - """gRPC AsyncIO backend transport for NetApp. - - NetApp Files Google Cloud Service - - 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 = 'netapp.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 = 'netapp.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: 'netapp.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), - ], - ) - - self._interceptor = _LoggingClientAIOInterceptor() - self._grpc_channel._unary_unary_interceptors.append(self._interceptor) - self._logged_channel = self._grpc_channel - self._wrap_with_kind = "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters - # Wrap messages. This must be done after self._logged_channel exists - 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._logged_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def list_storage_pools(self) -> Callable[ - [storage_pool.ListStoragePoolsRequest], - Awaitable[storage_pool.ListStoragePoolsResponse]]: - r"""Return a callable for the list storage pools method over gRPC. - - Returns descriptions of all storage pools owned by - the caller. - - Returns: - Callable[[~.ListStoragePoolsRequest], - Awaitable[~.ListStoragePoolsResponse]]: - 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_storage_pools' not in self._stubs: - self._stubs['list_storage_pools'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ListStoragePools', - request_serializer=storage_pool.ListStoragePoolsRequest.serialize, - response_deserializer=storage_pool.ListStoragePoolsResponse.deserialize, - ) - return self._stubs['list_storage_pools'] - - @property - def create_storage_pool(self) -> Callable[ - [gcn_storage_pool.CreateStoragePoolRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create storage pool method over gRPC. - - Creates a new storage pool. - - Returns: - Callable[[~.CreateStoragePoolRequest], - 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_storage_pool' not in self._stubs: - self._stubs['create_storage_pool'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/CreateStoragePool', - request_serializer=gcn_storage_pool.CreateStoragePoolRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_storage_pool'] - - @property - def get_storage_pool(self) -> Callable[ - [storage_pool.GetStoragePoolRequest], - Awaitable[storage_pool.StoragePool]]: - r"""Return a callable for the get storage pool method over gRPC. - - Returns the description of the specified storage pool - by poolId. - - Returns: - Callable[[~.GetStoragePoolRequest], - Awaitable[~.StoragePool]]: - 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_storage_pool' not in self._stubs: - self._stubs['get_storage_pool'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/GetStoragePool', - request_serializer=storage_pool.GetStoragePoolRequest.serialize, - response_deserializer=storage_pool.StoragePool.deserialize, - ) - return self._stubs['get_storage_pool'] - - @property - def update_storage_pool(self) -> Callable[ - [gcn_storage_pool.UpdateStoragePoolRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update storage pool method over gRPC. - - Updates the storage pool properties with the full - spec - - Returns: - Callable[[~.UpdateStoragePoolRequest], - 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 'update_storage_pool' not in self._stubs: - self._stubs['update_storage_pool'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/UpdateStoragePool', - request_serializer=gcn_storage_pool.UpdateStoragePoolRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_storage_pool'] - - @property - def delete_storage_pool(self) -> Callable[ - [storage_pool.DeleteStoragePoolRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete storage pool method over gRPC. - - Warning! This operation will permanently delete the - storage pool. - - Returns: - Callable[[~.DeleteStoragePoolRequest], - 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_storage_pool' not in self._stubs: - self._stubs['delete_storage_pool'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/DeleteStoragePool', - request_serializer=storage_pool.DeleteStoragePoolRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_storage_pool'] - - @property - def validate_directory_service(self) -> Callable[ - [storage_pool.ValidateDirectoryServiceRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the validate directory service method over gRPC. - - ValidateDirectoryService does a connectivity check - for a directory service policy attached to the storage - pool. - - Returns: - Callable[[~.ValidateDirectoryServiceRequest], - 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 'validate_directory_service' not in self._stubs: - self._stubs['validate_directory_service'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ValidateDirectoryService', - request_serializer=storage_pool.ValidateDirectoryServiceRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['validate_directory_service'] - - @property - def switch_active_replica_zone(self) -> Callable[ - [storage_pool.SwitchActiveReplicaZoneRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the switch active replica zone method over gRPC. - - This operation will switch the active/replica zone - for a regional storagePool. - - Returns: - Callable[[~.SwitchActiveReplicaZoneRequest], - 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 'switch_active_replica_zone' not in self._stubs: - self._stubs['switch_active_replica_zone'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/SwitchActiveReplicaZone', - request_serializer=storage_pool.SwitchActiveReplicaZoneRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['switch_active_replica_zone'] - - @property - def list_volumes(self) -> Callable[ - [volume.ListVolumesRequest], - Awaitable[volume.ListVolumesResponse]]: - r"""Return a callable for the list volumes method over gRPC. - - Lists Volumes in a given project. - - Returns: - Callable[[~.ListVolumesRequest], - Awaitable[~.ListVolumesResponse]]: - 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_volumes' not in self._stubs: - self._stubs['list_volumes'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ListVolumes', - request_serializer=volume.ListVolumesRequest.serialize, - response_deserializer=volume.ListVolumesResponse.deserialize, - ) - return self._stubs['list_volumes'] - - @property - def get_volume(self) -> Callable[ - [volume.GetVolumeRequest], - Awaitable[volume.Volume]]: - r"""Return a callable for the get volume method over gRPC. - - Gets details of a single Volume. - - Returns: - Callable[[~.GetVolumeRequest], - Awaitable[~.Volume]]: - 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_volume' not in self._stubs: - self._stubs['get_volume'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/GetVolume', - request_serializer=volume.GetVolumeRequest.serialize, - response_deserializer=volume.Volume.deserialize, - ) - return self._stubs['get_volume'] - - @property - def create_volume(self) -> Callable[ - [gcn_volume.CreateVolumeRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create volume method over gRPC. - - Creates a new Volume in a given project and location. - - Returns: - Callable[[~.CreateVolumeRequest], - 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_volume' not in self._stubs: - self._stubs['create_volume'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/CreateVolume', - request_serializer=gcn_volume.CreateVolumeRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_volume'] - - @property - def update_volume(self) -> Callable[ - [gcn_volume.UpdateVolumeRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update volume method over gRPC. - - Updates the parameters of a single Volume. - - Returns: - Callable[[~.UpdateVolumeRequest], - 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 'update_volume' not in self._stubs: - self._stubs['update_volume'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/UpdateVolume', - request_serializer=gcn_volume.UpdateVolumeRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_volume'] - - @property - def delete_volume(self) -> Callable[ - [volume.DeleteVolumeRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete volume method over gRPC. - - Deletes a single Volume. - - Returns: - Callable[[~.DeleteVolumeRequest], - 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_volume' not in self._stubs: - self._stubs['delete_volume'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/DeleteVolume', - request_serializer=volume.DeleteVolumeRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_volume'] - - @property - def revert_volume(self) -> Callable[ - [volume.RevertVolumeRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the revert volume method over gRPC. - - Revert an existing volume to a specified snapshot. - Warning! This operation will permanently revert all - changes made after the snapshot was created. - - Returns: - Callable[[~.RevertVolumeRequest], - 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 'revert_volume' not in self._stubs: - self._stubs['revert_volume'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/RevertVolume', - request_serializer=volume.RevertVolumeRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['revert_volume'] - - @property - def list_snapshots(self) -> Callable[ - [snapshot.ListSnapshotsRequest], - Awaitable[snapshot.ListSnapshotsResponse]]: - r"""Return a callable for the list snapshots method over gRPC. - - Returns descriptions of all snapshots for a volume. - - Returns: - Callable[[~.ListSnapshotsRequest], - Awaitable[~.ListSnapshotsResponse]]: - 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_snapshots' not in self._stubs: - self._stubs['list_snapshots'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ListSnapshots', - request_serializer=snapshot.ListSnapshotsRequest.serialize, - response_deserializer=snapshot.ListSnapshotsResponse.deserialize, - ) - return self._stubs['list_snapshots'] - - @property - def get_snapshot(self) -> Callable[ - [snapshot.GetSnapshotRequest], - Awaitable[snapshot.Snapshot]]: - r"""Return a callable for the get snapshot method over gRPC. - - Describe a snapshot for a volume. - - Returns: - Callable[[~.GetSnapshotRequest], - Awaitable[~.Snapshot]]: - 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_snapshot' not in self._stubs: - self._stubs['get_snapshot'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/GetSnapshot', - request_serializer=snapshot.GetSnapshotRequest.serialize, - response_deserializer=snapshot.Snapshot.deserialize, - ) - return self._stubs['get_snapshot'] - - @property - def create_snapshot(self) -> Callable[ - [gcn_snapshot.CreateSnapshotRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create snapshot method over gRPC. - - Create a new snapshot for a volume. - - Returns: - Callable[[~.CreateSnapshotRequest], - 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_snapshot' not in self._stubs: - self._stubs['create_snapshot'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/CreateSnapshot', - request_serializer=gcn_snapshot.CreateSnapshotRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_snapshot'] - - @property - def delete_snapshot(self) -> Callable[ - [snapshot.DeleteSnapshotRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete snapshot method over gRPC. - - Deletes a snapshot. - - Returns: - Callable[[~.DeleteSnapshotRequest], - 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_snapshot' not in self._stubs: - self._stubs['delete_snapshot'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/DeleteSnapshot', - request_serializer=snapshot.DeleteSnapshotRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_snapshot'] - - @property - def update_snapshot(self) -> Callable[ - [gcn_snapshot.UpdateSnapshotRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update snapshot method over gRPC. - - Updates the settings of a specific snapshot. - - Returns: - Callable[[~.UpdateSnapshotRequest], - 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 'update_snapshot' not in self._stubs: - self._stubs['update_snapshot'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/UpdateSnapshot', - request_serializer=gcn_snapshot.UpdateSnapshotRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_snapshot'] - - @property - def list_active_directories(self) -> Callable[ - [active_directory.ListActiveDirectoriesRequest], - Awaitable[active_directory.ListActiveDirectoriesResponse]]: - r"""Return a callable for the list active directories method over gRPC. - - Lists active directories. - - Returns: - Callable[[~.ListActiveDirectoriesRequest], - Awaitable[~.ListActiveDirectoriesResponse]]: - 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_active_directories' not in self._stubs: - self._stubs['list_active_directories'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ListActiveDirectories', - request_serializer=active_directory.ListActiveDirectoriesRequest.serialize, - response_deserializer=active_directory.ListActiveDirectoriesResponse.deserialize, - ) - return self._stubs['list_active_directories'] - - @property - def get_active_directory(self) -> Callable[ - [active_directory.GetActiveDirectoryRequest], - Awaitable[active_directory.ActiveDirectory]]: - r"""Return a callable for the get active directory method over gRPC. - - Describes a specified active directory. - - Returns: - Callable[[~.GetActiveDirectoryRequest], - Awaitable[~.ActiveDirectory]]: - 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_active_directory' not in self._stubs: - self._stubs['get_active_directory'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/GetActiveDirectory', - request_serializer=active_directory.GetActiveDirectoryRequest.serialize, - response_deserializer=active_directory.ActiveDirectory.deserialize, - ) - return self._stubs['get_active_directory'] - - @property - def create_active_directory(self) -> Callable[ - [gcn_active_directory.CreateActiveDirectoryRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create active directory method over gRPC. - - CreateActiveDirectory - Creates the active directory specified in the request. - - Returns: - Callable[[~.CreateActiveDirectoryRequest], - 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_active_directory' not in self._stubs: - self._stubs['create_active_directory'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/CreateActiveDirectory', - request_serializer=gcn_active_directory.CreateActiveDirectoryRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_active_directory'] - - @property - def update_active_directory(self) -> Callable[ - [gcn_active_directory.UpdateActiveDirectoryRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update active directory method over gRPC. - - Update the parameters of an active directories. - - Returns: - Callable[[~.UpdateActiveDirectoryRequest], - 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 'update_active_directory' not in self._stubs: - self._stubs['update_active_directory'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/UpdateActiveDirectory', - request_serializer=gcn_active_directory.UpdateActiveDirectoryRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_active_directory'] - - @property - def delete_active_directory(self) -> Callable[ - [active_directory.DeleteActiveDirectoryRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete active directory method over gRPC. - - Delete the active directory specified in the request. - - Returns: - Callable[[~.DeleteActiveDirectoryRequest], - 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_active_directory' not in self._stubs: - self._stubs['delete_active_directory'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/DeleteActiveDirectory', - request_serializer=active_directory.DeleteActiveDirectoryRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_active_directory'] - - @property - def list_kms_configs(self) -> Callable[ - [kms.ListKmsConfigsRequest], - Awaitable[kms.ListKmsConfigsResponse]]: - r"""Return a callable for the list kms configs method over gRPC. - - Returns descriptions of all KMS configs owned by the - caller. - - Returns: - Callable[[~.ListKmsConfigsRequest], - Awaitable[~.ListKmsConfigsResponse]]: - 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_kms_configs' not in self._stubs: - self._stubs['list_kms_configs'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ListKmsConfigs', - request_serializer=kms.ListKmsConfigsRequest.serialize, - response_deserializer=kms.ListKmsConfigsResponse.deserialize, - ) - return self._stubs['list_kms_configs'] - - @property - def create_kms_config(self) -> Callable[ - [kms.CreateKmsConfigRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create kms config method over gRPC. - - Creates a new KMS config. - - Returns: - Callable[[~.CreateKmsConfigRequest], - 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_kms_config' not in self._stubs: - self._stubs['create_kms_config'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/CreateKmsConfig', - request_serializer=kms.CreateKmsConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_kms_config'] - - @property - def get_kms_config(self) -> Callable[ - [kms.GetKmsConfigRequest], - Awaitable[kms.KmsConfig]]: - r"""Return a callable for the get kms config method over gRPC. - - Returns the description of the specified KMS config by - kms_config_id. - - Returns: - Callable[[~.GetKmsConfigRequest], - Awaitable[~.KmsConfig]]: - 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_kms_config' not in self._stubs: - self._stubs['get_kms_config'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/GetKmsConfig', - request_serializer=kms.GetKmsConfigRequest.serialize, - response_deserializer=kms.KmsConfig.deserialize, - ) - return self._stubs['get_kms_config'] - - @property - def update_kms_config(self) -> Callable[ - [kms.UpdateKmsConfigRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update kms config method over gRPC. - - Updates the Kms config properties with the full spec - - Returns: - Callable[[~.UpdateKmsConfigRequest], - 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 'update_kms_config' not in self._stubs: - self._stubs['update_kms_config'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/UpdateKmsConfig', - request_serializer=kms.UpdateKmsConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_kms_config'] - - @property - def encrypt_volumes(self) -> Callable[ - [kms.EncryptVolumesRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the encrypt volumes method over gRPC. - - Encrypt the existing volumes without CMEK encryption - with the desired the KMS config for the whole region. - - Returns: - Callable[[~.EncryptVolumesRequest], - 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 'encrypt_volumes' not in self._stubs: - self._stubs['encrypt_volumes'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/EncryptVolumes', - request_serializer=kms.EncryptVolumesRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['encrypt_volumes'] - - @property - def verify_kms_config(self) -> Callable[ - [kms.VerifyKmsConfigRequest], - Awaitable[kms.VerifyKmsConfigResponse]]: - r"""Return a callable for the verify kms config method over gRPC. - - Verifies KMS config reachability. - - Returns: - Callable[[~.VerifyKmsConfigRequest], - Awaitable[~.VerifyKmsConfigResponse]]: - 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 'verify_kms_config' not in self._stubs: - self._stubs['verify_kms_config'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/VerifyKmsConfig', - request_serializer=kms.VerifyKmsConfigRequest.serialize, - response_deserializer=kms.VerifyKmsConfigResponse.deserialize, - ) - return self._stubs['verify_kms_config'] - - @property - def delete_kms_config(self) -> Callable[ - [kms.DeleteKmsConfigRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete kms config method over gRPC. - - Warning! This operation will permanently delete the - Kms config. - - Returns: - Callable[[~.DeleteKmsConfigRequest], - 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_kms_config' not in self._stubs: - self._stubs['delete_kms_config'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/DeleteKmsConfig', - request_serializer=kms.DeleteKmsConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_kms_config'] - - @property - def list_replications(self) -> Callable[ - [replication.ListReplicationsRequest], - Awaitable[replication.ListReplicationsResponse]]: - r"""Return a callable for the list replications method over gRPC. - - Returns descriptions of all replications for a - volume. - - Returns: - Callable[[~.ListReplicationsRequest], - Awaitable[~.ListReplicationsResponse]]: - 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_replications' not in self._stubs: - self._stubs['list_replications'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ListReplications', - request_serializer=replication.ListReplicationsRequest.serialize, - response_deserializer=replication.ListReplicationsResponse.deserialize, - ) - return self._stubs['list_replications'] - - @property - def get_replication(self) -> Callable[ - [replication.GetReplicationRequest], - Awaitable[replication.Replication]]: - r"""Return a callable for the get replication method over gRPC. - - Describe a replication for a volume. - - Returns: - Callable[[~.GetReplicationRequest], - Awaitable[~.Replication]]: - 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_replication' not in self._stubs: - self._stubs['get_replication'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/GetReplication', - request_serializer=replication.GetReplicationRequest.serialize, - response_deserializer=replication.Replication.deserialize, - ) - return self._stubs['get_replication'] - - @property - def create_replication(self) -> Callable[ - [gcn_replication.CreateReplicationRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create replication method over gRPC. - - Create a new replication for a volume. - - Returns: - Callable[[~.CreateReplicationRequest], - 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_replication' not in self._stubs: - self._stubs['create_replication'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/CreateReplication', - request_serializer=gcn_replication.CreateReplicationRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_replication'] - - @property - def delete_replication(self) -> Callable[ - [replication.DeleteReplicationRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete replication method over gRPC. - - Deletes a replication. - - Returns: - Callable[[~.DeleteReplicationRequest], - 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_replication' not in self._stubs: - self._stubs['delete_replication'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/DeleteReplication', - request_serializer=replication.DeleteReplicationRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_replication'] - - @property - def update_replication(self) -> Callable[ - [gcn_replication.UpdateReplicationRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update replication method over gRPC. - - Updates the settings of a specific replication. - - Returns: - Callable[[~.UpdateReplicationRequest], - 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 'update_replication' not in self._stubs: - self._stubs['update_replication'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/UpdateReplication', - request_serializer=gcn_replication.UpdateReplicationRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_replication'] - - @property - def stop_replication(self) -> Callable[ - [replication.StopReplicationRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the stop replication method over gRPC. - - Stop Cross Region Replication. - - Returns: - Callable[[~.StopReplicationRequest], - 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 'stop_replication' not in self._stubs: - self._stubs['stop_replication'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/StopReplication', - request_serializer=replication.StopReplicationRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['stop_replication'] - - @property - def resume_replication(self) -> Callable[ - [replication.ResumeReplicationRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the resume replication method over gRPC. - - Resume Cross Region Replication. - - Returns: - Callable[[~.ResumeReplicationRequest], - 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 'resume_replication' not in self._stubs: - self._stubs['resume_replication'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ResumeReplication', - request_serializer=replication.ResumeReplicationRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['resume_replication'] - - @property - def reverse_replication_direction(self) -> Callable[ - [replication.ReverseReplicationDirectionRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the reverse replication direction method over gRPC. - - Reverses direction of replication. Source becomes - destination and destination becomes source. - - Returns: - Callable[[~.ReverseReplicationDirectionRequest], - 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 'reverse_replication_direction' not in self._stubs: - self._stubs['reverse_replication_direction'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ReverseReplicationDirection', - request_serializer=replication.ReverseReplicationDirectionRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['reverse_replication_direction'] - - @property - def establish_peering(self) -> Callable[ - [replication.EstablishPeeringRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the establish peering method over gRPC. - - Establish replication peering. - - Returns: - Callable[[~.EstablishPeeringRequest], - 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 'establish_peering' not in self._stubs: - self._stubs['establish_peering'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/EstablishPeering', - request_serializer=replication.EstablishPeeringRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['establish_peering'] - - @property - def sync_replication(self) -> Callable[ - [replication.SyncReplicationRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the sync replication method over gRPC. - - Syncs the replication. This will invoke one time - volume data transfer from source to destination. - - Returns: - Callable[[~.SyncReplicationRequest], - 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 'sync_replication' not in self._stubs: - self._stubs['sync_replication'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/SyncReplication', - request_serializer=replication.SyncReplicationRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['sync_replication'] - - @property - def create_backup_vault(self) -> Callable[ - [gcn_backup_vault.CreateBackupVaultRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create backup vault method over gRPC. - - Creates new backup vault - - Returns: - Callable[[~.CreateBackupVaultRequest], - 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_backup_vault' not in self._stubs: - self._stubs['create_backup_vault'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/CreateBackupVault', - request_serializer=gcn_backup_vault.CreateBackupVaultRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_backup_vault'] - - @property - def get_backup_vault(self) -> Callable[ - [backup_vault.GetBackupVaultRequest], - Awaitable[backup_vault.BackupVault]]: - r"""Return a callable for the get backup vault method over gRPC. - - Returns the description of the specified backup vault - - Returns: - Callable[[~.GetBackupVaultRequest], - Awaitable[~.BackupVault]]: - 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_backup_vault' not in self._stubs: - self._stubs['get_backup_vault'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/GetBackupVault', - request_serializer=backup_vault.GetBackupVaultRequest.serialize, - response_deserializer=backup_vault.BackupVault.deserialize, - ) - return self._stubs['get_backup_vault'] - - @property - def list_backup_vaults(self) -> Callable[ - [backup_vault.ListBackupVaultsRequest], - Awaitable[backup_vault.ListBackupVaultsResponse]]: - r"""Return a callable for the list backup vaults method over gRPC. - - Returns list of all available backup vaults. - - Returns: - Callable[[~.ListBackupVaultsRequest], - Awaitable[~.ListBackupVaultsResponse]]: - 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_backup_vaults' not in self._stubs: - self._stubs['list_backup_vaults'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ListBackupVaults', - request_serializer=backup_vault.ListBackupVaultsRequest.serialize, - response_deserializer=backup_vault.ListBackupVaultsResponse.deserialize, - ) - return self._stubs['list_backup_vaults'] - - @property - def update_backup_vault(self) -> Callable[ - [gcn_backup_vault.UpdateBackupVaultRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update backup vault method over gRPC. - - Updates the settings of a specific backup vault. - - Returns: - Callable[[~.UpdateBackupVaultRequest], - 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 'update_backup_vault' not in self._stubs: - self._stubs['update_backup_vault'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/UpdateBackupVault', - request_serializer=gcn_backup_vault.UpdateBackupVaultRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_backup_vault'] - - @property - def delete_backup_vault(self) -> Callable[ - [backup_vault.DeleteBackupVaultRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete backup vault method over gRPC. - - Warning! This operation will permanently delete the - backup vault. - - Returns: - Callable[[~.DeleteBackupVaultRequest], - 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_backup_vault' not in self._stubs: - self._stubs['delete_backup_vault'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/DeleteBackupVault', - request_serializer=backup_vault.DeleteBackupVaultRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_backup_vault'] - - @property - def create_backup(self) -> Callable[ - [gcn_backup.CreateBackupRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create backup method over gRPC. - - Creates a backup from the volume specified in the - request The backup can be created from the given - snapshot if specified in the request. If no snapshot - specified, there'll be a new snapshot taken to initiate - the backup creation. - - Returns: - Callable[[~.CreateBackupRequest], - 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_backup' not in self._stubs: - self._stubs['create_backup'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/CreateBackup', - request_serializer=gcn_backup.CreateBackupRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_backup'] - - @property - def get_backup(self) -> Callable[ - [backup.GetBackupRequest], - Awaitable[backup.Backup]]: - r"""Return a callable for the get backup method over gRPC. - - Returns the description of the specified backup - - Returns: - Callable[[~.GetBackupRequest], - Awaitable[~.Backup]]: - 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_backup' not in self._stubs: - self._stubs['get_backup'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/GetBackup', - request_serializer=backup.GetBackupRequest.serialize, - response_deserializer=backup.Backup.deserialize, - ) - return self._stubs['get_backup'] - - @property - def list_backups(self) -> Callable[ - [backup.ListBackupsRequest], - Awaitable[backup.ListBackupsResponse]]: - r"""Return a callable for the list backups method over gRPC. - - Returns descriptions of all backups for a - backupVault. - - Returns: - Callable[[~.ListBackupsRequest], - Awaitable[~.ListBackupsResponse]]: - 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_backups' not in self._stubs: - self._stubs['list_backups'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ListBackups', - request_serializer=backup.ListBackupsRequest.serialize, - response_deserializer=backup.ListBackupsResponse.deserialize, - ) - return self._stubs['list_backups'] - - @property - def delete_backup(self) -> Callable[ - [backup.DeleteBackupRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete backup method over gRPC. - - Warning! This operation will permanently delete the - backup. - - Returns: - Callable[[~.DeleteBackupRequest], - 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_backup' not in self._stubs: - self._stubs['delete_backup'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/DeleteBackup', - request_serializer=backup.DeleteBackupRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_backup'] - - @property - def update_backup(self) -> Callable[ - [gcn_backup.UpdateBackupRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update backup method over gRPC. - - Update backup with full spec. - - Returns: - Callable[[~.UpdateBackupRequest], - 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 'update_backup' not in self._stubs: - self._stubs['update_backup'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/UpdateBackup', - request_serializer=gcn_backup.UpdateBackupRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_backup'] - - @property - def create_backup_policy(self) -> Callable[ - [gcn_backup_policy.CreateBackupPolicyRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create backup policy method over gRPC. - - Creates new backup policy - - Returns: - Callable[[~.CreateBackupPolicyRequest], - 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_backup_policy' not in self._stubs: - self._stubs['create_backup_policy'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/CreateBackupPolicy', - request_serializer=gcn_backup_policy.CreateBackupPolicyRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_backup_policy'] - - @property - def get_backup_policy(self) -> Callable[ - [backup_policy.GetBackupPolicyRequest], - Awaitable[backup_policy.BackupPolicy]]: - r"""Return a callable for the get backup policy method over gRPC. - - Returns the description of the specified backup policy by - backup_policy_id. - - Returns: - Callable[[~.GetBackupPolicyRequest], - Awaitable[~.BackupPolicy]]: - 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_backup_policy' not in self._stubs: - self._stubs['get_backup_policy'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/GetBackupPolicy', - request_serializer=backup_policy.GetBackupPolicyRequest.serialize, - response_deserializer=backup_policy.BackupPolicy.deserialize, - ) - return self._stubs['get_backup_policy'] - - @property - def list_backup_policies(self) -> Callable[ - [backup_policy.ListBackupPoliciesRequest], - Awaitable[backup_policy.ListBackupPoliciesResponse]]: - r"""Return a callable for the list backup policies method over gRPC. - - Returns list of all available backup policies. - - Returns: - Callable[[~.ListBackupPoliciesRequest], - Awaitable[~.ListBackupPoliciesResponse]]: - 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_backup_policies' not in self._stubs: - self._stubs['list_backup_policies'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ListBackupPolicies', - request_serializer=backup_policy.ListBackupPoliciesRequest.serialize, - response_deserializer=backup_policy.ListBackupPoliciesResponse.deserialize, - ) - return self._stubs['list_backup_policies'] - - @property - def update_backup_policy(self) -> Callable[ - [gcn_backup_policy.UpdateBackupPolicyRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update backup policy method over gRPC. - - Updates settings of a specific backup policy. - - Returns: - Callable[[~.UpdateBackupPolicyRequest], - 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 'update_backup_policy' not in self._stubs: - self._stubs['update_backup_policy'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/UpdateBackupPolicy', - request_serializer=gcn_backup_policy.UpdateBackupPolicyRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_backup_policy'] - - @property - def delete_backup_policy(self) -> Callable[ - [backup_policy.DeleteBackupPolicyRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete backup policy method over gRPC. - - Warning! This operation will permanently delete the - backup policy. - - Returns: - Callable[[~.DeleteBackupPolicyRequest], - 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_backup_policy' not in self._stubs: - self._stubs['delete_backup_policy'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/DeleteBackupPolicy', - request_serializer=backup_policy.DeleteBackupPolicyRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_backup_policy'] - - @property - def list_quota_rules(self) -> Callable[ - [quota_rule.ListQuotaRulesRequest], - Awaitable[quota_rule.ListQuotaRulesResponse]]: - r"""Return a callable for the list quota rules method over gRPC. - - Returns list of all quota rules in a location. - - Returns: - Callable[[~.ListQuotaRulesRequest], - Awaitable[~.ListQuotaRulesResponse]]: - 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_quota_rules' not in self._stubs: - self._stubs['list_quota_rules'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/ListQuotaRules', - request_serializer=quota_rule.ListQuotaRulesRequest.serialize, - response_deserializer=quota_rule.ListQuotaRulesResponse.deserialize, - ) - return self._stubs['list_quota_rules'] - - @property - def get_quota_rule(self) -> Callable[ - [quota_rule.GetQuotaRuleRequest], - Awaitable[quota_rule.QuotaRule]]: - r"""Return a callable for the get quota rule method over gRPC. - - Returns details of the specified quota rule. - - Returns: - Callable[[~.GetQuotaRuleRequest], - Awaitable[~.QuotaRule]]: - 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_quota_rule' not in self._stubs: - self._stubs['get_quota_rule'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/GetQuotaRule', - request_serializer=quota_rule.GetQuotaRuleRequest.serialize, - response_deserializer=quota_rule.QuotaRule.deserialize, - ) - return self._stubs['get_quota_rule'] - - @property - def create_quota_rule(self) -> Callable[ - [gcn_quota_rule.CreateQuotaRuleRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create quota rule method over gRPC. - - Creates a new quota rule. - - Returns: - Callable[[~.CreateQuotaRuleRequest], - 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_quota_rule' not in self._stubs: - self._stubs['create_quota_rule'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/CreateQuotaRule', - request_serializer=gcn_quota_rule.CreateQuotaRuleRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_quota_rule'] - - @property - def update_quota_rule(self) -> Callable[ - [gcn_quota_rule.UpdateQuotaRuleRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update quota rule method over gRPC. - - Updates a quota rule. - - Returns: - Callable[[~.UpdateQuotaRuleRequest], - 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 'update_quota_rule' not in self._stubs: - self._stubs['update_quota_rule'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/UpdateQuotaRule', - request_serializer=gcn_quota_rule.UpdateQuotaRuleRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_quota_rule'] - - @property - def delete_quota_rule(self) -> Callable[ - [quota_rule.DeleteQuotaRuleRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete quota rule method over gRPC. - - Deletes a quota rule. - - Returns: - Callable[[~.DeleteQuotaRuleRequest], - 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_quota_rule' not in self._stubs: - self._stubs['delete_quota_rule'] = self._logged_channel.unary_unary( - '/google.cloud.netapp.v1.NetApp/DeleteQuotaRule', - request_serializer=quota_rule.DeleteQuotaRuleRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_quota_rule'] - - 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_storage_pools: self._wrap_method( - self.list_storage_pools, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.create_storage_pool: self._wrap_method( - self.create_storage_pool, - default_timeout=60.0, - client_info=client_info, - ), - self.get_storage_pool: self._wrap_method( - self.get_storage_pool, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.update_storage_pool: self._wrap_method( - self.update_storage_pool, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_storage_pool: self._wrap_method( - self.delete_storage_pool, - default_timeout=60.0, - client_info=client_info, - ), - self.validate_directory_service: self._wrap_method( - self.validate_directory_service, - default_timeout=None, - client_info=client_info, - ), - self.switch_active_replica_zone: self._wrap_method( - self.switch_active_replica_zone, - default_timeout=None, - client_info=client_info, - ), - self.list_volumes: self._wrap_method( - self.list_volumes, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.get_volume: self._wrap_method( - self.get_volume, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.create_volume: self._wrap_method( - self.create_volume, - default_timeout=60.0, - client_info=client_info, - ), - self.update_volume: self._wrap_method( - self.update_volume, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_volume: self._wrap_method( - self.delete_volume, - default_timeout=60.0, - client_info=client_info, - ), - self.revert_volume: self._wrap_method( - self.revert_volume, - default_timeout=60.0, - client_info=client_info, - ), - self.list_snapshots: self._wrap_method( - self.list_snapshots, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.get_snapshot: self._wrap_method( - self.get_snapshot, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.create_snapshot: self._wrap_method( - self.create_snapshot, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_snapshot: self._wrap_method( - self.delete_snapshot, - default_timeout=60.0, - client_info=client_info, - ), - self.update_snapshot: self._wrap_method( - self.update_snapshot, - default_timeout=60.0, - client_info=client_info, - ), - self.list_active_directories: self._wrap_method( - self.list_active_directories, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.get_active_directory: self._wrap_method( - self.get_active_directory, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.create_active_directory: self._wrap_method( - self.create_active_directory, - default_timeout=60.0, - client_info=client_info, - ), - self.update_active_directory: self._wrap_method( - self.update_active_directory, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_active_directory: self._wrap_method( - self.delete_active_directory, - default_timeout=60.0, - client_info=client_info, - ), - self.list_kms_configs: self._wrap_method( - self.list_kms_configs, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.create_kms_config: self._wrap_method( - self.create_kms_config, - default_timeout=60.0, - client_info=client_info, - ), - self.get_kms_config: self._wrap_method( - self.get_kms_config, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.update_kms_config: self._wrap_method( - self.update_kms_config, - default_timeout=60.0, - client_info=client_info, - ), - self.encrypt_volumes: self._wrap_method( - self.encrypt_volumes, - default_timeout=60.0, - client_info=client_info, - ), - self.verify_kms_config: self._wrap_method( - self.verify_kms_config, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_kms_config: self._wrap_method( - self.delete_kms_config, - default_timeout=60.0, - client_info=client_info, - ), - self.list_replications: self._wrap_method( - self.list_replications, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.get_replication: self._wrap_method( - self.get_replication, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.create_replication: self._wrap_method( - self.create_replication, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_replication: self._wrap_method( - self.delete_replication, - default_timeout=60.0, - client_info=client_info, - ), - self.update_replication: self._wrap_method( - self.update_replication, - default_timeout=60.0, - client_info=client_info, - ), - self.stop_replication: self._wrap_method( - self.stop_replication, - default_timeout=60.0, - client_info=client_info, - ), - self.resume_replication: self._wrap_method( - self.resume_replication, - default_timeout=60.0, - client_info=client_info, - ), - self.reverse_replication_direction: self._wrap_method( - self.reverse_replication_direction, - default_timeout=60.0, - client_info=client_info, - ), - self.establish_peering: self._wrap_method( - self.establish_peering, - default_timeout=None, - client_info=client_info, - ), - self.sync_replication: self._wrap_method( - self.sync_replication, - default_timeout=None, - client_info=client_info, - ), - self.create_backup_vault: self._wrap_method( - self.create_backup_vault, - default_timeout=60.0, - client_info=client_info, - ), - self.get_backup_vault: self._wrap_method( - self.get_backup_vault, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.list_backup_vaults: self._wrap_method( - self.list_backup_vaults, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.update_backup_vault: self._wrap_method( - self.update_backup_vault, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_backup_vault: self._wrap_method( - self.delete_backup_vault, - default_timeout=60.0, - client_info=client_info, - ), - self.create_backup: self._wrap_method( - self.create_backup, - default_timeout=60.0, - client_info=client_info, - ), - self.get_backup: self._wrap_method( - self.get_backup, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.list_backups: self._wrap_method( - self.list_backups, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.delete_backup: self._wrap_method( - self.delete_backup, - default_timeout=60.0, - client_info=client_info, - ), - self.update_backup: self._wrap_method( - self.update_backup, - default_timeout=60.0, - client_info=client_info, - ), - self.create_backup_policy: self._wrap_method( - self.create_backup_policy, - default_timeout=60.0, - client_info=client_info, - ), - self.get_backup_policy: self._wrap_method( - self.get_backup_policy, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.list_backup_policies: self._wrap_method( - self.list_backup_policies, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.update_backup_policy: self._wrap_method( - self.update_backup_policy, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_backup_policy: self._wrap_method( - self.delete_backup_policy, - default_timeout=60.0, - client_info=client_info, - ), - self.list_quota_rules: self._wrap_method( - self.list_quota_rules, - default_timeout=None, - client_info=client_info, - ), - self.get_quota_rule: self._wrap_method( - self.get_quota_rule, - default_timeout=None, - client_info=client_info, - ), - self.create_quota_rule: self._wrap_method( - self.create_quota_rule, - default_timeout=None, - client_info=client_info, - ), - self.update_quota_rule: self._wrap_method( - self.update_quota_rule, - default_timeout=None, - client_info=client_info, - ), - self.delete_quota_rule: self._wrap_method( - self.delete_quota_rule, - 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.cancel_operation: self._wrap_method( - self.cancel_operation, - default_timeout=None, - client_info=client_info, - ), - self.delete_operation: self._wrap_method( - self.delete_operation, - default_timeout=None, - client_info=client_info, - ), - self.get_operation: self._wrap_method( - self.get_operation, - default_timeout=None, - client_info=client_info, - ), - self.list_operations: self._wrap_method( - self.list_operations, - 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._logged_channel.close() - - @property - def kind(self) -> str: - return "grpc_asyncio" - - @property - def delete_operation( - self, - ) -> Callable[[operations_pb2.DeleteOperationRequest], None]: - r"""Return a callable for the delete_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 "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self._logged_channel.unary_unary( - "/google.longrunning.Operations/DeleteOperation", - request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, - response_deserializer=None, - ) - return self._stubs["delete_operation"] - - @property - def cancel_operation( - self, - ) -> Callable[[operations_pb2.CancelOperationRequest], None]: - r"""Return a callable for the cancel_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 "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self._logged_channel.unary_unary( - "/google.longrunning.Operations/CancelOperation", - request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, - response_deserializer=None, - ) - return self._stubs["cancel_operation"] - - @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._logged_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_operations( - self, - ) -> Callable[[operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse]: - r"""Return a callable for the list_operations 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_operations" not in self._stubs: - self._stubs["list_operations"] = self._logged_channel.unary_unary( - "/google.longrunning.Operations/ListOperations", - request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, - response_deserializer=operations_pb2.ListOperationsResponse.FromString, - ) - return self._stubs["list_operations"] - - @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._logged_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._logged_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__ = ( - 'NetAppGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/rest.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/rest.py deleted file mode 100644 index 977f3b2803ad..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/rest.py +++ /dev/null @@ -1,11531 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 logging -import json # type: ignore - -from google.auth.transport.requests import AuthorizedSession # 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.netapp_v1.types import active_directory -from google.cloud.netapp_v1.types import active_directory as gcn_active_directory -from google.cloud.netapp_v1.types import backup -from google.cloud.netapp_v1.types import backup as gcn_backup -from google.cloud.netapp_v1.types import backup_policy -from google.cloud.netapp_v1.types import backup_policy as gcn_backup_policy -from google.cloud.netapp_v1.types import backup_vault -from google.cloud.netapp_v1.types import backup_vault as gcn_backup_vault -from google.cloud.netapp_v1.types import kms -from google.cloud.netapp_v1.types import quota_rule -from google.cloud.netapp_v1.types import quota_rule as gcn_quota_rule -from google.cloud.netapp_v1.types import replication -from google.cloud.netapp_v1.types import replication as gcn_replication -from google.cloud.netapp_v1.types import snapshot -from google.cloud.netapp_v1.types import snapshot as gcn_snapshot -from google.cloud.netapp_v1.types import storage_pool -from google.cloud.netapp_v1.types import storage_pool as gcn_storage_pool -from google.cloud.netapp_v1.types import volume -from google.cloud.netapp_v1.types import volume as gcn_volume -from google.longrunning import operations_pb2 # type: ignore - - -from .rest_base import _BaseNetAppRestTransport -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 - -try: - from google.api_core import client_logging # type: ignore - CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER -except ImportError: # pragma: NO COVER - CLIENT_LOGGING_SUPPORTED = False - -_LOGGER = logging.getLogger(__name__) - -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 NetAppRestInterceptor: - """Interceptor for NetApp. - - 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 NetAppRestTransport. - - .. code-block:: python - class MyCustomNetAppInterceptor(NetAppRestInterceptor): - def pre_create_active_directory(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_active_directory(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_backup(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_backup(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_backup_policy(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_backup_policy(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_backup_vault(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_backup_vault(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_kms_config(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_kms_config(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_quota_rule(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_quota_rule(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_replication(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_replication(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_snapshot(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_snapshot(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_storage_pool(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_storage_pool(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_volume(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_volume(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_active_directory(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_active_directory(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_backup(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_backup(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_backup_policy(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_backup_policy(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_backup_vault(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_backup_vault(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_kms_config(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_kms_config(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_quota_rule(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_quota_rule(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_replication(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_replication(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_snapshot(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_snapshot(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_storage_pool(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_storage_pool(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_volume(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_volume(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_encrypt_volumes(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_encrypt_volumes(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_establish_peering(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_establish_peering(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_active_directory(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_active_directory(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_backup(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_backup(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_backup_policy(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_backup_policy(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_backup_vault(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_backup_vault(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_kms_config(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_kms_config(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_quota_rule(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_quota_rule(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_replication(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_replication(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_snapshot(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_snapshot(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_storage_pool(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_storage_pool(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_volume(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_volume(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_active_directories(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_active_directories(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_backup_policies(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_backup_policies(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_backups(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_backups(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_backup_vaults(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_backup_vaults(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_kms_configs(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_kms_configs(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_quota_rules(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_quota_rules(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_replications(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_replications(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_snapshots(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_snapshots(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_storage_pools(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_storage_pools(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_volumes(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_volumes(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_resume_replication(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_resume_replication(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_reverse_replication_direction(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_reverse_replication_direction(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_revert_volume(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_revert_volume(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_stop_replication(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_stop_replication(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_switch_active_replica_zone(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_switch_active_replica_zone(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_sync_replication(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_sync_replication(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_active_directory(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_active_directory(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_backup(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_backup(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_backup_policy(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_backup_policy(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_backup_vault(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_backup_vault(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_kms_config(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_kms_config(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_quota_rule(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_quota_rule(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_replication(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_replication(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_snapshot(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_snapshot(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_storage_pool(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_storage_pool(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_volume(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_volume(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_validate_directory_service(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_validate_directory_service(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_verify_kms_config(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_verify_kms_config(self, response): - logging.log(f"Received response: {response}") - return response - - transport = NetAppRestTransport(interceptor=MyCustomNetAppInterceptor()) - client = NetAppClient(transport=transport) - - - """ - def pre_create_active_directory(self, request: gcn_active_directory.CreateActiveDirectoryRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_active_directory.CreateActiveDirectoryRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for create_active_directory - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_create_active_directory(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for create_active_directory - - DEPRECATED. Please use the `post_create_active_directory_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_create_active_directory` interceptor runs - before the `post_create_active_directory_with_metadata` interceptor. - """ - return response - - def post_create_active_directory_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for create_active_directory - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_create_active_directory_with_metadata` - interceptor in new development instead of the `post_create_active_directory` interceptor. - When both interceptors are used, this `post_create_active_directory_with_metadata` interceptor runs after the - `post_create_active_directory` interceptor. The (possibly modified) response returned by - `post_create_active_directory` will be passed to - `post_create_active_directory_with_metadata`. - """ - return response, metadata - - def pre_create_backup(self, request: gcn_backup.CreateBackupRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_backup.CreateBackupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for create_backup - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_create_backup(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for create_backup - - DEPRECATED. Please use the `post_create_backup_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_create_backup` interceptor runs - before the `post_create_backup_with_metadata` interceptor. - """ - return response - - def post_create_backup_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for create_backup - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_create_backup_with_metadata` - interceptor in new development instead of the `post_create_backup` interceptor. - When both interceptors are used, this `post_create_backup_with_metadata` interceptor runs after the - `post_create_backup` interceptor. The (possibly modified) response returned by - `post_create_backup` will be passed to - `post_create_backup_with_metadata`. - """ - return response, metadata - - def pre_create_backup_policy(self, request: gcn_backup_policy.CreateBackupPolicyRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_backup_policy.CreateBackupPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for create_backup_policy - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_create_backup_policy(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for create_backup_policy - - DEPRECATED. Please use the `post_create_backup_policy_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_create_backup_policy` interceptor runs - before the `post_create_backup_policy_with_metadata` interceptor. - """ - return response - - def post_create_backup_policy_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for create_backup_policy - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_create_backup_policy_with_metadata` - interceptor in new development instead of the `post_create_backup_policy` interceptor. - When both interceptors are used, this `post_create_backup_policy_with_metadata` interceptor runs after the - `post_create_backup_policy` interceptor. The (possibly modified) response returned by - `post_create_backup_policy` will be passed to - `post_create_backup_policy_with_metadata`. - """ - return response, metadata - - def pre_create_backup_vault(self, request: gcn_backup_vault.CreateBackupVaultRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_backup_vault.CreateBackupVaultRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for create_backup_vault - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_create_backup_vault(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for create_backup_vault - - DEPRECATED. Please use the `post_create_backup_vault_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_create_backup_vault` interceptor runs - before the `post_create_backup_vault_with_metadata` interceptor. - """ - return response - - def post_create_backup_vault_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for create_backup_vault - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_create_backup_vault_with_metadata` - interceptor in new development instead of the `post_create_backup_vault` interceptor. - When both interceptors are used, this `post_create_backup_vault_with_metadata` interceptor runs after the - `post_create_backup_vault` interceptor. The (possibly modified) response returned by - `post_create_backup_vault` will be passed to - `post_create_backup_vault_with_metadata`. - """ - return response, metadata - - def pre_create_kms_config(self, request: kms.CreateKmsConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[kms.CreateKmsConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for create_kms_config - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_create_kms_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for create_kms_config - - DEPRECATED. Please use the `post_create_kms_config_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_create_kms_config` interceptor runs - before the `post_create_kms_config_with_metadata` interceptor. - """ - return response - - def post_create_kms_config_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for create_kms_config - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_create_kms_config_with_metadata` - interceptor in new development instead of the `post_create_kms_config` interceptor. - When both interceptors are used, this `post_create_kms_config_with_metadata` interceptor runs after the - `post_create_kms_config` interceptor. The (possibly modified) response returned by - `post_create_kms_config` will be passed to - `post_create_kms_config_with_metadata`. - """ - return response, metadata - - def pre_create_quota_rule(self, request: gcn_quota_rule.CreateQuotaRuleRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_quota_rule.CreateQuotaRuleRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for create_quota_rule - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_create_quota_rule(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for create_quota_rule - - DEPRECATED. Please use the `post_create_quota_rule_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_create_quota_rule` interceptor runs - before the `post_create_quota_rule_with_metadata` interceptor. - """ - return response - - def post_create_quota_rule_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for create_quota_rule - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_create_quota_rule_with_metadata` - interceptor in new development instead of the `post_create_quota_rule` interceptor. - When both interceptors are used, this `post_create_quota_rule_with_metadata` interceptor runs after the - `post_create_quota_rule` interceptor. The (possibly modified) response returned by - `post_create_quota_rule` will be passed to - `post_create_quota_rule_with_metadata`. - """ - return response, metadata - - def pre_create_replication(self, request: gcn_replication.CreateReplicationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_replication.CreateReplicationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for create_replication - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_create_replication(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for create_replication - - DEPRECATED. Please use the `post_create_replication_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_create_replication` interceptor runs - before the `post_create_replication_with_metadata` interceptor. - """ - return response - - def post_create_replication_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for create_replication - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_create_replication_with_metadata` - interceptor in new development instead of the `post_create_replication` interceptor. - When both interceptors are used, this `post_create_replication_with_metadata` interceptor runs after the - `post_create_replication` interceptor. The (possibly modified) response returned by - `post_create_replication` will be passed to - `post_create_replication_with_metadata`. - """ - return response, metadata - - def pre_create_snapshot(self, request: gcn_snapshot.CreateSnapshotRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_snapshot.CreateSnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for create_snapshot - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_create_snapshot(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for create_snapshot - - DEPRECATED. Please use the `post_create_snapshot_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_create_snapshot` interceptor runs - before the `post_create_snapshot_with_metadata` interceptor. - """ - return response - - def post_create_snapshot_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for create_snapshot - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_create_snapshot_with_metadata` - interceptor in new development instead of the `post_create_snapshot` interceptor. - When both interceptors are used, this `post_create_snapshot_with_metadata` interceptor runs after the - `post_create_snapshot` interceptor. The (possibly modified) response returned by - `post_create_snapshot` will be passed to - `post_create_snapshot_with_metadata`. - """ - return response, metadata - - def pre_create_storage_pool(self, request: gcn_storage_pool.CreateStoragePoolRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_storage_pool.CreateStoragePoolRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for create_storage_pool - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_create_storage_pool(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for create_storage_pool - - DEPRECATED. Please use the `post_create_storage_pool_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_create_storage_pool` interceptor runs - before the `post_create_storage_pool_with_metadata` interceptor. - """ - return response - - def post_create_storage_pool_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for create_storage_pool - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_create_storage_pool_with_metadata` - interceptor in new development instead of the `post_create_storage_pool` interceptor. - When both interceptors are used, this `post_create_storage_pool_with_metadata` interceptor runs after the - `post_create_storage_pool` interceptor. The (possibly modified) response returned by - `post_create_storage_pool` will be passed to - `post_create_storage_pool_with_metadata`. - """ - return response, metadata - - def pre_create_volume(self, request: gcn_volume.CreateVolumeRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_volume.CreateVolumeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for create_volume - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_create_volume(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for create_volume - - DEPRECATED. Please use the `post_create_volume_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_create_volume` interceptor runs - before the `post_create_volume_with_metadata` interceptor. - """ - return response - - def post_create_volume_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for create_volume - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_create_volume_with_metadata` - interceptor in new development instead of the `post_create_volume` interceptor. - When both interceptors are used, this `post_create_volume_with_metadata` interceptor runs after the - `post_create_volume` interceptor. The (possibly modified) response returned by - `post_create_volume` will be passed to - `post_create_volume_with_metadata`. - """ - return response, metadata - - def pre_delete_active_directory(self, request: active_directory.DeleteActiveDirectoryRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[active_directory.DeleteActiveDirectoryRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for delete_active_directory - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_delete_active_directory(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_active_directory - - DEPRECATED. Please use the `post_delete_active_directory_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_delete_active_directory` interceptor runs - before the `post_delete_active_directory_with_metadata` interceptor. - """ - return response - - def post_delete_active_directory_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for delete_active_directory - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_delete_active_directory_with_metadata` - interceptor in new development instead of the `post_delete_active_directory` interceptor. - When both interceptors are used, this `post_delete_active_directory_with_metadata` interceptor runs after the - `post_delete_active_directory` interceptor. The (possibly modified) response returned by - `post_delete_active_directory` will be passed to - `post_delete_active_directory_with_metadata`. - """ - return response, metadata - - def pre_delete_backup(self, request: backup.DeleteBackupRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup.DeleteBackupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for delete_backup - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_delete_backup(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_backup - - DEPRECATED. Please use the `post_delete_backup_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_delete_backup` interceptor runs - before the `post_delete_backup_with_metadata` interceptor. - """ - return response - - def post_delete_backup_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for delete_backup - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_delete_backup_with_metadata` - interceptor in new development instead of the `post_delete_backup` interceptor. - When both interceptors are used, this `post_delete_backup_with_metadata` interceptor runs after the - `post_delete_backup` interceptor. The (possibly modified) response returned by - `post_delete_backup` will be passed to - `post_delete_backup_with_metadata`. - """ - return response, metadata - - def pre_delete_backup_policy(self, request: backup_policy.DeleteBackupPolicyRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup_policy.DeleteBackupPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for delete_backup_policy - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_delete_backup_policy(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_backup_policy - - DEPRECATED. Please use the `post_delete_backup_policy_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_delete_backup_policy` interceptor runs - before the `post_delete_backup_policy_with_metadata` interceptor. - """ - return response - - def post_delete_backup_policy_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for delete_backup_policy - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_delete_backup_policy_with_metadata` - interceptor in new development instead of the `post_delete_backup_policy` interceptor. - When both interceptors are used, this `post_delete_backup_policy_with_metadata` interceptor runs after the - `post_delete_backup_policy` interceptor. The (possibly modified) response returned by - `post_delete_backup_policy` will be passed to - `post_delete_backup_policy_with_metadata`. - """ - return response, metadata - - def pre_delete_backup_vault(self, request: backup_vault.DeleteBackupVaultRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup_vault.DeleteBackupVaultRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for delete_backup_vault - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_delete_backup_vault(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_backup_vault - - DEPRECATED. Please use the `post_delete_backup_vault_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_delete_backup_vault` interceptor runs - before the `post_delete_backup_vault_with_metadata` interceptor. - """ - return response - - def post_delete_backup_vault_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for delete_backup_vault - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_delete_backup_vault_with_metadata` - interceptor in new development instead of the `post_delete_backup_vault` interceptor. - When both interceptors are used, this `post_delete_backup_vault_with_metadata` interceptor runs after the - `post_delete_backup_vault` interceptor. The (possibly modified) response returned by - `post_delete_backup_vault` will be passed to - `post_delete_backup_vault_with_metadata`. - """ - return response, metadata - - def pre_delete_kms_config(self, request: kms.DeleteKmsConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[kms.DeleteKmsConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for delete_kms_config - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_delete_kms_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_kms_config - - DEPRECATED. Please use the `post_delete_kms_config_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_delete_kms_config` interceptor runs - before the `post_delete_kms_config_with_metadata` interceptor. - """ - return response - - def post_delete_kms_config_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for delete_kms_config - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_delete_kms_config_with_metadata` - interceptor in new development instead of the `post_delete_kms_config` interceptor. - When both interceptors are used, this `post_delete_kms_config_with_metadata` interceptor runs after the - `post_delete_kms_config` interceptor. The (possibly modified) response returned by - `post_delete_kms_config` will be passed to - `post_delete_kms_config_with_metadata`. - """ - return response, metadata - - def pre_delete_quota_rule(self, request: quota_rule.DeleteQuotaRuleRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[quota_rule.DeleteQuotaRuleRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for delete_quota_rule - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_delete_quota_rule(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_quota_rule - - DEPRECATED. Please use the `post_delete_quota_rule_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_delete_quota_rule` interceptor runs - before the `post_delete_quota_rule_with_metadata` interceptor. - """ - return response - - def post_delete_quota_rule_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for delete_quota_rule - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_delete_quota_rule_with_metadata` - interceptor in new development instead of the `post_delete_quota_rule` interceptor. - When both interceptors are used, this `post_delete_quota_rule_with_metadata` interceptor runs after the - `post_delete_quota_rule` interceptor. The (possibly modified) response returned by - `post_delete_quota_rule` will be passed to - `post_delete_quota_rule_with_metadata`. - """ - return response, metadata - - def pre_delete_replication(self, request: replication.DeleteReplicationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[replication.DeleteReplicationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for delete_replication - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_delete_replication(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_replication - - DEPRECATED. Please use the `post_delete_replication_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_delete_replication` interceptor runs - before the `post_delete_replication_with_metadata` interceptor. - """ - return response - - def post_delete_replication_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for delete_replication - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_delete_replication_with_metadata` - interceptor in new development instead of the `post_delete_replication` interceptor. - When both interceptors are used, this `post_delete_replication_with_metadata` interceptor runs after the - `post_delete_replication` interceptor. The (possibly modified) response returned by - `post_delete_replication` will be passed to - `post_delete_replication_with_metadata`. - """ - return response, metadata - - def pre_delete_snapshot(self, request: snapshot.DeleteSnapshotRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[snapshot.DeleteSnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for delete_snapshot - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_delete_snapshot(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_snapshot - - DEPRECATED. Please use the `post_delete_snapshot_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_delete_snapshot` interceptor runs - before the `post_delete_snapshot_with_metadata` interceptor. - """ - return response - - def post_delete_snapshot_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for delete_snapshot - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_delete_snapshot_with_metadata` - interceptor in new development instead of the `post_delete_snapshot` interceptor. - When both interceptors are used, this `post_delete_snapshot_with_metadata` interceptor runs after the - `post_delete_snapshot` interceptor. The (possibly modified) response returned by - `post_delete_snapshot` will be passed to - `post_delete_snapshot_with_metadata`. - """ - return response, metadata - - def pre_delete_storage_pool(self, request: storage_pool.DeleteStoragePoolRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[storage_pool.DeleteStoragePoolRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for delete_storage_pool - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_delete_storage_pool(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_storage_pool - - DEPRECATED. Please use the `post_delete_storage_pool_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_delete_storage_pool` interceptor runs - before the `post_delete_storage_pool_with_metadata` interceptor. - """ - return response - - def post_delete_storage_pool_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for delete_storage_pool - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_delete_storage_pool_with_metadata` - interceptor in new development instead of the `post_delete_storage_pool` interceptor. - When both interceptors are used, this `post_delete_storage_pool_with_metadata` interceptor runs after the - `post_delete_storage_pool` interceptor. The (possibly modified) response returned by - `post_delete_storage_pool` will be passed to - `post_delete_storage_pool_with_metadata`. - """ - return response, metadata - - def pre_delete_volume(self, request: volume.DeleteVolumeRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[volume.DeleteVolumeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for delete_volume - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_delete_volume(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_volume - - DEPRECATED. Please use the `post_delete_volume_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_delete_volume` interceptor runs - before the `post_delete_volume_with_metadata` interceptor. - """ - return response - - def post_delete_volume_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for delete_volume - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_delete_volume_with_metadata` - interceptor in new development instead of the `post_delete_volume` interceptor. - When both interceptors are used, this `post_delete_volume_with_metadata` interceptor runs after the - `post_delete_volume` interceptor. The (possibly modified) response returned by - `post_delete_volume` will be passed to - `post_delete_volume_with_metadata`. - """ - return response, metadata - - def pre_encrypt_volumes(self, request: kms.EncryptVolumesRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[kms.EncryptVolumesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for encrypt_volumes - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_encrypt_volumes(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for encrypt_volumes - - DEPRECATED. Please use the `post_encrypt_volumes_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_encrypt_volumes` interceptor runs - before the `post_encrypt_volumes_with_metadata` interceptor. - """ - return response - - def post_encrypt_volumes_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for encrypt_volumes - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_encrypt_volumes_with_metadata` - interceptor in new development instead of the `post_encrypt_volumes` interceptor. - When both interceptors are used, this `post_encrypt_volumes_with_metadata` interceptor runs after the - `post_encrypt_volumes` interceptor. The (possibly modified) response returned by - `post_encrypt_volumes` will be passed to - `post_encrypt_volumes_with_metadata`. - """ - return response, metadata - - def pre_establish_peering(self, request: replication.EstablishPeeringRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[replication.EstablishPeeringRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for establish_peering - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_establish_peering(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for establish_peering - - DEPRECATED. Please use the `post_establish_peering_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_establish_peering` interceptor runs - before the `post_establish_peering_with_metadata` interceptor. - """ - return response - - def post_establish_peering_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for establish_peering - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_establish_peering_with_metadata` - interceptor in new development instead of the `post_establish_peering` interceptor. - When both interceptors are used, this `post_establish_peering_with_metadata` interceptor runs after the - `post_establish_peering` interceptor. The (possibly modified) response returned by - `post_establish_peering` will be passed to - `post_establish_peering_with_metadata`. - """ - return response, metadata - - def pre_get_active_directory(self, request: active_directory.GetActiveDirectoryRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[active_directory.GetActiveDirectoryRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_active_directory - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_get_active_directory(self, response: active_directory.ActiveDirectory) -> active_directory.ActiveDirectory: - """Post-rpc interceptor for get_active_directory - - DEPRECATED. Please use the `post_get_active_directory_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_get_active_directory` interceptor runs - before the `post_get_active_directory_with_metadata` interceptor. - """ - return response - - def post_get_active_directory_with_metadata(self, response: active_directory.ActiveDirectory, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[active_directory.ActiveDirectory, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for get_active_directory - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_get_active_directory_with_metadata` - interceptor in new development instead of the `post_get_active_directory` interceptor. - When both interceptors are used, this `post_get_active_directory_with_metadata` interceptor runs after the - `post_get_active_directory` interceptor. The (possibly modified) response returned by - `post_get_active_directory` will be passed to - `post_get_active_directory_with_metadata`. - """ - return response, metadata - - def pre_get_backup(self, request: backup.GetBackupRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup.GetBackupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_backup - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_get_backup(self, response: backup.Backup) -> backup.Backup: - """Post-rpc interceptor for get_backup - - DEPRECATED. Please use the `post_get_backup_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_get_backup` interceptor runs - before the `post_get_backup_with_metadata` interceptor. - """ - return response - - def post_get_backup_with_metadata(self, response: backup.Backup, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup.Backup, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for get_backup - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_get_backup_with_metadata` - interceptor in new development instead of the `post_get_backup` interceptor. - When both interceptors are used, this `post_get_backup_with_metadata` interceptor runs after the - `post_get_backup` interceptor. The (possibly modified) response returned by - `post_get_backup` will be passed to - `post_get_backup_with_metadata`. - """ - return response, metadata - - def pre_get_backup_policy(self, request: backup_policy.GetBackupPolicyRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup_policy.GetBackupPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_backup_policy - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_get_backup_policy(self, response: backup_policy.BackupPolicy) -> backup_policy.BackupPolicy: - """Post-rpc interceptor for get_backup_policy - - DEPRECATED. Please use the `post_get_backup_policy_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_get_backup_policy` interceptor runs - before the `post_get_backup_policy_with_metadata` interceptor. - """ - return response - - def post_get_backup_policy_with_metadata(self, response: backup_policy.BackupPolicy, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup_policy.BackupPolicy, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for get_backup_policy - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_get_backup_policy_with_metadata` - interceptor in new development instead of the `post_get_backup_policy` interceptor. - When both interceptors are used, this `post_get_backup_policy_with_metadata` interceptor runs after the - `post_get_backup_policy` interceptor. The (possibly modified) response returned by - `post_get_backup_policy` will be passed to - `post_get_backup_policy_with_metadata`. - """ - return response, metadata - - def pre_get_backup_vault(self, request: backup_vault.GetBackupVaultRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup_vault.GetBackupVaultRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_backup_vault - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_get_backup_vault(self, response: backup_vault.BackupVault) -> backup_vault.BackupVault: - """Post-rpc interceptor for get_backup_vault - - DEPRECATED. Please use the `post_get_backup_vault_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_get_backup_vault` interceptor runs - before the `post_get_backup_vault_with_metadata` interceptor. - """ - return response - - def post_get_backup_vault_with_metadata(self, response: backup_vault.BackupVault, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup_vault.BackupVault, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for get_backup_vault - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_get_backup_vault_with_metadata` - interceptor in new development instead of the `post_get_backup_vault` interceptor. - When both interceptors are used, this `post_get_backup_vault_with_metadata` interceptor runs after the - `post_get_backup_vault` interceptor. The (possibly modified) response returned by - `post_get_backup_vault` will be passed to - `post_get_backup_vault_with_metadata`. - """ - return response, metadata - - def pre_get_kms_config(self, request: kms.GetKmsConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[kms.GetKmsConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_kms_config - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_get_kms_config(self, response: kms.KmsConfig) -> kms.KmsConfig: - """Post-rpc interceptor for get_kms_config - - DEPRECATED. Please use the `post_get_kms_config_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_get_kms_config` interceptor runs - before the `post_get_kms_config_with_metadata` interceptor. - """ - return response - - def post_get_kms_config_with_metadata(self, response: kms.KmsConfig, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[kms.KmsConfig, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for get_kms_config - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_get_kms_config_with_metadata` - interceptor in new development instead of the `post_get_kms_config` interceptor. - When both interceptors are used, this `post_get_kms_config_with_metadata` interceptor runs after the - `post_get_kms_config` interceptor. The (possibly modified) response returned by - `post_get_kms_config` will be passed to - `post_get_kms_config_with_metadata`. - """ - return response, metadata - - def pre_get_quota_rule(self, request: quota_rule.GetQuotaRuleRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[quota_rule.GetQuotaRuleRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_quota_rule - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_get_quota_rule(self, response: quota_rule.QuotaRule) -> quota_rule.QuotaRule: - """Post-rpc interceptor for get_quota_rule - - DEPRECATED. Please use the `post_get_quota_rule_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_get_quota_rule` interceptor runs - before the `post_get_quota_rule_with_metadata` interceptor. - """ - return response - - def post_get_quota_rule_with_metadata(self, response: quota_rule.QuotaRule, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[quota_rule.QuotaRule, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for get_quota_rule - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_get_quota_rule_with_metadata` - interceptor in new development instead of the `post_get_quota_rule` interceptor. - When both interceptors are used, this `post_get_quota_rule_with_metadata` interceptor runs after the - `post_get_quota_rule` interceptor. The (possibly modified) response returned by - `post_get_quota_rule` will be passed to - `post_get_quota_rule_with_metadata`. - """ - return response, metadata - - def pre_get_replication(self, request: replication.GetReplicationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[replication.GetReplicationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_replication - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_get_replication(self, response: replication.Replication) -> replication.Replication: - """Post-rpc interceptor for get_replication - - DEPRECATED. Please use the `post_get_replication_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_get_replication` interceptor runs - before the `post_get_replication_with_metadata` interceptor. - """ - return response - - def post_get_replication_with_metadata(self, response: replication.Replication, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[replication.Replication, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for get_replication - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_get_replication_with_metadata` - interceptor in new development instead of the `post_get_replication` interceptor. - When both interceptors are used, this `post_get_replication_with_metadata` interceptor runs after the - `post_get_replication` interceptor. The (possibly modified) response returned by - `post_get_replication` will be passed to - `post_get_replication_with_metadata`. - """ - return response, metadata - - def pre_get_snapshot(self, request: snapshot.GetSnapshotRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[snapshot.GetSnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_snapshot - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_get_snapshot(self, response: snapshot.Snapshot) -> snapshot.Snapshot: - """Post-rpc interceptor for get_snapshot - - DEPRECATED. Please use the `post_get_snapshot_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_get_snapshot` interceptor runs - before the `post_get_snapshot_with_metadata` interceptor. - """ - return response - - def post_get_snapshot_with_metadata(self, response: snapshot.Snapshot, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[snapshot.Snapshot, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for get_snapshot - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_get_snapshot_with_metadata` - interceptor in new development instead of the `post_get_snapshot` interceptor. - When both interceptors are used, this `post_get_snapshot_with_metadata` interceptor runs after the - `post_get_snapshot` interceptor. The (possibly modified) response returned by - `post_get_snapshot` will be passed to - `post_get_snapshot_with_metadata`. - """ - return response, metadata - - def pre_get_storage_pool(self, request: storage_pool.GetStoragePoolRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[storage_pool.GetStoragePoolRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_storage_pool - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_get_storage_pool(self, response: storage_pool.StoragePool) -> storage_pool.StoragePool: - """Post-rpc interceptor for get_storage_pool - - DEPRECATED. Please use the `post_get_storage_pool_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_get_storage_pool` interceptor runs - before the `post_get_storage_pool_with_metadata` interceptor. - """ - return response - - def post_get_storage_pool_with_metadata(self, response: storage_pool.StoragePool, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[storage_pool.StoragePool, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for get_storage_pool - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_get_storage_pool_with_metadata` - interceptor in new development instead of the `post_get_storage_pool` interceptor. - When both interceptors are used, this `post_get_storage_pool_with_metadata` interceptor runs after the - `post_get_storage_pool` interceptor. The (possibly modified) response returned by - `post_get_storage_pool` will be passed to - `post_get_storage_pool_with_metadata`. - """ - return response, metadata - - def pre_get_volume(self, request: volume.GetVolumeRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[volume.GetVolumeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_volume - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_get_volume(self, response: volume.Volume) -> volume.Volume: - """Post-rpc interceptor for get_volume - - DEPRECATED. Please use the `post_get_volume_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_get_volume` interceptor runs - before the `post_get_volume_with_metadata` interceptor. - """ - return response - - def post_get_volume_with_metadata(self, response: volume.Volume, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[volume.Volume, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for get_volume - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_get_volume_with_metadata` - interceptor in new development instead of the `post_get_volume` interceptor. - When both interceptors are used, this `post_get_volume_with_metadata` interceptor runs after the - `post_get_volume` interceptor. The (possibly modified) response returned by - `post_get_volume` will be passed to - `post_get_volume_with_metadata`. - """ - return response, metadata - - def pre_list_active_directories(self, request: active_directory.ListActiveDirectoriesRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[active_directory.ListActiveDirectoriesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_active_directories - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_list_active_directories(self, response: active_directory.ListActiveDirectoriesResponse) -> active_directory.ListActiveDirectoriesResponse: - """Post-rpc interceptor for list_active_directories - - DEPRECATED. Please use the `post_list_active_directories_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_list_active_directories` interceptor runs - before the `post_list_active_directories_with_metadata` interceptor. - """ - return response - - def post_list_active_directories_with_metadata(self, response: active_directory.ListActiveDirectoriesResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[active_directory.ListActiveDirectoriesResponse, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for list_active_directories - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_list_active_directories_with_metadata` - interceptor in new development instead of the `post_list_active_directories` interceptor. - When both interceptors are used, this `post_list_active_directories_with_metadata` interceptor runs after the - `post_list_active_directories` interceptor. The (possibly modified) response returned by - `post_list_active_directories` will be passed to - `post_list_active_directories_with_metadata`. - """ - return response, metadata - - def pre_list_backup_policies(self, request: backup_policy.ListBackupPoliciesRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup_policy.ListBackupPoliciesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_backup_policies - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_list_backup_policies(self, response: backup_policy.ListBackupPoliciesResponse) -> backup_policy.ListBackupPoliciesResponse: - """Post-rpc interceptor for list_backup_policies - - DEPRECATED. Please use the `post_list_backup_policies_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_list_backup_policies` interceptor runs - before the `post_list_backup_policies_with_metadata` interceptor. - """ - return response - - def post_list_backup_policies_with_metadata(self, response: backup_policy.ListBackupPoliciesResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup_policy.ListBackupPoliciesResponse, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for list_backup_policies - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_list_backup_policies_with_metadata` - interceptor in new development instead of the `post_list_backup_policies` interceptor. - When both interceptors are used, this `post_list_backup_policies_with_metadata` interceptor runs after the - `post_list_backup_policies` interceptor. The (possibly modified) response returned by - `post_list_backup_policies` will be passed to - `post_list_backup_policies_with_metadata`. - """ - return response, metadata - - def pre_list_backups(self, request: backup.ListBackupsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup.ListBackupsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_backups - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_list_backups(self, response: backup.ListBackupsResponse) -> backup.ListBackupsResponse: - """Post-rpc interceptor for list_backups - - DEPRECATED. Please use the `post_list_backups_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_list_backups` interceptor runs - before the `post_list_backups_with_metadata` interceptor. - """ - return response - - def post_list_backups_with_metadata(self, response: backup.ListBackupsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup.ListBackupsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for list_backups - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_list_backups_with_metadata` - interceptor in new development instead of the `post_list_backups` interceptor. - When both interceptors are used, this `post_list_backups_with_metadata` interceptor runs after the - `post_list_backups` interceptor. The (possibly modified) response returned by - `post_list_backups` will be passed to - `post_list_backups_with_metadata`. - """ - return response, metadata - - def pre_list_backup_vaults(self, request: backup_vault.ListBackupVaultsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup_vault.ListBackupVaultsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_backup_vaults - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_list_backup_vaults(self, response: backup_vault.ListBackupVaultsResponse) -> backup_vault.ListBackupVaultsResponse: - """Post-rpc interceptor for list_backup_vaults - - DEPRECATED. Please use the `post_list_backup_vaults_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_list_backup_vaults` interceptor runs - before the `post_list_backup_vaults_with_metadata` interceptor. - """ - return response - - def post_list_backup_vaults_with_metadata(self, response: backup_vault.ListBackupVaultsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[backup_vault.ListBackupVaultsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for list_backup_vaults - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_list_backup_vaults_with_metadata` - interceptor in new development instead of the `post_list_backup_vaults` interceptor. - When both interceptors are used, this `post_list_backup_vaults_with_metadata` interceptor runs after the - `post_list_backup_vaults` interceptor. The (possibly modified) response returned by - `post_list_backup_vaults` will be passed to - `post_list_backup_vaults_with_metadata`. - """ - return response, metadata - - def pre_list_kms_configs(self, request: kms.ListKmsConfigsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[kms.ListKmsConfigsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_kms_configs - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_list_kms_configs(self, response: kms.ListKmsConfigsResponse) -> kms.ListKmsConfigsResponse: - """Post-rpc interceptor for list_kms_configs - - DEPRECATED. Please use the `post_list_kms_configs_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_list_kms_configs` interceptor runs - before the `post_list_kms_configs_with_metadata` interceptor. - """ - return response - - def post_list_kms_configs_with_metadata(self, response: kms.ListKmsConfigsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[kms.ListKmsConfigsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for list_kms_configs - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_list_kms_configs_with_metadata` - interceptor in new development instead of the `post_list_kms_configs` interceptor. - When both interceptors are used, this `post_list_kms_configs_with_metadata` interceptor runs after the - `post_list_kms_configs` interceptor. The (possibly modified) response returned by - `post_list_kms_configs` will be passed to - `post_list_kms_configs_with_metadata`. - """ - return response, metadata - - def pre_list_quota_rules(self, request: quota_rule.ListQuotaRulesRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[quota_rule.ListQuotaRulesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_quota_rules - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_list_quota_rules(self, response: quota_rule.ListQuotaRulesResponse) -> quota_rule.ListQuotaRulesResponse: - """Post-rpc interceptor for list_quota_rules - - DEPRECATED. Please use the `post_list_quota_rules_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_list_quota_rules` interceptor runs - before the `post_list_quota_rules_with_metadata` interceptor. - """ - return response - - def post_list_quota_rules_with_metadata(self, response: quota_rule.ListQuotaRulesResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[quota_rule.ListQuotaRulesResponse, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for list_quota_rules - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_list_quota_rules_with_metadata` - interceptor in new development instead of the `post_list_quota_rules` interceptor. - When both interceptors are used, this `post_list_quota_rules_with_metadata` interceptor runs after the - `post_list_quota_rules` interceptor. The (possibly modified) response returned by - `post_list_quota_rules` will be passed to - `post_list_quota_rules_with_metadata`. - """ - return response, metadata - - def pre_list_replications(self, request: replication.ListReplicationsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[replication.ListReplicationsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_replications - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_list_replications(self, response: replication.ListReplicationsResponse) -> replication.ListReplicationsResponse: - """Post-rpc interceptor for list_replications - - DEPRECATED. Please use the `post_list_replications_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_list_replications` interceptor runs - before the `post_list_replications_with_metadata` interceptor. - """ - return response - - def post_list_replications_with_metadata(self, response: replication.ListReplicationsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[replication.ListReplicationsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for list_replications - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_list_replications_with_metadata` - interceptor in new development instead of the `post_list_replications` interceptor. - When both interceptors are used, this `post_list_replications_with_metadata` interceptor runs after the - `post_list_replications` interceptor. The (possibly modified) response returned by - `post_list_replications` will be passed to - `post_list_replications_with_metadata`. - """ - return response, metadata - - def pre_list_snapshots(self, request: snapshot.ListSnapshotsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[snapshot.ListSnapshotsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_snapshots - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_list_snapshots(self, response: snapshot.ListSnapshotsResponse) -> snapshot.ListSnapshotsResponse: - """Post-rpc interceptor for list_snapshots - - DEPRECATED. Please use the `post_list_snapshots_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_list_snapshots` interceptor runs - before the `post_list_snapshots_with_metadata` interceptor. - """ - return response - - def post_list_snapshots_with_metadata(self, response: snapshot.ListSnapshotsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[snapshot.ListSnapshotsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for list_snapshots - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_list_snapshots_with_metadata` - interceptor in new development instead of the `post_list_snapshots` interceptor. - When both interceptors are used, this `post_list_snapshots_with_metadata` interceptor runs after the - `post_list_snapshots` interceptor. The (possibly modified) response returned by - `post_list_snapshots` will be passed to - `post_list_snapshots_with_metadata`. - """ - return response, metadata - - def pre_list_storage_pools(self, request: storage_pool.ListStoragePoolsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[storage_pool.ListStoragePoolsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_storage_pools - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_list_storage_pools(self, response: storage_pool.ListStoragePoolsResponse) -> storage_pool.ListStoragePoolsResponse: - """Post-rpc interceptor for list_storage_pools - - DEPRECATED. Please use the `post_list_storage_pools_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_list_storage_pools` interceptor runs - before the `post_list_storage_pools_with_metadata` interceptor. - """ - return response - - def post_list_storage_pools_with_metadata(self, response: storage_pool.ListStoragePoolsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[storage_pool.ListStoragePoolsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for list_storage_pools - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_list_storage_pools_with_metadata` - interceptor in new development instead of the `post_list_storage_pools` interceptor. - When both interceptors are used, this `post_list_storage_pools_with_metadata` interceptor runs after the - `post_list_storage_pools` interceptor. The (possibly modified) response returned by - `post_list_storage_pools` will be passed to - `post_list_storage_pools_with_metadata`. - """ - return response, metadata - - def pre_list_volumes(self, request: volume.ListVolumesRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[volume.ListVolumesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_volumes - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_list_volumes(self, response: volume.ListVolumesResponse) -> volume.ListVolumesResponse: - """Post-rpc interceptor for list_volumes - - DEPRECATED. Please use the `post_list_volumes_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_list_volumes` interceptor runs - before the `post_list_volumes_with_metadata` interceptor. - """ - return response - - def post_list_volumes_with_metadata(self, response: volume.ListVolumesResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[volume.ListVolumesResponse, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for list_volumes - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_list_volumes_with_metadata` - interceptor in new development instead of the `post_list_volumes` interceptor. - When both interceptors are used, this `post_list_volumes_with_metadata` interceptor runs after the - `post_list_volumes` interceptor. The (possibly modified) response returned by - `post_list_volumes` will be passed to - `post_list_volumes_with_metadata`. - """ - return response, metadata - - def pre_resume_replication(self, request: replication.ResumeReplicationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[replication.ResumeReplicationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for resume_replication - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_resume_replication(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for resume_replication - - DEPRECATED. Please use the `post_resume_replication_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_resume_replication` interceptor runs - before the `post_resume_replication_with_metadata` interceptor. - """ - return response - - def post_resume_replication_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for resume_replication - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_resume_replication_with_metadata` - interceptor in new development instead of the `post_resume_replication` interceptor. - When both interceptors are used, this `post_resume_replication_with_metadata` interceptor runs after the - `post_resume_replication` interceptor. The (possibly modified) response returned by - `post_resume_replication` will be passed to - `post_resume_replication_with_metadata`. - """ - return response, metadata - - def pre_reverse_replication_direction(self, request: replication.ReverseReplicationDirectionRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[replication.ReverseReplicationDirectionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for reverse_replication_direction - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_reverse_replication_direction(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for reverse_replication_direction - - DEPRECATED. Please use the `post_reverse_replication_direction_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_reverse_replication_direction` interceptor runs - before the `post_reverse_replication_direction_with_metadata` interceptor. - """ - return response - - def post_reverse_replication_direction_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for reverse_replication_direction - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_reverse_replication_direction_with_metadata` - interceptor in new development instead of the `post_reverse_replication_direction` interceptor. - When both interceptors are used, this `post_reverse_replication_direction_with_metadata` interceptor runs after the - `post_reverse_replication_direction` interceptor. The (possibly modified) response returned by - `post_reverse_replication_direction` will be passed to - `post_reverse_replication_direction_with_metadata`. - """ - return response, metadata - - def pre_revert_volume(self, request: volume.RevertVolumeRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[volume.RevertVolumeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for revert_volume - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_revert_volume(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for revert_volume - - DEPRECATED. Please use the `post_revert_volume_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_revert_volume` interceptor runs - before the `post_revert_volume_with_metadata` interceptor. - """ - return response - - def post_revert_volume_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for revert_volume - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_revert_volume_with_metadata` - interceptor in new development instead of the `post_revert_volume` interceptor. - When both interceptors are used, this `post_revert_volume_with_metadata` interceptor runs after the - `post_revert_volume` interceptor. The (possibly modified) response returned by - `post_revert_volume` will be passed to - `post_revert_volume_with_metadata`. - """ - return response, metadata - - def pre_stop_replication(self, request: replication.StopReplicationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[replication.StopReplicationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for stop_replication - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_stop_replication(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for stop_replication - - DEPRECATED. Please use the `post_stop_replication_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_stop_replication` interceptor runs - before the `post_stop_replication_with_metadata` interceptor. - """ - return response - - def post_stop_replication_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for stop_replication - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_stop_replication_with_metadata` - interceptor in new development instead of the `post_stop_replication` interceptor. - When both interceptors are used, this `post_stop_replication_with_metadata` interceptor runs after the - `post_stop_replication` interceptor. The (possibly modified) response returned by - `post_stop_replication` will be passed to - `post_stop_replication_with_metadata`. - """ - return response, metadata - - def pre_switch_active_replica_zone(self, request: storage_pool.SwitchActiveReplicaZoneRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[storage_pool.SwitchActiveReplicaZoneRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for switch_active_replica_zone - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_switch_active_replica_zone(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for switch_active_replica_zone - - DEPRECATED. Please use the `post_switch_active_replica_zone_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_switch_active_replica_zone` interceptor runs - before the `post_switch_active_replica_zone_with_metadata` interceptor. - """ - return response - - def post_switch_active_replica_zone_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for switch_active_replica_zone - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_switch_active_replica_zone_with_metadata` - interceptor in new development instead of the `post_switch_active_replica_zone` interceptor. - When both interceptors are used, this `post_switch_active_replica_zone_with_metadata` interceptor runs after the - `post_switch_active_replica_zone` interceptor. The (possibly modified) response returned by - `post_switch_active_replica_zone` will be passed to - `post_switch_active_replica_zone_with_metadata`. - """ - return response, metadata - - def pre_sync_replication(self, request: replication.SyncReplicationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[replication.SyncReplicationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for sync_replication - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_sync_replication(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for sync_replication - - DEPRECATED. Please use the `post_sync_replication_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_sync_replication` interceptor runs - before the `post_sync_replication_with_metadata` interceptor. - """ - return response - - def post_sync_replication_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for sync_replication - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_sync_replication_with_metadata` - interceptor in new development instead of the `post_sync_replication` interceptor. - When both interceptors are used, this `post_sync_replication_with_metadata` interceptor runs after the - `post_sync_replication` interceptor. The (possibly modified) response returned by - `post_sync_replication` will be passed to - `post_sync_replication_with_metadata`. - """ - return response, metadata - - def pre_update_active_directory(self, request: gcn_active_directory.UpdateActiveDirectoryRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_active_directory.UpdateActiveDirectoryRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for update_active_directory - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_update_active_directory(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for update_active_directory - - DEPRECATED. Please use the `post_update_active_directory_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_update_active_directory` interceptor runs - before the `post_update_active_directory_with_metadata` interceptor. - """ - return response - - def post_update_active_directory_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for update_active_directory - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_update_active_directory_with_metadata` - interceptor in new development instead of the `post_update_active_directory` interceptor. - When both interceptors are used, this `post_update_active_directory_with_metadata` interceptor runs after the - `post_update_active_directory` interceptor. The (possibly modified) response returned by - `post_update_active_directory` will be passed to - `post_update_active_directory_with_metadata`. - """ - return response, metadata - - def pre_update_backup(self, request: gcn_backup.UpdateBackupRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_backup.UpdateBackupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for update_backup - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_update_backup(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for update_backup - - DEPRECATED. Please use the `post_update_backup_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_update_backup` interceptor runs - before the `post_update_backup_with_metadata` interceptor. - """ - return response - - def post_update_backup_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for update_backup - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_update_backup_with_metadata` - interceptor in new development instead of the `post_update_backup` interceptor. - When both interceptors are used, this `post_update_backup_with_metadata` interceptor runs after the - `post_update_backup` interceptor. The (possibly modified) response returned by - `post_update_backup` will be passed to - `post_update_backup_with_metadata`. - """ - return response, metadata - - def pre_update_backup_policy(self, request: gcn_backup_policy.UpdateBackupPolicyRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_backup_policy.UpdateBackupPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for update_backup_policy - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_update_backup_policy(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for update_backup_policy - - DEPRECATED. Please use the `post_update_backup_policy_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_update_backup_policy` interceptor runs - before the `post_update_backup_policy_with_metadata` interceptor. - """ - return response - - def post_update_backup_policy_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for update_backup_policy - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_update_backup_policy_with_metadata` - interceptor in new development instead of the `post_update_backup_policy` interceptor. - When both interceptors are used, this `post_update_backup_policy_with_metadata` interceptor runs after the - `post_update_backup_policy` interceptor. The (possibly modified) response returned by - `post_update_backup_policy` will be passed to - `post_update_backup_policy_with_metadata`. - """ - return response, metadata - - def pre_update_backup_vault(self, request: gcn_backup_vault.UpdateBackupVaultRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_backup_vault.UpdateBackupVaultRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for update_backup_vault - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_update_backup_vault(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for update_backup_vault - - DEPRECATED. Please use the `post_update_backup_vault_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_update_backup_vault` interceptor runs - before the `post_update_backup_vault_with_metadata` interceptor. - """ - return response - - def post_update_backup_vault_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for update_backup_vault - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_update_backup_vault_with_metadata` - interceptor in new development instead of the `post_update_backup_vault` interceptor. - When both interceptors are used, this `post_update_backup_vault_with_metadata` interceptor runs after the - `post_update_backup_vault` interceptor. The (possibly modified) response returned by - `post_update_backup_vault` will be passed to - `post_update_backup_vault_with_metadata`. - """ - return response, metadata - - def pre_update_kms_config(self, request: kms.UpdateKmsConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[kms.UpdateKmsConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for update_kms_config - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_update_kms_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for update_kms_config - - DEPRECATED. Please use the `post_update_kms_config_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_update_kms_config` interceptor runs - before the `post_update_kms_config_with_metadata` interceptor. - """ - return response - - def post_update_kms_config_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for update_kms_config - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_update_kms_config_with_metadata` - interceptor in new development instead of the `post_update_kms_config` interceptor. - When both interceptors are used, this `post_update_kms_config_with_metadata` interceptor runs after the - `post_update_kms_config` interceptor. The (possibly modified) response returned by - `post_update_kms_config` will be passed to - `post_update_kms_config_with_metadata`. - """ - return response, metadata - - def pre_update_quota_rule(self, request: gcn_quota_rule.UpdateQuotaRuleRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_quota_rule.UpdateQuotaRuleRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for update_quota_rule - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_update_quota_rule(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for update_quota_rule - - DEPRECATED. Please use the `post_update_quota_rule_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_update_quota_rule` interceptor runs - before the `post_update_quota_rule_with_metadata` interceptor. - """ - return response - - def post_update_quota_rule_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for update_quota_rule - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_update_quota_rule_with_metadata` - interceptor in new development instead of the `post_update_quota_rule` interceptor. - When both interceptors are used, this `post_update_quota_rule_with_metadata` interceptor runs after the - `post_update_quota_rule` interceptor. The (possibly modified) response returned by - `post_update_quota_rule` will be passed to - `post_update_quota_rule_with_metadata`. - """ - return response, metadata - - def pre_update_replication(self, request: gcn_replication.UpdateReplicationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_replication.UpdateReplicationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for update_replication - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_update_replication(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for update_replication - - DEPRECATED. Please use the `post_update_replication_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_update_replication` interceptor runs - before the `post_update_replication_with_metadata` interceptor. - """ - return response - - def post_update_replication_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for update_replication - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_update_replication_with_metadata` - interceptor in new development instead of the `post_update_replication` interceptor. - When both interceptors are used, this `post_update_replication_with_metadata` interceptor runs after the - `post_update_replication` interceptor. The (possibly modified) response returned by - `post_update_replication` will be passed to - `post_update_replication_with_metadata`. - """ - return response, metadata - - def pre_update_snapshot(self, request: gcn_snapshot.UpdateSnapshotRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_snapshot.UpdateSnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for update_snapshot - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_update_snapshot(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for update_snapshot - - DEPRECATED. Please use the `post_update_snapshot_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_update_snapshot` interceptor runs - before the `post_update_snapshot_with_metadata` interceptor. - """ - return response - - def post_update_snapshot_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for update_snapshot - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_update_snapshot_with_metadata` - interceptor in new development instead of the `post_update_snapshot` interceptor. - When both interceptors are used, this `post_update_snapshot_with_metadata` interceptor runs after the - `post_update_snapshot` interceptor. The (possibly modified) response returned by - `post_update_snapshot` will be passed to - `post_update_snapshot_with_metadata`. - """ - return response, metadata - - def pre_update_storage_pool(self, request: gcn_storage_pool.UpdateStoragePoolRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_storage_pool.UpdateStoragePoolRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for update_storage_pool - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_update_storage_pool(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for update_storage_pool - - DEPRECATED. Please use the `post_update_storage_pool_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_update_storage_pool` interceptor runs - before the `post_update_storage_pool_with_metadata` interceptor. - """ - return response - - def post_update_storage_pool_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for update_storage_pool - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_update_storage_pool_with_metadata` - interceptor in new development instead of the `post_update_storage_pool` interceptor. - When both interceptors are used, this `post_update_storage_pool_with_metadata` interceptor runs after the - `post_update_storage_pool` interceptor. The (possibly modified) response returned by - `post_update_storage_pool` will be passed to - `post_update_storage_pool_with_metadata`. - """ - return response, metadata - - def pre_update_volume(self, request: gcn_volume.UpdateVolumeRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[gcn_volume.UpdateVolumeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for update_volume - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_update_volume(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for update_volume - - DEPRECATED. Please use the `post_update_volume_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_update_volume` interceptor runs - before the `post_update_volume_with_metadata` interceptor. - """ - return response - - def post_update_volume_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for update_volume - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_update_volume_with_metadata` - interceptor in new development instead of the `post_update_volume` interceptor. - When both interceptors are used, this `post_update_volume_with_metadata` interceptor runs after the - `post_update_volume` interceptor. The (possibly modified) response returned by - `post_update_volume` will be passed to - `post_update_volume_with_metadata`. - """ - return response, metadata - - def pre_validate_directory_service(self, request: storage_pool.ValidateDirectoryServiceRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[storage_pool.ValidateDirectoryServiceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for validate_directory_service - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_validate_directory_service(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for validate_directory_service - - DEPRECATED. Please use the `post_validate_directory_service_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_validate_directory_service` interceptor runs - before the `post_validate_directory_service_with_metadata` interceptor. - """ - return response - - def post_validate_directory_service_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for validate_directory_service - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_validate_directory_service_with_metadata` - interceptor in new development instead of the `post_validate_directory_service` interceptor. - When both interceptors are used, this `post_validate_directory_service_with_metadata` interceptor runs after the - `post_validate_directory_service` interceptor. The (possibly modified) response returned by - `post_validate_directory_service` will be passed to - `post_validate_directory_service_with_metadata`. - """ - return response, metadata - - def pre_verify_kms_config(self, request: kms.VerifyKmsConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[kms.VerifyKmsConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for verify_kms_config - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_verify_kms_config(self, response: kms.VerifyKmsConfigResponse) -> kms.VerifyKmsConfigResponse: - """Post-rpc interceptor for verify_kms_config - - DEPRECATED. Please use the `post_verify_kms_config_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. This `post_verify_kms_config` interceptor runs - before the `post_verify_kms_config_with_metadata` interceptor. - """ - return response - - def post_verify_kms_config_with_metadata(self, response: kms.VerifyKmsConfigResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[kms.VerifyKmsConfigResponse, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for verify_kms_config - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the NetApp server but before it is returned to user code. - - We recommend only using this `post_verify_kms_config_with_metadata` - interceptor in new development instead of the `post_verify_kms_config` interceptor. - When both interceptors are used, this `post_verify_kms_config_with_metadata` interceptor runs after the - `post_verify_kms_config` interceptor. The (possibly modified) response returned by - `post_verify_kms_config` will be passed to - `post_verify_kms_config_with_metadata`. - """ - return response, metadata - - def pre_get_location( - self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_location - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp 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 NetApp server but before - it is returned to user code. - """ - return response - - def pre_list_locations( - self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_locations - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp 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 NetApp server but before - it is returned to user code. - """ - return response - - def pre_cancel_operation( - self, request: operations_pb2.CancelOperationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for cancel_operation - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_cancel_operation( - self, response: None - ) -> None: - """Post-rpc interceptor for cancel_operation - - Override in a subclass to manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. - """ - return response - - def pre_delete_operation( - self, request: operations_pb2.DeleteOperationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for delete_operation - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_delete_operation( - self, response: None - ) -> None: - """Post-rpc interceptor for delete_operation - - Override in a subclass to manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. - """ - return response - - def pre_get_operation( - self, request: operations_pb2.GetOperationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_operation - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp 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 NetApp server but before - it is returned to user code. - """ - return response - - def pre_list_operations( - self, request: operations_pb2.ListOperationsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_operations - - Override in a subclass to manipulate the request or metadata - before they are sent to the NetApp server. - """ - return request, metadata - - def post_list_operations( - self, response: operations_pb2.ListOperationsResponse - ) -> operations_pb2.ListOperationsResponse: - """Post-rpc interceptor for list_operations - - Override in a subclass to manipulate the response - after it is returned by the NetApp server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class NetAppRestStub: - _session: AuthorizedSession - _host: str - _interceptor: NetAppRestInterceptor - - -class NetAppRestTransport(_BaseNetAppRestTransport): - """REST backend synchronous transport for NetApp. - - NetApp Files Google Cloud Service - - 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 = 'netapp.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[NetAppRestInterceptor] = None, - api_audience: Optional[str] = None, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to (default: 'netapp.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 NetAppRestInterceptor() - 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.CancelOperation': [ - { - 'method': 'post', - 'uri': '/v1/{name=projects/*/locations/*/operations/*}:cancel', - 'body': '*', - }, - ], - 'google.longrunning.Operations.DeleteOperation': [ - { - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/operations/*}', - }, - ], - 'google.longrunning.Operations.GetOperation': [ - { - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/operations/*}', - }, - ], - 'google.longrunning.Operations.ListOperations': [ - { - '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 _CreateActiveDirectory(_BaseNetAppRestTransport._BaseCreateActiveDirectory, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.CreateActiveDirectory") - - @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: gcn_active_directory.CreateActiveDirectoryRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the create active directory method over HTTP. - - Args: - request (~.gcn_active_directory.CreateActiveDirectoryRequest): - The request object. CreateActiveDirectoryRequest for - creating an active directory. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseCreateActiveDirectory._get_http_options() - - request, metadata = self._interceptor.pre_create_active_directory(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseCreateActiveDirectory._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseCreateActiveDirectory._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseCreateActiveDirectory._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.CreateActiveDirectory", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "CreateActiveDirectory", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._CreateActiveDirectory._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_active_directory(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_create_active_directory_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.create_active_directory", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "CreateActiveDirectory", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _CreateBackup(_BaseNetAppRestTransport._BaseCreateBackup, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.CreateBackup") - - @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: gcn_backup.CreateBackupRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the create backup method over HTTP. - - Args: - request (~.gcn_backup.CreateBackupRequest): - The request object. CreateBackupRequest creates a backup. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseCreateBackup._get_http_options() - - request, metadata = self._interceptor.pre_create_backup(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseCreateBackup._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseCreateBackup._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseCreateBackup._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.CreateBackup", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "CreateBackup", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._CreateBackup._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_backup(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_create_backup_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.create_backup", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "CreateBackup", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _CreateBackupPolicy(_BaseNetAppRestTransport._BaseCreateBackupPolicy, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.CreateBackupPolicy") - - @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: gcn_backup_policy.CreateBackupPolicyRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the create backup policy method over HTTP. - - Args: - request (~.gcn_backup_policy.CreateBackupPolicyRequest): - The request object. CreateBackupPolicyRequest creates a - backupPolicy. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseCreateBackupPolicy._get_http_options() - - request, metadata = self._interceptor.pre_create_backup_policy(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseCreateBackupPolicy._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseCreateBackupPolicy._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseCreateBackupPolicy._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.CreateBackupPolicy", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "CreateBackupPolicy", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._CreateBackupPolicy._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_backup_policy(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_create_backup_policy_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.create_backup_policy", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "CreateBackupPolicy", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _CreateBackupVault(_BaseNetAppRestTransport._BaseCreateBackupVault, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.CreateBackupVault") - - @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: gcn_backup_vault.CreateBackupVaultRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the create backup vault method over HTTP. - - Args: - request (~.gcn_backup_vault.CreateBackupVaultRequest): - The request object. CreateBackupVaultRequest creates a - backup vault. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseCreateBackupVault._get_http_options() - - request, metadata = self._interceptor.pre_create_backup_vault(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseCreateBackupVault._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseCreateBackupVault._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseCreateBackupVault._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.CreateBackupVault", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "CreateBackupVault", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._CreateBackupVault._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_backup_vault(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_create_backup_vault_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.create_backup_vault", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "CreateBackupVault", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _CreateKmsConfig(_BaseNetAppRestTransport._BaseCreateKmsConfig, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.CreateKmsConfig") - - @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: kms.CreateKmsConfigRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the create kms config method over HTTP. - - Args: - request (~.kms.CreateKmsConfigRequest): - The request object. CreateKmsConfigRequest creates a KMS - Config. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseCreateKmsConfig._get_http_options() - - request, metadata = self._interceptor.pre_create_kms_config(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseCreateKmsConfig._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseCreateKmsConfig._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseCreateKmsConfig._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.CreateKmsConfig", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "CreateKmsConfig", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._CreateKmsConfig._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_kms_config(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_create_kms_config_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.create_kms_config", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "CreateKmsConfig", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _CreateQuotaRule(_BaseNetAppRestTransport._BaseCreateQuotaRule, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.CreateQuotaRule") - - @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: gcn_quota_rule.CreateQuotaRuleRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the create quota rule method over HTTP. - - Args: - request (~.gcn_quota_rule.CreateQuotaRuleRequest): - The request object. CreateQuotaRuleRequest for creating a - quota 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseCreateQuotaRule._get_http_options() - - request, metadata = self._interceptor.pre_create_quota_rule(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseCreateQuotaRule._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseCreateQuotaRule._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseCreateQuotaRule._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.CreateQuotaRule", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "CreateQuotaRule", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._CreateQuotaRule._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_quota_rule(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_create_quota_rule_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.create_quota_rule", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "CreateQuotaRule", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _CreateReplication(_BaseNetAppRestTransport._BaseCreateReplication, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.CreateReplication") - - @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: gcn_replication.CreateReplicationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the create replication method over HTTP. - - Args: - request (~.gcn_replication.CreateReplicationRequest): - The request object. CreateReplicationRequest creates a - replication. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseCreateReplication._get_http_options() - - request, metadata = self._interceptor.pre_create_replication(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseCreateReplication._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseCreateReplication._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseCreateReplication._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.CreateReplication", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "CreateReplication", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._CreateReplication._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_replication(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_create_replication_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.create_replication", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "CreateReplication", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _CreateSnapshot(_BaseNetAppRestTransport._BaseCreateSnapshot, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.CreateSnapshot") - - @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: gcn_snapshot.CreateSnapshotRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the create snapshot method over HTTP. - - Args: - request (~.gcn_snapshot.CreateSnapshotRequest): - The request object. CreateSnapshotRequest creates a - snapshot. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseCreateSnapshot._get_http_options() - - request, metadata = self._interceptor.pre_create_snapshot(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseCreateSnapshot._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseCreateSnapshot._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseCreateSnapshot._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.CreateSnapshot", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "CreateSnapshot", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._CreateSnapshot._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_snapshot(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_create_snapshot_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.create_snapshot", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "CreateSnapshot", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _CreateStoragePool(_BaseNetAppRestTransport._BaseCreateStoragePool, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.CreateStoragePool") - - @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: gcn_storage_pool.CreateStoragePoolRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the create storage pool method over HTTP. - - Args: - request (~.gcn_storage_pool.CreateStoragePoolRequest): - The request object. CreateStoragePoolRequest creates a - Storage Pool. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseCreateStoragePool._get_http_options() - - request, metadata = self._interceptor.pre_create_storage_pool(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseCreateStoragePool._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseCreateStoragePool._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseCreateStoragePool._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.CreateStoragePool", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "CreateStoragePool", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._CreateStoragePool._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_storage_pool(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_create_storage_pool_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.create_storage_pool", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "CreateStoragePool", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _CreateVolume(_BaseNetAppRestTransport._BaseCreateVolume, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.CreateVolume") - - @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: gcn_volume.CreateVolumeRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the create volume method over HTTP. - - Args: - request (~.gcn_volume.CreateVolumeRequest): - The request object. Message for creating a Volume - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseCreateVolume._get_http_options() - - request, metadata = self._interceptor.pre_create_volume(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseCreateVolume._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseCreateVolume._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseCreateVolume._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.CreateVolume", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "CreateVolume", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._CreateVolume._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_volume(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_create_volume_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.create_volume", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "CreateVolume", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _DeleteActiveDirectory(_BaseNetAppRestTransport._BaseDeleteActiveDirectory, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.DeleteActiveDirectory") - - @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: active_directory.DeleteActiveDirectoryRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete active directory method over HTTP. - - Args: - request (~.active_directory.DeleteActiveDirectoryRequest): - The request object. DeleteActiveDirectoryRequest for - deleting a single active directory. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseDeleteActiveDirectory._get_http_options() - - request, metadata = self._interceptor.pre_delete_active_directory(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseDeleteActiveDirectory._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseDeleteActiveDirectory._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteActiveDirectory", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "DeleteActiveDirectory", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._DeleteActiveDirectory._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_active_directory(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_delete_active_directory_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.delete_active_directory", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "DeleteActiveDirectory", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _DeleteBackup(_BaseNetAppRestTransport._BaseDeleteBackup, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.DeleteBackup") - - @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: backup.DeleteBackupRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete backup method over HTTP. - - Args: - request (~.backup.DeleteBackupRequest): - The request object. DeleteBackupRequest deletes a backup. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseDeleteBackup._get_http_options() - - request, metadata = self._interceptor.pre_delete_backup(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseDeleteBackup._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseDeleteBackup._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteBackup", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "DeleteBackup", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._DeleteBackup._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_backup(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_delete_backup_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.delete_backup", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "DeleteBackup", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _DeleteBackupPolicy(_BaseNetAppRestTransport._BaseDeleteBackupPolicy, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.DeleteBackupPolicy") - - @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: backup_policy.DeleteBackupPolicyRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete backup policy method over HTTP. - - Args: - request (~.backup_policy.DeleteBackupPolicyRequest): - The request object. DeleteBackupPolicyRequest deletes a - backup policy. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseDeleteBackupPolicy._get_http_options() - - request, metadata = self._interceptor.pre_delete_backup_policy(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseDeleteBackupPolicy._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseDeleteBackupPolicy._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteBackupPolicy", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "DeleteBackupPolicy", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._DeleteBackupPolicy._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_backup_policy(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_delete_backup_policy_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.delete_backup_policy", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "DeleteBackupPolicy", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _DeleteBackupVault(_BaseNetAppRestTransport._BaseDeleteBackupVault, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.DeleteBackupVault") - - @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: backup_vault.DeleteBackupVaultRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete backup vault method over HTTP. - - Args: - request (~.backup_vault.DeleteBackupVaultRequest): - The request object. DeleteBackupVaultRequest deletes a - backupVault. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseDeleteBackupVault._get_http_options() - - request, metadata = self._interceptor.pre_delete_backup_vault(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseDeleteBackupVault._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseDeleteBackupVault._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteBackupVault", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "DeleteBackupVault", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._DeleteBackupVault._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_backup_vault(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_delete_backup_vault_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.delete_backup_vault", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "DeleteBackupVault", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _DeleteKmsConfig(_BaseNetAppRestTransport._BaseDeleteKmsConfig, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.DeleteKmsConfig") - - @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: kms.DeleteKmsConfigRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete kms config method over HTTP. - - Args: - request (~.kms.DeleteKmsConfigRequest): - The request object. DeleteKmsConfigRequest deletes a KMS - Config. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseDeleteKmsConfig._get_http_options() - - request, metadata = self._interceptor.pre_delete_kms_config(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseDeleteKmsConfig._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseDeleteKmsConfig._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteKmsConfig", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "DeleteKmsConfig", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._DeleteKmsConfig._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_kms_config(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_delete_kms_config_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.delete_kms_config", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "DeleteKmsConfig", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _DeleteQuotaRule(_BaseNetAppRestTransport._BaseDeleteQuotaRule, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.DeleteQuotaRule") - - @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: quota_rule.DeleteQuotaRuleRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete quota rule method over HTTP. - - Args: - request (~.quota_rule.DeleteQuotaRuleRequest): - The request object. DeleteQuotaRuleRequest for deleting a - single quota 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseDeleteQuotaRule._get_http_options() - - request, metadata = self._interceptor.pre_delete_quota_rule(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseDeleteQuotaRule._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseDeleteQuotaRule._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteQuotaRule", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "DeleteQuotaRule", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._DeleteQuotaRule._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_quota_rule(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_delete_quota_rule_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.delete_quota_rule", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "DeleteQuotaRule", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _DeleteReplication(_BaseNetAppRestTransport._BaseDeleteReplication, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.DeleteReplication") - - @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: replication.DeleteReplicationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete replication method over HTTP. - - Args: - request (~.replication.DeleteReplicationRequest): - The request object. DeleteReplicationRequest deletes a - replication. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseDeleteReplication._get_http_options() - - request, metadata = self._interceptor.pre_delete_replication(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseDeleteReplication._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseDeleteReplication._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteReplication", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "DeleteReplication", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._DeleteReplication._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_replication(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_delete_replication_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.delete_replication", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "DeleteReplication", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _DeleteSnapshot(_BaseNetAppRestTransport._BaseDeleteSnapshot, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.DeleteSnapshot") - - @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: snapshot.DeleteSnapshotRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete snapshot method over HTTP. - - Args: - request (~.snapshot.DeleteSnapshotRequest): - The request object. DeleteSnapshotRequest deletes a - snapshot. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseDeleteSnapshot._get_http_options() - - request, metadata = self._interceptor.pre_delete_snapshot(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseDeleteSnapshot._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseDeleteSnapshot._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteSnapshot", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "DeleteSnapshot", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._DeleteSnapshot._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_snapshot(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_delete_snapshot_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.delete_snapshot", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "DeleteSnapshot", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _DeleteStoragePool(_BaseNetAppRestTransport._BaseDeleteStoragePool, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.DeleteStoragePool") - - @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: storage_pool.DeleteStoragePoolRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete storage pool method over HTTP. - - Args: - request (~.storage_pool.DeleteStoragePoolRequest): - The request object. DeleteStoragePoolRequest deletes a - Storage Pool. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseDeleteStoragePool._get_http_options() - - request, metadata = self._interceptor.pre_delete_storage_pool(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseDeleteStoragePool._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseDeleteStoragePool._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteStoragePool", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "DeleteStoragePool", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._DeleteStoragePool._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_storage_pool(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_delete_storage_pool_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.delete_storage_pool", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "DeleteStoragePool", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _DeleteVolume(_BaseNetAppRestTransport._BaseDeleteVolume, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.DeleteVolume") - - @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: volume.DeleteVolumeRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete volume method over HTTP. - - Args: - request (~.volume.DeleteVolumeRequest): - The request object. Message for deleting a Volume - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseDeleteVolume._get_http_options() - - request, metadata = self._interceptor.pre_delete_volume(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseDeleteVolume._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseDeleteVolume._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteVolume", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "DeleteVolume", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._DeleteVolume._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_volume(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_delete_volume_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.delete_volume", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "DeleteVolume", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _EncryptVolumes(_BaseNetAppRestTransport._BaseEncryptVolumes, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.EncryptVolumes") - - @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: kms.EncryptVolumesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the encrypt volumes method over HTTP. - - Args: - request (~.kms.EncryptVolumesRequest): - The request object. EncryptVolumesRequest specifies the - KMS config to encrypt existing volumes. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseEncryptVolumes._get_http_options() - - request, metadata = self._interceptor.pre_encrypt_volumes(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseEncryptVolumes._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseEncryptVolumes._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseEncryptVolumes._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.EncryptVolumes", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "EncryptVolumes", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._EncryptVolumes._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_encrypt_volumes(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_encrypt_volumes_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.encrypt_volumes", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "EncryptVolumes", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _EstablishPeering(_BaseNetAppRestTransport._BaseEstablishPeering, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.EstablishPeering") - - @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: replication.EstablishPeeringRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the establish peering method over HTTP. - - Args: - request (~.replication.EstablishPeeringRequest): - The request object. EstablishPeeringRequest establishes - cluster and svm peerings between the - source and the destination replications. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseEstablishPeering._get_http_options() - - request, metadata = self._interceptor.pre_establish_peering(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseEstablishPeering._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseEstablishPeering._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseEstablishPeering._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.EstablishPeering", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "EstablishPeering", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._EstablishPeering._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_establish_peering(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_establish_peering_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.establish_peering", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "EstablishPeering", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _GetActiveDirectory(_BaseNetAppRestTransport._BaseGetActiveDirectory, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.GetActiveDirectory") - - @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: active_directory.GetActiveDirectoryRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> active_directory.ActiveDirectory: - r"""Call the get active directory method over HTTP. - - Args: - request (~.active_directory.GetActiveDirectoryRequest): - The request object. GetActiveDirectory for getting a - single active directory. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.active_directory.ActiveDirectory: - ActiveDirectory is the public - representation of the active directory - config. - - """ - - http_options = _BaseNetAppRestTransport._BaseGetActiveDirectory._get_http_options() - - request, metadata = self._interceptor.pre_get_active_directory(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseGetActiveDirectory._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseGetActiveDirectory._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.GetActiveDirectory", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetActiveDirectory", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._GetActiveDirectory._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 = active_directory.ActiveDirectory() - pb_resp = active_directory.ActiveDirectory.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_get_active_directory(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_active_directory_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = active_directory.ActiveDirectory.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.get_active_directory", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetActiveDirectory", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _GetBackup(_BaseNetAppRestTransport._BaseGetBackup, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.GetBackup") - - @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: backup.GetBackupRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> backup.Backup: - r"""Call the get backup method over HTTP. - - Args: - request (~.backup.GetBackupRequest): - The request object. GetBackupRequest gets the state of a - backup. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.backup.Backup: - A NetApp Backup. - """ - - http_options = _BaseNetAppRestTransport._BaseGetBackup._get_http_options() - - request, metadata = self._interceptor.pre_get_backup(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseGetBackup._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseGetBackup._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.GetBackup", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetBackup", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._GetBackup._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 = backup.Backup() - pb_resp = backup.Backup.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_get_backup(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_backup_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = backup.Backup.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.get_backup", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetBackup", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _GetBackupPolicy(_BaseNetAppRestTransport._BaseGetBackupPolicy, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.GetBackupPolicy") - - @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: backup_policy.GetBackupPolicyRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> backup_policy.BackupPolicy: - r"""Call the get backup policy method over HTTP. - - Args: - request (~.backup_policy.GetBackupPolicyRequest): - The request object. GetBackupPolicyRequest gets the state - of a backupPolicy. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.backup_policy.BackupPolicy: - Backup Policy. - """ - - http_options = _BaseNetAppRestTransport._BaseGetBackupPolicy._get_http_options() - - request, metadata = self._interceptor.pre_get_backup_policy(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseGetBackupPolicy._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseGetBackupPolicy._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.GetBackupPolicy", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetBackupPolicy", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._GetBackupPolicy._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 = backup_policy.BackupPolicy() - pb_resp = backup_policy.BackupPolicy.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_get_backup_policy(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_backup_policy_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = backup_policy.BackupPolicy.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.get_backup_policy", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetBackupPolicy", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _GetBackupVault(_BaseNetAppRestTransport._BaseGetBackupVault, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.GetBackupVault") - - @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: backup_vault.GetBackupVaultRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> backup_vault.BackupVault: - r"""Call the get backup vault method over HTTP. - - Args: - request (~.backup_vault.GetBackupVaultRequest): - The request object. GetBackupVaultRequest gets the state - of a backupVault. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.backup_vault.BackupVault: - A NetApp BackupVault. - """ - - http_options = _BaseNetAppRestTransport._BaseGetBackupVault._get_http_options() - - request, metadata = self._interceptor.pre_get_backup_vault(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseGetBackupVault._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseGetBackupVault._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.GetBackupVault", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetBackupVault", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._GetBackupVault._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 = backup_vault.BackupVault() - pb_resp = backup_vault.BackupVault.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_get_backup_vault(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_backup_vault_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = backup_vault.BackupVault.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.get_backup_vault", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetBackupVault", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _GetKmsConfig(_BaseNetAppRestTransport._BaseGetKmsConfig, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.GetKmsConfig") - - @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: kms.GetKmsConfigRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> kms.KmsConfig: - r"""Call the get kms config method over HTTP. - - Args: - request (~.kms.GetKmsConfigRequest): - The request object. GetKmsConfigRequest gets a KMS - Config. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.kms.KmsConfig: - KmsConfig is the customer managed - encryption key(CMEK) configuration. - - """ - - http_options = _BaseNetAppRestTransport._BaseGetKmsConfig._get_http_options() - - request, metadata = self._interceptor.pre_get_kms_config(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseGetKmsConfig._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseGetKmsConfig._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.GetKmsConfig", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetKmsConfig", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._GetKmsConfig._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 = kms.KmsConfig() - pb_resp = kms.KmsConfig.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_get_kms_config(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_kms_config_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = kms.KmsConfig.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.get_kms_config", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetKmsConfig", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _GetQuotaRule(_BaseNetAppRestTransport._BaseGetQuotaRule, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.GetQuotaRule") - - @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: quota_rule.GetQuotaRuleRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> quota_rule.QuotaRule: - r"""Call the get quota rule method over HTTP. - - Args: - request (~.quota_rule.GetQuotaRuleRequest): - The request object. GetQuotaRuleRequest for getting a - quota 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.quota_rule.QuotaRule: - QuotaRule specifies the maximum disk - space a user or group can use within a - volume. They can be used for creating - default and individual quota rules. - - """ - - http_options = _BaseNetAppRestTransport._BaseGetQuotaRule._get_http_options() - - request, metadata = self._interceptor.pre_get_quota_rule(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseGetQuotaRule._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseGetQuotaRule._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.GetQuotaRule", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetQuotaRule", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._GetQuotaRule._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 = quota_rule.QuotaRule() - pb_resp = quota_rule.QuotaRule.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_get_quota_rule(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_quota_rule_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = quota_rule.QuotaRule.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.get_quota_rule", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetQuotaRule", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _GetReplication(_BaseNetAppRestTransport._BaseGetReplication, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.GetReplication") - - @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: replication.GetReplicationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> replication.Replication: - r"""Call the get replication method over HTTP. - - Args: - request (~.replication.GetReplicationRequest): - The request object. GetReplicationRequest gets the state - of a replication. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.replication.Replication: - Replication is a nested resource - under Volume, that describes a - cross-region replication relationship - between 2 volumes in different regions. - - """ - - http_options = _BaseNetAppRestTransport._BaseGetReplication._get_http_options() - - request, metadata = self._interceptor.pre_get_replication(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseGetReplication._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseGetReplication._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.GetReplication", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetReplication", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._GetReplication._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 = replication.Replication() - pb_resp = replication.Replication.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_get_replication(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_replication_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = replication.Replication.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.get_replication", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetReplication", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _GetSnapshot(_BaseNetAppRestTransport._BaseGetSnapshot, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.GetSnapshot") - - @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: snapshot.GetSnapshotRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> snapshot.Snapshot: - r"""Call the get snapshot method over HTTP. - - Args: - request (~.snapshot.GetSnapshotRequest): - The request object. GetSnapshotRequest gets the state of - a snapshot. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.snapshot.Snapshot: - Snapshot is a point-in-time version - of a Volume's content. - - """ - - http_options = _BaseNetAppRestTransport._BaseGetSnapshot._get_http_options() - - request, metadata = self._interceptor.pre_get_snapshot(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseGetSnapshot._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseGetSnapshot._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.GetSnapshot", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetSnapshot", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._GetSnapshot._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 = snapshot.Snapshot() - pb_resp = snapshot.Snapshot.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_get_snapshot(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_snapshot_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = snapshot.Snapshot.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.get_snapshot", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetSnapshot", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _GetStoragePool(_BaseNetAppRestTransport._BaseGetStoragePool, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.GetStoragePool") - - @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: storage_pool.GetStoragePoolRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> storage_pool.StoragePool: - r"""Call the get storage pool method over HTTP. - - Args: - request (~.storage_pool.GetStoragePoolRequest): - The request object. GetStoragePoolRequest gets a Storage - Pool. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.storage_pool.StoragePool: - StoragePool is a container for - volumes with a service level and - capacity. Volumes can be created in a - pool of sufficient available capacity. - StoragePool capacity is what you are - billed for. - - """ - - http_options = _BaseNetAppRestTransport._BaseGetStoragePool._get_http_options() - - request, metadata = self._interceptor.pre_get_storage_pool(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseGetStoragePool._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseGetStoragePool._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.GetStoragePool", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetStoragePool", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._GetStoragePool._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 = storage_pool.StoragePool() - pb_resp = storage_pool.StoragePool.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_get_storage_pool(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_storage_pool_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = storage_pool.StoragePool.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.get_storage_pool", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetStoragePool", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _GetVolume(_BaseNetAppRestTransport._BaseGetVolume, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.GetVolume") - - @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: volume.GetVolumeRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> volume.Volume: - r"""Call the get volume method over HTTP. - - Args: - request (~.volume.GetVolumeRequest): - The request object. Message for getting a Volume - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.volume.Volume: - Volume provides a filesystem that you - can mount. - - """ - - http_options = _BaseNetAppRestTransport._BaseGetVolume._get_http_options() - - request, metadata = self._interceptor.pre_get_volume(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseGetVolume._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseGetVolume._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.GetVolume", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetVolume", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._GetVolume._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 = volume.Volume() - pb_resp = volume.Volume.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_get_volume(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_volume_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = volume.Volume.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.get_volume", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetVolume", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _ListActiveDirectories(_BaseNetAppRestTransport._BaseListActiveDirectories, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.ListActiveDirectories") - - @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: active_directory.ListActiveDirectoriesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> active_directory.ListActiveDirectoriesResponse: - r"""Call the list active directories method over HTTP. - - Args: - request (~.active_directory.ListActiveDirectoriesRequest): - The request object. ListActiveDirectoriesRequest for - requesting multiple active directories. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.active_directory.ListActiveDirectoriesResponse: - ListActiveDirectoriesResponse - contains all the active directories - requested. - - """ - - http_options = _BaseNetAppRestTransport._BaseListActiveDirectories._get_http_options() - - request, metadata = self._interceptor.pre_list_active_directories(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseListActiveDirectories._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseListActiveDirectories._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.ListActiveDirectories", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListActiveDirectories", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._ListActiveDirectories._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 = active_directory.ListActiveDirectoriesResponse() - pb_resp = active_directory.ListActiveDirectoriesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_list_active_directories(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_list_active_directories_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = active_directory.ListActiveDirectoriesResponse.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.list_active_directories", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListActiveDirectories", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _ListBackupPolicies(_BaseNetAppRestTransport._BaseListBackupPolicies, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.ListBackupPolicies") - - @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: backup_policy.ListBackupPoliciesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> backup_policy.ListBackupPoliciesResponse: - r"""Call the list backup policies method over HTTP. - - Args: - request (~.backup_policy.ListBackupPoliciesRequest): - The request object. ListBackupPoliciesRequest for - requesting multiple backup policies. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.backup_policy.ListBackupPoliciesResponse: - ListBackupPoliciesResponse contains - all the backup policies requested. - - """ - - http_options = _BaseNetAppRestTransport._BaseListBackupPolicies._get_http_options() - - request, metadata = self._interceptor.pre_list_backup_policies(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseListBackupPolicies._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseListBackupPolicies._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.ListBackupPolicies", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListBackupPolicies", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._ListBackupPolicies._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 = backup_policy.ListBackupPoliciesResponse() - pb_resp = backup_policy.ListBackupPoliciesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_list_backup_policies(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_list_backup_policies_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = backup_policy.ListBackupPoliciesResponse.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.list_backup_policies", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListBackupPolicies", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _ListBackups(_BaseNetAppRestTransport._BaseListBackups, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.ListBackups") - - @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: backup.ListBackupsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> backup.ListBackupsResponse: - r"""Call the list backups method over HTTP. - - Args: - request (~.backup.ListBackupsRequest): - The request object. ListBackupsRequest lists backups. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.backup.ListBackupsResponse: - ListBackupsResponse is the result of - ListBackupsRequest. - - """ - - http_options = _BaseNetAppRestTransport._BaseListBackups._get_http_options() - - request, metadata = self._interceptor.pre_list_backups(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseListBackups._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseListBackups._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.ListBackups", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListBackups", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._ListBackups._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 = backup.ListBackupsResponse() - pb_resp = backup.ListBackupsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_list_backups(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_list_backups_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = backup.ListBackupsResponse.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.list_backups", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListBackups", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _ListBackupVaults(_BaseNetAppRestTransport._BaseListBackupVaults, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.ListBackupVaults") - - @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: backup_vault.ListBackupVaultsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> backup_vault.ListBackupVaultsResponse: - r"""Call the list backup vaults method over HTTP. - - Args: - request (~.backup_vault.ListBackupVaultsRequest): - The request object. ListBackupVaultsRequest lists - backupVaults. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.backup_vault.ListBackupVaultsResponse: - ListBackupVaultsResponse is the - result of ListBackupVaultsRequest. - - """ - - http_options = _BaseNetAppRestTransport._BaseListBackupVaults._get_http_options() - - request, metadata = self._interceptor.pre_list_backup_vaults(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseListBackupVaults._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseListBackupVaults._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.ListBackupVaults", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListBackupVaults", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._ListBackupVaults._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 = backup_vault.ListBackupVaultsResponse() - pb_resp = backup_vault.ListBackupVaultsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_list_backup_vaults(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_list_backup_vaults_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = backup_vault.ListBackupVaultsResponse.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.list_backup_vaults", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListBackupVaults", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _ListKmsConfigs(_BaseNetAppRestTransport._BaseListKmsConfigs, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.ListKmsConfigs") - - @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: kms.ListKmsConfigsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> kms.ListKmsConfigsResponse: - r"""Call the list kms configs method over HTTP. - - Args: - request (~.kms.ListKmsConfigsRequest): - The request object. ListKmsConfigsRequest lists KMS - Configs. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.kms.ListKmsConfigsResponse: - ListKmsConfigsResponse is the - response to a ListKmsConfigsRequest. - - """ - - http_options = _BaseNetAppRestTransport._BaseListKmsConfigs._get_http_options() - - request, metadata = self._interceptor.pre_list_kms_configs(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseListKmsConfigs._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseListKmsConfigs._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.ListKmsConfigs", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListKmsConfigs", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._ListKmsConfigs._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 = kms.ListKmsConfigsResponse() - pb_resp = kms.ListKmsConfigsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_list_kms_configs(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_list_kms_configs_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = kms.ListKmsConfigsResponse.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.list_kms_configs", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListKmsConfigs", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _ListQuotaRules(_BaseNetAppRestTransport._BaseListQuotaRules, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.ListQuotaRules") - - @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: quota_rule.ListQuotaRulesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> quota_rule.ListQuotaRulesResponse: - r"""Call the list quota rules method over HTTP. - - Args: - request (~.quota_rule.ListQuotaRulesRequest): - The request object. ListQuotaRulesRequest for listing - quota 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.quota_rule.ListQuotaRulesResponse: - ListQuotaRulesResponse is the - response to a ListQuotaRulesRequest. - - """ - - http_options = _BaseNetAppRestTransport._BaseListQuotaRules._get_http_options() - - request, metadata = self._interceptor.pre_list_quota_rules(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseListQuotaRules._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseListQuotaRules._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.ListQuotaRules", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListQuotaRules", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._ListQuotaRules._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 = quota_rule.ListQuotaRulesResponse() - pb_resp = quota_rule.ListQuotaRulesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_list_quota_rules(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_list_quota_rules_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = quota_rule.ListQuotaRulesResponse.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.list_quota_rules", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListQuotaRules", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _ListReplications(_BaseNetAppRestTransport._BaseListReplications, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.ListReplications") - - @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: replication.ListReplicationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> replication.ListReplicationsResponse: - r"""Call the list replications method over HTTP. - - Args: - request (~.replication.ListReplicationsRequest): - The request object. ListReplications lists replications. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.replication.ListReplicationsResponse: - ListReplicationsResponse is the - result of ListReplicationsRequest. - - """ - - http_options = _BaseNetAppRestTransport._BaseListReplications._get_http_options() - - request, metadata = self._interceptor.pre_list_replications(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseListReplications._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseListReplications._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.ListReplications", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListReplications", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._ListReplications._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 = replication.ListReplicationsResponse() - pb_resp = replication.ListReplicationsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_list_replications(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_list_replications_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = replication.ListReplicationsResponse.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.list_replications", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListReplications", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _ListSnapshots(_BaseNetAppRestTransport._BaseListSnapshots, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.ListSnapshots") - - @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: snapshot.ListSnapshotsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> snapshot.ListSnapshotsResponse: - r"""Call the list snapshots method over HTTP. - - Args: - request (~.snapshot.ListSnapshotsRequest): - The request object. ListSnapshotsRequest lists snapshots. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.snapshot.ListSnapshotsResponse: - ListSnapshotsResponse is the result - of ListSnapshotsRequest. - - """ - - http_options = _BaseNetAppRestTransport._BaseListSnapshots._get_http_options() - - request, metadata = self._interceptor.pre_list_snapshots(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseListSnapshots._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseListSnapshots._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.ListSnapshots", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListSnapshots", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._ListSnapshots._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 = snapshot.ListSnapshotsResponse() - pb_resp = snapshot.ListSnapshotsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_list_snapshots(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_list_snapshots_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = snapshot.ListSnapshotsResponse.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.list_snapshots", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListSnapshots", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _ListStoragePools(_BaseNetAppRestTransport._BaseListStoragePools, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.ListStoragePools") - - @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: storage_pool.ListStoragePoolsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> storage_pool.ListStoragePoolsResponse: - r"""Call the list storage pools method over HTTP. - - Args: - request (~.storage_pool.ListStoragePoolsRequest): - The request object. ListStoragePoolsRequest lists Storage - Pools. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.storage_pool.ListStoragePoolsResponse: - ListStoragePoolsResponse is the - response to a ListStoragePoolsRequest. - - """ - - http_options = _BaseNetAppRestTransport._BaseListStoragePools._get_http_options() - - request, metadata = self._interceptor.pre_list_storage_pools(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseListStoragePools._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseListStoragePools._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.ListStoragePools", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListStoragePools", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._ListStoragePools._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 = storage_pool.ListStoragePoolsResponse() - pb_resp = storage_pool.ListStoragePoolsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_list_storage_pools(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_list_storage_pools_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = storage_pool.ListStoragePoolsResponse.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.list_storage_pools", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListStoragePools", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _ListVolumes(_BaseNetAppRestTransport._BaseListVolumes, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.ListVolumes") - - @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: volume.ListVolumesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> volume.ListVolumesResponse: - r"""Call the list volumes method over HTTP. - - Args: - request (~.volume.ListVolumesRequest): - The request object. Message for requesting list of - Volumes - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.volume.ListVolumesResponse: - Message for response to listing - Volumes - - """ - - http_options = _BaseNetAppRestTransport._BaseListVolumes._get_http_options() - - request, metadata = self._interceptor.pre_list_volumes(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseListVolumes._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseListVolumes._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.ListVolumes", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListVolumes", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._ListVolumes._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 = volume.ListVolumesResponse() - pb_resp = volume.ListVolumesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_list_volumes(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_list_volumes_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = volume.ListVolumesResponse.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.list_volumes", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListVolumes", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _ResumeReplication(_BaseNetAppRestTransport._BaseResumeReplication, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.ResumeReplication") - - @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: replication.ResumeReplicationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the resume replication method over HTTP. - - Args: - request (~.replication.ResumeReplicationRequest): - The request object. ResumeReplicationRequest resumes a - stopped replication. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseResumeReplication._get_http_options() - - request, metadata = self._interceptor.pre_resume_replication(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseResumeReplication._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseResumeReplication._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseResumeReplication._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.ResumeReplication", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ResumeReplication", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._ResumeReplication._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_resume_replication(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_resume_replication_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.resume_replication", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ResumeReplication", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _ReverseReplicationDirection(_BaseNetAppRestTransport._BaseReverseReplicationDirection, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.ReverseReplicationDirection") - - @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: replication.ReverseReplicationDirectionRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the reverse replication - direction method over HTTP. - - Args: - request (~.replication.ReverseReplicationDirectionRequest): - The request object. ReverseReplicationDirectionRequest - reverses direction of replication. - Source becomes destination and - destination becomes source. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseReverseReplicationDirection._get_http_options() - - request, metadata = self._interceptor.pre_reverse_replication_direction(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseReverseReplicationDirection._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseReverseReplicationDirection._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseReverseReplicationDirection._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.ReverseReplicationDirection", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ReverseReplicationDirection", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._ReverseReplicationDirection._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_reverse_replication_direction(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_reverse_replication_direction_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.reverse_replication_direction", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ReverseReplicationDirection", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _RevertVolume(_BaseNetAppRestTransport._BaseRevertVolume, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.RevertVolume") - - @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: volume.RevertVolumeRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the revert volume method over HTTP. - - Args: - request (~.volume.RevertVolumeRequest): - The request object. RevertVolumeRequest reverts the given - volume to the specified snapshot. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseRevertVolume._get_http_options() - - request, metadata = self._interceptor.pre_revert_volume(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseRevertVolume._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseRevertVolume._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseRevertVolume._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.RevertVolume", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "RevertVolume", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._RevertVolume._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_revert_volume(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_revert_volume_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.revert_volume", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "RevertVolume", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _StopReplication(_BaseNetAppRestTransport._BaseStopReplication, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.StopReplication") - - @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: replication.StopReplicationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the stop replication method over HTTP. - - Args: - request (~.replication.StopReplicationRequest): - The request object. StopReplicationRequest stops a - replication until resumed. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseStopReplication._get_http_options() - - request, metadata = self._interceptor.pre_stop_replication(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseStopReplication._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseStopReplication._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseStopReplication._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.StopReplication", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "StopReplication", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._StopReplication._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_stop_replication(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_stop_replication_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.stop_replication", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "StopReplication", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _SwitchActiveReplicaZone(_BaseNetAppRestTransport._BaseSwitchActiveReplicaZone, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.SwitchActiveReplicaZone") - - @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: storage_pool.SwitchActiveReplicaZoneRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the switch active replica - zone method over HTTP. - - Args: - request (~.storage_pool.SwitchActiveReplicaZoneRequest): - The request object. SwitchActiveReplicaZoneRequest switch - the active/replica zone for a regional - storagePool. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseSwitchActiveReplicaZone._get_http_options() - - request, metadata = self._interceptor.pre_switch_active_replica_zone(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseSwitchActiveReplicaZone._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseSwitchActiveReplicaZone._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseSwitchActiveReplicaZone._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.SwitchActiveReplicaZone", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "SwitchActiveReplicaZone", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._SwitchActiveReplicaZone._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_switch_active_replica_zone(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_switch_active_replica_zone_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.switch_active_replica_zone", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "SwitchActiveReplicaZone", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _SyncReplication(_BaseNetAppRestTransport._BaseSyncReplication, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.SyncReplication") - - @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: replication.SyncReplicationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the sync replication method over HTTP. - - Args: - request (~.replication.SyncReplicationRequest): - The request object. SyncReplicationRequest syncs the - replication from source to destination. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseSyncReplication._get_http_options() - - request, metadata = self._interceptor.pre_sync_replication(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseSyncReplication._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseSyncReplication._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseSyncReplication._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.SyncReplication", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "SyncReplication", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._SyncReplication._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_sync_replication(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_sync_replication_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.sync_replication", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "SyncReplication", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _UpdateActiveDirectory(_BaseNetAppRestTransport._BaseUpdateActiveDirectory, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.UpdateActiveDirectory") - - @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: gcn_active_directory.UpdateActiveDirectoryRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the update active directory method over HTTP. - - Args: - request (~.gcn_active_directory.UpdateActiveDirectoryRequest): - The request object. UpdateActiveDirectoryRequest for - updating an active directory. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseUpdateActiveDirectory._get_http_options() - - request, metadata = self._interceptor.pre_update_active_directory(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseUpdateActiveDirectory._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseUpdateActiveDirectory._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseUpdateActiveDirectory._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.UpdateActiveDirectory", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "UpdateActiveDirectory", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._UpdateActiveDirectory._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_update_active_directory(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_update_active_directory_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.update_active_directory", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "UpdateActiveDirectory", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _UpdateBackup(_BaseNetAppRestTransport._BaseUpdateBackup, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.UpdateBackup") - - @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: gcn_backup.UpdateBackupRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the update backup method over HTTP. - - Args: - request (~.gcn_backup.UpdateBackupRequest): - The request object. UpdateBackupRequest updates - description and/or labels for a backup. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseUpdateBackup._get_http_options() - - request, metadata = self._interceptor.pre_update_backup(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseUpdateBackup._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseUpdateBackup._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseUpdateBackup._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.UpdateBackup", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "UpdateBackup", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._UpdateBackup._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_update_backup(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_update_backup_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.update_backup", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "UpdateBackup", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _UpdateBackupPolicy(_BaseNetAppRestTransport._BaseUpdateBackupPolicy, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.UpdateBackupPolicy") - - @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: gcn_backup_policy.UpdateBackupPolicyRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the update backup policy method over HTTP. - - Args: - request (~.gcn_backup_policy.UpdateBackupPolicyRequest): - The request object. UpdateBackupPolicyRequest for - updating a backup policy. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseUpdateBackupPolicy._get_http_options() - - request, metadata = self._interceptor.pre_update_backup_policy(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseUpdateBackupPolicy._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseUpdateBackupPolicy._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseUpdateBackupPolicy._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.UpdateBackupPolicy", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "UpdateBackupPolicy", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._UpdateBackupPolicy._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_update_backup_policy(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_update_backup_policy_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.update_backup_policy", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "UpdateBackupPolicy", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _UpdateBackupVault(_BaseNetAppRestTransport._BaseUpdateBackupVault, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.UpdateBackupVault") - - @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: gcn_backup_vault.UpdateBackupVaultRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the update backup vault method over HTTP. - - Args: - request (~.gcn_backup_vault.UpdateBackupVaultRequest): - The request object. UpdateBackupVaultRequest updates - description and/or labels for a - backupVault. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseUpdateBackupVault._get_http_options() - - request, metadata = self._interceptor.pre_update_backup_vault(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseUpdateBackupVault._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseUpdateBackupVault._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseUpdateBackupVault._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.UpdateBackupVault", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "UpdateBackupVault", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._UpdateBackupVault._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_update_backup_vault(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_update_backup_vault_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.update_backup_vault", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "UpdateBackupVault", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _UpdateKmsConfig(_BaseNetAppRestTransport._BaseUpdateKmsConfig, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.UpdateKmsConfig") - - @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: kms.UpdateKmsConfigRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the update kms config method over HTTP. - - Args: - request (~.kms.UpdateKmsConfigRequest): - The request object. UpdateKmsConfigRequest updates a KMS - Config. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseUpdateKmsConfig._get_http_options() - - request, metadata = self._interceptor.pre_update_kms_config(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseUpdateKmsConfig._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseUpdateKmsConfig._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseUpdateKmsConfig._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.UpdateKmsConfig", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "UpdateKmsConfig", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._UpdateKmsConfig._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_update_kms_config(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_update_kms_config_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.update_kms_config", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "UpdateKmsConfig", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _UpdateQuotaRule(_BaseNetAppRestTransport._BaseUpdateQuotaRule, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.UpdateQuotaRule") - - @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: gcn_quota_rule.UpdateQuotaRuleRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the update quota rule method over HTTP. - - Args: - request (~.gcn_quota_rule.UpdateQuotaRuleRequest): - The request object. UpdateQuotaRuleRequest for updating a - quota 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseUpdateQuotaRule._get_http_options() - - request, metadata = self._interceptor.pre_update_quota_rule(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseUpdateQuotaRule._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseUpdateQuotaRule._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseUpdateQuotaRule._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.UpdateQuotaRule", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "UpdateQuotaRule", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._UpdateQuotaRule._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_update_quota_rule(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_update_quota_rule_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.update_quota_rule", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "UpdateQuotaRule", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _UpdateReplication(_BaseNetAppRestTransport._BaseUpdateReplication, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.UpdateReplication") - - @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: gcn_replication.UpdateReplicationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the update replication method over HTTP. - - Args: - request (~.gcn_replication.UpdateReplicationRequest): - The request object. UpdateReplicationRequest updates - description and/or labels for a - replication. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseUpdateReplication._get_http_options() - - request, metadata = self._interceptor.pre_update_replication(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseUpdateReplication._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseUpdateReplication._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseUpdateReplication._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.UpdateReplication", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "UpdateReplication", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._UpdateReplication._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_update_replication(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_update_replication_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.update_replication", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "UpdateReplication", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _UpdateSnapshot(_BaseNetAppRestTransport._BaseUpdateSnapshot, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.UpdateSnapshot") - - @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: gcn_snapshot.UpdateSnapshotRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the update snapshot method over HTTP. - - Args: - request (~.gcn_snapshot.UpdateSnapshotRequest): - The request object. UpdateSnapshotRequest updates - description and/or labels for a - snapshot. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseUpdateSnapshot._get_http_options() - - request, metadata = self._interceptor.pre_update_snapshot(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseUpdateSnapshot._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseUpdateSnapshot._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseUpdateSnapshot._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.UpdateSnapshot", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "UpdateSnapshot", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._UpdateSnapshot._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_update_snapshot(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_update_snapshot_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.update_snapshot", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "UpdateSnapshot", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _UpdateStoragePool(_BaseNetAppRestTransport._BaseUpdateStoragePool, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.UpdateStoragePool") - - @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: gcn_storage_pool.UpdateStoragePoolRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the update storage pool method over HTTP. - - Args: - request (~.gcn_storage_pool.UpdateStoragePoolRequest): - The request object. UpdateStoragePoolRequest updates a - Storage Pool. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseUpdateStoragePool._get_http_options() - - request, metadata = self._interceptor.pre_update_storage_pool(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseUpdateStoragePool._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseUpdateStoragePool._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseUpdateStoragePool._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.UpdateStoragePool", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "UpdateStoragePool", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._UpdateStoragePool._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_update_storage_pool(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_update_storage_pool_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.update_storage_pool", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "UpdateStoragePool", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _UpdateVolume(_BaseNetAppRestTransport._BaseUpdateVolume, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.UpdateVolume") - - @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: gcn_volume.UpdateVolumeRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the update volume method over HTTP. - - Args: - request (~.gcn_volume.UpdateVolumeRequest): - The request object. Message for updating a Volume - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseUpdateVolume._get_http_options() - - request, metadata = self._interceptor.pre_update_volume(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseUpdateVolume._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseUpdateVolume._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseUpdateVolume._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.UpdateVolume", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "UpdateVolume", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._UpdateVolume._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_update_volume(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_update_volume_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.update_volume", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "UpdateVolume", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _ValidateDirectoryService(_BaseNetAppRestTransport._BaseValidateDirectoryService, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.ValidateDirectoryService") - - @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: storage_pool.ValidateDirectoryServiceRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the validate directory - service method over HTTP. - - Args: - request (~.storage_pool.ValidateDirectoryServiceRequest): - The request object. ValidateDirectoryServiceRequest - validates the directory service policy - attached to the storage pool. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseNetAppRestTransport._BaseValidateDirectoryService._get_http_options() - - request, metadata = self._interceptor.pre_validate_directory_service(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseValidateDirectoryService._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseValidateDirectoryService._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseValidateDirectoryService._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.ValidateDirectoryService", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ValidateDirectoryService", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._ValidateDirectoryService._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_validate_directory_service(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_validate_directory_service_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.validate_directory_service", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ValidateDirectoryService", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _VerifyKmsConfig(_BaseNetAppRestTransport._BaseVerifyKmsConfig, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.VerifyKmsConfig") - - @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: kms.VerifyKmsConfigRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> kms.VerifyKmsConfigResponse: - r"""Call the verify kms config method over HTTP. - - Args: - request (~.kms.VerifyKmsConfigRequest): - The request object. VerifyKmsConfigRequest specifies the - KMS config to be validated. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.kms.VerifyKmsConfigResponse: - VerifyKmsConfigResponse contains the - information if the config is correctly - and error message. - - """ - - http_options = _BaseNetAppRestTransport._BaseVerifyKmsConfig._get_http_options() - - request, metadata = self._interceptor.pre_verify_kms_config(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseVerifyKmsConfig._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseVerifyKmsConfig._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseVerifyKmsConfig._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.VerifyKmsConfig", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "VerifyKmsConfig", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._VerifyKmsConfig._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 = kms.VerifyKmsConfigResponse() - pb_resp = kms.VerifyKmsConfigResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_verify_kms_config(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_verify_kms_config_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = kms.VerifyKmsConfigResponse.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppClient.verify_kms_config", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "VerifyKmsConfig", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - @property - def create_active_directory(self) -> Callable[ - [gcn_active_directory.CreateActiveDirectoryRequest], - 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._CreateActiveDirectory(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_backup(self) -> Callable[ - [gcn_backup.CreateBackupRequest], - 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._CreateBackup(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_backup_policy(self) -> Callable[ - [gcn_backup_policy.CreateBackupPolicyRequest], - 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._CreateBackupPolicy(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_backup_vault(self) -> Callable[ - [gcn_backup_vault.CreateBackupVaultRequest], - 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._CreateBackupVault(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_kms_config(self) -> Callable[ - [kms.CreateKmsConfigRequest], - 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._CreateKmsConfig(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_quota_rule(self) -> Callable[ - [gcn_quota_rule.CreateQuotaRuleRequest], - 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._CreateQuotaRule(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_replication(self) -> Callable[ - [gcn_replication.CreateReplicationRequest], - 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._CreateReplication(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_snapshot(self) -> Callable[ - [gcn_snapshot.CreateSnapshotRequest], - 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._CreateSnapshot(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_storage_pool(self) -> Callable[ - [gcn_storage_pool.CreateStoragePoolRequest], - 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._CreateStoragePool(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_volume(self) -> Callable[ - [gcn_volume.CreateVolumeRequest], - 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._CreateVolume(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_active_directory(self) -> Callable[ - [active_directory.DeleteActiveDirectoryRequest], - 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._DeleteActiveDirectory(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_backup(self) -> Callable[ - [backup.DeleteBackupRequest], - 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._DeleteBackup(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_backup_policy(self) -> Callable[ - [backup_policy.DeleteBackupPolicyRequest], - 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._DeleteBackupPolicy(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_backup_vault(self) -> Callable[ - [backup_vault.DeleteBackupVaultRequest], - 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._DeleteBackupVault(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_kms_config(self) -> Callable[ - [kms.DeleteKmsConfigRequest], - 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._DeleteKmsConfig(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_quota_rule(self) -> Callable[ - [quota_rule.DeleteQuotaRuleRequest], - 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._DeleteQuotaRule(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_replication(self) -> Callable[ - [replication.DeleteReplicationRequest], - 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._DeleteReplication(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_snapshot(self) -> Callable[ - [snapshot.DeleteSnapshotRequest], - 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._DeleteSnapshot(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_storage_pool(self) -> Callable[ - [storage_pool.DeleteStoragePoolRequest], - 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._DeleteStoragePool(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_volume(self) -> Callable[ - [volume.DeleteVolumeRequest], - 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._DeleteVolume(self._session, self._host, self._interceptor) # type: ignore - - @property - def encrypt_volumes(self) -> Callable[ - [kms.EncryptVolumesRequest], - 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._EncryptVolumes(self._session, self._host, self._interceptor) # type: ignore - - @property - def establish_peering(self) -> Callable[ - [replication.EstablishPeeringRequest], - 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._EstablishPeering(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_active_directory(self) -> Callable[ - [active_directory.GetActiveDirectoryRequest], - active_directory.ActiveDirectory]: - # 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._GetActiveDirectory(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_backup(self) -> Callable[ - [backup.GetBackupRequest], - backup.Backup]: - # 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._GetBackup(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_backup_policy(self) -> Callable[ - [backup_policy.GetBackupPolicyRequest], - backup_policy.BackupPolicy]: - # 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._GetBackupPolicy(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_backup_vault(self) -> Callable[ - [backup_vault.GetBackupVaultRequest], - backup_vault.BackupVault]: - # 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._GetBackupVault(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_kms_config(self) -> Callable[ - [kms.GetKmsConfigRequest], - kms.KmsConfig]: - # 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._GetKmsConfig(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_quota_rule(self) -> Callable[ - [quota_rule.GetQuotaRuleRequest], - quota_rule.QuotaRule]: - # 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._GetQuotaRule(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_replication(self) -> Callable[ - [replication.GetReplicationRequest], - replication.Replication]: - # 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._GetReplication(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_snapshot(self) -> Callable[ - [snapshot.GetSnapshotRequest], - snapshot.Snapshot]: - # 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._GetSnapshot(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_storage_pool(self) -> Callable[ - [storage_pool.GetStoragePoolRequest], - storage_pool.StoragePool]: - # 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._GetStoragePool(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_volume(self) -> Callable[ - [volume.GetVolumeRequest], - volume.Volume]: - # 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._GetVolume(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_active_directories(self) -> Callable[ - [active_directory.ListActiveDirectoriesRequest], - active_directory.ListActiveDirectoriesResponse]: - # 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._ListActiveDirectories(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_backup_policies(self) -> Callable[ - [backup_policy.ListBackupPoliciesRequest], - backup_policy.ListBackupPoliciesResponse]: - # 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._ListBackupPolicies(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_backups(self) -> Callable[ - [backup.ListBackupsRequest], - backup.ListBackupsResponse]: - # 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._ListBackups(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_backup_vaults(self) -> Callable[ - [backup_vault.ListBackupVaultsRequest], - backup_vault.ListBackupVaultsResponse]: - # 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._ListBackupVaults(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_kms_configs(self) -> Callable[ - [kms.ListKmsConfigsRequest], - kms.ListKmsConfigsResponse]: - # 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._ListKmsConfigs(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_quota_rules(self) -> Callable[ - [quota_rule.ListQuotaRulesRequest], - quota_rule.ListQuotaRulesResponse]: - # 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._ListQuotaRules(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_replications(self) -> Callable[ - [replication.ListReplicationsRequest], - replication.ListReplicationsResponse]: - # 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._ListReplications(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_snapshots(self) -> Callable[ - [snapshot.ListSnapshotsRequest], - snapshot.ListSnapshotsResponse]: - # 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._ListSnapshots(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_storage_pools(self) -> Callable[ - [storage_pool.ListStoragePoolsRequest], - storage_pool.ListStoragePoolsResponse]: - # 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._ListStoragePools(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_volumes(self) -> Callable[ - [volume.ListVolumesRequest], - volume.ListVolumesResponse]: - # 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._ListVolumes(self._session, self._host, self._interceptor) # type: ignore - - @property - def resume_replication(self) -> Callable[ - [replication.ResumeReplicationRequest], - 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._ResumeReplication(self._session, self._host, self._interceptor) # type: ignore - - @property - def reverse_replication_direction(self) -> Callable[ - [replication.ReverseReplicationDirectionRequest], - 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._ReverseReplicationDirection(self._session, self._host, self._interceptor) # type: ignore - - @property - def revert_volume(self) -> Callable[ - [volume.RevertVolumeRequest], - 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._RevertVolume(self._session, self._host, self._interceptor) # type: ignore - - @property - def stop_replication(self) -> Callable[ - [replication.StopReplicationRequest], - 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._StopReplication(self._session, self._host, self._interceptor) # type: ignore - - @property - def switch_active_replica_zone(self) -> Callable[ - [storage_pool.SwitchActiveReplicaZoneRequest], - 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._SwitchActiveReplicaZone(self._session, self._host, self._interceptor) # type: ignore - - @property - def sync_replication(self) -> Callable[ - [replication.SyncReplicationRequest], - 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._SyncReplication(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_active_directory(self) -> Callable[ - [gcn_active_directory.UpdateActiveDirectoryRequest], - 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._UpdateActiveDirectory(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_backup(self) -> Callable[ - [gcn_backup.UpdateBackupRequest], - 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._UpdateBackup(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_backup_policy(self) -> Callable[ - [gcn_backup_policy.UpdateBackupPolicyRequest], - 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._UpdateBackupPolicy(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_backup_vault(self) -> Callable[ - [gcn_backup_vault.UpdateBackupVaultRequest], - 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._UpdateBackupVault(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_kms_config(self) -> Callable[ - [kms.UpdateKmsConfigRequest], - 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._UpdateKmsConfig(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_quota_rule(self) -> Callable[ - [gcn_quota_rule.UpdateQuotaRuleRequest], - 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._UpdateQuotaRule(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_replication(self) -> Callable[ - [gcn_replication.UpdateReplicationRequest], - 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._UpdateReplication(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_snapshot(self) -> Callable[ - [gcn_snapshot.UpdateSnapshotRequest], - 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._UpdateSnapshot(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_storage_pool(self) -> Callable[ - [gcn_storage_pool.UpdateStoragePoolRequest], - 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._UpdateStoragePool(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_volume(self) -> Callable[ - [gcn_volume.UpdateVolumeRequest], - 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._UpdateVolume(self._session, self._host, self._interceptor) # type: ignore - - @property - def validate_directory_service(self) -> Callable[ - [storage_pool.ValidateDirectoryServiceRequest], - 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._ValidateDirectoryService(self._session, self._host, self._interceptor) # type: ignore - - @property - def verify_kms_config(self) -> Callable[ - [kms.VerifyKmsConfigRequest], - kms.VerifyKmsConfigResponse]: - # 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._VerifyKmsConfig(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(_BaseNetAppRestTransport._BaseGetLocation, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.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, Union[str, bytes]]]=(), - ) -> 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - locations_pb2.Location: Response from GetLocation method. - """ - - http_options = _BaseNetAppRestTransport._BaseGetLocation._get_http_options() - - request, metadata = self._interceptor.pre_get_location(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseGetLocation._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseGetLocation._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.GetLocation", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetLocation", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._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) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppAsyncClient.GetLocation", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetLocation", - "httpResponse": http_response, - "metadata": http_response["headers"], - }, - ) - return resp - - @property - def list_locations(self): - return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore - - class _ListLocations(_BaseNetAppRestTransport._BaseListLocations, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.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, Union[str, bytes]]]=(), - ) -> 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - locations_pb2.ListLocationsResponse: Response from ListLocations method. - """ - - http_options = _BaseNetAppRestTransport._BaseListLocations._get_http_options() - - request, metadata = self._interceptor.pre_list_locations(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseListLocations._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseListLocations._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.ListLocations", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListLocations", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._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) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppAsyncClient.ListLocations", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListLocations", - "httpResponse": http_response, - "metadata": http_response["headers"], - }, - ) - return resp - - @property - def cancel_operation(self): - return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore - - class _CancelOperation(_BaseNetAppRestTransport._BaseCancelOperation, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.CancelOperation") - - @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: operations_pb2.CancelOperationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> None: - - r"""Call the cancel operation method over HTTP. - - Args: - request (operations_pb2.CancelOperationRequest): - The request object for CancelOperation 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - - http_options = _BaseNetAppRestTransport._BaseCancelOperation._get_http_options() - - request, metadata = self._interceptor.pre_cancel_operation(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseCancelOperation._get_transcoded_request(http_options, request) - - body = _BaseNetAppRestTransport._BaseCancelOperation._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseCancelOperation._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.CancelOperation", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "CancelOperation", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._CancelOperation._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 self._interceptor.post_cancel_operation(None) - - @property - def delete_operation(self): - return self._DeleteOperation(self._session, self._host, self._interceptor) # type: ignore - - class _DeleteOperation(_BaseNetAppRestTransport._BaseDeleteOperation, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.DeleteOperation") - - @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.DeleteOperationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> None: - - r"""Call the delete operation method over HTTP. - - Args: - request (operations_pb2.DeleteOperationRequest): - The request object for DeleteOperation 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - - http_options = _BaseNetAppRestTransport._BaseDeleteOperation._get_http_options() - - request, metadata = self._interceptor.pre_delete_operation(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseDeleteOperation._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseDeleteOperation._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.DeleteOperation", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "DeleteOperation", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._DeleteOperation._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 self._interceptor.post_delete_operation(None) - - @property - def get_operation(self): - return self._GetOperation(self._session, self._host, self._interceptor) # type: ignore - - class _GetOperation(_BaseNetAppRestTransport._BaseGetOperation, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.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, Union[str, bytes]]]=(), - ) -> 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - operations_pb2.Operation: Response from GetOperation method. - """ - - http_options = _BaseNetAppRestTransport._BaseGetOperation._get_http_options() - - request, metadata = self._interceptor.pre_get_operation(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseGetOperation._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseGetOperation._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.GetOperation", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetOperation", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._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) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppAsyncClient.GetOperation", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "GetOperation", - "httpResponse": http_response, - "metadata": http_response["headers"], - }, - ) - return resp - - @property - def list_operations(self): - return self._ListOperations(self._session, self._host, self._interceptor) # type: ignore - - class _ListOperations(_BaseNetAppRestTransport._BaseListOperations, NetAppRestStub): - def __hash__(self): - return hash("NetAppRestTransport.ListOperations") - - @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.ListOperationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.ListOperationsResponse: - - r"""Call the list operations method over HTTP. - - Args: - request (operations_pb2.ListOperationsRequest): - The request object for ListOperations 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - operations_pb2.ListOperationsResponse: Response from ListOperations method. - """ - - http_options = _BaseNetAppRestTransport._BaseListOperations._get_http_options() - - request, metadata = self._interceptor.pre_list_operations(request, metadata) - transcoded_request = _BaseNetAppRestTransport._BaseListOperations._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseNetAppRestTransport._BaseListOperations._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.netapp_v1.NetAppClient.ListOperations", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListOperations", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = NetAppRestTransport._ListOperations._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.ListOperationsResponse() - resp = json_format.Parse(content, resp) - resp = self._interceptor.post_list_operations(resp) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.netapp_v1.NetAppAsyncClient.ListOperations", - extra = { - "serviceName": "google.cloud.netapp.v1.NetApp", - "rpcName": "ListOperations", - "httpResponse": http_response, - "metadata": http_response["headers"], - }, - ) - return resp - - @property - def kind(self) -> str: - return "rest" - - def close(self): - self._session.close() - - -__all__=( - 'NetAppRestTransport', -) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/rest_base.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/rest_base.py deleted file mode 100644 index 925fcfe32010..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/services/net_app/transports/rest_base.py +++ /dev/null @@ -1,2786 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 NetAppTransport, DEFAULT_CLIENT_INFO - -import re -from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union - - -from google.cloud.netapp_v1.types import active_directory -from google.cloud.netapp_v1.types import active_directory as gcn_active_directory -from google.cloud.netapp_v1.types import backup -from google.cloud.netapp_v1.types import backup as gcn_backup -from google.cloud.netapp_v1.types import backup_policy -from google.cloud.netapp_v1.types import backup_policy as gcn_backup_policy -from google.cloud.netapp_v1.types import backup_vault -from google.cloud.netapp_v1.types import backup_vault as gcn_backup_vault -from google.cloud.netapp_v1.types import kms -from google.cloud.netapp_v1.types import quota_rule -from google.cloud.netapp_v1.types import quota_rule as gcn_quota_rule -from google.cloud.netapp_v1.types import replication -from google.cloud.netapp_v1.types import replication as gcn_replication -from google.cloud.netapp_v1.types import snapshot -from google.cloud.netapp_v1.types import snapshot as gcn_snapshot -from google.cloud.netapp_v1.types import storage_pool -from google.cloud.netapp_v1.types import storage_pool as gcn_storage_pool -from google.cloud.netapp_v1.types import volume -from google.cloud.netapp_v1.types import volume as gcn_volume -from google.longrunning import operations_pb2 # type: ignore - - -class _BaseNetAppRestTransport(NetAppTransport): - """Base REST backend transport for NetApp. - - 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 = 'netapp.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: 'netapp.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 _BaseCreateActiveDirectory: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "activeDirectoryId" : "", } - - @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/*}/activeDirectories', - 'body': 'active_directory', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gcn_active_directory.CreateActiveDirectoryRequest.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(_BaseNetAppRestTransport._BaseCreateActiveDirectory._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseCreateBackup: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "backupId" : "", } - - @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/*/backupVaults/*}/backups', - 'body': 'backup', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gcn_backup.CreateBackupRequest.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(_BaseNetAppRestTransport._BaseCreateBackup._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseCreateBackupPolicy: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "backupPolicyId" : "", } - - @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/*}/backupPolicies', - 'body': 'backup_policy', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gcn_backup_policy.CreateBackupPolicyRequest.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(_BaseNetAppRestTransport._BaseCreateBackupPolicy._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseCreateBackupVault: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "backupVaultId" : "", } - - @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/*}/backupVaults', - 'body': 'backup_vault', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gcn_backup_vault.CreateBackupVaultRequest.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(_BaseNetAppRestTransport._BaseCreateBackupVault._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseCreateKmsConfig: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "kmsConfigId" : "", } - - @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/*}/kmsConfigs', - 'body': 'kms_config', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = kms.CreateKmsConfigRequest.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(_BaseNetAppRestTransport._BaseCreateKmsConfig._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseCreateQuotaRule: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "quotaRuleId" : "", } - - @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/*/volumes/*}/quotaRules', - 'body': 'quota_rule', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gcn_quota_rule.CreateQuotaRuleRequest.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(_BaseNetAppRestTransport._BaseCreateQuotaRule._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseCreateReplication: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "replicationId" : "", } - - @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/*/volumes/*}/replications', - 'body': 'replication', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gcn_replication.CreateReplicationRequest.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(_BaseNetAppRestTransport._BaseCreateReplication._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseCreateSnapshot: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "snapshotId" : "", } - - @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/*/volumes/*}/snapshots', - 'body': 'snapshot', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gcn_snapshot.CreateSnapshotRequest.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(_BaseNetAppRestTransport._BaseCreateSnapshot._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseCreateStoragePool: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "storagePoolId" : "", } - - @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/*}/storagePools', - 'body': 'storage_pool', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gcn_storage_pool.CreateStoragePoolRequest.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(_BaseNetAppRestTransport._BaseCreateStoragePool._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseCreateVolume: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "volumeId" : "", } - - @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/*}/volumes', - 'body': 'volume', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gcn_volume.CreateVolumeRequest.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(_BaseNetAppRestTransport._BaseCreateVolume._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseDeleteActiveDirectory: - 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/*/activeDirectories/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = active_directory.DeleteActiveDirectoryRequest.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(_BaseNetAppRestTransport._BaseDeleteActiveDirectory._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseDeleteBackup: - 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/*/backupVaults/*/backups/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = backup.DeleteBackupRequest.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(_BaseNetAppRestTransport._BaseDeleteBackup._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseDeleteBackupPolicy: - 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/*/backupPolicies/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = backup_policy.DeleteBackupPolicyRequest.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(_BaseNetAppRestTransport._BaseDeleteBackupPolicy._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseDeleteBackupVault: - 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/*/backupVaults/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = backup_vault.DeleteBackupVaultRequest.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(_BaseNetAppRestTransport._BaseDeleteBackupVault._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseDeleteKmsConfig: - 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/*/kmsConfigs/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = kms.DeleteKmsConfigRequest.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(_BaseNetAppRestTransport._BaseDeleteKmsConfig._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseDeleteQuotaRule: - 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/*/volumes/*/quotaRules/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = quota_rule.DeleteQuotaRuleRequest.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(_BaseNetAppRestTransport._BaseDeleteQuotaRule._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseDeleteReplication: - 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/*/volumes/*/replications/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = replication.DeleteReplicationRequest.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(_BaseNetAppRestTransport._BaseDeleteReplication._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseDeleteSnapshot: - 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/*/volumes/*/snapshots/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = snapshot.DeleteSnapshotRequest.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(_BaseNetAppRestTransport._BaseDeleteSnapshot._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseDeleteStoragePool: - 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/*/storagePools/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = storage_pool.DeleteStoragePoolRequest.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(_BaseNetAppRestTransport._BaseDeleteStoragePool._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseDeleteVolume: - 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/*/volumes/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = volume.DeleteVolumeRequest.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(_BaseNetAppRestTransport._BaseDeleteVolume._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseEncryptVolumes: - 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/{name=projects/*/locations/*/kmsConfigs/*}:encrypt', - 'body': '*', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = kms.EncryptVolumesRequest.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(_BaseNetAppRestTransport._BaseEncryptVolumes._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseEstablishPeering: - 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/{name=projects/*/locations/*/volumes/*/replications/*}:establishPeering', - 'body': '*', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = replication.EstablishPeeringRequest.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(_BaseNetAppRestTransport._BaseEstablishPeering._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetActiveDirectory: - 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/*/activeDirectories/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = active_directory.GetActiveDirectoryRequest.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(_BaseNetAppRestTransport._BaseGetActiveDirectory._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetBackup: - 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/*/backupVaults/*/backups/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = backup.GetBackupRequest.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(_BaseNetAppRestTransport._BaseGetBackup._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetBackupPolicy: - 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/*/backupPolicies/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = backup_policy.GetBackupPolicyRequest.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(_BaseNetAppRestTransport._BaseGetBackupPolicy._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetBackupVault: - 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/*/backupVaults/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = backup_vault.GetBackupVaultRequest.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(_BaseNetAppRestTransport._BaseGetBackupVault._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetKmsConfig: - 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/*/kmsConfigs/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = kms.GetKmsConfigRequest.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(_BaseNetAppRestTransport._BaseGetKmsConfig._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetQuotaRule: - 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/*/volumes/*/quotaRules/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = quota_rule.GetQuotaRuleRequest.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(_BaseNetAppRestTransport._BaseGetQuotaRule._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetReplication: - 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/*/volumes/*/replications/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = replication.GetReplicationRequest.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(_BaseNetAppRestTransport._BaseGetReplication._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetSnapshot: - 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/*/volumes/*/snapshots/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = snapshot.GetSnapshotRequest.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(_BaseNetAppRestTransport._BaseGetSnapshot._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetStoragePool: - 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/*/storagePools/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = storage_pool.GetStoragePoolRequest.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(_BaseNetAppRestTransport._BaseGetStoragePool._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetVolume: - 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/*/volumes/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = volume.GetVolumeRequest.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(_BaseNetAppRestTransport._BaseGetVolume._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListActiveDirectories: - 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/*}/activeDirectories', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = active_directory.ListActiveDirectoriesRequest.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(_BaseNetAppRestTransport._BaseListActiveDirectories._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListBackupPolicies: - 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/*}/backupPolicies', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = backup_policy.ListBackupPoliciesRequest.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(_BaseNetAppRestTransport._BaseListBackupPolicies._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListBackups: - 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/*/backupVaults/*}/backups', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = backup.ListBackupsRequest.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(_BaseNetAppRestTransport._BaseListBackups._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListBackupVaults: - 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/*}/backupVaults', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = backup_vault.ListBackupVaultsRequest.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(_BaseNetAppRestTransport._BaseListBackupVaults._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListKmsConfigs: - 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/*}/kmsConfigs', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = kms.ListKmsConfigsRequest.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(_BaseNetAppRestTransport._BaseListKmsConfigs._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListQuotaRules: - 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/*/volumes/*}/quotaRules', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = quota_rule.ListQuotaRulesRequest.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(_BaseNetAppRestTransport._BaseListQuotaRules._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListReplications: - 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/*/volumes/*}/replications', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = replication.ListReplicationsRequest.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(_BaseNetAppRestTransport._BaseListReplications._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListSnapshots: - 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/*/volumes/*}/snapshots', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = snapshot.ListSnapshotsRequest.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(_BaseNetAppRestTransport._BaseListSnapshots._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListStoragePools: - 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/*}/storagePools', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = storage_pool.ListStoragePoolsRequest.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(_BaseNetAppRestTransport._BaseListStoragePools._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListVolumes: - 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/*}/volumes', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = volume.ListVolumesRequest.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(_BaseNetAppRestTransport._BaseListVolumes._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseResumeReplication: - 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/{name=projects/*/locations/*/volumes/*/replications/*}:resume', - 'body': '*', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = replication.ResumeReplicationRequest.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(_BaseNetAppRestTransport._BaseResumeReplication._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseReverseReplicationDirection: - 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/{name=projects/*/locations/*/volumes/*/replications/*}:reverseDirection', - 'body': '*', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = replication.ReverseReplicationDirectionRequest.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(_BaseNetAppRestTransport._BaseReverseReplicationDirection._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseRevertVolume: - 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/{name=projects/*/locations/*/volumes/*}:revert', - 'body': '*', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = volume.RevertVolumeRequest.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(_BaseNetAppRestTransport._BaseRevertVolume._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseStopReplication: - 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/{name=projects/*/locations/*/volumes/*/replications/*}:stop', - 'body': '*', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = replication.StopReplicationRequest.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(_BaseNetAppRestTransport._BaseStopReplication._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseSwitchActiveReplicaZone: - 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/{name=projects/*/locations/*/storagePools/*}:switch', - 'body': '*', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = storage_pool.SwitchActiveReplicaZoneRequest.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(_BaseNetAppRestTransport._BaseSwitchActiveReplicaZone._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseSyncReplication: - 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/{name=projects/*/locations/*/volumes/*/replications/*}:sync', - 'body': '*', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = replication.SyncReplicationRequest.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(_BaseNetAppRestTransport._BaseSyncReplication._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseUpdateActiveDirectory: - 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/{active_directory.name=projects/*/locations/*/activeDirectories/*}', - 'body': 'active_directory', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gcn_active_directory.UpdateActiveDirectoryRequest.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(_BaseNetAppRestTransport._BaseUpdateActiveDirectory._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseUpdateBackup: - 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/{backup.name=projects/*/locations/*/backupVaults/*/backups/*}', - 'body': 'backup', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gcn_backup.UpdateBackupRequest.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(_BaseNetAppRestTransport._BaseUpdateBackup._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseUpdateBackupPolicy: - 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/{backup_policy.name=projects/*/locations/*/backupPolicies/*}', - 'body': 'backup_policy', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gcn_backup_policy.UpdateBackupPolicyRequest.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(_BaseNetAppRestTransport._BaseUpdateBackupPolicy._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseUpdateBackupVault: - 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/{backup_vault.name=projects/*/locations/*/backupVaults/*}', - 'body': 'backup_vault', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gcn_backup_vault.UpdateBackupVaultRequest.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(_BaseNetAppRestTransport._BaseUpdateBackupVault._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseUpdateKmsConfig: - 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/{kms_config.name=projects/*/locations/*/kmsConfigs/*}', - 'body': 'kms_config', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = kms.UpdateKmsConfigRequest.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(_BaseNetAppRestTransport._BaseUpdateKmsConfig._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseUpdateQuotaRule: - 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/{quota_rule.name=projects/*/locations/*/volumes/*/quotaRules/*}', - 'body': 'quota_rule', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gcn_quota_rule.UpdateQuotaRuleRequest.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(_BaseNetAppRestTransport._BaseUpdateQuotaRule._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseUpdateReplication: - 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/{replication.name=projects/*/locations/*/volumes/*/replications/*}', - 'body': 'replication', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gcn_replication.UpdateReplicationRequest.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(_BaseNetAppRestTransport._BaseUpdateReplication._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseUpdateSnapshot: - 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/{snapshot.name=projects/*/locations/*/volumes/*/snapshots/*}', - 'body': 'snapshot', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gcn_snapshot.UpdateSnapshotRequest.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(_BaseNetAppRestTransport._BaseUpdateSnapshot._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseUpdateStoragePool: - 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/{storage_pool.name=projects/*/locations/*/storagePools/*}', - 'body': 'storage_pool', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gcn_storage_pool.UpdateStoragePoolRequest.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(_BaseNetAppRestTransport._BaseUpdateStoragePool._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseUpdateVolume: - 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/{volume.name=projects/*/locations/*/volumes/*}', - 'body': 'volume', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gcn_volume.UpdateVolumeRequest.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(_BaseNetAppRestTransport._BaseUpdateVolume._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseValidateDirectoryService: - 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/{name=projects/*/locations/*/storagePools/*}:validateDirectoryService', - 'body': '*', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = storage_pool.ValidateDirectoryServiceRequest.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(_BaseNetAppRestTransport._BaseValidateDirectoryService._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseVerifyKmsConfig: - 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/{name=projects/*/locations/*/kmsConfigs/*}:verify', - 'body': '*', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = kms.VerifyKmsConfigRequest.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(_BaseNetAppRestTransport._BaseVerifyKmsConfig._get_unset_required_fields(query_params)) - - 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 _BaseCancelOperation: - 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/{name=projects/*/locations/*/operations/*}:cancel', - 'body': '*', - }, - ] - 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_request_body_json(transcoded_request): - body = json.dumps(transcoded_request['body']) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json.dumps(transcoded_request['query_params'])) - return query_params - - class _BaseDeleteOperation: - 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/*/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 - - 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 - - class _BaseListOperations: - 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__=( - '_BaseNetAppRestTransport', -) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/__init__.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/__init__.py deleted file mode 100644 index 38df5cf58049..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/__init__.py +++ /dev/null @@ -1,256 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 .active_directory import ( - ActiveDirectory, - CreateActiveDirectoryRequest, - DeleteActiveDirectoryRequest, - GetActiveDirectoryRequest, - ListActiveDirectoriesRequest, - ListActiveDirectoriesResponse, - UpdateActiveDirectoryRequest, -) -from .backup import ( - Backup, - CreateBackupRequest, - DeleteBackupRequest, - GetBackupRequest, - ListBackupsRequest, - ListBackupsResponse, - UpdateBackupRequest, -) -from .backup_policy import ( - BackupPolicy, - CreateBackupPolicyRequest, - DeleteBackupPolicyRequest, - GetBackupPolicyRequest, - ListBackupPoliciesRequest, - ListBackupPoliciesResponse, - UpdateBackupPolicyRequest, -) -from .backup_vault import ( - BackupVault, - CreateBackupVaultRequest, - DeleteBackupVaultRequest, - GetBackupVaultRequest, - ListBackupVaultsRequest, - ListBackupVaultsResponse, - UpdateBackupVaultRequest, -) -from .cloud_netapp_service import ( - OperationMetadata, -) -from .common import ( - LocationMetadata, - DirectoryServiceType, - EncryptionType, - FlexPerformance, - ServiceLevel, -) -from .kms import ( - CreateKmsConfigRequest, - DeleteKmsConfigRequest, - EncryptVolumesRequest, - GetKmsConfigRequest, - KmsConfig, - ListKmsConfigsRequest, - ListKmsConfigsResponse, - UpdateKmsConfigRequest, - VerifyKmsConfigRequest, - VerifyKmsConfigResponse, -) -from .quota_rule import ( - CreateQuotaRuleRequest, - DeleteQuotaRuleRequest, - GetQuotaRuleRequest, - ListQuotaRulesRequest, - ListQuotaRulesResponse, - QuotaRule, - UpdateQuotaRuleRequest, -) -from .replication import ( - CreateReplicationRequest, - DeleteReplicationRequest, - DestinationVolumeParameters, - EstablishPeeringRequest, - GetReplicationRequest, - HybridPeeringDetails, - ListReplicationsRequest, - ListReplicationsResponse, - Replication, - ResumeReplicationRequest, - ReverseReplicationDirectionRequest, - StopReplicationRequest, - SyncReplicationRequest, - TransferStats, - UpdateReplicationRequest, -) -from .snapshot import ( - CreateSnapshotRequest, - DeleteSnapshotRequest, - GetSnapshotRequest, - ListSnapshotsRequest, - ListSnapshotsResponse, - Snapshot, - UpdateSnapshotRequest, -) -from .storage_pool import ( - CreateStoragePoolRequest, - DeleteStoragePoolRequest, - GetStoragePoolRequest, - ListStoragePoolsRequest, - ListStoragePoolsResponse, - StoragePool, - SwitchActiveReplicaZoneRequest, - UpdateStoragePoolRequest, - ValidateDirectoryServiceRequest, -) -from .volume import ( - BackupConfig, - CreateVolumeRequest, - DailySchedule, - DeleteVolumeRequest, - ExportPolicy, - GetVolumeRequest, - HourlySchedule, - HybridReplicationParameters, - ListVolumesRequest, - ListVolumesResponse, - MonthlySchedule, - MountOption, - RestoreParameters, - RevertVolumeRequest, - SimpleExportPolicyRule, - SnapshotPolicy, - TieringPolicy, - UpdateVolumeRequest, - Volume, - WeeklySchedule, - AccessType, - Protocols, - RestrictedAction, - SecurityStyle, - SMBSettings, -) - -__all__ = ( - 'ActiveDirectory', - 'CreateActiveDirectoryRequest', - 'DeleteActiveDirectoryRequest', - 'GetActiveDirectoryRequest', - 'ListActiveDirectoriesRequest', - 'ListActiveDirectoriesResponse', - 'UpdateActiveDirectoryRequest', - 'Backup', - 'CreateBackupRequest', - 'DeleteBackupRequest', - 'GetBackupRequest', - 'ListBackupsRequest', - 'ListBackupsResponse', - 'UpdateBackupRequest', - 'BackupPolicy', - 'CreateBackupPolicyRequest', - 'DeleteBackupPolicyRequest', - 'GetBackupPolicyRequest', - 'ListBackupPoliciesRequest', - 'ListBackupPoliciesResponse', - 'UpdateBackupPolicyRequest', - 'BackupVault', - 'CreateBackupVaultRequest', - 'DeleteBackupVaultRequest', - 'GetBackupVaultRequest', - 'ListBackupVaultsRequest', - 'ListBackupVaultsResponse', - 'UpdateBackupVaultRequest', - 'OperationMetadata', - 'LocationMetadata', - 'DirectoryServiceType', - 'EncryptionType', - 'FlexPerformance', - 'ServiceLevel', - 'CreateKmsConfigRequest', - 'DeleteKmsConfigRequest', - 'EncryptVolumesRequest', - 'GetKmsConfigRequest', - 'KmsConfig', - 'ListKmsConfigsRequest', - 'ListKmsConfigsResponse', - 'UpdateKmsConfigRequest', - 'VerifyKmsConfigRequest', - 'VerifyKmsConfigResponse', - 'CreateQuotaRuleRequest', - 'DeleteQuotaRuleRequest', - 'GetQuotaRuleRequest', - 'ListQuotaRulesRequest', - 'ListQuotaRulesResponse', - 'QuotaRule', - 'UpdateQuotaRuleRequest', - 'CreateReplicationRequest', - 'DeleteReplicationRequest', - 'DestinationVolumeParameters', - 'EstablishPeeringRequest', - 'GetReplicationRequest', - 'HybridPeeringDetails', - 'ListReplicationsRequest', - 'ListReplicationsResponse', - 'Replication', - 'ResumeReplicationRequest', - 'ReverseReplicationDirectionRequest', - 'StopReplicationRequest', - 'SyncReplicationRequest', - 'TransferStats', - 'UpdateReplicationRequest', - 'CreateSnapshotRequest', - 'DeleteSnapshotRequest', - 'GetSnapshotRequest', - 'ListSnapshotsRequest', - 'ListSnapshotsResponse', - 'Snapshot', - 'UpdateSnapshotRequest', - 'CreateStoragePoolRequest', - 'DeleteStoragePoolRequest', - 'GetStoragePoolRequest', - 'ListStoragePoolsRequest', - 'ListStoragePoolsResponse', - 'StoragePool', - 'SwitchActiveReplicaZoneRequest', - 'UpdateStoragePoolRequest', - 'ValidateDirectoryServiceRequest', - 'BackupConfig', - 'CreateVolumeRequest', - 'DailySchedule', - 'DeleteVolumeRequest', - 'ExportPolicy', - 'GetVolumeRequest', - 'HourlySchedule', - 'HybridReplicationParameters', - 'ListVolumesRequest', - 'ListVolumesResponse', - 'MonthlySchedule', - 'MountOption', - 'RestoreParameters', - 'RevertVolumeRequest', - 'SimpleExportPolicyRule', - 'SnapshotPolicy', - 'TieringPolicy', - 'UpdateVolumeRequest', - 'Volume', - 'WeeklySchedule', - 'AccessType', - 'Protocols', - 'RestrictedAction', - 'SecurityStyle', - 'SMBSettings', -) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/active_directory.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/active_directory.py deleted file mode 100644 index fe4a6ca27b2b..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/active_directory.py +++ /dev/null @@ -1,401 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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.cloud.netapp.v1', - manifest={ - 'ListActiveDirectoriesRequest', - 'ListActiveDirectoriesResponse', - 'GetActiveDirectoryRequest', - 'CreateActiveDirectoryRequest', - 'UpdateActiveDirectoryRequest', - 'DeleteActiveDirectoryRequest', - 'ActiveDirectory', - }, -) - - -class ListActiveDirectoriesRequest(proto.Message): - r"""ListActiveDirectoriesRequest for requesting multiple active - directories. - - Attributes: - parent (str): - Required. Parent value for - ListActiveDirectoriesRequest - page_size (int): - Requested page size. Server may return fewer - items than requested. If unspecified, the server - will pick an appropriate default. - page_token (str): - A token identifying a page of results the - server should return. - filter (str): - Filtering results - order_by (str): - Hint for how to order the results - """ - - 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 ListActiveDirectoriesResponse(proto.Message): - r"""ListActiveDirectoriesResponse contains all the active - directories requested. - - Attributes: - active_directories (MutableSequence[google.cloud.netapp_v1.types.ActiveDirectory]): - The list of active directories. - next_page_token (str): - A token identifying a page of results the - server should return. - unreachable (MutableSequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - active_directories: MutableSequence['ActiveDirectory'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='ActiveDirectory', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - unreachable: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class GetActiveDirectoryRequest(proto.Message): - r"""GetActiveDirectory for getting a single active directory. - - Attributes: - name (str): - Required. Name of the active directory. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateActiveDirectoryRequest(proto.Message): - r"""CreateActiveDirectoryRequest for creating an active - directory. - - Attributes: - parent (str): - Required. Value for parent. - active_directory (google.cloud.netapp_v1.types.ActiveDirectory): - Required. Fields of the to be created active - directory. - active_directory_id (str): - Required. ID of the active directory to - create. Must be unique within the parent - resource. Must contain only letters, numbers and - hyphen, with the first character a letter , the - last a letter or a number, and a 63 character - maximum. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - active_directory: 'ActiveDirectory' = proto.Field( - proto.MESSAGE, - number=2, - message='ActiveDirectory', - ) - active_directory_id: str = proto.Field( - proto.STRING, - number=3, - ) - - -class UpdateActiveDirectoryRequest(proto.Message): - r"""UpdateActiveDirectoryRequest for updating an active - directory. - - Attributes: - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the Active Directory resource by the update. - The fields specified in the update_mask are relative to the - resource, not the full request. A field will be overwritten - if it is in the mask. If the user does not provide a mask - then all fields will be overwritten. - active_directory (google.cloud.netapp_v1.types.ActiveDirectory): - Required. The volume being updated - """ - - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=1, - message=field_mask_pb2.FieldMask, - ) - active_directory: 'ActiveDirectory' = proto.Field( - proto.MESSAGE, - number=2, - message='ActiveDirectory', - ) - - -class DeleteActiveDirectoryRequest(proto.Message): - r"""DeleteActiveDirectoryRequest for deleting a single active - directory. - - Attributes: - name (str): - Required. Name of the active directory. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ActiveDirectory(proto.Message): - r"""ActiveDirectory is the public representation of the active - directory config. - - Attributes: - name (str): - Identifier. The resource name of the active directory. - Format: - ``projects/{project_number}/locations/{location_id}/activeDirectories/{active_directory_id}``. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Create time of the active - directory. - state (google.cloud.netapp_v1.types.ActiveDirectory.State): - Output only. The state of the AD. - domain (str): - Required. Name of the Active Directory domain - site (str): - The Active Directory site the service will - limit Domain Controller discovery too. - dns (str): - Required. Comma separated list of DNS server - IP addresses for the Active Directory domain. - net_bios_prefix (str): - Required. NetBIOSPrefix is used as a prefix - for SMB server name. - organizational_unit (str): - The Organizational Unit (OU) within the - Windows Active Directory the user belongs to. - aes_encryption (bool): - If enabled, AES encryption will be enabled - for SMB communication. - username (str): - Required. Username of the Active Directory - domain administrator. - password (str): - Required. Password of the Active Directory - domain administrator. - backup_operators (MutableSequence[str]): - Optional. Users to be added to the Built-in - Backup Operator active directory group. - administrators (MutableSequence[str]): - Optional. Users to be added to the Built-in - Admininstrators group. - security_operators (MutableSequence[str]): - Optional. Domain users to be given the - SeSecurityPrivilege. - kdc_hostname (str): - Name of the active directory machine. This - optional parameter is used only while creating - kerberos volume - kdc_ip (str): - KDC server IP address for the active - directory machine. - nfs_users_with_ldap (bool): - If enabled, will allow access to local users - and LDAP users. If access is needed for only - LDAP users, it has to be disabled. - description (str): - Description of the active directory. - ldap_signing (bool): - Specifies whether or not the LDAP traffic - needs to be signed. - encrypt_dc_connections (bool): - If enabled, traffic between the SMB server to - Domain Controller (DC) will be encrypted. - labels (MutableMapping[str, str]): - Labels for the active directory. - state_details (str): - Output only. The state details of the Active - Directory. - """ - class State(proto.Enum): - r"""The Active Directory States - - Values: - STATE_UNSPECIFIED (0): - Unspecified Active Directory State - CREATING (1): - Active Directory State is Creating - READY (2): - Active Directory State is Ready - UPDATING (3): - Active Directory State is Updating - IN_USE (4): - Active Directory State is In use - DELETING (5): - Active Directory State is Deleting - ERROR (6): - Active Directory State is Error - DIAGNOSING (7): - Active Directory State is Diagnosing. - """ - STATE_UNSPECIFIED = 0 - CREATING = 1 - READY = 2 - UPDATING = 3 - IN_USE = 4 - DELETING = 5 - ERROR = 6 - DIAGNOSING = 7 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - state: State = proto.Field( - proto.ENUM, - number=3, - enum=State, - ) - domain: str = proto.Field( - proto.STRING, - number=4, - ) - site: str = proto.Field( - proto.STRING, - number=5, - ) - dns: str = proto.Field( - proto.STRING, - number=6, - ) - net_bios_prefix: str = proto.Field( - proto.STRING, - number=7, - ) - organizational_unit: str = proto.Field( - proto.STRING, - number=8, - ) - aes_encryption: bool = proto.Field( - proto.BOOL, - number=9, - ) - username: str = proto.Field( - proto.STRING, - number=10, - ) - password: str = proto.Field( - proto.STRING, - number=11, - ) - backup_operators: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=12, - ) - administrators: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=22, - ) - security_operators: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=13, - ) - kdc_hostname: str = proto.Field( - proto.STRING, - number=14, - ) - kdc_ip: str = proto.Field( - proto.STRING, - number=15, - ) - nfs_users_with_ldap: bool = proto.Field( - proto.BOOL, - number=16, - ) - description: str = proto.Field( - proto.STRING, - number=17, - ) - ldap_signing: bool = proto.Field( - proto.BOOL, - number=18, - ) - encrypt_dc_connections: bool = proto.Field( - proto.BOOL, - number=19, - ) - labels: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=20, - ) - state_details: str = proto.Field( - proto.STRING, - number=21, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup.py deleted file mode 100644 index a8af8d3427b8..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup.py +++ /dev/null @@ -1,372 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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.cloud.netapp.v1', - manifest={ - 'Backup', - 'ListBackupsRequest', - 'ListBackupsResponse', - 'GetBackupRequest', - 'CreateBackupRequest', - 'DeleteBackupRequest', - 'UpdateBackupRequest', - }, -) - - -class Backup(proto.Message): - r"""A NetApp Backup. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - name (str): - Identifier. The resource name of the backup. Format: - ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id}``. - state (google.cloud.netapp_v1.types.Backup.State): - Output only. The backup state. - description (str): - A description of the backup with 2048 - characters or less. Requests with longer - descriptions will be rejected. - volume_usage_bytes (int): - Output only. Size of the file system when the - backup was created. When creating a new volume - from the backup, the volume capacity will have - to be at least as big. - backup_type (google.cloud.netapp_v1.types.Backup.Type): - Output only. Type of backup, manually created - or created by a backup policy. - source_volume (str): - Volume full name of this backup belongs to. Format: - ``projects/{projects_id}/locations/{location}/volumes/{volume_id}`` - source_snapshot (str): - If specified, backup will be created from the given - snapshot. If not specified, there will be a new snapshot - taken to initiate the backup creation. Format: - ``projects/{project_id}/locations/{location}/volumes/{volume_id}/snapshots/{snapshot_id}`` - - This field is a member of `oneof`_ ``_source_snapshot``. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time when the backup was - created. - labels (MutableMapping[str, str]): - Resource labels to represent user provided - metadata. - chain_storage_bytes (int): - Output only. Total size of all backups in a - chain in bytes = baseline backup size + - sum(incremental backup size) - satisfies_pzs (bool): - Output only. Reserved for future use - satisfies_pzi (bool): - Output only. Reserved for future use - """ - class State(proto.Enum): - r"""The Backup States - - Values: - STATE_UNSPECIFIED (0): - State not set. - CREATING (1): - Backup is being created. While in this state, - the snapshot for the backup point-in-time may - not have been created yet, and so the - point-in-time may not have been fixed. - UPLOADING (2): - Backup is being uploaded. While in this - state, none of the writes to the volume will be - included in the backup. - READY (3): - Backup is available for use. - DELETING (4): - Backup is being deleted. - ERROR (5): - Backup is not valid and cannot be used for - creating new volumes or restoring existing - volumes. - UPDATING (6): - Backup is being updated. - """ - STATE_UNSPECIFIED = 0 - CREATING = 1 - UPLOADING = 2 - READY = 3 - DELETING = 4 - ERROR = 5 - UPDATING = 6 - - class Type(proto.Enum): - r"""Backup types. - - Values: - TYPE_UNSPECIFIED (0): - Unspecified backup type. - MANUAL (1): - Manual backup type. - SCHEDULED (2): - Scheduled backup type. - """ - TYPE_UNSPECIFIED = 0 - MANUAL = 1 - SCHEDULED = 2 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - state: State = proto.Field( - proto.ENUM, - number=2, - enum=State, - ) - description: str = proto.Field( - proto.STRING, - number=3, - ) - volume_usage_bytes: int = proto.Field( - proto.INT64, - number=4, - ) - backup_type: Type = proto.Field( - proto.ENUM, - number=5, - enum=Type, - ) - source_volume: str = proto.Field( - proto.STRING, - number=6, - ) - source_snapshot: str = proto.Field( - proto.STRING, - number=7, - optional=True, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - labels: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=9, - ) - chain_storage_bytes: int = proto.Field( - proto.INT64, - number=10, - ) - satisfies_pzs: bool = proto.Field( - proto.BOOL, - number=11, - ) - satisfies_pzi: bool = proto.Field( - proto.BOOL, - number=12, - ) - - -class ListBackupsRequest(proto.Message): - r"""ListBackupsRequest lists backups. - - Attributes: - parent (str): - Required. The backupVault for which to retrieve backup - information, in the format - ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}``. - To retrieve backup information for all locations, use "-" - for the ``{location}`` value. To retrieve backup information - for all backupVaults, use "-" for the ``{backup_vault_id}`` - value. To retrieve backup information for a volume, use "-" - for the ``{backup_vault_id}`` value and specify volume full - name with the filter. - page_size (int): - The maximum number of items to return. The - service may return fewer than this value. The - maximum value is 1000; values above 1000 will be - coerced to 1000. - page_token (str): - The next_page_token value to use if there are additional - results to retrieve for this list request. - order_by (str): - Sort results. Supported values are "name", - "name desc" or "" (unsorted). - filter (str): - The standard list filter. - If specified, backups will be returned based on - the attribute name that matches the filter - expression. If empty, then no backups are - filtered out. See https://google.aip.dev/160 - """ - - 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, - ) - filter: str = proto.Field( - proto.STRING, - number=5, - ) - - -class ListBackupsResponse(proto.Message): - r"""ListBackupsResponse is the result of ListBackupsRequest. - - Attributes: - backups (MutableSequence[google.cloud.netapp_v1.types.Backup]): - A list of backups in the project. - next_page_token (str): - The token you can use to retrieve the next - page of results. Not returned if there are no - more results in the list. - unreachable (MutableSequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - backups: MutableSequence['Backup'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Backup', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - unreachable: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class GetBackupRequest(proto.Message): - r"""GetBackupRequest gets the state of a backup. - - Attributes: - name (str): - Required. The backup resource name, in the format - ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id}`` - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateBackupRequest(proto.Message): - r"""CreateBackupRequest creates a backup. - - Attributes: - parent (str): - Required. The NetApp backupVault to create the backups of, - in the format - ``projects/*/locations/*/backupVaults/{backup_vault_id}`` - backup_id (str): - Required. The ID to use for the backup. - The ID must be unique within the specified - backupVault. Must contain only letters, numbers - and hyphen, with the first character a letter, - the last a letter or a - number, and a 63 character maximum. - backup (google.cloud.netapp_v1.types.Backup): - Required. A backup resource - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - backup_id: str = proto.Field( - proto.STRING, - number=2, - ) - backup: 'Backup' = proto.Field( - proto.MESSAGE, - number=3, - message='Backup', - ) - - -class DeleteBackupRequest(proto.Message): - r"""DeleteBackupRequest deletes a backup. - - Attributes: - name (str): - Required. The backup resource name, in the format - ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id}`` - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateBackupRequest(proto.Message): - r"""UpdateBackupRequest updates description and/or labels for a - backup. - - Attributes: - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the Backup resource to be updated. The fields - specified in the update_mask are relative to the resource, - not the full request. A field will be overwritten if it is - in the mask. If the user does not provide a mask then all - fields will be overwritten. - backup (google.cloud.netapp_v1.types.Backup): - Required. The backup being updated - """ - - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=1, - message=field_mask_pb2.FieldMask, - ) - backup: 'Backup' = proto.Field( - proto.MESSAGE, - number=2, - message='Backup', - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup_policy.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup_policy.py deleted file mode 100644 index af1e884c9353..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup_policy.py +++ /dev/null @@ -1,333 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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.cloud.netapp.v1', - manifest={ - 'BackupPolicy', - 'CreateBackupPolicyRequest', - 'GetBackupPolicyRequest', - 'ListBackupPoliciesRequest', - 'ListBackupPoliciesResponse', - 'UpdateBackupPolicyRequest', - 'DeleteBackupPolicyRequest', - }, -) - - -class BackupPolicy(proto.Message): - r"""Backup Policy. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - name (str): - Identifier. The resource name of the backup policy. Format: - ``projects/{project_id}/locations/{location}/backupPolicies/{backup_policy_id}``. - daily_backup_limit (int): - Number of daily backups to keep. Note that - the minimum daily backup limit is 2. - - This field is a member of `oneof`_ ``_daily_backup_limit``. - weekly_backup_limit (int): - Number of weekly backups to keep. Note that - the sum of daily, weekly and monthly backups - should be greater than 1. - - This field is a member of `oneof`_ ``_weekly_backup_limit``. - monthly_backup_limit (int): - Number of monthly backups to keep. Note that - the sum of daily, weekly and monthly backups - should be greater than 1. - - This field is a member of `oneof`_ ``_monthly_backup_limit``. - description (str): - Description of the backup policy. - - This field is a member of `oneof`_ ``_description``. - enabled (bool): - If enabled, make backups automatically - according to the schedules. This will be applied - to all volumes that have this policy attached - and enforced on volume level. If not specified, - default is true. - - This field is a member of `oneof`_ ``_enabled``. - assigned_volume_count (int): - Output only. The total number of volumes - assigned by this backup policy. - - This field is a member of `oneof`_ ``_assigned_volume_count``. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time when the backup policy - was created. - labels (MutableMapping[str, str]): - Resource labels to represent user provided - metadata. - state (google.cloud.netapp_v1.types.BackupPolicy.State): - Output only. The backup policy state. - """ - class State(proto.Enum): - r""" - - Values: - STATE_UNSPECIFIED (0): - State not set. - CREATING (1): - BackupPolicy is being created. - READY (2): - BackupPolicy is available for use. - DELETING (3): - BackupPolicy is being deleted. - ERROR (4): - BackupPolicy is not valid and cannot be used. - UPDATING (5): - BackupPolicy is being updated. - """ - STATE_UNSPECIFIED = 0 - CREATING = 1 - READY = 2 - DELETING = 3 - ERROR = 4 - UPDATING = 5 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - daily_backup_limit: int = proto.Field( - proto.INT32, - number=2, - optional=True, - ) - weekly_backup_limit: int = proto.Field( - proto.INT32, - number=3, - optional=True, - ) - monthly_backup_limit: int = proto.Field( - proto.INT32, - number=4, - optional=True, - ) - description: str = proto.Field( - proto.STRING, - number=5, - optional=True, - ) - enabled: bool = proto.Field( - proto.BOOL, - number=6, - optional=True, - ) - assigned_volume_count: int = proto.Field( - proto.INT32, - number=7, - optional=True, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - labels: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=9, - ) - state: State = proto.Field( - proto.ENUM, - number=10, - enum=State, - ) - - -class CreateBackupPolicyRequest(proto.Message): - r"""CreateBackupPolicyRequest creates a backupPolicy. - - Attributes: - parent (str): - Required. The location to create the backup policies of, in - the format ``projects/{project_id}/locations/{location}`` - backup_policy (google.cloud.netapp_v1.types.BackupPolicy): - Required. A backupPolicy resource - backup_policy_id (str): - Required. The ID to use for the backup - policy. The ID must be unique within the - specified location. Must contain only letters, - numbers and hyphen, with the first character a - letter, the last a letter or a - number, and a 63 character maximum. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - backup_policy: 'BackupPolicy' = proto.Field( - proto.MESSAGE, - number=2, - message='BackupPolicy', - ) - backup_policy_id: str = proto.Field( - proto.STRING, - number=3, - ) - - -class GetBackupPolicyRequest(proto.Message): - r"""GetBackupPolicyRequest gets the state of a backupPolicy. - - Attributes: - name (str): - Required. The backupPolicy resource name, in the format - ``projects/{project_id}/locations/{location}/backupPolicies/{backup_policy_id}`` - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ListBackupPoliciesRequest(proto.Message): - r"""ListBackupPoliciesRequest for requesting multiple backup - policies. - - Attributes: - parent (str): - Required. Parent value for - ListBackupPoliciesRequest - page_size (int): - Requested page size. Server may return fewer - items than requested. If unspecified, the server - will pick an appropriate default. - page_token (str): - A token identifying a page of results the - server should return. - filter (str): - Filtering results - order_by (str): - Hint for how to order the results - """ - - 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 ListBackupPoliciesResponse(proto.Message): - r"""ListBackupPoliciesResponse contains all the backup policies - requested. - - Attributes: - backup_policies (MutableSequence[google.cloud.netapp_v1.types.BackupPolicy]): - The list of backup policies. - next_page_token (str): - A token identifying a page of results the - server should return. - unreachable (MutableSequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - backup_policies: MutableSequence['BackupPolicy'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='BackupPolicy', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - unreachable: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class UpdateBackupPolicyRequest(proto.Message): - r"""UpdateBackupPolicyRequest for updating a backup policy. - - Attributes: - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the Backup Policy resource by the update. The - fields specified in the update_mask are relative to the - resource, not the full request. A field will be overwritten - if it is in the mask. If the user does not provide a mask - then all fields will be overwritten. - backup_policy (google.cloud.netapp_v1.types.BackupPolicy): - Required. The backup policy being updated - """ - - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=1, - message=field_mask_pb2.FieldMask, - ) - backup_policy: 'BackupPolicy' = proto.Field( - proto.MESSAGE, - number=2, - message='BackupPolicy', - ) - - -class DeleteBackupPolicyRequest(proto.Message): - r"""DeleteBackupPolicyRequest deletes a backup policy. - - Attributes: - name (str): - Required. The backup policy resource name, in the format - ``projects/{project_id}/locations/{location}/backupPolicies/{backup_policy_id}`` - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup_vault.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup_vault.py deleted file mode 100644 index 449c1d0d26cd..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/backup_vault.py +++ /dev/null @@ -1,274 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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.cloud.netapp.v1', - manifest={ - 'BackupVault', - 'GetBackupVaultRequest', - 'ListBackupVaultsRequest', - 'ListBackupVaultsResponse', - 'CreateBackupVaultRequest', - 'DeleteBackupVaultRequest', - 'UpdateBackupVaultRequest', - }, -) - - -class BackupVault(proto.Message): - r"""A NetApp BackupVault. - - Attributes: - name (str): - Identifier. The resource name of the backup vault. Format: - ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}``. - state (google.cloud.netapp_v1.types.BackupVault.State): - Output only. The backup vault state. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Create time of the backup vault. - description (str): - Description of the backup vault. - labels (MutableMapping[str, str]): - Resource labels to represent user provided - metadata. - """ - class State(proto.Enum): - r"""The Backup Vault States - - Values: - STATE_UNSPECIFIED (0): - State not set. - CREATING (1): - BackupVault is being created. - READY (2): - BackupVault is available for use. - DELETING (3): - BackupVault is being deleted. - ERROR (4): - BackupVault is not valid and cannot be used. - UPDATING (5): - BackupVault is being updated. - """ - STATE_UNSPECIFIED = 0 - CREATING = 1 - READY = 2 - DELETING = 3 - ERROR = 4 - UPDATING = 5 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - state: State = proto.Field( - proto.ENUM, - number=2, - enum=State, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - description: str = proto.Field( - proto.STRING, - number=4, - ) - labels: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=5, - ) - - -class GetBackupVaultRequest(proto.Message): - r"""GetBackupVaultRequest gets the state of a backupVault. - - Attributes: - name (str): - Required. The backupVault resource name, in the format - ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}`` - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ListBackupVaultsRequest(proto.Message): - r"""ListBackupVaultsRequest lists backupVaults. - - Attributes: - parent (str): - Required. The location for which to retrieve backupVault - information, in the format - ``projects/{project_id}/locations/{location}``. - page_size (int): - The maximum number of items to return. - page_token (str): - The next_page_token value to use if there are additional - results to retrieve for this list request. - order_by (str): - Sort results. Supported values are "name", - "name desc" or "" (unsorted). - filter (str): - List filter. - """ - - 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, - ) - filter: str = proto.Field( - proto.STRING, - number=5, - ) - - -class ListBackupVaultsResponse(proto.Message): - r"""ListBackupVaultsResponse is the result of - ListBackupVaultsRequest. - - Attributes: - backup_vaults (MutableSequence[google.cloud.netapp_v1.types.BackupVault]): - A list of backupVaults in the project for the - specified location. - next_page_token (str): - The token you can use to retrieve the next - page of results. Not returned if there are no - more results in the list. - unreachable (MutableSequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - backup_vaults: MutableSequence['BackupVault'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='BackupVault', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - unreachable: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class CreateBackupVaultRequest(proto.Message): - r"""CreateBackupVaultRequest creates a backup vault. - - Attributes: - parent (str): - Required. The location to create the backup vaults, in the - format ``projects/{project_id}/locations/{location}`` - backup_vault_id (str): - Required. The ID to use for the backupVault. - The ID must be unique within the specified - location. Must contain only letters, numbers and - hyphen, with the first character a letter, the - last a letter or a - number, and a 63 character maximum. - backup_vault (google.cloud.netapp_v1.types.BackupVault): - Required. A backupVault resource - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - backup_vault_id: str = proto.Field( - proto.STRING, - number=2, - ) - backup_vault: 'BackupVault' = proto.Field( - proto.MESSAGE, - number=3, - message='BackupVault', - ) - - -class DeleteBackupVaultRequest(proto.Message): - r"""DeleteBackupVaultRequest deletes a backupVault. - - Attributes: - name (str): - Required. The backupVault resource name, in the format - ``projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id}`` - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateBackupVaultRequest(proto.Message): - r"""UpdateBackupVaultRequest updates description and/or labels - for a backupVault. - - Attributes: - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the Backup resource to be updated. The fields - specified in the update_mask are relative to the resource, - not the full request. A field will be overwritten if it is - in the mask. If the user does not provide a mask then all - fields will be overwritten. - backup_vault (google.cloud.netapp_v1.types.BackupVault): - Required. The backupVault being updated - """ - - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=1, - message=field_mask_pb2.FieldMask, - ) - backup_vault: 'BackupVault' = proto.Field( - proto.MESSAGE, - number=2, - message='BackupVault', - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/cloud_netapp_service.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/cloud_netapp_service.py deleted file mode 100644 index 2c3fec7fef5f..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/cloud_netapp_service.py +++ /dev/null @@ -1,95 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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.cloud.netapp.v1', - manifest={ - 'OperationMetadata', - }, -) - - -class OperationMetadata(proto.Message): - r"""Represents the metadata of the long-running operation. - - Attributes: - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation was - created. - end_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation finished - running. - target (str): - Output only. Server-defined resource path for - the target of the operation. - verb (str): - Output only. Name of the verb executed by the - operation. - status_message (str): - Output only. Human-readable status of the - operation, if any. - requested_cancellation (bool): - Output only. Identifies whether the user has requested - cancellation of the operation. Operations that have been - canceled successfully have [Operation.error][] value with a - [google.rpc.Status.code][google.rpc.Status.code] of 1, - corresponding to ``Code.CANCELLED``. - api_version (str): - Output only. API version used to start the - operation. - """ - - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - target: str = proto.Field( - proto.STRING, - number=3, - ) - verb: str = proto.Field( - proto.STRING, - number=4, - ) - status_message: str = proto.Field( - proto.STRING, - number=5, - ) - requested_cancellation: bool = proto.Field( - proto.BOOL, - number=6, - ) - api_version: str = proto.Field( - proto.STRING, - number=7, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/common.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/common.py deleted file mode 100644 index 324846f99933..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/common.py +++ /dev/null @@ -1,130 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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.cloud.netapp.v1', - manifest={ - 'ServiceLevel', - 'FlexPerformance', - 'EncryptionType', - 'DirectoryServiceType', - 'LocationMetadata', - }, -) - - -class ServiceLevel(proto.Enum): - r"""The service level of a storage pool and its volumes. - - Values: - SERVICE_LEVEL_UNSPECIFIED (0): - Unspecified service level. - PREMIUM (1): - Premium service level. - EXTREME (2): - Extreme service level. - STANDARD (3): - Standard service level. - FLEX (4): - Flex service level. - """ - SERVICE_LEVEL_UNSPECIFIED = 0 - PREMIUM = 1 - EXTREME = 2 - STANDARD = 3 - FLEX = 4 - - -class FlexPerformance(proto.Enum): - r"""Flex Storage Pool performance. - - Values: - FLEX_PERFORMANCE_UNSPECIFIED (0): - Unspecified flex performance. - FLEX_PERFORMANCE_DEFAULT (1): - Flex Storage Pool with default performance. - FLEX_PERFORMANCE_CUSTOM (2): - Flex Storage Pool with custom performance. - """ - FLEX_PERFORMANCE_UNSPECIFIED = 0 - FLEX_PERFORMANCE_DEFAULT = 1 - FLEX_PERFORMANCE_CUSTOM = 2 - - -class EncryptionType(proto.Enum): - r"""The volume encryption key source. - - Values: - ENCRYPTION_TYPE_UNSPECIFIED (0): - The source of the encryption key is not - specified. - SERVICE_MANAGED (1): - Google managed encryption key. - CLOUD_KMS (2): - Customer managed encryption key, which is - stored in KMS. - """ - ENCRYPTION_TYPE_UNSPECIFIED = 0 - SERVICE_MANAGED = 1 - CLOUD_KMS = 2 - - -class DirectoryServiceType(proto.Enum): - r"""Type of directory service - - Values: - DIRECTORY_SERVICE_TYPE_UNSPECIFIED (0): - Directory service type is not specified. - ACTIVE_DIRECTORY (1): - Active directory policy attached to the - storage pool. - """ - DIRECTORY_SERVICE_TYPE_UNSPECIFIED = 0 - ACTIVE_DIRECTORY = 1 - - -class LocationMetadata(proto.Message): - r"""Metadata for a given - [google.cloud.location.Location][google.cloud.location.Location]. - - Attributes: - supported_service_levels (MutableSequence[google.cloud.netapp_v1.types.ServiceLevel]): - Output only. Supported service levels in a - location. - supported_flex_performance (MutableSequence[google.cloud.netapp_v1.types.FlexPerformance]): - Output only. Supported flex performance in a - location. - """ - - supported_service_levels: MutableSequence['ServiceLevel'] = proto.RepeatedField( - proto.ENUM, - number=1, - enum='ServiceLevel', - ) - supported_flex_performance: MutableSequence['FlexPerformance'] = proto.RepeatedField( - proto.ENUM, - number=2, - enum='FlexPerformance', - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/kms.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/kms.py deleted file mode 100644 index e946fa604c6b..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/kms.py +++ /dev/null @@ -1,381 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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.cloud.netapp.v1', - manifest={ - 'GetKmsConfigRequest', - 'ListKmsConfigsRequest', - 'ListKmsConfigsResponse', - 'CreateKmsConfigRequest', - 'UpdateKmsConfigRequest', - 'DeleteKmsConfigRequest', - 'EncryptVolumesRequest', - 'VerifyKmsConfigRequest', - 'VerifyKmsConfigResponse', - 'KmsConfig', - }, -) - - -class GetKmsConfigRequest(proto.Message): - r"""GetKmsConfigRequest gets a KMS Config. - - Attributes: - name (str): - Required. Name of the KmsConfig - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ListKmsConfigsRequest(proto.Message): - r"""ListKmsConfigsRequest lists KMS Configs. - - Attributes: - parent (str): - Required. Parent value - page_size (int): - The maximum number of items to return. - page_token (str): - The next_page_token value to use if there are additional - results to retrieve for this list request. - order_by (str): - Sort results. Supported values are "name", - "name desc" or "" (unsorted). - filter (str): - List filter. - """ - - 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, - ) - filter: str = proto.Field( - proto.STRING, - number=5, - ) - - -class ListKmsConfigsResponse(proto.Message): - r"""ListKmsConfigsResponse is the response to a - ListKmsConfigsRequest. - - Attributes: - kms_configs (MutableSequence[google.cloud.netapp_v1.types.KmsConfig]): - The list of KmsConfigs - next_page_token (str): - A token identifying a page of results the - server should return. - unreachable (MutableSequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - kms_configs: MutableSequence['KmsConfig'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='KmsConfig', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - unreachable: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class CreateKmsConfigRequest(proto.Message): - r"""CreateKmsConfigRequest creates a KMS Config. - - Attributes: - parent (str): - Required. Value for parent. - kms_config_id (str): - Required. Id of the requesting KmsConfig. - Must be unique within the parent resource. Must - contain only letters, numbers and hyphen, with - the first character a letter, the last a letter - or a - number, and a 63 character maximum. - kms_config (google.cloud.netapp_v1.types.KmsConfig): - Required. The required parameters to create a - new KmsConfig. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - kms_config_id: str = proto.Field( - proto.STRING, - number=2, - ) - kms_config: 'KmsConfig' = proto.Field( - proto.MESSAGE, - number=3, - message='KmsConfig', - ) - - -class UpdateKmsConfigRequest(proto.Message): - r"""UpdateKmsConfigRequest updates a KMS Config. - - Attributes: - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the KmsConfig resource by the update. The - fields specified in the update_mask are relative to the - resource, not the full request. A field will be overwritten - if it is in the mask. If the user does not provide a mask - then all fields will be overwritten. - kms_config (google.cloud.netapp_v1.types.KmsConfig): - Required. The KmsConfig being updated - """ - - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=1, - message=field_mask_pb2.FieldMask, - ) - kms_config: 'KmsConfig' = proto.Field( - proto.MESSAGE, - number=2, - message='KmsConfig', - ) - - -class DeleteKmsConfigRequest(proto.Message): - r"""DeleteKmsConfigRequest deletes a KMS Config. - - Attributes: - name (str): - Required. Name of the KmsConfig. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class EncryptVolumesRequest(proto.Message): - r"""EncryptVolumesRequest specifies the KMS config to encrypt - existing volumes. - - Attributes: - name (str): - Required. Name of the KmsConfig. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class VerifyKmsConfigRequest(proto.Message): - r"""VerifyKmsConfigRequest specifies the KMS config to be - validated. - - Attributes: - name (str): - Required. Name of the KMS Config to be - verified. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class VerifyKmsConfigResponse(proto.Message): - r"""VerifyKmsConfigResponse contains the information if the - config is correctly and error message. - - Attributes: - healthy (bool): - Output only. If the customer key configured - correctly to the encrypt volume. - health_error (str): - Output only. Error message if config is not - healthy. - instructions (str): - Output only. Instructions for the customers - to provide the access to the encryption key. - """ - - healthy: bool = proto.Field( - proto.BOOL, - number=1, - ) - health_error: str = proto.Field( - proto.STRING, - number=2, - ) - instructions: str = proto.Field( - proto.STRING, - number=3, - ) - - -class KmsConfig(proto.Message): - r"""KmsConfig is the customer managed encryption key(CMEK) - configuration. - - Attributes: - name (str): - Identifier. Name of the KmsConfig. - crypto_key_name (str): - Required. Customer managed crypto key resource full name. - Format: - projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{key}. - state (google.cloud.netapp_v1.types.KmsConfig.State): - Output only. State of the KmsConfig. - state_details (str): - Output only. State details of the KmsConfig. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Create time of the KmsConfig. - description (str): - Description of the KmsConfig. - labels (MutableMapping[str, str]): - Labels as key value pairs - instructions (str): - Output only. Instructions to provide the - access to the customer provided encryption key. - service_account (str): - Output only. The Service account which will - have access to the customer provided encryption - key. - """ - class State(proto.Enum): - r"""The KmsConfig States - - Values: - STATE_UNSPECIFIED (0): - Unspecified KmsConfig State - READY (1): - KmsConfig State is Ready - CREATING (2): - KmsConfig State is Creating - DELETING (3): - KmsConfig State is Deleting - UPDATING (4): - KmsConfig State is Updating - IN_USE (5): - KmsConfig State is In Use. - ERROR (6): - KmsConfig State is Error - KEY_CHECK_PENDING (7): - KmsConfig State is Pending to verify crypto - key access. - KEY_NOT_REACHABLE (8): - KmsConfig State is Not accessbile by the SDE - service account to the crypto key. - DISABLING (9): - KmsConfig State is Disabling. - DISABLED (10): - KmsConfig State is Disabled. - MIGRATING (11): - KmsConfig State is Migrating. - The existing volumes are migrating from SMEK to - CMEK. - """ - STATE_UNSPECIFIED = 0 - READY = 1 - CREATING = 2 - DELETING = 3 - UPDATING = 4 - IN_USE = 5 - ERROR = 6 - KEY_CHECK_PENDING = 7 - KEY_NOT_REACHABLE = 8 - DISABLING = 9 - DISABLED = 10 - MIGRATING = 11 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - crypto_key_name: str = proto.Field( - proto.STRING, - number=2, - ) - state: State = proto.Field( - proto.ENUM, - number=3, - enum=State, - ) - state_details: str = proto.Field( - proto.STRING, - number=4, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=5, - message=timestamp_pb2.Timestamp, - ) - description: str = proto.Field( - proto.STRING, - number=6, - ) - labels: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=7, - ) - instructions: str = proto.Field( - proto.STRING, - number=8, - ) - service_account: str = proto.Field( - proto.STRING, - number=9, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/quota_rule.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/quota_rule.py deleted file mode 100644 index 76310bebc9f8..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/quota_rule.py +++ /dev/null @@ -1,321 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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.cloud.netapp.v1', - manifest={ - 'ListQuotaRulesRequest', - 'ListQuotaRulesResponse', - 'GetQuotaRuleRequest', - 'CreateQuotaRuleRequest', - 'UpdateQuotaRuleRequest', - 'DeleteQuotaRuleRequest', - 'QuotaRule', - }, -) - - -class ListQuotaRulesRequest(proto.Message): - r"""ListQuotaRulesRequest for listing quota rules. - - Attributes: - parent (str): - Required. Parent value for - ListQuotaRulesRequest - page_size (int): - Optional. Requested page size. Server may - return fewer items than requested. If - unspecified, the server will pick an appropriate - default. - page_token (str): - Optional. A token identifying a page of - results the server should return. - filter (str): - Optional. Filtering results - order_by (str): - Optional. Hint for how to order the results - """ - - 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 ListQuotaRulesResponse(proto.Message): - r"""ListQuotaRulesResponse is the response to a - ListQuotaRulesRequest. - - Attributes: - quota_rules (MutableSequence[google.cloud.netapp_v1.types.QuotaRule]): - List of quota rules - next_page_token (str): - A token identifying a page of results the - server should return. - unreachable (MutableSequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - quota_rules: MutableSequence['QuotaRule'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='QuotaRule', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - unreachable: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class GetQuotaRuleRequest(proto.Message): - r"""GetQuotaRuleRequest for getting a quota rule. - - Attributes: - name (str): - Required. Name of the quota rule - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateQuotaRuleRequest(proto.Message): - r"""CreateQuotaRuleRequest for creating a quota rule. - - Attributes: - parent (str): - Required. Parent value for - CreateQuotaRuleRequest - quota_rule (google.cloud.netapp_v1.types.QuotaRule): - Required. Fields of the to be created quota - rule. - quota_rule_id (str): - Required. ID of the quota rule to create. - Must be unique within the parent resource. Must - contain only letters, numbers, underscore and - hyphen, with the first character a letter or - underscore, the last a letter or underscore or a - number, and a 63 character maximum. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - quota_rule: 'QuotaRule' = proto.Field( - proto.MESSAGE, - number=2, - message='QuotaRule', - ) - quota_rule_id: str = proto.Field( - proto.STRING, - number=3, - ) - - -class UpdateQuotaRuleRequest(proto.Message): - r"""UpdateQuotaRuleRequest for updating a quota rule. - - Attributes: - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Optional. Field mask is used to specify the fields to be - overwritten in the Quota Rule resource by the update. The - fields specified in the update_mask are relative to the - resource, not the full request. A field will be overwritten - if it is in the mask. If the user does not provide a mask - then all fields will be overwritten. - quota_rule (google.cloud.netapp_v1.types.QuotaRule): - Required. The quota rule being updated - """ - - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=1, - message=field_mask_pb2.FieldMask, - ) - quota_rule: 'QuotaRule' = proto.Field( - proto.MESSAGE, - number=2, - message='QuotaRule', - ) - - -class DeleteQuotaRuleRequest(proto.Message): - r"""DeleteQuotaRuleRequest for deleting a single quota rule. - - Attributes: - name (str): - Required. Name of the quota rule. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class QuotaRule(proto.Message): - r"""QuotaRule specifies the maximum disk space a user or group - can use within a volume. They can be used for creating default - and individual quota rules. - - Attributes: - name (str): - Identifier. The resource name of the quota rule. Format: - ``projects/{project_number}/locations/{location_id}/volumes/volumes/{volume_id}/quotaRules/{quota_rule_id}``. - target (str): - Optional. The quota rule applies to the - specified user or group, identified by a Unix - UID/GID, Windows SID, or null for default. - type_ (google.cloud.netapp_v1.types.QuotaRule.Type): - Required. The type of quota rule. - disk_limit_mib (int): - Required. The maximum allowed disk space in - MiB. - state (google.cloud.netapp_v1.types.QuotaRule.State): - Output only. State of the quota rule - state_details (str): - Output only. State details of the quota rule - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Create time of the quota rule - description (str): - Optional. Description of the quota rule - labels (MutableMapping[str, str]): - Optional. Labels of the quota rule - """ - class Type(proto.Enum): - r"""Types of Quota Rule - - Values: - TYPE_UNSPECIFIED (0): - Unspecified type for quota rule - INDIVIDUAL_USER_QUOTA (1): - Individual user quota rule - INDIVIDUAL_GROUP_QUOTA (2): - Individual group quota rule - DEFAULT_USER_QUOTA (3): - Default user quota rule - DEFAULT_GROUP_QUOTA (4): - Default group quota rule - """ - TYPE_UNSPECIFIED = 0 - INDIVIDUAL_USER_QUOTA = 1 - INDIVIDUAL_GROUP_QUOTA = 2 - DEFAULT_USER_QUOTA = 3 - DEFAULT_GROUP_QUOTA = 4 - - class State(proto.Enum): - r"""Quota Rule states - - Values: - STATE_UNSPECIFIED (0): - Unspecified state for quota rule - CREATING (1): - Quota rule is creating - UPDATING (2): - Quota rule is updating - DELETING (3): - Quota rule is deleting - READY (4): - Quota rule is ready - ERROR (5): - Quota rule is in error state. - """ - STATE_UNSPECIFIED = 0 - CREATING = 1 - UPDATING = 2 - DELETING = 3 - READY = 4 - ERROR = 5 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - target: str = proto.Field( - proto.STRING, - number=2, - ) - type_: Type = proto.Field( - proto.ENUM, - number=3, - enum=Type, - ) - disk_limit_mib: int = proto.Field( - proto.INT32, - number=4, - ) - state: State = proto.Field( - proto.ENUM, - number=6, - enum=State, - ) - state_details: str = proto.Field( - proto.STRING, - number=7, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - description: str = proto.Field( - proto.STRING, - number=9, - ) - labels: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=10, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/replication.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/replication.py deleted file mode 100644 index dcc90cc82f8d..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/replication.py +++ /dev/null @@ -1,817 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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.netapp_v1.types import volume -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.cloud.netapp.v1', - manifest={ - 'TransferStats', - 'Replication', - 'HybridPeeringDetails', - 'ListReplicationsRequest', - 'ListReplicationsResponse', - 'GetReplicationRequest', - 'DestinationVolumeParameters', - 'CreateReplicationRequest', - 'DeleteReplicationRequest', - 'UpdateReplicationRequest', - 'StopReplicationRequest', - 'ResumeReplicationRequest', - 'ReverseReplicationDirectionRequest', - 'EstablishPeeringRequest', - 'SyncReplicationRequest', - }, -) - - -class TransferStats(proto.Message): - r"""TransferStats reports all statistics related to replication - transfer. - - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - transfer_bytes (int): - Cumulative bytes trasferred so far for the - replication relatinonship. - - This field is a member of `oneof`_ ``_transfer_bytes``. - total_transfer_duration (google.protobuf.duration_pb2.Duration): - Cumulative time taken across all transfers - for the replication relationship. - - This field is a member of `oneof`_ ``_total_transfer_duration``. - last_transfer_bytes (int): - Last transfer size in bytes. - - This field is a member of `oneof`_ ``_last_transfer_bytes``. - last_transfer_duration (google.protobuf.duration_pb2.Duration): - Time taken during last transfer. - - This field is a member of `oneof`_ ``_last_transfer_duration``. - lag_duration (google.protobuf.duration_pb2.Duration): - Lag duration indicates the duration by which - Destination region volume content lags behind - the primary region volume content. - - This field is a member of `oneof`_ ``_lag_duration``. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Time when progress was updated last. - - This field is a member of `oneof`_ ``_update_time``. - last_transfer_end_time (google.protobuf.timestamp_pb2.Timestamp): - Time when last transfer completed. - - This field is a member of `oneof`_ ``_last_transfer_end_time``. - last_transfer_error (str): - A message describing the cause of the last - transfer failure. - - This field is a member of `oneof`_ ``_last_transfer_error``. - """ - - transfer_bytes: int = proto.Field( - proto.INT64, - number=1, - optional=True, - ) - total_transfer_duration: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=2, - optional=True, - message=duration_pb2.Duration, - ) - last_transfer_bytes: int = proto.Field( - proto.INT64, - number=3, - optional=True, - ) - last_transfer_duration: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=4, - optional=True, - message=duration_pb2.Duration, - ) - lag_duration: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=5, - optional=True, - message=duration_pb2.Duration, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=6, - optional=True, - message=timestamp_pb2.Timestamp, - ) - last_transfer_end_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=7, - optional=True, - message=timestamp_pb2.Timestamp, - ) - last_transfer_error: str = proto.Field( - proto.STRING, - number=8, - optional=True, - ) - - -class Replication(proto.Message): - r"""Replication is a nested resource under Volume, that describes - a cross-region replication relationship between 2 volumes in - different regions. - - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - name (str): - Identifier. The resource name of the Replication. Format: - ``projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}``. - state (google.cloud.netapp_v1.types.Replication.State): - Output only. State of the replication. - state_details (str): - Output only. State details of the - replication. - role (google.cloud.netapp_v1.types.Replication.ReplicationRole): - Output only. Indicates whether this points to - source or destination. - replication_schedule (google.cloud.netapp_v1.types.Replication.ReplicationSchedule): - Required. Indicates the schedule for - replication. - mirror_state (google.cloud.netapp_v1.types.Replication.MirrorState): - Output only. Indicates the state of - mirroring. - healthy (bool): - Output only. Condition of the relationship. - Can be one of the following: - - - true: The replication relationship is healthy. - It has not missed the most recent scheduled - transfer. - - false: The replication relationship is not - healthy. It has missed the most recent - scheduled transfer. - - This field is a member of `oneof`_ ``_healthy``. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Replication create time. - destination_volume (str): - Output only. Full name of destination volume resource. - Example : - "projects/{project}/locations/{location}/volumes/{volume_id}". - transfer_stats (google.cloud.netapp_v1.types.TransferStats): - Output only. Replication transfer statistics. - labels (MutableMapping[str, str]): - Resource labels to represent user provided - metadata. - description (str): - A description about this replication - relationship. - - This field is a member of `oneof`_ ``_description``. - destination_volume_parameters (google.cloud.netapp_v1.types.DestinationVolumeParameters): - Required. Input only. Destination volume - parameters - source_volume (str): - Output only. Full name of source volume resource. Example : - "projects/{project}/locations/{location}/volumes/{volume_id}". - hybrid_peering_details (google.cloud.netapp_v1.types.HybridPeeringDetails): - Output only. Hybrid peering details. - cluster_location (str): - Optional. Location of the user cluster. - hybrid_replication_type (google.cloud.netapp_v1.types.Replication.HybridReplicationType): - Output only. Type of the hybrid replication. - """ - class State(proto.Enum): - r"""The replication states - New enum values may be added in future to indicate possible new - states. - - Values: - STATE_UNSPECIFIED (0): - Unspecified replication State - CREATING (1): - Replication is creating. - READY (2): - Replication is ready. - UPDATING (3): - Replication is updating. - DELETING (5): - Replication is deleting. - ERROR (6): - Replication is in error state. - PENDING_CLUSTER_PEERING (8): - Replication is waiting for cluster peering to - be established. - PENDING_SVM_PEERING (9): - Replication is waiting for SVM peering to be - established. - """ - STATE_UNSPECIFIED = 0 - CREATING = 1 - READY = 2 - UPDATING = 3 - DELETING = 5 - ERROR = 6 - PENDING_CLUSTER_PEERING = 8 - PENDING_SVM_PEERING = 9 - - class ReplicationRole(proto.Enum): - r"""New enum values may be added in future to support different - replication topology. - - Values: - REPLICATION_ROLE_UNSPECIFIED (0): - Unspecified replication role - SOURCE (1): - Indicates Source volume. - DESTINATION (2): - Indicates Destination volume. - """ - REPLICATION_ROLE_UNSPECIFIED = 0 - SOURCE = 1 - DESTINATION = 2 - - class ReplicationSchedule(proto.Enum): - r"""Schedule for Replication. - New enum values may be added in future to support different - frequency of replication. - - Values: - REPLICATION_SCHEDULE_UNSPECIFIED (0): - Unspecified ReplicationSchedule - EVERY_10_MINUTES (1): - Replication happens once every 10 minutes. - HOURLY (2): - Replication happens once every hour. - DAILY (3): - Replication happens once every day. - """ - REPLICATION_SCHEDULE_UNSPECIFIED = 0 - EVERY_10_MINUTES = 1 - HOURLY = 2 - DAILY = 3 - - class MirrorState(proto.Enum): - r"""Mirroring states. - No new value is expected to be added in future. - - Values: - MIRROR_STATE_UNSPECIFIED (0): - Unspecified MirrorState - PREPARING (1): - Destination volume is being prepared. - MIRRORED (2): - Destination volume has been initialized and - is ready to receive replication transfers. - STOPPED (3): - Destination volume is not receiving - replication transfers. - TRANSFERRING (4): - Incremental replication is in progress. - BASELINE_TRANSFERRING (5): - Baseline replication is in progress. - ABORTED (6): - Replication is aborted. - """ - MIRROR_STATE_UNSPECIFIED = 0 - PREPARING = 1 - MIRRORED = 2 - STOPPED = 3 - TRANSFERRING = 4 - BASELINE_TRANSFERRING = 5 - ABORTED = 6 - - class HybridReplicationType(proto.Enum): - r"""Hybrid replication type. - - Values: - HYBRID_REPLICATION_TYPE_UNSPECIFIED (0): - Unspecified hybrid replication type. - MIGRATION (1): - Hybrid replication type for migration. - CONTINUOUS_REPLICATION (2): - Hybrid replication type for continuous - replication. - """ - HYBRID_REPLICATION_TYPE_UNSPECIFIED = 0 - MIGRATION = 1 - CONTINUOUS_REPLICATION = 2 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - state: State = proto.Field( - proto.ENUM, - number=2, - enum=State, - ) - state_details: str = proto.Field( - proto.STRING, - number=3, - ) - role: ReplicationRole = proto.Field( - proto.ENUM, - number=4, - enum=ReplicationRole, - ) - replication_schedule: ReplicationSchedule = proto.Field( - proto.ENUM, - number=5, - enum=ReplicationSchedule, - ) - mirror_state: MirrorState = proto.Field( - proto.ENUM, - number=6, - enum=MirrorState, - ) - healthy: bool = proto.Field( - proto.BOOL, - number=8, - optional=True, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=9, - message=timestamp_pb2.Timestamp, - ) - destination_volume: str = proto.Field( - proto.STRING, - number=10, - ) - transfer_stats: 'TransferStats' = proto.Field( - proto.MESSAGE, - number=11, - message='TransferStats', - ) - labels: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=12, - ) - description: str = proto.Field( - proto.STRING, - number=13, - optional=True, - ) - destination_volume_parameters: 'DestinationVolumeParameters' = proto.Field( - proto.MESSAGE, - number=14, - message='DestinationVolumeParameters', - ) - source_volume: str = proto.Field( - proto.STRING, - number=15, - ) - hybrid_peering_details: 'HybridPeeringDetails' = proto.Field( - proto.MESSAGE, - number=16, - message='HybridPeeringDetails', - ) - cluster_location: str = proto.Field( - proto.STRING, - number=18, - ) - hybrid_replication_type: HybridReplicationType = proto.Field( - proto.ENUM, - number=19, - enum=HybridReplicationType, - ) - - -class HybridPeeringDetails(proto.Message): - r"""HybridPeeringDetails contains details about the hybrid - peering. - - Attributes: - subnet_ip (str): - Optional. IP address of the subnet. - command (str): - Optional. Copy-paste-able commands to be used - on user's ONTAP to accept peering requests. - command_expiry_time (google.protobuf.timestamp_pb2.Timestamp): - Optional. Expiration time for the peering - command to be executed on user's ONTAP. - passphrase (str): - Optional. Temporary passphrase generated to - accept cluster peering command. - peer_volume_name (str): - Optional. Name of the user's local source - volume to be peered with the destination volume. - peer_cluster_name (str): - Optional. Name of the user's local source - cluster to be peered with the destination - cluster. - peer_svm_name (str): - Optional. Name of the user's local source - vserver svm to be peered with the destination - vserver svm. - """ - - subnet_ip: str = proto.Field( - proto.STRING, - number=1, - ) - command: str = proto.Field( - proto.STRING, - number=2, - ) - command_expiry_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - passphrase: str = proto.Field( - proto.STRING, - number=4, - ) - peer_volume_name: str = proto.Field( - proto.STRING, - number=5, - ) - peer_cluster_name: str = proto.Field( - proto.STRING, - number=6, - ) - peer_svm_name: str = proto.Field( - proto.STRING, - number=7, - ) - - -class ListReplicationsRequest(proto.Message): - r"""ListReplications lists replications. - - Attributes: - parent (str): - Required. The volume for which to retrieve replication - information, in the format - ``projects/{project_id}/locations/{location}/volumes/{volume_id}``. - page_size (int): - The maximum number of items to return. - page_token (str): - The next_page_token value to use if there are additional - results to retrieve for this list request. - order_by (str): - Sort results. Supported values are "name", - "name desc" or "" (unsorted). - filter (str): - List filter. - """ - - 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, - ) - filter: str = proto.Field( - proto.STRING, - number=5, - ) - - -class ListReplicationsResponse(proto.Message): - r"""ListReplicationsResponse is the result of - ListReplicationsRequest. - - Attributes: - replications (MutableSequence[google.cloud.netapp_v1.types.Replication]): - A list of replications in the project for the - specified volume. - next_page_token (str): - The token you can use to retrieve the next - page of results. Not returned if there are no - more results in the list. - unreachable (MutableSequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - replications: MutableSequence['Replication'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Replication', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - unreachable: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class GetReplicationRequest(proto.Message): - r"""GetReplicationRequest gets the state of a replication. - - Attributes: - name (str): - Required. The replication resource name, in the format - ``projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}`` - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class DestinationVolumeParameters(proto.Message): - r"""DestinationVolumeParameters specify input parameters used for - creating destination volume. - - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - storage_pool (str): - Required. Existing destination StoragePool - name. - volume_id (str): - Desired destination volume resource id. If - not specified, source volume's resource id will - be used. This value must start with a lowercase - letter followed by up to 62 lowercase letters, - numbers, or hyphens, and cannot end with a - hyphen. - share_name (str): - Destination volume's share name. If not - specified, source volume's share name will be - used. - description (str): - Description for the destination volume. - - This field is a member of `oneof`_ ``_description``. - tiering_policy (google.cloud.netapp_v1.types.TieringPolicy): - Optional. Tiering policy for the volume. - - This field is a member of `oneof`_ ``_tiering_policy``. - """ - - storage_pool: str = proto.Field( - proto.STRING, - number=1, - ) - volume_id: str = proto.Field( - proto.STRING, - number=2, - ) - share_name: str = proto.Field( - proto.STRING, - number=3, - ) - description: str = proto.Field( - proto.STRING, - number=4, - optional=True, - ) - tiering_policy: volume.TieringPolicy = proto.Field( - proto.MESSAGE, - number=5, - optional=True, - message=volume.TieringPolicy, - ) - - -class CreateReplicationRequest(proto.Message): - r"""CreateReplicationRequest creates a replication. - - Attributes: - parent (str): - Required. The NetApp volume to create the replications of, - in the format - ``projects/{project_id}/locations/{location}/volumes/{volume_id}`` - replication (google.cloud.netapp_v1.types.Replication): - Required. A replication resource - replication_id (str): - Required. ID of the replication to create. - Must be unique within the parent resource. Must - contain only letters, numbers and hyphen, with - the first character a letter, the last a letter - or a - number, and a 63 character maximum. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - replication: 'Replication' = proto.Field( - proto.MESSAGE, - number=2, - message='Replication', - ) - replication_id: str = proto.Field( - proto.STRING, - number=3, - ) - - -class DeleteReplicationRequest(proto.Message): - r"""DeleteReplicationRequest deletes a replication. - - Attributes: - name (str): - Required. The replication resource name, in the format - ``projects/*/locations/*/volumes/*/replications/{replication_id}`` - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateReplicationRequest(proto.Message): - r"""UpdateReplicationRequest updates description and/or labels - for a replication. - - Attributes: - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Mask of fields to update. At least - one path must be supplied in this field. - replication (google.cloud.netapp_v1.types.Replication): - Required. A replication resource - """ - - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=1, - message=field_mask_pb2.FieldMask, - ) - replication: 'Replication' = proto.Field( - proto.MESSAGE, - number=2, - message='Replication', - ) - - -class StopReplicationRequest(proto.Message): - r"""StopReplicationRequest stops a replication until resumed. - - Attributes: - name (str): - Required. The resource name of the replication, in the - format of - projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}. - force (bool): - Indicates whether to stop replication - forcefully while data transfer is in progress. - Warning! if force is true, this will abort any - current transfers and can lead to data loss due - to partial transfer. If force is false, stop - replication will fail while data transfer is in - progress and you will need to retry later. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - force: bool = proto.Field( - proto.BOOL, - number=2, - ) - - -class ResumeReplicationRequest(proto.Message): - r"""ResumeReplicationRequest resumes a stopped replication. - - Attributes: - name (str): - Required. The resource name of the replication, in the - format of - projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ReverseReplicationDirectionRequest(proto.Message): - r"""ReverseReplicationDirectionRequest reverses direction of - replication. Source becomes destination and destination becomes - source. - - Attributes: - name (str): - Required. The resource name of the replication, in the - format of - projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class EstablishPeeringRequest(proto.Message): - r"""EstablishPeeringRequest establishes cluster and svm peerings - between the source and the destination replications. - - Attributes: - name (str): - Required. The resource name of the replication, in the - format of - projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}. - peer_cluster_name (str): - Required. Name of the user's local source - cluster to be peered with the destination - cluster. - peer_svm_name (str): - Required. Name of the user's local source - vserver svm to be peered with the destination - vserver svm. - peer_ip_addresses (MutableSequence[str]): - Optional. List of IPv4 ip addresses to be - used for peering. - peer_volume_name (str): - Required. Name of the user's local source - volume to be peered with the destination volume. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - peer_cluster_name: str = proto.Field( - proto.STRING, - number=2, - ) - peer_svm_name: str = proto.Field( - proto.STRING, - number=3, - ) - peer_ip_addresses: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=4, - ) - peer_volume_name: str = proto.Field( - proto.STRING, - number=5, - ) - - -class SyncReplicationRequest(proto.Message): - r"""SyncReplicationRequest syncs the replication from source to - destination. - - Attributes: - name (str): - Required. The resource name of the replication, in the - format of - projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/snapshot.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/snapshot.py deleted file mode 100644 index f0f3f17cdbbb..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/snapshot.py +++ /dev/null @@ -1,290 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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.cloud.netapp.v1', - manifest={ - 'ListSnapshotsRequest', - 'ListSnapshotsResponse', - 'GetSnapshotRequest', - 'CreateSnapshotRequest', - 'DeleteSnapshotRequest', - 'UpdateSnapshotRequest', - 'Snapshot', - }, -) - - -class ListSnapshotsRequest(proto.Message): - r"""ListSnapshotsRequest lists snapshots. - - Attributes: - parent (str): - Required. The volume for which to retrieve snapshot - information, in the format - ``projects/{project_id}/locations/{location}/volumes/{volume_id}``. - page_size (int): - The maximum number of items to return. - page_token (str): - The next_page_token value to use if there are additional - results to retrieve for this list request. - order_by (str): - Sort results. Supported values are "name", - "name desc" or "" (unsorted). - filter (str): - List filter. - """ - - 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, - ) - filter: str = proto.Field( - proto.STRING, - number=5, - ) - - -class ListSnapshotsResponse(proto.Message): - r"""ListSnapshotsResponse is the result of ListSnapshotsRequest. - - Attributes: - snapshots (MutableSequence[google.cloud.netapp_v1.types.Snapshot]): - A list of snapshots in the project for the - specified volume. - next_page_token (str): - The token you can use to retrieve the next - page of results. Not returned if there are no - more results in the list. - unreachable (MutableSequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - snapshots: MutableSequence['Snapshot'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Snapshot', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - unreachable: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class GetSnapshotRequest(proto.Message): - r"""GetSnapshotRequest gets the state of a snapshot. - - Attributes: - name (str): - Required. The snapshot resource name, in the format - ``projects/{project_id}/locations/{location}/volumes/{volume_id}/snapshots/{snapshot_id}`` - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateSnapshotRequest(proto.Message): - r"""CreateSnapshotRequest creates a snapshot. - - Attributes: - parent (str): - Required. The NetApp volume to create the snapshots of, in - the format - ``projects/{project_id}/locations/{location}/volumes/{volume_id}`` - snapshot (google.cloud.netapp_v1.types.Snapshot): - Required. A snapshot resource - snapshot_id (str): - Required. ID of the snapshot to create. Must - be unique within the parent resource. Must - contain only letters, numbers and hyphen, with - the first character a letter, the last a letter - or a - number, and a 63 character maximum. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - snapshot: 'Snapshot' = proto.Field( - proto.MESSAGE, - number=2, - message='Snapshot', - ) - snapshot_id: str = proto.Field( - proto.STRING, - number=3, - ) - - -class DeleteSnapshotRequest(proto.Message): - r"""DeleteSnapshotRequest deletes a snapshot. - - Attributes: - name (str): - Required. The snapshot resource name, in the format - ``projects/*/locations/*/volumes/*/snapshots/{snapshot_id}`` - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateSnapshotRequest(proto.Message): - r"""UpdateSnapshotRequest updates description and/or labels for a - snapshot. - - Attributes: - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Mask of fields to update. At least - one path must be supplied in this field. - snapshot (google.cloud.netapp_v1.types.Snapshot): - Required. A snapshot resource - """ - - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=1, - message=field_mask_pb2.FieldMask, - ) - snapshot: 'Snapshot' = proto.Field( - proto.MESSAGE, - number=2, - message='Snapshot', - ) - - -class Snapshot(proto.Message): - r"""Snapshot is a point-in-time version of a Volume's content. - - Attributes: - name (str): - Identifier. The resource name of the snapshot. Format: - ``projects/{project_id}/locations/{location}/volumes/{volume_id}/snapshots/{snapshot_id}``. - state (google.cloud.netapp_v1.types.Snapshot.State): - Output only. The snapshot state. - state_details (str): - Output only. State details of the storage - pool - description (str): - A description of the snapshot with 2048 - characters or less. Requests with longer - descriptions will be rejected. - used_bytes (float): - Output only. Current storage usage for the - snapshot in bytes. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time when the snapshot was - created. - labels (MutableMapping[str, str]): - Resource labels to represent user provided - metadata. - """ - class State(proto.Enum): - r"""The Snapshot States - - Values: - STATE_UNSPECIFIED (0): - Unspecified Snapshot State - READY (1): - Snapshot State is Ready - CREATING (2): - Snapshot State is Creating - DELETING (3): - Snapshot State is Deleting - UPDATING (4): - Snapshot State is Updating - DISABLED (5): - Snapshot State is Disabled - ERROR (6): - Snapshot State is Error - """ - STATE_UNSPECIFIED = 0 - READY = 1 - CREATING = 2 - DELETING = 3 - UPDATING = 4 - DISABLED = 5 - ERROR = 6 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - state: State = proto.Field( - proto.ENUM, - number=2, - enum=State, - ) - state_details: str = proto.Field( - proto.STRING, - number=3, - ) - description: str = proto.Field( - proto.STRING, - number=4, - ) - used_bytes: float = proto.Field( - proto.DOUBLE, - number=5, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - labels: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=7, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/storage_pool.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/storage_pool.py deleted file mode 100644 index 526379c6e072..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/storage_pool.py +++ /dev/null @@ -1,440 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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.netapp_v1.types import common -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.netapp.v1', - manifest={ - 'GetStoragePoolRequest', - 'ListStoragePoolsRequest', - 'ListStoragePoolsResponse', - 'CreateStoragePoolRequest', - 'UpdateStoragePoolRequest', - 'DeleteStoragePoolRequest', - 'SwitchActiveReplicaZoneRequest', - 'StoragePool', - 'ValidateDirectoryServiceRequest', - }, -) - - -class GetStoragePoolRequest(proto.Message): - r"""GetStoragePoolRequest gets a Storage Pool. - - Attributes: - name (str): - Required. Name of the storage pool - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ListStoragePoolsRequest(proto.Message): - r"""ListStoragePoolsRequest lists Storage Pools. - - Attributes: - parent (str): - Required. Parent value - page_size (int): - Optional. The maximum number of items to - return. - page_token (str): - Optional. The next_page_token value to use if there are - additional results to retrieve for this list request. - order_by (str): - Optional. Sort results. Supported values are - "name", "name desc" or "" (unsorted). - filter (str): - Optional. List filter. - """ - - 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, - ) - filter: str = proto.Field( - proto.STRING, - number=5, - ) - - -class ListStoragePoolsResponse(proto.Message): - r"""ListStoragePoolsResponse is the response to a - ListStoragePoolsRequest. - - Attributes: - storage_pools (MutableSequence[google.cloud.netapp_v1.types.StoragePool]): - The list of StoragePools - next_page_token (str): - A token identifying a page of results the - server should return. - unreachable (MutableSequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - storage_pools: MutableSequence['StoragePool'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='StoragePool', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - unreachable: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class CreateStoragePoolRequest(proto.Message): - r"""CreateStoragePoolRequest creates a Storage Pool. - - Attributes: - parent (str): - Required. Value for parent. - storage_pool_id (str): - Required. Id of the requesting storage pool. - Must be unique within the parent resource. Must - contain only letters, numbers and hyphen, with - the first character a letter, the last a letter - or a number, and a 63 character maximum. - storage_pool (google.cloud.netapp_v1.types.StoragePool): - Required. The required parameters to create a - new storage pool. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - storage_pool_id: str = proto.Field( - proto.STRING, - number=2, - ) - storage_pool: 'StoragePool' = proto.Field( - proto.MESSAGE, - number=3, - message='StoragePool', - ) - - -class UpdateStoragePoolRequest(proto.Message): - r"""UpdateStoragePoolRequest updates a Storage Pool. - - Attributes: - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the StoragePool resource by the update. The - fields specified in the update_mask are relative to the - resource, not the full request. A field will be overwritten - if it is in the mask. If the user does not provide a mask - then all fields will be overwritten. - storage_pool (google.cloud.netapp_v1.types.StoragePool): - Required. The pool being updated - """ - - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=1, - message=field_mask_pb2.FieldMask, - ) - storage_pool: 'StoragePool' = proto.Field( - proto.MESSAGE, - number=2, - message='StoragePool', - ) - - -class DeleteStoragePoolRequest(proto.Message): - r"""DeleteStoragePoolRequest deletes a Storage Pool. - - Attributes: - name (str): - Required. Name of the storage pool - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class SwitchActiveReplicaZoneRequest(proto.Message): - r"""SwitchActiveReplicaZoneRequest switch the active/replica zone - for a regional storagePool. - - Attributes: - name (str): - Required. Name of the storage pool - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class StoragePool(proto.Message): - r"""StoragePool is a container for volumes with a service level - and capacity. Volumes can be created in a pool of sufficient - available capacity. StoragePool capacity is what you are billed - for. - - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - name (str): - Identifier. Name of the storage pool - service_level (google.cloud.netapp_v1.types.ServiceLevel): - Required. Service level of the storage pool - capacity_gib (int): - Required. Capacity in GIB of the pool - volume_capacity_gib (int): - Output only. Allocated size of all volumes in - GIB in the storage pool - volume_count (int): - Output only. Volume count of the storage pool - state (google.cloud.netapp_v1.types.StoragePool.State): - Output only. State of the storage pool - state_details (str): - Output only. State details of the storage - pool - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Create time of the storage pool - description (str): - Optional. Description of the storage pool - labels (MutableMapping[str, str]): - Optional. Labels as key value pairs - network (str): - Required. VPC Network name. - Format: - projects/{project}/global/networks/{network} - active_directory (str): - Optional. Specifies the Active Directory to - be used for creating a SMB volume. - kms_config (str): - Optional. Specifies the KMS config to be used - for volume encryption. - ldap_enabled (bool): - Optional. Flag indicating if the pool is NFS - LDAP enabled or not. - psa_range (str): - Optional. This field is not implemented. The - values provided in this field are ignored. - encryption_type (google.cloud.netapp_v1.types.EncryptionType): - Output only. Specifies the current pool - encryption key source. - global_access_allowed (bool): - Deprecated. Used to allow SO pool to access - AD or DNS server from other regions. - - This field is a member of `oneof`_ ``_global_access_allowed``. - allow_auto_tiering (bool): - Optional. True if the storage pool supports - Auto Tiering enabled volumes. Default is false. - Auto-tiering can be enabled after storage pool - creation but it can't be disabled once enabled. - replica_zone (str): - Optional. Specifies the replica zone for - regional storagePool. - zone (str): - Optional. Specifies the active zone for - regional storagePool. - satisfies_pzs (bool): - Output only. Reserved for future use - satisfies_pzi (bool): - Output only. Reserved for future use - """ - class State(proto.Enum): - r"""The Storage Pool States - - Values: - STATE_UNSPECIFIED (0): - Unspecified Storage Pool State - READY (1): - Storage Pool State is Ready - CREATING (2): - Storage Pool State is Creating - DELETING (3): - Storage Pool State is Deleting - UPDATING (4): - Storage Pool State is Updating - RESTORING (5): - Storage Pool State is Restoring - DISABLED (6): - Storage Pool State is Disabled - ERROR (7): - Storage Pool State is Error - """ - STATE_UNSPECIFIED = 0 - READY = 1 - CREATING = 2 - DELETING = 3 - UPDATING = 4 - RESTORING = 5 - DISABLED = 6 - ERROR = 7 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - service_level: common.ServiceLevel = proto.Field( - proto.ENUM, - number=2, - enum=common.ServiceLevel, - ) - capacity_gib: int = proto.Field( - proto.INT64, - number=3, - ) - volume_capacity_gib: int = proto.Field( - proto.INT64, - number=4, - ) - volume_count: int = proto.Field( - proto.INT32, - number=5, - ) - state: State = proto.Field( - proto.ENUM, - number=6, - enum=State, - ) - state_details: str = proto.Field( - proto.STRING, - number=7, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - description: str = proto.Field( - proto.STRING, - number=9, - ) - labels: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=10, - ) - network: str = proto.Field( - proto.STRING, - number=11, - ) - active_directory: str = proto.Field( - proto.STRING, - number=12, - ) - kms_config: str = proto.Field( - proto.STRING, - number=13, - ) - ldap_enabled: bool = proto.Field( - proto.BOOL, - number=14, - ) - psa_range: str = proto.Field( - proto.STRING, - number=15, - ) - encryption_type: common.EncryptionType = proto.Field( - proto.ENUM, - number=16, - enum=common.EncryptionType, - ) - global_access_allowed: bool = proto.Field( - proto.BOOL, - number=17, - optional=True, - ) - allow_auto_tiering: bool = proto.Field( - proto.BOOL, - number=18, - ) - replica_zone: str = proto.Field( - proto.STRING, - number=20, - ) - zone: str = proto.Field( - proto.STRING, - number=21, - ) - satisfies_pzs: bool = proto.Field( - proto.BOOL, - number=23, - ) - satisfies_pzi: bool = proto.Field( - proto.BOOL, - number=24, - ) - - -class ValidateDirectoryServiceRequest(proto.Message): - r"""ValidateDirectoryServiceRequest validates the directory - service policy attached to the storage pool. - - Attributes: - name (str): - Required. Name of the storage pool - directory_service_type (google.cloud.netapp_v1.types.DirectoryServiceType): - Type of directory service policy attached to - the storage pool. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - directory_service_type: common.DirectoryServiceType = proto.Field( - proto.ENUM, - number=2, - enum=common.DirectoryServiceType, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/volume.py b/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/volume.py deleted file mode 100644 index 2e4febc008e5..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/google/cloud/netapp_v1/types/volume.py +++ /dev/null @@ -1,1322 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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.netapp_v1.types import common -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.netapp.v1', - manifest={ - 'Protocols', - 'AccessType', - 'SMBSettings', - 'SecurityStyle', - 'RestrictedAction', - 'ListVolumesRequest', - 'ListVolumesResponse', - 'GetVolumeRequest', - 'CreateVolumeRequest', - 'UpdateVolumeRequest', - 'DeleteVolumeRequest', - 'RevertVolumeRequest', - 'Volume', - 'ExportPolicy', - 'SimpleExportPolicyRule', - 'SnapshotPolicy', - 'HourlySchedule', - 'DailySchedule', - 'WeeklySchedule', - 'MonthlySchedule', - 'MountOption', - 'RestoreParameters', - 'BackupConfig', - 'TieringPolicy', - 'HybridReplicationParameters', - }, -) - - -class Protocols(proto.Enum): - r"""Protocols is an enum of all the supported network protocols - for a volume. - - Values: - PROTOCOLS_UNSPECIFIED (0): - Unspecified protocol - NFSV3 (1): - NFS V3 protocol - NFSV4 (2): - NFS V4 protocol - SMB (3): - SMB protocol - """ - PROTOCOLS_UNSPECIFIED = 0 - NFSV3 = 1 - NFSV4 = 2 - SMB = 3 - - -class AccessType(proto.Enum): - r"""AccessType is an enum of all the supported access types for a - volume. - - Values: - ACCESS_TYPE_UNSPECIFIED (0): - Unspecified Access Type - READ_ONLY (1): - Read Only - READ_WRITE (2): - Read Write - READ_NONE (3): - None - """ - ACCESS_TYPE_UNSPECIFIED = 0 - READ_ONLY = 1 - READ_WRITE = 2 - READ_NONE = 3 - - -class SMBSettings(proto.Enum): - r"""SMBSettings - Modifies the behaviour of a SMB volume. - - Values: - SMB_SETTINGS_UNSPECIFIED (0): - Unspecified default option - ENCRYPT_DATA (1): - SMB setting encrypt data - BROWSABLE (2): - SMB setting browsable - CHANGE_NOTIFY (3): - SMB setting notify change - NON_BROWSABLE (4): - SMB setting not to notify change - OPLOCKS (5): - SMB setting oplocks - SHOW_SNAPSHOT (6): - SMB setting to show snapshots - SHOW_PREVIOUS_VERSIONS (7): - SMB setting to show previous versions - ACCESS_BASED_ENUMERATION (8): - SMB setting to access volume based on - enumerartion - CONTINUOUSLY_AVAILABLE (9): - Continuously available enumeration - """ - SMB_SETTINGS_UNSPECIFIED = 0 - ENCRYPT_DATA = 1 - BROWSABLE = 2 - CHANGE_NOTIFY = 3 - NON_BROWSABLE = 4 - OPLOCKS = 5 - SHOW_SNAPSHOT = 6 - SHOW_PREVIOUS_VERSIONS = 7 - ACCESS_BASED_ENUMERATION = 8 - CONTINUOUSLY_AVAILABLE = 9 - - -class SecurityStyle(proto.Enum): - r"""The security style of the volume, can be either UNIX or NTFS. - - Values: - SECURITY_STYLE_UNSPECIFIED (0): - SecurityStyle is unspecified - NTFS (1): - SecurityStyle uses NTFS - UNIX (2): - SecurityStyle uses UNIX - """ - SECURITY_STYLE_UNSPECIFIED = 0 - NTFS = 1 - UNIX = 2 - - -class RestrictedAction(proto.Enum): - r"""Actions to be restricted for a volume. - - Values: - RESTRICTED_ACTION_UNSPECIFIED (0): - Unspecified restricted action - DELETE (1): - Prevent volume from being deleted when - mounted. - """ - RESTRICTED_ACTION_UNSPECIFIED = 0 - DELETE = 1 - - -class ListVolumesRequest(proto.Message): - r"""Message for requesting list of Volumes - - Attributes: - parent (str): - Required. Parent value for ListVolumesRequest - page_size (int): - Requested page size. Server may return fewer - items than requested. If unspecified, the server - will pick an appropriate default. - page_token (str): - A token identifying a page of results the - server should return. - filter (str): - Filtering results - order_by (str): - Hint for how to order the results - """ - - 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 ListVolumesResponse(proto.Message): - r"""Message for response to listing Volumes - - Attributes: - volumes (MutableSequence[google.cloud.netapp_v1.types.Volume]): - The list of Volume - next_page_token (str): - A token identifying a page of results the - server should return. - unreachable (MutableSequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - volumes: MutableSequence['Volume'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Volume', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - unreachable: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class GetVolumeRequest(proto.Message): - r"""Message for getting a Volume - - Attributes: - name (str): - Required. Name of the volume - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateVolumeRequest(proto.Message): - r"""Message for creating a Volume - - Attributes: - parent (str): - Required. Value for parent. - volume_id (str): - Required. Id of the requesting volume. Must - be unique within the parent resource. Must - contain only letters, numbers and hyphen, with - the first character a letter, the last a letter - or a number, and a 63 character maximum. - volume (google.cloud.netapp_v1.types.Volume): - Required. The volume being created. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - volume_id: str = proto.Field( - proto.STRING, - number=2, - ) - volume: 'Volume' = proto.Field( - proto.MESSAGE, - number=3, - message='Volume', - ) - - -class UpdateVolumeRequest(proto.Message): - r"""Message for updating a Volume - - Attributes: - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the Volume resource by the update. The fields - specified in the update_mask are relative to the resource, - not the full request. A field will be overwritten if it is - in the mask. If the user does not provide a mask then all - fields will be overwritten. - volume (google.cloud.netapp_v1.types.Volume): - Required. The volume being updated - """ - - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=1, - message=field_mask_pb2.FieldMask, - ) - volume: 'Volume' = proto.Field( - proto.MESSAGE, - number=2, - message='Volume', - ) - - -class DeleteVolumeRequest(proto.Message): - r"""Message for deleting a Volume - - Attributes: - name (str): - Required. Name of the volume - force (bool): - If this field is set as true, CCFE will not - block the volume resource deletion even if it - has any snapshots resource. (Otherwise, the - request will only work if the volume has no - snapshots.) - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - force: bool = proto.Field( - proto.BOOL, - number=2, - ) - - -class RevertVolumeRequest(proto.Message): - r"""RevertVolumeRequest reverts the given volume to the specified - snapshot. - - Attributes: - name (str): - Required. The resource name of the volume, in the format of - projects/{project_id}/locations/{location}/volumes/{volume_id}. - snapshot_id (str): - Required. The snapshot resource ID, in the format - 'my-snapshot', where the specified ID is the {snapshot_id} - of the fully qualified name like - projects/{project_id}/locations/{location_id}/volumes/{volume_id}/snapshots/{snapshot_id} - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - snapshot_id: str = proto.Field( - proto.STRING, - number=2, - ) - - -class Volume(proto.Message): - r"""Volume provides a filesystem that you can mount. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - name (str): - Identifier. Name of the volume - state (google.cloud.netapp_v1.types.Volume.State): - Output only. State of the volume - state_details (str): - Output only. State details of the volume - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Create time of the volume - share_name (str): - Required. Share name of the volume - psa_range (str): - Output only. This field is not implemented. - The values provided in this field are ignored. - storage_pool (str): - Required. StoragePool name of the volume - network (str): - Output only. VPC Network name. - Format: - projects/{project}/global/networks/{network} - service_level (google.cloud.netapp_v1.types.ServiceLevel): - Output only. Service level of the volume - capacity_gib (int): - Required. Capacity in GIB of the volume - export_policy (google.cloud.netapp_v1.types.ExportPolicy): - Optional. Export policy of the volume - protocols (MutableSequence[google.cloud.netapp_v1.types.Protocols]): - Required. Protocols required for the volume - smb_settings (MutableSequence[google.cloud.netapp_v1.types.SMBSettings]): - Optional. SMB share settings for the volume. - mount_options (MutableSequence[google.cloud.netapp_v1.types.MountOption]): - Output only. Mount options of this volume - unix_permissions (str): - Optional. Default unix style permission (e.g. - 777) the mount point will be created with. - Applicable for NFS protocol types only. - labels (MutableMapping[str, str]): - Optional. Labels as key value pairs - description (str): - Optional. Description of the volume - snapshot_policy (google.cloud.netapp_v1.types.SnapshotPolicy): - Optional. SnapshotPolicy for a volume. - snap_reserve (float): - Optional. Snap_reserve specifies percentage of volume - storage reserved for snapshot storage. Default is 0 percent. - snapshot_directory (bool): - Optional. Snapshot_directory if enabled (true) the volume - will contain a read-only .snapshot directory which provides - access to each of the volume's snapshots. - used_gib (int): - Output only. Used capacity in GIB of the - volume. This is computed periodically and it - does not represent the realtime usage. - security_style (google.cloud.netapp_v1.types.SecurityStyle): - Optional. Security Style of the Volume - kerberos_enabled (bool): - Optional. Flag indicating if the volume is a - kerberos volume or not, export policy rules - control kerberos security modes (krb5, krb5i, - krb5p). - ldap_enabled (bool): - Output only. Flag indicating if the volume is - NFS LDAP enabled or not. - active_directory (str): - Output only. Specifies the ActiveDirectory - name of a SMB volume. - restore_parameters (google.cloud.netapp_v1.types.RestoreParameters): - Optional. Specifies the source of the volume - to be created from. - kms_config (str): - Output only. Specifies the KMS config to be - used for volume encryption. - encryption_type (google.cloud.netapp_v1.types.EncryptionType): - Output only. Specified the current volume - encryption key source. - has_replication (bool): - Output only. Indicates whether the volume is - part of a replication relationship. - backup_config (google.cloud.netapp_v1.types.BackupConfig): - BackupConfig of the volume. - - This field is a member of `oneof`_ ``_backup_config``. - restricted_actions (MutableSequence[google.cloud.netapp_v1.types.RestrictedAction]): - Optional. List of actions that are restricted - on this volume. - large_capacity (bool): - Optional. Flag indicating if the volume will - be a large capacity volume or a regular volume. - multiple_endpoints (bool): - Optional. Flag indicating if the volume will have an IP - address per node for volumes supporting multiple IP - endpoints. Only the volume with large_capacity will be - allowed to have multiple endpoints. - tiering_policy (google.cloud.netapp_v1.types.TieringPolicy): - Tiering policy for the volume. - - This field is a member of `oneof`_ ``_tiering_policy``. - replica_zone (str): - Output only. Specifies the replica zone for - regional volume. - zone (str): - Output only. Specifies the active zone for - regional volume. - cold_tier_size_gib (int): - Output only. Size of the volume cold tier - data in GiB. - hybrid_replication_parameters (google.cloud.netapp_v1.types.HybridReplicationParameters): - Optional. The Hybrid Replication parameters - for the volume. - """ - class State(proto.Enum): - r"""The volume states - - Values: - STATE_UNSPECIFIED (0): - Unspecified Volume State - READY (1): - Volume State is Ready - CREATING (2): - Volume State is Creating - DELETING (3): - Volume State is Deleting - UPDATING (4): - Volume State is Updating - RESTORING (5): - Volume State is Restoring - DISABLED (6): - Volume State is Disabled - ERROR (7): - Volume State is Error - PREPARING (8): - Volume State is Preparing. Note that this is - different from CREATING where CREATING means the - volume is being created, while PREPARING means - the volume is created and now being prepared for - the replication. - READ_ONLY (9): - Volume State is Read Only - """ - STATE_UNSPECIFIED = 0 - READY = 1 - CREATING = 2 - DELETING = 3 - UPDATING = 4 - RESTORING = 5 - DISABLED = 6 - ERROR = 7 - PREPARING = 8 - READ_ONLY = 9 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - state: State = proto.Field( - proto.ENUM, - number=2, - enum=State, - ) - state_details: str = proto.Field( - proto.STRING, - number=3, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.Timestamp, - ) - share_name: str = proto.Field( - proto.STRING, - number=5, - ) - psa_range: str = proto.Field( - proto.STRING, - number=6, - ) - storage_pool: str = proto.Field( - proto.STRING, - number=7, - ) - network: str = proto.Field( - proto.STRING, - number=8, - ) - service_level: common.ServiceLevel = proto.Field( - proto.ENUM, - number=9, - enum=common.ServiceLevel, - ) - capacity_gib: int = proto.Field( - proto.INT64, - number=10, - ) - export_policy: 'ExportPolicy' = proto.Field( - proto.MESSAGE, - number=11, - message='ExportPolicy', - ) - protocols: MutableSequence['Protocols'] = proto.RepeatedField( - proto.ENUM, - number=12, - enum='Protocols', - ) - smb_settings: MutableSequence['SMBSettings'] = proto.RepeatedField( - proto.ENUM, - number=13, - enum='SMBSettings', - ) - mount_options: MutableSequence['MountOption'] = proto.RepeatedField( - proto.MESSAGE, - number=14, - message='MountOption', - ) - unix_permissions: str = proto.Field( - proto.STRING, - number=15, - ) - labels: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=16, - ) - description: str = proto.Field( - proto.STRING, - number=17, - ) - snapshot_policy: 'SnapshotPolicy' = proto.Field( - proto.MESSAGE, - number=18, - message='SnapshotPolicy', - ) - snap_reserve: float = proto.Field( - proto.DOUBLE, - number=19, - ) - snapshot_directory: bool = proto.Field( - proto.BOOL, - number=20, - ) - used_gib: int = proto.Field( - proto.INT64, - number=21, - ) - security_style: 'SecurityStyle' = proto.Field( - proto.ENUM, - number=22, - enum='SecurityStyle', - ) - kerberos_enabled: bool = proto.Field( - proto.BOOL, - number=23, - ) - ldap_enabled: bool = proto.Field( - proto.BOOL, - number=24, - ) - active_directory: str = proto.Field( - proto.STRING, - number=25, - ) - restore_parameters: 'RestoreParameters' = proto.Field( - proto.MESSAGE, - number=26, - message='RestoreParameters', - ) - kms_config: str = proto.Field( - proto.STRING, - number=27, - ) - encryption_type: common.EncryptionType = proto.Field( - proto.ENUM, - number=28, - enum=common.EncryptionType, - ) - has_replication: bool = proto.Field( - proto.BOOL, - number=29, - ) - backup_config: 'BackupConfig' = proto.Field( - proto.MESSAGE, - number=30, - optional=True, - message='BackupConfig', - ) - restricted_actions: MutableSequence['RestrictedAction'] = proto.RepeatedField( - proto.ENUM, - number=31, - enum='RestrictedAction', - ) - large_capacity: bool = proto.Field( - proto.BOOL, - number=32, - ) - multiple_endpoints: bool = proto.Field( - proto.BOOL, - number=33, - ) - tiering_policy: 'TieringPolicy' = proto.Field( - proto.MESSAGE, - number=34, - optional=True, - message='TieringPolicy', - ) - replica_zone: str = proto.Field( - proto.STRING, - number=36, - ) - zone: str = proto.Field( - proto.STRING, - number=37, - ) - cold_tier_size_gib: int = proto.Field( - proto.INT64, - number=39, - ) - hybrid_replication_parameters: 'HybridReplicationParameters' = proto.Field( - proto.MESSAGE, - number=40, - message='HybridReplicationParameters', - ) - - -class ExportPolicy(proto.Message): - r"""Defines the export policy for the volume. - - Attributes: - rules (MutableSequence[google.cloud.netapp_v1.types.SimpleExportPolicyRule]): - Required. List of export policy rules - """ - - rules: MutableSequence['SimpleExportPolicyRule'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='SimpleExportPolicyRule', - ) - - -class SimpleExportPolicyRule(proto.Message): - r"""An export policy rule describing various export options. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - allowed_clients (str): - Comma separated list of allowed clients IP - addresses - - This field is a member of `oneof`_ ``_allowed_clients``. - has_root_access (str): - Whether Unix root access will be granted. - - This field is a member of `oneof`_ ``_has_root_access``. - access_type (google.cloud.netapp_v1.types.AccessType): - Access type (ReadWrite, ReadOnly, None) - - This field is a member of `oneof`_ ``_access_type``. - nfsv3 (bool): - NFS V3 protocol. - - This field is a member of `oneof`_ ``_nfsv3``. - nfsv4 (bool): - NFS V4 protocol. - - This field is a member of `oneof`_ ``_nfsv4``. - kerberos_5_read_only (bool): - If enabled (true) the rule defines a read - only access for clients matching the - 'allowedClients' specification. It enables nfs - clients to mount using 'authentication' kerberos - security mode. - - This field is a member of `oneof`_ ``_kerberos_5_read_only``. - kerberos_5_read_write (bool): - If enabled (true) the rule defines read and - write access for clients matching the - 'allowedClients' specification. It enables nfs - clients to mount using 'authentication' kerberos - security mode. The 'kerberos5ReadOnly' value be - ignored if this is enabled. - - This field is a member of `oneof`_ ``_kerberos_5_read_write``. - kerberos_5i_read_only (bool): - If enabled (true) the rule defines a read - only access for clients matching the - 'allowedClients' specification. It enables nfs - clients to mount using 'integrity' kerberos - security mode. - - This field is a member of `oneof`_ ``_kerberos_5i_read_only``. - kerberos_5i_read_write (bool): - If enabled (true) the rule defines read and - write access for clients matching the - 'allowedClients' specification. It enables nfs - clients to mount using 'integrity' kerberos - security mode. The 'kerberos5iReadOnly' value be - ignored if this is enabled. - - This field is a member of `oneof`_ ``_kerberos_5i_read_write``. - kerberos_5p_read_only (bool): - If enabled (true) the rule defines a read - only access for clients matching the - 'allowedClients' specification. It enables nfs - clients to mount using 'privacy' kerberos - security mode. - - This field is a member of `oneof`_ ``_kerberos_5p_read_only``. - kerberos_5p_read_write (bool): - If enabled (true) the rule defines read and - write access for clients matching the - 'allowedClients' specification. It enables nfs - clients to mount using 'privacy' kerberos - security mode. The 'kerberos5pReadOnly' value be - ignored if this is enabled. - - This field is a member of `oneof`_ ``_kerberos_5p_read_write``. - """ - - allowed_clients: str = proto.Field( - proto.STRING, - number=1, - optional=True, - ) - has_root_access: str = proto.Field( - proto.STRING, - number=2, - optional=True, - ) - access_type: 'AccessType' = proto.Field( - proto.ENUM, - number=3, - optional=True, - enum='AccessType', - ) - nfsv3: bool = proto.Field( - proto.BOOL, - number=4, - optional=True, - ) - nfsv4: bool = proto.Field( - proto.BOOL, - number=5, - optional=True, - ) - kerberos_5_read_only: bool = proto.Field( - proto.BOOL, - number=6, - optional=True, - ) - kerberos_5_read_write: bool = proto.Field( - proto.BOOL, - number=7, - optional=True, - ) - kerberos_5i_read_only: bool = proto.Field( - proto.BOOL, - number=8, - optional=True, - ) - kerberos_5i_read_write: bool = proto.Field( - proto.BOOL, - number=9, - optional=True, - ) - kerberos_5p_read_only: bool = proto.Field( - proto.BOOL, - number=10, - optional=True, - ) - kerberos_5p_read_write: bool = proto.Field( - proto.BOOL, - number=11, - optional=True, - ) - - -class SnapshotPolicy(proto.Message): - r"""Snapshot Policy for a volume. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - enabled (bool): - If enabled, make snapshots automatically - according to the schedules. Default is false. - - This field is a member of `oneof`_ ``_enabled``. - hourly_schedule (google.cloud.netapp_v1.types.HourlySchedule): - Hourly schedule policy. - - This field is a member of `oneof`_ ``_hourly_schedule``. - daily_schedule (google.cloud.netapp_v1.types.DailySchedule): - Daily schedule policy. - - This field is a member of `oneof`_ ``_daily_schedule``. - weekly_schedule (google.cloud.netapp_v1.types.WeeklySchedule): - Weekly schedule policy. - - This field is a member of `oneof`_ ``_weekly_schedule``. - monthly_schedule (google.cloud.netapp_v1.types.MonthlySchedule): - Monthly schedule policy. - - This field is a member of `oneof`_ ``_monthly_schedule``. - """ - - enabled: bool = proto.Field( - proto.BOOL, - number=1, - optional=True, - ) - hourly_schedule: 'HourlySchedule' = proto.Field( - proto.MESSAGE, - number=2, - optional=True, - message='HourlySchedule', - ) - daily_schedule: 'DailySchedule' = proto.Field( - proto.MESSAGE, - number=3, - optional=True, - message='DailySchedule', - ) - weekly_schedule: 'WeeklySchedule' = proto.Field( - proto.MESSAGE, - number=4, - optional=True, - message='WeeklySchedule', - ) - monthly_schedule: 'MonthlySchedule' = proto.Field( - proto.MESSAGE, - number=5, - optional=True, - message='MonthlySchedule', - ) - - -class HourlySchedule(proto.Message): - r"""Make a snapshot every hour e.g. at 04:00, 05:00, 06:00. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - snapshots_to_keep (float): - The maximum number of Snapshots to keep for - the hourly schedule - - This field is a member of `oneof`_ ``_snapshots_to_keep``. - minute (float): - Set the minute of the hour to start the - snapshot (0-59), defaults to the top of the hour - (0). - - This field is a member of `oneof`_ ``_minute``. - """ - - snapshots_to_keep: float = proto.Field( - proto.DOUBLE, - number=1, - optional=True, - ) - minute: float = proto.Field( - proto.DOUBLE, - number=2, - optional=True, - ) - - -class DailySchedule(proto.Message): - r"""Make a snapshot every day e.g. at 04:00, 05:20, 23:50 - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - snapshots_to_keep (float): - The maximum number of Snapshots to keep for - the hourly schedule - - This field is a member of `oneof`_ ``_snapshots_to_keep``. - minute (float): - Set the minute of the hour to start the - snapshot (0-59), defaults to the top of the hour - (0). - - This field is a member of `oneof`_ ``_minute``. - hour (float): - Set the hour to start the snapshot (0-23), - defaults to midnight (0). - - This field is a member of `oneof`_ ``_hour``. - """ - - snapshots_to_keep: float = proto.Field( - proto.DOUBLE, - number=1, - optional=True, - ) - minute: float = proto.Field( - proto.DOUBLE, - number=2, - optional=True, - ) - hour: float = proto.Field( - proto.DOUBLE, - number=3, - optional=True, - ) - - -class WeeklySchedule(proto.Message): - r"""Make a snapshot every week e.g. at Monday 04:00, Wednesday - 05:20, Sunday 23:50 - - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - snapshots_to_keep (float): - The maximum number of Snapshots to keep for - the hourly schedule - - This field is a member of `oneof`_ ``_snapshots_to_keep``. - minute (float): - Set the minute of the hour to start the - snapshot (0-59), defaults to the top of the hour - (0). - - This field is a member of `oneof`_ ``_minute``. - hour (float): - Set the hour to start the snapshot (0-23), - defaults to midnight (0). - - This field is a member of `oneof`_ ``_hour``. - day (str): - Set the day or days of the week to make a - snapshot. Accepts a comma separated days of the - week. Defaults to 'Sunday'. - - This field is a member of `oneof`_ ``_day``. - """ - - snapshots_to_keep: float = proto.Field( - proto.DOUBLE, - number=1, - optional=True, - ) - minute: float = proto.Field( - proto.DOUBLE, - number=2, - optional=True, - ) - hour: float = proto.Field( - proto.DOUBLE, - number=3, - optional=True, - ) - day: str = proto.Field( - proto.STRING, - number=4, - optional=True, - ) - - -class MonthlySchedule(proto.Message): - r"""Make a snapshot once a month e.g. at 2nd 04:00, 7th 05:20, - 24th 23:50 - - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - snapshots_to_keep (float): - The maximum number of Snapshots to keep for - the hourly schedule - - This field is a member of `oneof`_ ``_snapshots_to_keep``. - minute (float): - Set the minute of the hour to start the - snapshot (0-59), defaults to the top of the hour - (0). - - This field is a member of `oneof`_ ``_minute``. - hour (float): - Set the hour to start the snapshot (0-23), - defaults to midnight (0). - - This field is a member of `oneof`_ ``_hour``. - days_of_month (str): - Set the day or days of the month to make a - snapshot (1-31). Accepts a comma separated - number of days. Defaults to '1'. - - This field is a member of `oneof`_ ``_days_of_month``. - """ - - snapshots_to_keep: float = proto.Field( - proto.DOUBLE, - number=1, - optional=True, - ) - minute: float = proto.Field( - proto.DOUBLE, - number=2, - optional=True, - ) - hour: float = proto.Field( - proto.DOUBLE, - number=3, - optional=True, - ) - days_of_month: str = proto.Field( - proto.STRING, - number=4, - optional=True, - ) - - -class MountOption(proto.Message): - r"""View only mount options for a volume. - - Attributes: - export (str): - Export string - export_full (str): - Full export string - protocol (google.cloud.netapp_v1.types.Protocols): - Protocol to mount with. - instructions (str): - Instructions for mounting - ip_address (str): - Output only. IP Address. - """ - - export: str = proto.Field( - proto.STRING, - number=1, - ) - export_full: str = proto.Field( - proto.STRING, - number=2, - ) - protocol: 'Protocols' = proto.Field( - proto.ENUM, - number=3, - enum='Protocols', - ) - instructions: str = proto.Field( - proto.STRING, - number=4, - ) - ip_address: str = proto.Field( - proto.STRING, - number=5, - ) - - -class RestoreParameters(proto.Message): - r"""The RestoreParameters if volume is created from a snapshot or - backup. - - 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: - source_snapshot (str): - Full name of the snapshot resource. - Format: - - projects/{project}/locations/{location}/volumes/{volume}/snapshots/{snapshot} - - This field is a member of `oneof`_ ``source``. - source_backup (str): - Full name of the backup resource. Format: - projects/{project}/locations/{location}/backupVaults/{backup_vault_id}/backups/{backup_id} - - This field is a member of `oneof`_ ``source``. - """ - - source_snapshot: str = proto.Field( - proto.STRING, - number=1, - oneof='source', - ) - source_backup: str = proto.Field( - proto.STRING, - number=2, - oneof='source', - ) - - -class BackupConfig(proto.Message): - r"""BackupConfig contains backup related config on a volume. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - backup_policies (MutableSequence[str]): - Optional. When specified, schedule backups - will be created based on the policy - configuration. - backup_vault (str): - Optional. Name of backup vault. Format: - projects/{project_id}/locations/{location}/backupVaults/{backup_vault_id} - scheduled_backup_enabled (bool): - Optional. When set to true, scheduled backup - is enabled on the volume. This field should be - nil when there's no backup policy attached. - - This field is a member of `oneof`_ ``_scheduled_backup_enabled``. - backup_chain_bytes (int): - Output only. Total size of all backups in a - chain in bytes = baseline backup size + - sum(incremental backup size). - - This field is a member of `oneof`_ ``_backup_chain_bytes``. - """ - - backup_policies: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=1, - ) - backup_vault: str = proto.Field( - proto.STRING, - number=2, - ) - scheduled_backup_enabled: bool = proto.Field( - proto.BOOL, - number=3, - optional=True, - ) - backup_chain_bytes: int = proto.Field( - proto.INT64, - number=4, - optional=True, - ) - - -class TieringPolicy(proto.Message): - r"""Defines tiering policy for the volume. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - tier_action (google.cloud.netapp_v1.types.TieringPolicy.TierAction): - Optional. Flag indicating if the volume has - tiering policy enable/pause. Default is PAUSED. - - This field is a member of `oneof`_ ``_tier_action``. - cooling_threshold_days (int): - Optional. Time in days to mark the volume's - data block as cold and make it eligible for - tiering, can be range from 2-183. Default is 31. - - This field is a member of `oneof`_ ``_cooling_threshold_days``. - """ - class TierAction(proto.Enum): - r"""Tier action for the volume. - - Values: - TIER_ACTION_UNSPECIFIED (0): - Unspecified. - ENABLED (1): - When tiering is enabled, new cold data will - be tiered. - PAUSED (2): - When paused, tiering won't be performed on - new data. Existing data stays tiered until - accessed. - """ - TIER_ACTION_UNSPECIFIED = 0 - ENABLED = 1 - PAUSED = 2 - - tier_action: TierAction = proto.Field( - proto.ENUM, - number=1, - optional=True, - enum=TierAction, - ) - cooling_threshold_days: int = proto.Field( - proto.INT32, - number=2, - optional=True, - ) - - -class HybridReplicationParameters(proto.Message): - r"""The Hybrid Replication parameters for the volume. - - Attributes: - replication (str): - Required. Desired name for the replication of - this volume. - peer_volume_name (str): - Required. Name of the user's local source - volume to be peered with the destination volume. - peer_cluster_name (str): - Required. Name of the user's local source - cluster to be peered with the destination - cluster. - peer_svm_name (str): - Required. Name of the user's local source - vserver svm to be peered with the destination - vserver svm. - peer_ip_addresses (MutableSequence[str]): - Required. List of node ip addresses to be - peered with. - cluster_location (str): - Optional. Name of source cluster location - associated with the Hybrid replication. This is - a free-form field for the display purpose only. - description (str): - Optional. Description of the replication. - labels (MutableMapping[str, str]): - Optional. Labels to be added to the - replication as the key value pairs. - """ - - replication: str = proto.Field( - proto.STRING, - number=1, - ) - peer_volume_name: str = proto.Field( - proto.STRING, - number=2, - ) - peer_cluster_name: str = proto.Field( - proto.STRING, - number=3, - ) - peer_svm_name: str = proto.Field( - proto.STRING, - number=4, - ) - peer_ip_addresses: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=5, - ) - cluster_location: str = proto.Field( - proto.STRING, - number=6, - ) - description: str = proto.Field( - proto.STRING, - number=7, - ) - labels: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=8, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-netapp/v1/mypy.ini b/owl-bot-staging/google-cloud-netapp/v1/mypy.ini deleted file mode 100644 index 574c5aed394b..000000000000 --- a/owl-bot-staging/google-cloud-netapp/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-netapp/v1/noxfile.py b/owl-bot-staging/google-cloud-netapp/v1/noxfile.py deleted file mode 100644 index 2cfb1a836588..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/noxfile.py +++ /dev/null @@ -1,591 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 - -from typing import Dict, List -import warnings - -import nox - -BLACK_VERSION = "black[jupyter]==23.7.0" -ISORT_VERSION = "isort==5.11.0" - -LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] - -ALL_PYTHON = [ - "3.7", - "3.8", - "3.9", - "3.10", - "3.11", - "3.12", - "3.13", -] - -DEFAULT_PYTHON_VERSION = ALL_PYTHON[-1] - -CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() - -LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" -PACKAGE_NAME = "google-cloud-netapp" - -UNIT_TEST_STANDARD_DEPENDENCIES = [ - "mock", - "asyncmock", - "pytest", - "pytest-cov", - "pytest-asyncio", -] -UNIT_TEST_EXTERNAL_DEPENDENCIES: List[str] = [] -UNIT_TEST_LOCAL_DEPENDENCIES: List[str] = [] -UNIT_TEST_DEPENDENCIES: List[str] = [] -UNIT_TEST_EXTRAS: List[str] = [] -UNIT_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {} - -SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] -SYSTEM_TEST_STANDARD_DEPENDENCIES = [ - "mock", - "pytest", - "google-cloud-testutils", -] -SYSTEM_TEST_EXTERNAL_DEPENDENCIES: List[str] = [] -SYSTEM_TEST_LOCAL_DEPENDENCIES: List[str] = [] -SYSTEM_TEST_DEPENDENCIES: List[str] = [] -SYSTEM_TEST_EXTRAS: List[str] = [] -SYSTEM_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {} - -nox.options.sessions = [ - "unit", - "system", - "cover", - "lint", - "lint_setup_py", - "blacken", - "docs", -] - -# Error if a python version is missing -nox.options.error_on_missing_interpreters = True - - -@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 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", - *LINT_PATHS, - ) - - session.run("flake8", "google", "tests") - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def blacken(session): - """Run black. Format code to uniform standard.""" - session.install(BLACK_VERSION) - session.run( - "black", - *LINT_PATHS, - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def format(session): - """ - Run isort to sort imports. Then run black - to format code to uniform standard. - """ - session.install(BLACK_VERSION, ISORT_VERSION) - # Use the --fss option to sort imports using strict alphabetical order. - # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections - session.run( - "isort", - "--fss", - *LINT_PATHS, - ) - session.run( - "black", - *LINT_PATHS, - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def lint_setup_py(session): - """Verify that setup.py is valid (including RST check).""" - session.install("setuptools", "docutils", "pygments") - session.run("python", "setup.py", "check", "--restructuredtext", "--strict") - - -def install_unittest_dependencies(session, *constraints): - standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES - session.install(*standard_deps, *constraints) - - if UNIT_TEST_EXTERNAL_DEPENDENCIES: - warnings.warn( - "'unit_test_external_dependencies' is deprecated. Instead, please " - "use 'unit_test_dependencies' or 'unit_test_local_dependencies'.", - DeprecationWarning, - ) - session.install(*UNIT_TEST_EXTERNAL_DEPENDENCIES, *constraints) - - if UNIT_TEST_LOCAL_DEPENDENCIES: - session.install(*UNIT_TEST_LOCAL_DEPENDENCIES, *constraints) - - if UNIT_TEST_EXTRAS_BY_PYTHON: - extras = UNIT_TEST_EXTRAS_BY_PYTHON.get(session.python, []) - elif UNIT_TEST_EXTRAS: - extras = UNIT_TEST_EXTRAS - else: - extras = [] - - if extras: - session.install("-e", f".[{','.join(extras)}]", *constraints) - else: - session.install("-e", ".", *constraints) - - -@nox.session(python=ALL_PYTHON) -@nox.parametrize( - "protobuf_implementation", - ["python", "upb", "cpp"], -) -def unit(session, protobuf_implementation): - # Install all test dependencies, then install this package in-place. - - 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+") - - constraints_path = str( - CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" - ) - install_unittest_dependencies(session, "-c", constraints_path) - - # TODO(https://github.com/googleapis/synthtool/issues/1976): - # 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") - - # Run py.test against the unit tests. - session.run( - "py.test", - "--quiet", - f"--junitxml=unit_{session.python}_sponge_log.xml", - "--cov=google", - "--cov=tests/unit", - "--cov-append", - "--cov-config=.coveragerc", - "--cov-report=", - "--cov-fail-under=0", - os.path.join("tests", "unit"), - *session.posargs, - env={ - "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, - }, - ) - - -def install_systemtest_dependencies(session, *constraints): - session.install("--pre", "grpcio") - - session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES, *constraints) - - if SYSTEM_TEST_EXTERNAL_DEPENDENCIES: - session.install(*SYSTEM_TEST_EXTERNAL_DEPENDENCIES, *constraints) - - if SYSTEM_TEST_LOCAL_DEPENDENCIES: - session.install("-e", *SYSTEM_TEST_LOCAL_DEPENDENCIES, *constraints) - - if SYSTEM_TEST_DEPENDENCIES: - session.install("-e", *SYSTEM_TEST_DEPENDENCIES, *constraints) - - if SYSTEM_TEST_EXTRAS_BY_PYTHON: - extras = SYSTEM_TEST_EXTRAS_BY_PYTHON.get(session.python, []) - elif SYSTEM_TEST_EXTRAS: - extras = SYSTEM_TEST_EXTRAS - else: - extras = [] - - if extras: - session.install("-e", f".[{','.join(extras)}]", *constraints) - else: - session.install("-e", ".", *constraints) - - -@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) -def system(session): - """Run the system test suite.""" - constraints_path = str( - CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" - ) - system_test_path = os.path.join("tests", "system.py") - system_test_folder_path = os.path.join("tests", "system") - - # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true. - if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false": - session.skip("RUN_SYSTEM_TESTS is set to false, skipping") - # Install pyopenssl for mTLS testing. - if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true": - session.install("pyopenssl") - - system_test_exists = os.path.exists(system_test_path) - system_test_folder_exists = os.path.exists(system_test_folder_path) - # Sanity check: only run tests if found. - if not system_test_exists and not system_test_folder_exists: - session.skip("System tests were not found") - - install_systemtest_dependencies(session, "-c", constraints_path) - - # Run py.test against the system tests. - if system_test_exists: - session.run( - "py.test", - "--quiet", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_path, - *session.posargs, - ) - if system_test_folder_exists: - session.run( - "py.test", - "--quiet", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_folder_path, - *session.posargs, - ) - - -@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="3.10") -def docs(session): - """Build the docs for this library.""" - - session.install("-e", ".") - session.install( - # We need to pin to specific versions of the `sphinxcontrib-*` packages - # which still support sphinx 4.x. - # See https://github.com/googleapis/sphinx-docfx-yaml/issues/344 - # and https://github.com/googleapis/sphinx-docfx-yaml/issues/345. - "sphinxcontrib-applehelp==1.0.4", - "sphinxcontrib-devhelp==1.0.2", - "sphinxcontrib-htmlhelp==2.0.1", - "sphinxcontrib-qthelp==1.0.3", - "sphinxcontrib-serializinghtml==1.1.5", - "sphinx==4.5.0", - "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="3.10") -def docfx(session): - """Build the docfx yaml files for this library.""" - - session.install("-e", ".") - session.install( - # We need to pin to specific versions of the `sphinxcontrib-*` packages - # which still support sphinx 4.x. - # See https://github.com/googleapis/sphinx-docfx-yaml/issues/344 - # and https://github.com/googleapis/sphinx-docfx-yaml/issues/345. - "sphinxcontrib-applehelp==1.0.4", - "sphinxcontrib-devhelp==1.0.2", - "sphinxcontrib-htmlhelp==2.0.1", - "sphinxcontrib-qthelp==1.0.3", - "sphinxcontrib-serializinghtml==1.1.5", - "gcp-sphinx-docfx-yaml", - "alabaster", - "recommonmark", - ) - - shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) - session.run( - "sphinx-build", - "-T", # show full traceback on exception - "-N", # no colors - "-D", - ( - "extensions=sphinx.ext.autodoc," - "sphinx.ext.autosummary," - "docfx_yaml.extension," - "sphinx.ext.intersphinx," - "sphinx.ext.coverage," - "sphinx.ext.napoleon," - "sphinx.ext.todo," - "sphinx.ext.viewcode," - "recommonmark" - ), - "-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) -@nox.parametrize( - "protobuf_implementation", - ["python", "upb", "cpp"], -) -def prerelease_deps(session, protobuf_implementation): - """ - Run all tests with pre-release versions of dependencies installed - rather than the standard non pre-release versions. - Pre-release versions can be installed using - `pip install --pre `. - """ - - 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 all dependencies - session.install("-e", ".") - - # Install dependencies for the unit test environment - unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES - session.install(*unit_deps_all) - - # Install dependencies for the system test environment - system_deps_all = ( - SYSTEM_TEST_STANDARD_DEPENDENCIES - + SYSTEM_TEST_EXTERNAL_DEPENDENCIES - + SYSTEM_TEST_EXTRAS - ) - session.install(*system_deps_all) - - # Because we test minimum dependency versions on the minimum Python - # version, the first version we test with in the unit tests sessions has a - # constraints file containing all 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 - ) - ] - - # Install dependencies specified in `testing/constraints-X.txt`. - session.install(*constraints_deps) - - # Note: If a dependency is added to the `prerel_deps` list, - # the `core_dependencies_from_source` list in the `core_deps_from_source` - # nox session should also be updated. - prerel_deps = [ - "googleapis-common-protos", - "google-api-core", - "google-auth", - "grpc-google-iam-v1", - "grpcio", - "grpcio-status", - "protobuf", - "proto-plus", - ] - - for dep in prerel_deps: - session.install("--pre", "--no-deps", "--ignore-installed", dep) - # TODO(https://github.com/grpc/grpc/issues/38965): Add `grpcio-status`` - # to the dictionary below once this bug is fixed. - # TODO(https://github.com/googleapis/google-cloud-python/issues/13643): Add - # `googleapis-common-protos` and `grpc-google-iam-v1` to the dictionary below - # once this bug is fixed. - package_namespaces = { - "google-api-core": "google.api_core", - "google-auth": "google.auth", - "grpcio": "grpc", - "protobuf": "google.protobuf", - "proto-plus": "proto", - } - - version_namespace = package_namespaces.get(dep) - - print(f"Installed {dep}") - if version_namespace: - session.run( - "python", - "-c", - f"import {version_namespace}; print({version_namespace}.__version__)", - ) - - session.run( - "py.test", - "tests/unit", - env={ - "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, - }, - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -@nox.parametrize( - "protobuf_implementation", - ["python", "upb"], -) -def core_deps_from_source(session, protobuf_implementation): - """Run all tests with core dependencies installed from source - rather than pulling the dependencies from PyPI. - """ - - # Install all dependencies - session.install("-e", ".") - - # Install dependencies for the unit test environment - unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES - session.install(*unit_deps_all) - - # Install dependencies for the system test environment - system_deps_all = ( - SYSTEM_TEST_STANDARD_DEPENDENCIES - + SYSTEM_TEST_EXTERNAL_DEPENDENCIES - + SYSTEM_TEST_EXTRAS - ) - session.install(*system_deps_all) - - # Because we test minimum dependency versions on the minimum Python - # version, the first version we test with in the unit tests sessions has a - # constraints file containing all 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 - ) - ] - - # Install dependencies specified in `testing/constraints-X.txt`. - session.install(*constraints_deps) - - # TODO(https://github.com/googleapis/gapic-generator-python/issues/2358): `grpcio` and - # `grpcio-status` should be added to the list below so that they are installed from source, - # rather than PyPI. - # TODO(https://github.com/googleapis/gapic-generator-python/issues/2357): `protobuf` should be - # added to the list below so that it is installed from source, rather than PyPI - # Note: If a dependency is added to the `core_dependencies_from_source` list, - # the `prerel_deps` list in the `prerelease_deps` nox session should also be updated. - core_dependencies_from_source = [ - "googleapis-common-protos @ git+https://github.com/googleapis/google-cloud-python#egg=googleapis-common-protos&subdirectory=packages/googleapis-common-protos", - "google-api-core @ git+https://github.com/googleapis/python-api-core.git", - "google-auth @ git+https://github.com/googleapis/google-auth-library-python.git", - "grpc-google-iam-v1 @ git+https://github.com/googleapis/google-cloud-python#egg=grpc-google-iam-v1&subdirectory=packages/grpc-google-iam-v1", - "proto-plus @ git+https://github.com/googleapis/proto-plus-python.git", - ] - - for dep in core_dependencies_from_source: - session.install(dep, "--no-deps", "--ignore-installed") - print(f"Installed {dep}") - - session.run( - "py.test", - "tests/unit", - env={ - "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, - }, - ) diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_active_directory_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_active_directory_async.py deleted file mode 100644 index 68db13f439cb..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_active_directory_async.py +++ /dev/null @@ -1,65 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 CreateActiveDirectory -# 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-netapp - - -# [START netapp_v1_generated_NetApp_CreateActiveDirectory_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 netapp_v1 - - -async def sample_create_active_directory(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - active_directory = netapp_v1.ActiveDirectory() - active_directory.domain = "domain_value" - active_directory.dns = "dns_value" - active_directory.net_bios_prefix = "net_bios_prefix_value" - active_directory.username = "username_value" - active_directory.password = "password_value" - - request = netapp_v1.CreateActiveDirectoryRequest( - parent="parent_value", - active_directory=active_directory, - active_directory_id="active_directory_id_value", - ) - - # Make the request - operation = client.create_active_directory(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_CreateActiveDirectory_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_active_directory_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_active_directory_sync.py deleted file mode 100644 index dbeb51d4eb88..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_active_directory_sync.py +++ /dev/null @@ -1,65 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 CreateActiveDirectory -# 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-netapp - - -# [START netapp_v1_generated_NetApp_CreateActiveDirectory_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 netapp_v1 - - -def sample_create_active_directory(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - active_directory = netapp_v1.ActiveDirectory() - active_directory.domain = "domain_value" - active_directory.dns = "dns_value" - active_directory.net_bios_prefix = "net_bios_prefix_value" - active_directory.username = "username_value" - active_directory.password = "password_value" - - request = netapp_v1.CreateActiveDirectoryRequest( - parent="parent_value", - active_directory=active_directory, - active_directory_id="active_directory_id_value", - ) - - # Make the request - operation = client.create_active_directory(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_CreateActiveDirectory_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_async.py deleted file mode 100644 index a0637addb59b..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_async.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 CreateBackup -# 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-netapp - - -# [START netapp_v1_generated_NetApp_CreateBackup_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 netapp_v1 - - -async def sample_create_backup(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.CreateBackupRequest( - parent="parent_value", - backup_id="backup_id_value", - ) - - # Make the request - operation = client.create_backup(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_CreateBackup_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_policy_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_policy_async.py deleted file mode 100644 index 62f847456233..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_policy_async.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 CreateBackupPolicy -# 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-netapp - - -# [START netapp_v1_generated_NetApp_CreateBackupPolicy_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 netapp_v1 - - -async def sample_create_backup_policy(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.CreateBackupPolicyRequest( - parent="parent_value", - backup_policy_id="backup_policy_id_value", - ) - - # Make the request - operation = client.create_backup_policy(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_CreateBackupPolicy_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_policy_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_policy_sync.py deleted file mode 100644 index 35b63b7d35a6..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_policy_sync.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 CreateBackupPolicy -# 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-netapp - - -# [START netapp_v1_generated_NetApp_CreateBackupPolicy_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 netapp_v1 - - -def sample_create_backup_policy(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.CreateBackupPolicyRequest( - parent="parent_value", - backup_policy_id="backup_policy_id_value", - ) - - # Make the request - operation = client.create_backup_policy(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_CreateBackupPolicy_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_sync.py deleted file mode 100644 index e37762062ff2..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_sync.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 CreateBackup -# 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-netapp - - -# [START netapp_v1_generated_NetApp_CreateBackup_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 netapp_v1 - - -def sample_create_backup(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.CreateBackupRequest( - parent="parent_value", - backup_id="backup_id_value", - ) - - # Make the request - operation = client.create_backup(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_CreateBackup_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_vault_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_vault_async.py deleted file mode 100644 index 90dba3250398..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_vault_async.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 CreateBackupVault -# 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-netapp - - -# [START netapp_v1_generated_NetApp_CreateBackupVault_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 netapp_v1 - - -async def sample_create_backup_vault(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.CreateBackupVaultRequest( - parent="parent_value", - backup_vault_id="backup_vault_id_value", - ) - - # Make the request - operation = client.create_backup_vault(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_CreateBackupVault_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_vault_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_vault_sync.py deleted file mode 100644 index 3436f0b95416..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_backup_vault_sync.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 CreateBackupVault -# 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-netapp - - -# [START netapp_v1_generated_NetApp_CreateBackupVault_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 netapp_v1 - - -def sample_create_backup_vault(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.CreateBackupVaultRequest( - parent="parent_value", - backup_vault_id="backup_vault_id_value", - ) - - # Make the request - operation = client.create_backup_vault(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_CreateBackupVault_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_kms_config_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_kms_config_async.py deleted file mode 100644 index af1ad187dd76..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_kms_config_async.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 CreateKmsConfig -# 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-netapp - - -# [START netapp_v1_generated_NetApp_CreateKmsConfig_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 netapp_v1 - - -async def sample_create_kms_config(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - kms_config = netapp_v1.KmsConfig() - kms_config.crypto_key_name = "crypto_key_name_value" - - request = netapp_v1.CreateKmsConfigRequest( - parent="parent_value", - kms_config_id="kms_config_id_value", - kms_config=kms_config, - ) - - # Make the request - operation = client.create_kms_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_CreateKmsConfig_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_kms_config_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_kms_config_sync.py deleted file mode 100644 index e747809cbf7d..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_kms_config_sync.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 CreateKmsConfig -# 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-netapp - - -# [START netapp_v1_generated_NetApp_CreateKmsConfig_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 netapp_v1 - - -def sample_create_kms_config(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - kms_config = netapp_v1.KmsConfig() - kms_config.crypto_key_name = "crypto_key_name_value" - - request = netapp_v1.CreateKmsConfigRequest( - parent="parent_value", - kms_config_id="kms_config_id_value", - kms_config=kms_config, - ) - - # Make the request - operation = client.create_kms_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_CreateKmsConfig_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_quota_rule_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_quota_rule_async.py deleted file mode 100644 index cdacc5c35f32..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_quota_rule_async.py +++ /dev/null @@ -1,62 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 CreateQuotaRule -# 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-netapp - - -# [START netapp_v1_generated_NetApp_CreateQuotaRule_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 netapp_v1 - - -async def sample_create_quota_rule(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - quota_rule = netapp_v1.QuotaRule() - quota_rule.type_ = "DEFAULT_GROUP_QUOTA" - quota_rule.disk_limit_mib = 1472 - - request = netapp_v1.CreateQuotaRuleRequest( - parent="parent_value", - quota_rule=quota_rule, - quota_rule_id="quota_rule_id_value", - ) - - # Make the request - operation = client.create_quota_rule(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_CreateQuotaRule_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_quota_rule_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_quota_rule_sync.py deleted file mode 100644 index 378365cf9610..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_quota_rule_sync.py +++ /dev/null @@ -1,62 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 CreateQuotaRule -# 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-netapp - - -# [START netapp_v1_generated_NetApp_CreateQuotaRule_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 netapp_v1 - - -def sample_create_quota_rule(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - quota_rule = netapp_v1.QuotaRule() - quota_rule.type_ = "DEFAULT_GROUP_QUOTA" - quota_rule.disk_limit_mib = 1472 - - request = netapp_v1.CreateQuotaRuleRequest( - parent="parent_value", - quota_rule=quota_rule, - quota_rule_id="quota_rule_id_value", - ) - - # Make the request - operation = client.create_quota_rule(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_CreateQuotaRule_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_replication_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_replication_async.py deleted file mode 100644 index 7173a0fedba6..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_replication_async.py +++ /dev/null @@ -1,62 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 CreateReplication -# 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-netapp - - -# [START netapp_v1_generated_NetApp_CreateReplication_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 netapp_v1 - - -async def sample_create_replication(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - replication = netapp_v1.Replication() - replication.replication_schedule = "DAILY" - replication.destination_volume_parameters.storage_pool = "storage_pool_value" - - request = netapp_v1.CreateReplicationRequest( - parent="parent_value", - replication=replication, - replication_id="replication_id_value", - ) - - # Make the request - operation = client.create_replication(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_CreateReplication_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_replication_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_replication_sync.py deleted file mode 100644 index 651f49b4e486..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_replication_sync.py +++ /dev/null @@ -1,62 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 CreateReplication -# 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-netapp - - -# [START netapp_v1_generated_NetApp_CreateReplication_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 netapp_v1 - - -def sample_create_replication(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - replication = netapp_v1.Replication() - replication.replication_schedule = "DAILY" - replication.destination_volume_parameters.storage_pool = "storage_pool_value" - - request = netapp_v1.CreateReplicationRequest( - parent="parent_value", - replication=replication, - replication_id="replication_id_value", - ) - - # Make the request - operation = client.create_replication(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_CreateReplication_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_snapshot_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_snapshot_async.py deleted file mode 100644 index 5871e5653f71..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_snapshot_async.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 CreateSnapshot -# 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-netapp - - -# [START netapp_v1_generated_NetApp_CreateSnapshot_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 netapp_v1 - - -async def sample_create_snapshot(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.CreateSnapshotRequest( - parent="parent_value", - snapshot_id="snapshot_id_value", - ) - - # Make the request - operation = client.create_snapshot(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_CreateSnapshot_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_snapshot_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_snapshot_sync.py deleted file mode 100644 index 48ddd6bca703..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_snapshot_sync.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 CreateSnapshot -# 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-netapp - - -# [START netapp_v1_generated_NetApp_CreateSnapshot_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 netapp_v1 - - -def sample_create_snapshot(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.CreateSnapshotRequest( - parent="parent_value", - snapshot_id="snapshot_id_value", - ) - - # Make the request - operation = client.create_snapshot(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_CreateSnapshot_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_storage_pool_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_storage_pool_async.py deleted file mode 100644 index 37c7ebdaa309..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_storage_pool_async.py +++ /dev/null @@ -1,63 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 CreateStoragePool -# 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-netapp - - -# [START netapp_v1_generated_NetApp_CreateStoragePool_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 netapp_v1 - - -async def sample_create_storage_pool(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - storage_pool = netapp_v1.StoragePool() - storage_pool.service_level = "FLEX" - storage_pool.capacity_gib = 1247 - storage_pool.network = "network_value" - - request = netapp_v1.CreateStoragePoolRequest( - parent="parent_value", - storage_pool_id="storage_pool_id_value", - storage_pool=storage_pool, - ) - - # Make the request - operation = client.create_storage_pool(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_CreateStoragePool_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_storage_pool_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_storage_pool_sync.py deleted file mode 100644 index 8cc857ef3bc8..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_storage_pool_sync.py +++ /dev/null @@ -1,63 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 CreateStoragePool -# 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-netapp - - -# [START netapp_v1_generated_NetApp_CreateStoragePool_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 netapp_v1 - - -def sample_create_storage_pool(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - storage_pool = netapp_v1.StoragePool() - storage_pool.service_level = "FLEX" - storage_pool.capacity_gib = 1247 - storage_pool.network = "network_value" - - request = netapp_v1.CreateStoragePoolRequest( - parent="parent_value", - storage_pool_id="storage_pool_id_value", - storage_pool=storage_pool, - ) - - # Make the request - operation = client.create_storage_pool(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_CreateStoragePool_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_volume_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_volume_async.py deleted file mode 100644 index 7eeb7e350539..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_volume_async.py +++ /dev/null @@ -1,64 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 CreateVolume -# 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-netapp - - -# [START netapp_v1_generated_NetApp_CreateVolume_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 netapp_v1 - - -async def sample_create_volume(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - volume = netapp_v1.Volume() - volume.share_name = "share_name_value" - volume.storage_pool = "storage_pool_value" - volume.capacity_gib = 1247 - volume.protocols = ['SMB'] - - request = netapp_v1.CreateVolumeRequest( - parent="parent_value", - volume_id="volume_id_value", - volume=volume, - ) - - # Make the request - operation = client.create_volume(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_CreateVolume_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_volume_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_volume_sync.py deleted file mode 100644 index 44df864734bb..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_create_volume_sync.py +++ /dev/null @@ -1,64 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 CreateVolume -# 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-netapp - - -# [START netapp_v1_generated_NetApp_CreateVolume_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 netapp_v1 - - -def sample_create_volume(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - volume = netapp_v1.Volume() - volume.share_name = "share_name_value" - volume.storage_pool = "storage_pool_value" - volume.capacity_gib = 1247 - volume.protocols = ['SMB'] - - request = netapp_v1.CreateVolumeRequest( - parent="parent_value", - volume_id="volume_id_value", - volume=volume, - ) - - # Make the request - operation = client.create_volume(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_CreateVolume_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_active_directory_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_active_directory_async.py deleted file mode 100644 index e52627384057..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_active_directory_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 DeleteActiveDirectory -# 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-netapp - - -# [START netapp_v1_generated_NetApp_DeleteActiveDirectory_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 netapp_v1 - - -async def sample_delete_active_directory(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteActiveDirectoryRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_active_directory(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_DeleteActiveDirectory_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_active_directory_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_active_directory_sync.py deleted file mode 100644 index 3aba485d1423..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_active_directory_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 DeleteActiveDirectory -# 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-netapp - - -# [START netapp_v1_generated_NetApp_DeleteActiveDirectory_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 netapp_v1 - - -def sample_delete_active_directory(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteActiveDirectoryRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_active_directory(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_DeleteActiveDirectory_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_async.py deleted file mode 100644 index d42e7ab02301..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 DeleteBackup -# 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-netapp - - -# [START netapp_v1_generated_NetApp_DeleteBackup_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 netapp_v1 - - -async def sample_delete_backup(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteBackupRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_backup(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_DeleteBackup_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_policy_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_policy_async.py deleted file mode 100644 index d032f9f1e4d8..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_policy_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 DeleteBackupPolicy -# 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-netapp - - -# [START netapp_v1_generated_NetApp_DeleteBackupPolicy_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 netapp_v1 - - -async def sample_delete_backup_policy(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteBackupPolicyRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_backup_policy(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_DeleteBackupPolicy_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_policy_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_policy_sync.py deleted file mode 100644 index dfef618513ff..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_policy_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 DeleteBackupPolicy -# 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-netapp - - -# [START netapp_v1_generated_NetApp_DeleteBackupPolicy_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 netapp_v1 - - -def sample_delete_backup_policy(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteBackupPolicyRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_backup_policy(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_DeleteBackupPolicy_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_sync.py deleted file mode 100644 index 239666c79a47..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 DeleteBackup -# 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-netapp - - -# [START netapp_v1_generated_NetApp_DeleteBackup_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 netapp_v1 - - -def sample_delete_backup(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteBackupRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_backup(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_DeleteBackup_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_vault_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_vault_async.py deleted file mode 100644 index 739e29110da3..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_vault_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 DeleteBackupVault -# 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-netapp - - -# [START netapp_v1_generated_NetApp_DeleteBackupVault_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 netapp_v1 - - -async def sample_delete_backup_vault(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteBackupVaultRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_backup_vault(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_DeleteBackupVault_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_vault_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_vault_sync.py deleted file mode 100644 index 3ebe471bef8e..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_backup_vault_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 DeleteBackupVault -# 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-netapp - - -# [START netapp_v1_generated_NetApp_DeleteBackupVault_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 netapp_v1 - - -def sample_delete_backup_vault(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteBackupVaultRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_backup_vault(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_DeleteBackupVault_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_kms_config_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_kms_config_async.py deleted file mode 100644 index 9c12eaabba11..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_kms_config_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 DeleteKmsConfig -# 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-netapp - - -# [START netapp_v1_generated_NetApp_DeleteKmsConfig_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 netapp_v1 - - -async def sample_delete_kms_config(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteKmsConfigRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_kms_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_DeleteKmsConfig_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_kms_config_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_kms_config_sync.py deleted file mode 100644 index aa0ec1dca192..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_kms_config_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 DeleteKmsConfig -# 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-netapp - - -# [START netapp_v1_generated_NetApp_DeleteKmsConfig_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 netapp_v1 - - -def sample_delete_kms_config(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteKmsConfigRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_kms_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_DeleteKmsConfig_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_quota_rule_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_quota_rule_async.py deleted file mode 100644 index 5ce02f7d731e..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_quota_rule_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 DeleteQuotaRule -# 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-netapp - - -# [START netapp_v1_generated_NetApp_DeleteQuotaRule_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 netapp_v1 - - -async def sample_delete_quota_rule(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteQuotaRuleRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_quota_rule(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_DeleteQuotaRule_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_quota_rule_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_quota_rule_sync.py deleted file mode 100644 index 55e4148e07db..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_quota_rule_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 DeleteQuotaRule -# 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-netapp - - -# [START netapp_v1_generated_NetApp_DeleteQuotaRule_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 netapp_v1 - - -def sample_delete_quota_rule(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteQuotaRuleRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_quota_rule(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_DeleteQuotaRule_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_replication_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_replication_async.py deleted file mode 100644 index b7584460a4da..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_replication_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 DeleteReplication -# 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-netapp - - -# [START netapp_v1_generated_NetApp_DeleteReplication_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 netapp_v1 - - -async def sample_delete_replication(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteReplicationRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_replication(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_DeleteReplication_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_replication_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_replication_sync.py deleted file mode 100644 index 916a9f19bbba..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_replication_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 DeleteReplication -# 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-netapp - - -# [START netapp_v1_generated_NetApp_DeleteReplication_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 netapp_v1 - - -def sample_delete_replication(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteReplicationRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_replication(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_DeleteReplication_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_snapshot_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_snapshot_async.py deleted file mode 100644 index 9bfcaa1d58b0..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_snapshot_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 DeleteSnapshot -# 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-netapp - - -# [START netapp_v1_generated_NetApp_DeleteSnapshot_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 netapp_v1 - - -async def sample_delete_snapshot(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteSnapshotRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_snapshot(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_DeleteSnapshot_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_snapshot_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_snapshot_sync.py deleted file mode 100644 index 27de789c2042..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_snapshot_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 DeleteSnapshot -# 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-netapp - - -# [START netapp_v1_generated_NetApp_DeleteSnapshot_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 netapp_v1 - - -def sample_delete_snapshot(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteSnapshotRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_snapshot(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_DeleteSnapshot_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_storage_pool_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_storage_pool_async.py deleted file mode 100644 index 130c5e1bfbbb..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_storage_pool_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 DeleteStoragePool -# 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-netapp - - -# [START netapp_v1_generated_NetApp_DeleteStoragePool_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 netapp_v1 - - -async def sample_delete_storage_pool(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteStoragePoolRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_storage_pool(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_DeleteStoragePool_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_storage_pool_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_storage_pool_sync.py deleted file mode 100644 index bcc5c964ba27..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_storage_pool_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 DeleteStoragePool -# 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-netapp - - -# [START netapp_v1_generated_NetApp_DeleteStoragePool_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 netapp_v1 - - -def sample_delete_storage_pool(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteStoragePoolRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_storage_pool(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_DeleteStoragePool_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_volume_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_volume_async.py deleted file mode 100644 index af546bde6238..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_volume_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 DeleteVolume -# 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-netapp - - -# [START netapp_v1_generated_NetApp_DeleteVolume_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 netapp_v1 - - -async def sample_delete_volume(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteVolumeRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_volume(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_DeleteVolume_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_volume_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_volume_sync.py deleted file mode 100644 index 8cd2ff1adaae..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_delete_volume_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 DeleteVolume -# 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-netapp - - -# [START netapp_v1_generated_NetApp_DeleteVolume_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 netapp_v1 - - -def sample_delete_volume(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.DeleteVolumeRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_volume(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_DeleteVolume_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_encrypt_volumes_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_encrypt_volumes_async.py deleted file mode 100644 index 0429cd3bb171..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_encrypt_volumes_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 EncryptVolumes -# 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-netapp - - -# [START netapp_v1_generated_NetApp_EncryptVolumes_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 netapp_v1 - - -async def sample_encrypt_volumes(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.EncryptVolumesRequest( - name="name_value", - ) - - # Make the request - operation = client.encrypt_volumes(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_EncryptVolumes_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_encrypt_volumes_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_encrypt_volumes_sync.py deleted file mode 100644 index d9fdc0531033..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_encrypt_volumes_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 EncryptVolumes -# 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-netapp - - -# [START netapp_v1_generated_NetApp_EncryptVolumes_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 netapp_v1 - - -def sample_encrypt_volumes(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.EncryptVolumesRequest( - name="name_value", - ) - - # Make the request - operation = client.encrypt_volumes(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_EncryptVolumes_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_establish_peering_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_establish_peering_async.py deleted file mode 100644 index d4e5fd989c0c..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_establish_peering_async.py +++ /dev/null @@ -1,59 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 EstablishPeering -# 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-netapp - - -# [START netapp_v1_generated_NetApp_EstablishPeering_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 netapp_v1 - - -async def sample_establish_peering(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.EstablishPeeringRequest( - name="name_value", - peer_cluster_name="peer_cluster_name_value", - peer_svm_name="peer_svm_name_value", - peer_volume_name="peer_volume_name_value", - ) - - # Make the request - operation = client.establish_peering(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_EstablishPeering_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_establish_peering_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_establish_peering_sync.py deleted file mode 100644 index 2ea87d047c3f..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_establish_peering_sync.py +++ /dev/null @@ -1,59 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 EstablishPeering -# 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-netapp - - -# [START netapp_v1_generated_NetApp_EstablishPeering_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 netapp_v1 - - -def sample_establish_peering(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.EstablishPeeringRequest( - name="name_value", - peer_cluster_name="peer_cluster_name_value", - peer_svm_name="peer_svm_name_value", - peer_volume_name="peer_volume_name_value", - ) - - # Make the request - operation = client.establish_peering(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_EstablishPeering_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_active_directory_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_active_directory_async.py deleted file mode 100644 index d97bee09ca0f..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_active_directory_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 GetActiveDirectory -# 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-netapp - - -# [START netapp_v1_generated_NetApp_GetActiveDirectory_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 netapp_v1 - - -async def sample_get_active_directory(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.GetActiveDirectoryRequest( - name="name_value", - ) - - # Make the request - response = await client.get_active_directory(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_GetActiveDirectory_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_active_directory_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_active_directory_sync.py deleted file mode 100644 index 19e29f8db2d2..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_active_directory_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 GetActiveDirectory -# 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-netapp - - -# [START netapp_v1_generated_NetApp_GetActiveDirectory_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 netapp_v1 - - -def sample_get_active_directory(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.GetActiveDirectoryRequest( - name="name_value", - ) - - # Make the request - response = client.get_active_directory(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_GetActiveDirectory_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_async.py deleted file mode 100644 index 1682f4f212b1..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 GetBackup -# 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-netapp - - -# [START netapp_v1_generated_NetApp_GetBackup_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 netapp_v1 - - -async def sample_get_backup(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.GetBackupRequest( - name="name_value", - ) - - # Make the request - response = await client.get_backup(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_GetBackup_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_policy_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_policy_async.py deleted file mode 100644 index 7db112c2ff9d..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_policy_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 GetBackupPolicy -# 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-netapp - - -# [START netapp_v1_generated_NetApp_GetBackupPolicy_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 netapp_v1 - - -async def sample_get_backup_policy(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.GetBackupPolicyRequest( - name="name_value", - ) - - # Make the request - response = await client.get_backup_policy(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_GetBackupPolicy_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_policy_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_policy_sync.py deleted file mode 100644 index 32564bd4e65a..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_policy_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 GetBackupPolicy -# 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-netapp - - -# [START netapp_v1_generated_NetApp_GetBackupPolicy_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 netapp_v1 - - -def sample_get_backup_policy(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.GetBackupPolicyRequest( - name="name_value", - ) - - # Make the request - response = client.get_backup_policy(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_GetBackupPolicy_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_sync.py deleted file mode 100644 index 6db31307d7dc..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 GetBackup -# 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-netapp - - -# [START netapp_v1_generated_NetApp_GetBackup_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 netapp_v1 - - -def sample_get_backup(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.GetBackupRequest( - name="name_value", - ) - - # Make the request - response = client.get_backup(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_GetBackup_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_vault_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_vault_async.py deleted file mode 100644 index f75d6b658feb..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_vault_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 GetBackupVault -# 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-netapp - - -# [START netapp_v1_generated_NetApp_GetBackupVault_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 netapp_v1 - - -async def sample_get_backup_vault(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.GetBackupVaultRequest( - name="name_value", - ) - - # Make the request - response = await client.get_backup_vault(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_GetBackupVault_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_vault_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_vault_sync.py deleted file mode 100644 index 83deff7dfaaf..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_backup_vault_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 GetBackupVault -# 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-netapp - - -# [START netapp_v1_generated_NetApp_GetBackupVault_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 netapp_v1 - - -def sample_get_backup_vault(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.GetBackupVaultRequest( - name="name_value", - ) - - # Make the request - response = client.get_backup_vault(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_GetBackupVault_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_kms_config_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_kms_config_async.py deleted file mode 100644 index beed80da366c..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_kms_config_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 GetKmsConfig -# 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-netapp - - -# [START netapp_v1_generated_NetApp_GetKmsConfig_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 netapp_v1 - - -async def sample_get_kms_config(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.GetKmsConfigRequest( - name="name_value", - ) - - # Make the request - response = await client.get_kms_config(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_GetKmsConfig_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_kms_config_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_kms_config_sync.py deleted file mode 100644 index 6eb24f195ea5..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_kms_config_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 GetKmsConfig -# 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-netapp - - -# [START netapp_v1_generated_NetApp_GetKmsConfig_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 netapp_v1 - - -def sample_get_kms_config(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.GetKmsConfigRequest( - name="name_value", - ) - - # Make the request - response = client.get_kms_config(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_GetKmsConfig_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_quota_rule_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_quota_rule_async.py deleted file mode 100644 index 4f2efeae6482..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_quota_rule_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 GetQuotaRule -# 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-netapp - - -# [START netapp_v1_generated_NetApp_GetQuotaRule_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 netapp_v1 - - -async def sample_get_quota_rule(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.GetQuotaRuleRequest( - name="name_value", - ) - - # Make the request - response = await client.get_quota_rule(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_GetQuotaRule_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_quota_rule_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_quota_rule_sync.py deleted file mode 100644 index 658449d977d7..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_quota_rule_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 GetQuotaRule -# 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-netapp - - -# [START netapp_v1_generated_NetApp_GetQuotaRule_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 netapp_v1 - - -def sample_get_quota_rule(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.GetQuotaRuleRequest( - name="name_value", - ) - - # Make the request - response = client.get_quota_rule(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_GetQuotaRule_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_replication_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_replication_async.py deleted file mode 100644 index c62a97d5ffb9..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_replication_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 GetReplication -# 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-netapp - - -# [START netapp_v1_generated_NetApp_GetReplication_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 netapp_v1 - - -async def sample_get_replication(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.GetReplicationRequest( - name="name_value", - ) - - # Make the request - response = await client.get_replication(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_GetReplication_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_replication_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_replication_sync.py deleted file mode 100644 index 7fa9188d65a1..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_replication_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 GetReplication -# 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-netapp - - -# [START netapp_v1_generated_NetApp_GetReplication_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 netapp_v1 - - -def sample_get_replication(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.GetReplicationRequest( - name="name_value", - ) - - # Make the request - response = client.get_replication(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_GetReplication_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_snapshot_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_snapshot_async.py deleted file mode 100644 index 2a163e73d010..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_snapshot_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 GetSnapshot -# 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-netapp - - -# [START netapp_v1_generated_NetApp_GetSnapshot_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 netapp_v1 - - -async def sample_get_snapshot(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.GetSnapshotRequest( - name="name_value", - ) - - # Make the request - response = await client.get_snapshot(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_GetSnapshot_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_snapshot_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_snapshot_sync.py deleted file mode 100644 index b5877a0bde61..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_snapshot_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 GetSnapshot -# 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-netapp - - -# [START netapp_v1_generated_NetApp_GetSnapshot_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 netapp_v1 - - -def sample_get_snapshot(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.GetSnapshotRequest( - name="name_value", - ) - - # Make the request - response = client.get_snapshot(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_GetSnapshot_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_storage_pool_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_storage_pool_async.py deleted file mode 100644 index 741ef8435aa8..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_storage_pool_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 GetStoragePool -# 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-netapp - - -# [START netapp_v1_generated_NetApp_GetStoragePool_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 netapp_v1 - - -async def sample_get_storage_pool(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.GetStoragePoolRequest( - name="name_value", - ) - - # Make the request - response = await client.get_storage_pool(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_GetStoragePool_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_storage_pool_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_storage_pool_sync.py deleted file mode 100644 index fbbef2efca11..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_storage_pool_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 GetStoragePool -# 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-netapp - - -# [START netapp_v1_generated_NetApp_GetStoragePool_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 netapp_v1 - - -def sample_get_storage_pool(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.GetStoragePoolRequest( - name="name_value", - ) - - # Make the request - response = client.get_storage_pool(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_GetStoragePool_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_volume_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_volume_async.py deleted file mode 100644 index 368b07d6b400..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_volume_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 GetVolume -# 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-netapp - - -# [START netapp_v1_generated_NetApp_GetVolume_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 netapp_v1 - - -async def sample_get_volume(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.GetVolumeRequest( - name="name_value", - ) - - # Make the request - response = await client.get_volume(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_GetVolume_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_volume_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_volume_sync.py deleted file mode 100644 index 225fec682f2e..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_get_volume_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 GetVolume -# 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-netapp - - -# [START netapp_v1_generated_NetApp_GetVolume_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 netapp_v1 - - -def sample_get_volume(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.GetVolumeRequest( - name="name_value", - ) - - # Make the request - response = client.get_volume(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_GetVolume_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_active_directories_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_active_directories_async.py deleted file mode 100644 index 0c2e0ee2be3c..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_active_directories_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ListActiveDirectories -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ListActiveDirectories_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 netapp_v1 - - -async def sample_list_active_directories(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ListActiveDirectoriesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_active_directories(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END netapp_v1_generated_NetApp_ListActiveDirectories_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_active_directories_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_active_directories_sync.py deleted file mode 100644 index c26c74e5e8a4..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_active_directories_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ListActiveDirectories -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ListActiveDirectories_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 netapp_v1 - - -def sample_list_active_directories(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ListActiveDirectoriesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_active_directories(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END netapp_v1_generated_NetApp_ListActiveDirectories_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_policies_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_policies_async.py deleted file mode 100644 index e5501e2b863e..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_policies_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ListBackupPolicies -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ListBackupPolicies_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 netapp_v1 - - -async def sample_list_backup_policies(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ListBackupPoliciesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_backup_policies(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END netapp_v1_generated_NetApp_ListBackupPolicies_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_policies_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_policies_sync.py deleted file mode 100644 index 78ba50a73755..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_policies_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ListBackupPolicies -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ListBackupPolicies_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 netapp_v1 - - -def sample_list_backup_policies(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ListBackupPoliciesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_backup_policies(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END netapp_v1_generated_NetApp_ListBackupPolicies_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_vaults_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_vaults_async.py deleted file mode 100644 index 363a6e994e47..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_vaults_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ListBackupVaults -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ListBackupVaults_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 netapp_v1 - - -async def sample_list_backup_vaults(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ListBackupVaultsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_backup_vaults(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END netapp_v1_generated_NetApp_ListBackupVaults_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_vaults_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_vaults_sync.py deleted file mode 100644 index ffacc1cd9508..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backup_vaults_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ListBackupVaults -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ListBackupVaults_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 netapp_v1 - - -def sample_list_backup_vaults(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ListBackupVaultsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_backup_vaults(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END netapp_v1_generated_NetApp_ListBackupVaults_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backups_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backups_async.py deleted file mode 100644 index 6bc8399cb19c..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backups_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ListBackups -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ListBackups_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 netapp_v1 - - -async def sample_list_backups(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ListBackupsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_backups(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END netapp_v1_generated_NetApp_ListBackups_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backups_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backups_sync.py deleted file mode 100644 index 6947c5392560..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_backups_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ListBackups -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ListBackups_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 netapp_v1 - - -def sample_list_backups(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ListBackupsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_backups(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END netapp_v1_generated_NetApp_ListBackups_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_kms_configs_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_kms_configs_async.py deleted file mode 100644 index b9a6cd457249..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_kms_configs_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ListKmsConfigs -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ListKmsConfigs_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 netapp_v1 - - -async def sample_list_kms_configs(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ListKmsConfigsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_kms_configs(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END netapp_v1_generated_NetApp_ListKmsConfigs_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_kms_configs_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_kms_configs_sync.py deleted file mode 100644 index 325c8896feba..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_kms_configs_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ListKmsConfigs -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ListKmsConfigs_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 netapp_v1 - - -def sample_list_kms_configs(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ListKmsConfigsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_kms_configs(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END netapp_v1_generated_NetApp_ListKmsConfigs_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_quota_rules_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_quota_rules_async.py deleted file mode 100644 index 5f0467611351..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_quota_rules_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ListQuotaRules -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ListQuotaRules_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 netapp_v1 - - -async def sample_list_quota_rules(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ListQuotaRulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_quota_rules(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END netapp_v1_generated_NetApp_ListQuotaRules_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_quota_rules_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_quota_rules_sync.py deleted file mode 100644 index dc8134556656..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_quota_rules_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ListQuotaRules -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ListQuotaRules_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 netapp_v1 - - -def sample_list_quota_rules(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ListQuotaRulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_quota_rules(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END netapp_v1_generated_NetApp_ListQuotaRules_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_replications_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_replications_async.py deleted file mode 100644 index 2cfe1808b1e0..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_replications_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ListReplications -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ListReplications_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 netapp_v1 - - -async def sample_list_replications(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ListReplicationsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_replications(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END netapp_v1_generated_NetApp_ListReplications_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_replications_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_replications_sync.py deleted file mode 100644 index 9be705416091..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_replications_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ListReplications -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ListReplications_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 netapp_v1 - - -def sample_list_replications(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ListReplicationsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_replications(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END netapp_v1_generated_NetApp_ListReplications_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_snapshots_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_snapshots_async.py deleted file mode 100644 index 9ed4edf2851e..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_snapshots_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ListSnapshots -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ListSnapshots_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 netapp_v1 - - -async def sample_list_snapshots(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ListSnapshotsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_snapshots(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END netapp_v1_generated_NetApp_ListSnapshots_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_snapshots_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_snapshots_sync.py deleted file mode 100644 index c784ba2ecf62..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_snapshots_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ListSnapshots -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ListSnapshots_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 netapp_v1 - - -def sample_list_snapshots(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ListSnapshotsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_snapshots(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END netapp_v1_generated_NetApp_ListSnapshots_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_storage_pools_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_storage_pools_async.py deleted file mode 100644 index 7c93ff5f79d8..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_storage_pools_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ListStoragePools -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ListStoragePools_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 netapp_v1 - - -async def sample_list_storage_pools(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ListStoragePoolsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_storage_pools(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END netapp_v1_generated_NetApp_ListStoragePools_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_storage_pools_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_storage_pools_sync.py deleted file mode 100644 index fa35a4e7918e..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_storage_pools_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ListStoragePools -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ListStoragePools_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 netapp_v1 - - -def sample_list_storage_pools(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ListStoragePoolsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_storage_pools(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END netapp_v1_generated_NetApp_ListStoragePools_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_volumes_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_volumes_async.py deleted file mode 100644 index 13b9c408b694..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_volumes_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ListVolumes -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ListVolumes_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 netapp_v1 - - -async def sample_list_volumes(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ListVolumesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_volumes(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END netapp_v1_generated_NetApp_ListVolumes_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_volumes_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_volumes_sync.py deleted file mode 100644 index 14fff2b8e3b3..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_list_volumes_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ListVolumes -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ListVolumes_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 netapp_v1 - - -def sample_list_volumes(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ListVolumesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_volumes(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END netapp_v1_generated_NetApp_ListVolumes_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_resume_replication_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_resume_replication_async.py deleted file mode 100644 index 9848bc814886..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_resume_replication_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ResumeReplication -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ResumeReplication_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 netapp_v1 - - -async def sample_resume_replication(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ResumeReplicationRequest( - name="name_value", - ) - - # Make the request - operation = client.resume_replication(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_ResumeReplication_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_resume_replication_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_resume_replication_sync.py deleted file mode 100644 index 918b479f6f00..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_resume_replication_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ResumeReplication -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ResumeReplication_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 netapp_v1 - - -def sample_resume_replication(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ResumeReplicationRequest( - name="name_value", - ) - - # Make the request - operation = client.resume_replication(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_ResumeReplication_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_reverse_replication_direction_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_reverse_replication_direction_async.py deleted file mode 100644 index 3e4600e46fcd..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_reverse_replication_direction_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ReverseReplicationDirection -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ReverseReplicationDirection_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 netapp_v1 - - -async def sample_reverse_replication_direction(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ReverseReplicationDirectionRequest( - name="name_value", - ) - - # Make the request - operation = client.reverse_replication_direction(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_ReverseReplicationDirection_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_reverse_replication_direction_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_reverse_replication_direction_sync.py deleted file mode 100644 index 8de151ce9ce3..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_reverse_replication_direction_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ReverseReplicationDirection -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ReverseReplicationDirection_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 netapp_v1 - - -def sample_reverse_replication_direction(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ReverseReplicationDirectionRequest( - name="name_value", - ) - - # Make the request - operation = client.reverse_replication_direction(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_ReverseReplicationDirection_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_revert_volume_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_revert_volume_async.py deleted file mode 100644 index 52d540a715da..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_revert_volume_async.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 RevertVolume -# 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-netapp - - -# [START netapp_v1_generated_NetApp_RevertVolume_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 netapp_v1 - - -async def sample_revert_volume(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.RevertVolumeRequest( - name="name_value", - snapshot_id="snapshot_id_value", - ) - - # Make the request - operation = client.revert_volume(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_RevertVolume_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_revert_volume_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_revert_volume_sync.py deleted file mode 100644 index cbbee6a7923a..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_revert_volume_sync.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 RevertVolume -# 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-netapp - - -# [START netapp_v1_generated_NetApp_RevertVolume_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 netapp_v1 - - -def sample_revert_volume(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.RevertVolumeRequest( - name="name_value", - snapshot_id="snapshot_id_value", - ) - - # Make the request - operation = client.revert_volume(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_RevertVolume_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_stop_replication_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_stop_replication_async.py deleted file mode 100644 index 47de97775f33..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_stop_replication_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 StopReplication -# 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-netapp - - -# [START netapp_v1_generated_NetApp_StopReplication_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 netapp_v1 - - -async def sample_stop_replication(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.StopReplicationRequest( - name="name_value", - ) - - # Make the request - operation = client.stop_replication(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_StopReplication_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_stop_replication_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_stop_replication_sync.py deleted file mode 100644 index 0b4f1814e0c8..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_stop_replication_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 StopReplication -# 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-netapp - - -# [START netapp_v1_generated_NetApp_StopReplication_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 netapp_v1 - - -def sample_stop_replication(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.StopReplicationRequest( - name="name_value", - ) - - # Make the request - operation = client.stop_replication(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_StopReplication_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_switch_active_replica_zone_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_switch_active_replica_zone_async.py deleted file mode 100644 index 0d525351cf47..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_switch_active_replica_zone_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 SwitchActiveReplicaZone -# 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-netapp - - -# [START netapp_v1_generated_NetApp_SwitchActiveReplicaZone_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 netapp_v1 - - -async def sample_switch_active_replica_zone(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.SwitchActiveReplicaZoneRequest( - name="name_value", - ) - - # Make the request - operation = client.switch_active_replica_zone(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_SwitchActiveReplicaZone_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_switch_active_replica_zone_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_switch_active_replica_zone_sync.py deleted file mode 100644 index 15ef1a413752..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_switch_active_replica_zone_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 SwitchActiveReplicaZone -# 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-netapp - - -# [START netapp_v1_generated_NetApp_SwitchActiveReplicaZone_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 netapp_v1 - - -def sample_switch_active_replica_zone(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.SwitchActiveReplicaZoneRequest( - name="name_value", - ) - - # Make the request - operation = client.switch_active_replica_zone(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_SwitchActiveReplicaZone_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_sync_replication_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_sync_replication_async.py deleted file mode 100644 index c8fbb37c96fb..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_sync_replication_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 SyncReplication -# 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-netapp - - -# [START netapp_v1_generated_NetApp_SyncReplication_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 netapp_v1 - - -async def sample_sync_replication(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.SyncReplicationRequest( - name="name_value", - ) - - # Make the request - operation = client.sync_replication(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_SyncReplication_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_sync_replication_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_sync_replication_sync.py deleted file mode 100644 index 46b7d6e4c94d..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_sync_replication_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 SyncReplication -# 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-netapp - - -# [START netapp_v1_generated_NetApp_SyncReplication_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 netapp_v1 - - -def sample_sync_replication(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.SyncReplicationRequest( - name="name_value", - ) - - # Make the request - operation = client.sync_replication(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_SyncReplication_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_active_directory_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_active_directory_async.py deleted file mode 100644 index 7f073528eb59..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_active_directory_async.py +++ /dev/null @@ -1,63 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 UpdateActiveDirectory -# 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-netapp - - -# [START netapp_v1_generated_NetApp_UpdateActiveDirectory_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 netapp_v1 - - -async def sample_update_active_directory(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - active_directory = netapp_v1.ActiveDirectory() - active_directory.domain = "domain_value" - active_directory.dns = "dns_value" - active_directory.net_bios_prefix = "net_bios_prefix_value" - active_directory.username = "username_value" - active_directory.password = "password_value" - - request = netapp_v1.UpdateActiveDirectoryRequest( - active_directory=active_directory, - ) - - # Make the request - operation = client.update_active_directory(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_UpdateActiveDirectory_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_active_directory_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_active_directory_sync.py deleted file mode 100644 index 5d6495c79739..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_active_directory_sync.py +++ /dev/null @@ -1,63 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 UpdateActiveDirectory -# 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-netapp - - -# [START netapp_v1_generated_NetApp_UpdateActiveDirectory_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 netapp_v1 - - -def sample_update_active_directory(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - active_directory = netapp_v1.ActiveDirectory() - active_directory.domain = "domain_value" - active_directory.dns = "dns_value" - active_directory.net_bios_prefix = "net_bios_prefix_value" - active_directory.username = "username_value" - active_directory.password = "password_value" - - request = netapp_v1.UpdateActiveDirectoryRequest( - active_directory=active_directory, - ) - - # Make the request - operation = client.update_active_directory(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_UpdateActiveDirectory_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_async.py deleted file mode 100644 index ca705c2e25c2..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_async.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 UpdateBackup -# 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-netapp - - -# [START netapp_v1_generated_NetApp_UpdateBackup_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 netapp_v1 - - -async def sample_update_backup(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.UpdateBackupRequest( - ) - - # Make the request - operation = client.update_backup(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_UpdateBackup_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_policy_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_policy_async.py deleted file mode 100644 index 09e2b0a77430..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_policy_async.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 UpdateBackupPolicy -# 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-netapp - - -# [START netapp_v1_generated_NetApp_UpdateBackupPolicy_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 netapp_v1 - - -async def sample_update_backup_policy(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.UpdateBackupPolicyRequest( - ) - - # Make the request - operation = client.update_backup_policy(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_UpdateBackupPolicy_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_policy_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_policy_sync.py deleted file mode 100644 index ed77b39e5b49..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_policy_sync.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 UpdateBackupPolicy -# 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-netapp - - -# [START netapp_v1_generated_NetApp_UpdateBackupPolicy_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 netapp_v1 - - -def sample_update_backup_policy(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.UpdateBackupPolicyRequest( - ) - - # Make the request - operation = client.update_backup_policy(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_UpdateBackupPolicy_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_sync.py deleted file mode 100644 index d74d12a32032..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_sync.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 UpdateBackup -# 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-netapp - - -# [START netapp_v1_generated_NetApp_UpdateBackup_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 netapp_v1 - - -def sample_update_backup(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.UpdateBackupRequest( - ) - - # Make the request - operation = client.update_backup(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_UpdateBackup_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_vault_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_vault_async.py deleted file mode 100644 index d841e4400c1b..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_vault_async.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 UpdateBackupVault -# 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-netapp - - -# [START netapp_v1_generated_NetApp_UpdateBackupVault_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 netapp_v1 - - -async def sample_update_backup_vault(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.UpdateBackupVaultRequest( - ) - - # Make the request - operation = client.update_backup_vault(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_UpdateBackupVault_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_vault_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_vault_sync.py deleted file mode 100644 index e4fc6120d21f..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_backup_vault_sync.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 UpdateBackupVault -# 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-netapp - - -# [START netapp_v1_generated_NetApp_UpdateBackupVault_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 netapp_v1 - - -def sample_update_backup_vault(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.UpdateBackupVaultRequest( - ) - - # Make the request - operation = client.update_backup_vault(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_UpdateBackupVault_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_kms_config_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_kms_config_async.py deleted file mode 100644 index fab3b0c1f176..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_kms_config_async.py +++ /dev/null @@ -1,59 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 UpdateKmsConfig -# 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-netapp - - -# [START netapp_v1_generated_NetApp_UpdateKmsConfig_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 netapp_v1 - - -async def sample_update_kms_config(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - kms_config = netapp_v1.KmsConfig() - kms_config.crypto_key_name = "crypto_key_name_value" - - request = netapp_v1.UpdateKmsConfigRequest( - kms_config=kms_config, - ) - - # Make the request - operation = client.update_kms_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_UpdateKmsConfig_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_kms_config_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_kms_config_sync.py deleted file mode 100644 index 3be0e1feb618..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_kms_config_sync.py +++ /dev/null @@ -1,59 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 UpdateKmsConfig -# 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-netapp - - -# [START netapp_v1_generated_NetApp_UpdateKmsConfig_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 netapp_v1 - - -def sample_update_kms_config(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - kms_config = netapp_v1.KmsConfig() - kms_config.crypto_key_name = "crypto_key_name_value" - - request = netapp_v1.UpdateKmsConfigRequest( - kms_config=kms_config, - ) - - # Make the request - operation = client.update_kms_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_UpdateKmsConfig_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_quota_rule_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_quota_rule_async.py deleted file mode 100644 index 81ae846fef1a..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_quota_rule_async.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 UpdateQuotaRule -# 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-netapp - - -# [START netapp_v1_generated_NetApp_UpdateQuotaRule_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 netapp_v1 - - -async def sample_update_quota_rule(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - quota_rule = netapp_v1.QuotaRule() - quota_rule.type_ = "DEFAULT_GROUP_QUOTA" - quota_rule.disk_limit_mib = 1472 - - request = netapp_v1.UpdateQuotaRuleRequest( - quota_rule=quota_rule, - ) - - # Make the request - operation = client.update_quota_rule(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_UpdateQuotaRule_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_quota_rule_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_quota_rule_sync.py deleted file mode 100644 index 0d45f7fe7cb9..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_quota_rule_sync.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 UpdateQuotaRule -# 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-netapp - - -# [START netapp_v1_generated_NetApp_UpdateQuotaRule_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 netapp_v1 - - -def sample_update_quota_rule(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - quota_rule = netapp_v1.QuotaRule() - quota_rule.type_ = "DEFAULT_GROUP_QUOTA" - quota_rule.disk_limit_mib = 1472 - - request = netapp_v1.UpdateQuotaRuleRequest( - quota_rule=quota_rule, - ) - - # Make the request - operation = client.update_quota_rule(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_UpdateQuotaRule_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_replication_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_replication_async.py deleted file mode 100644 index 2009635bd229..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_replication_async.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 UpdateReplication -# 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-netapp - - -# [START netapp_v1_generated_NetApp_UpdateReplication_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 netapp_v1 - - -async def sample_update_replication(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - replication = netapp_v1.Replication() - replication.replication_schedule = "DAILY" - replication.destination_volume_parameters.storage_pool = "storage_pool_value" - - request = netapp_v1.UpdateReplicationRequest( - replication=replication, - ) - - # Make the request - operation = client.update_replication(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_UpdateReplication_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_replication_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_replication_sync.py deleted file mode 100644 index 30b07ff90309..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_replication_sync.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 UpdateReplication -# 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-netapp - - -# [START netapp_v1_generated_NetApp_UpdateReplication_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 netapp_v1 - - -def sample_update_replication(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - replication = netapp_v1.Replication() - replication.replication_schedule = "DAILY" - replication.destination_volume_parameters.storage_pool = "storage_pool_value" - - request = netapp_v1.UpdateReplicationRequest( - replication=replication, - ) - - # Make the request - operation = client.update_replication(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_UpdateReplication_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_snapshot_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_snapshot_async.py deleted file mode 100644 index 0bd358a6acc9..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_snapshot_async.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 UpdateSnapshot -# 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-netapp - - -# [START netapp_v1_generated_NetApp_UpdateSnapshot_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 netapp_v1 - - -async def sample_update_snapshot(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.UpdateSnapshotRequest( - ) - - # Make the request - operation = client.update_snapshot(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_UpdateSnapshot_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_snapshot_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_snapshot_sync.py deleted file mode 100644 index 5b7aa65a9352..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_snapshot_sync.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 UpdateSnapshot -# 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-netapp - - -# [START netapp_v1_generated_NetApp_UpdateSnapshot_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 netapp_v1 - - -def sample_update_snapshot(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.UpdateSnapshotRequest( - ) - - # Make the request - operation = client.update_snapshot(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_UpdateSnapshot_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_storage_pool_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_storage_pool_async.py deleted file mode 100644 index adb8dadd9565..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_storage_pool_async.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 UpdateStoragePool -# 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-netapp - - -# [START netapp_v1_generated_NetApp_UpdateStoragePool_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 netapp_v1 - - -async def sample_update_storage_pool(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - storage_pool = netapp_v1.StoragePool() - storage_pool.service_level = "FLEX" - storage_pool.capacity_gib = 1247 - storage_pool.network = "network_value" - - request = netapp_v1.UpdateStoragePoolRequest( - storage_pool=storage_pool, - ) - - # Make the request - operation = client.update_storage_pool(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_UpdateStoragePool_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_storage_pool_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_storage_pool_sync.py deleted file mode 100644 index 458dec81bb23..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_storage_pool_sync.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 UpdateStoragePool -# 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-netapp - - -# [START netapp_v1_generated_NetApp_UpdateStoragePool_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 netapp_v1 - - -def sample_update_storage_pool(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - storage_pool = netapp_v1.StoragePool() - storage_pool.service_level = "FLEX" - storage_pool.capacity_gib = 1247 - storage_pool.network = "network_value" - - request = netapp_v1.UpdateStoragePoolRequest( - storage_pool=storage_pool, - ) - - # Make the request - operation = client.update_storage_pool(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_UpdateStoragePool_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_volume_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_volume_async.py deleted file mode 100644 index 737f5332650d..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_volume_async.py +++ /dev/null @@ -1,62 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 UpdateVolume -# 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-netapp - - -# [START netapp_v1_generated_NetApp_UpdateVolume_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 netapp_v1 - - -async def sample_update_volume(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - volume = netapp_v1.Volume() - volume.share_name = "share_name_value" - volume.storage_pool = "storage_pool_value" - volume.capacity_gib = 1247 - volume.protocols = ['SMB'] - - request = netapp_v1.UpdateVolumeRequest( - volume=volume, - ) - - # Make the request - operation = client.update_volume(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_UpdateVolume_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_volume_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_volume_sync.py deleted file mode 100644 index a4fc0731d75d..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_update_volume_sync.py +++ /dev/null @@ -1,62 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 UpdateVolume -# 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-netapp - - -# [START netapp_v1_generated_NetApp_UpdateVolume_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 netapp_v1 - - -def sample_update_volume(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - volume = netapp_v1.Volume() - volume.share_name = "share_name_value" - volume.storage_pool = "storage_pool_value" - volume.capacity_gib = 1247 - volume.protocols = ['SMB'] - - request = netapp_v1.UpdateVolumeRequest( - volume=volume, - ) - - # Make the request - operation = client.update_volume(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_UpdateVolume_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_validate_directory_service_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_validate_directory_service_async.py deleted file mode 100644 index 128629200c77..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_validate_directory_service_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ValidateDirectoryService -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ValidateDirectoryService_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 netapp_v1 - - -async def sample_validate_directory_service(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.ValidateDirectoryServiceRequest( - name="name_value", - ) - - # Make the request - operation = client.validate_directory_service(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_ValidateDirectoryService_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_validate_directory_service_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_validate_directory_service_sync.py deleted file mode 100644 index 83cc3bb7839e..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_validate_directory_service_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 ValidateDirectoryService -# 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-netapp - - -# [START netapp_v1_generated_NetApp_ValidateDirectoryService_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 netapp_v1 - - -def sample_validate_directory_service(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.ValidateDirectoryServiceRequest( - name="name_value", - ) - - # Make the request - operation = client.validate_directory_service(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_ValidateDirectoryService_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_verify_kms_config_async.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_verify_kms_config_async.py deleted file mode 100644 index 40d65dfaa2f7..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_verify_kms_config_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 VerifyKmsConfig -# 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-netapp - - -# [START netapp_v1_generated_NetApp_VerifyKmsConfig_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 netapp_v1 - - -async def sample_verify_kms_config(): - # Create a client - client = netapp_v1.NetAppAsyncClient() - - # Initialize request argument(s) - request = netapp_v1.VerifyKmsConfigRequest( - name="name_value", - ) - - # Make the request - response = await client.verify_kms_config(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_VerifyKmsConfig_async] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_verify_kms_config_sync.py b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_verify_kms_config_sync.py deleted file mode 100644 index 95ca55b4b031..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/netapp_v1_generated_net_app_verify_kms_config_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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 VerifyKmsConfig -# 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-netapp - - -# [START netapp_v1_generated_NetApp_VerifyKmsConfig_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 netapp_v1 - - -def sample_verify_kms_config(): - # Create a client - client = netapp_v1.NetAppClient() - - # Initialize request argument(s) - request = netapp_v1.VerifyKmsConfigRequest( - name="name_value", - ) - - # Make the request - response = client.verify_kms_config(request=request) - - # Handle the response - print(response) - -# [END netapp_v1_generated_NetApp_VerifyKmsConfig_sync] diff --git a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/snippet_metadata_google.cloud.netapp.v1.json b/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/snippet_metadata_google.cloud.netapp.v1.json deleted file mode 100644 index 59d2f45cdea3..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/samples/generated_samples/snippet_metadata_google.cloud.netapp.v1.json +++ /dev/null @@ -1,9835 +0,0 @@ -{ - "clientLibrary": { - "apis": [ - { - "id": "google.cloud.netapp.v1", - "version": "v1" - } - ], - "language": "PYTHON", - "name": "google-cloud-netapp", - "version": "0.1.0" - }, - "snippets": [ - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.create_active_directory", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.CreateActiveDirectory", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "CreateActiveDirectory" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.CreateActiveDirectoryRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "active_directory", - "type": "google.cloud.netapp_v1.types.ActiveDirectory" - }, - { - "name": "active_directory_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_active_directory" - }, - "description": "Sample for CreateActiveDirectory", - "file": "netapp_v1_generated_net_app_create_active_directory_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_CreateActiveDirectory_async", - "segments": [ - { - "end": 64, - "start": 27, - "type": "FULL" - }, - { - "end": 64, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 54, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 61, - "start": 55, - "type": "REQUEST_EXECUTION" - }, - { - "end": 65, - "start": 62, - "type": "RESPONSE_HANDLING" - } - ], - "title": "netapp_v1_generated_net_app_create_active_directory_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.create_active_directory", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.CreateActiveDirectory", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "CreateActiveDirectory" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.CreateActiveDirectoryRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "active_directory", - "type": "google.cloud.netapp_v1.types.ActiveDirectory" - }, - { - "name": "active_directory_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_active_directory" - }, - "description": "Sample for CreateActiveDirectory", - "file": "netapp_v1_generated_net_app_create_active_directory_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_CreateActiveDirectory_sync", - "segments": [ - { - "end": 64, - "start": 27, - "type": "FULL" - }, - { - "end": 64, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 54, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 61, - "start": 55, - "type": "REQUEST_EXECUTION" - }, - { - "end": 65, - "start": 62, - "type": "RESPONSE_HANDLING" - } - ], - "title": "netapp_v1_generated_net_app_create_active_directory_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.create_backup_policy", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.CreateBackupPolicy", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "CreateBackupPolicy" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.CreateBackupPolicyRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "backup_policy", - "type": "google.cloud.netapp_v1.types.BackupPolicy" - }, - { - "name": "backup_policy_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_backup_policy" - }, - "description": "Sample for CreateBackupPolicy", - "file": "netapp_v1_generated_net_app_create_backup_policy_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_CreateBackupPolicy_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": "netapp_v1_generated_net_app_create_backup_policy_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.create_backup_policy", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.CreateBackupPolicy", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "CreateBackupPolicy" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.CreateBackupPolicyRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "backup_policy", - "type": "google.cloud.netapp_v1.types.BackupPolicy" - }, - { - "name": "backup_policy_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_backup_policy" - }, - "description": "Sample for CreateBackupPolicy", - "file": "netapp_v1_generated_net_app_create_backup_policy_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_CreateBackupPolicy_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": "netapp_v1_generated_net_app_create_backup_policy_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.create_backup_vault", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.CreateBackupVault", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "CreateBackupVault" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.CreateBackupVaultRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "backup_vault", - "type": "google.cloud.netapp_v1.types.BackupVault" - }, - { - "name": "backup_vault_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_backup_vault" - }, - "description": "Sample for CreateBackupVault", - "file": "netapp_v1_generated_net_app_create_backup_vault_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_CreateBackupVault_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": "netapp_v1_generated_net_app_create_backup_vault_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.create_backup_vault", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.CreateBackupVault", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "CreateBackupVault" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.CreateBackupVaultRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "backup_vault", - "type": "google.cloud.netapp_v1.types.BackupVault" - }, - { - "name": "backup_vault_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_backup_vault" - }, - "description": "Sample for CreateBackupVault", - "file": "netapp_v1_generated_net_app_create_backup_vault_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_CreateBackupVault_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": "netapp_v1_generated_net_app_create_backup_vault_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.create_backup", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.CreateBackup", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "CreateBackup" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.CreateBackupRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "backup", - "type": "google.cloud.netapp_v1.types.Backup" - }, - { - "name": "backup_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_backup" - }, - "description": "Sample for CreateBackup", - "file": "netapp_v1_generated_net_app_create_backup_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_CreateBackup_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": "netapp_v1_generated_net_app_create_backup_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.create_backup", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.CreateBackup", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "CreateBackup" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.CreateBackupRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "backup", - "type": "google.cloud.netapp_v1.types.Backup" - }, - { - "name": "backup_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_backup" - }, - "description": "Sample for CreateBackup", - "file": "netapp_v1_generated_net_app_create_backup_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_CreateBackup_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": "netapp_v1_generated_net_app_create_backup_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.create_kms_config", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.CreateKmsConfig", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "CreateKmsConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.CreateKmsConfigRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "kms_config", - "type": "google.cloud.netapp_v1.types.KmsConfig" - }, - { - "name": "kms_config_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_kms_config" - }, - "description": "Sample for CreateKmsConfig", - "file": "netapp_v1_generated_net_app_create_kms_config_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_CreateKmsConfig_async", - "segments": [ - { - "end": 60, - "start": 27, - "type": "FULL" - }, - { - "end": 60, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 50, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 57, - "start": 51, - "type": "REQUEST_EXECUTION" - }, - { - "end": 61, - "start": 58, - "type": "RESPONSE_HANDLING" - } - ], - "title": "netapp_v1_generated_net_app_create_kms_config_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.create_kms_config", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.CreateKmsConfig", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "CreateKmsConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.CreateKmsConfigRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "kms_config", - "type": "google.cloud.netapp_v1.types.KmsConfig" - }, - { - "name": "kms_config_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_kms_config" - }, - "description": "Sample for CreateKmsConfig", - "file": "netapp_v1_generated_net_app_create_kms_config_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_CreateKmsConfig_sync", - "segments": [ - { - "end": 60, - "start": 27, - "type": "FULL" - }, - { - "end": 60, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 50, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 57, - "start": 51, - "type": "REQUEST_EXECUTION" - }, - { - "end": 61, - "start": 58, - "type": "RESPONSE_HANDLING" - } - ], - "title": "netapp_v1_generated_net_app_create_kms_config_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.create_quota_rule", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.CreateQuotaRule", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "CreateQuotaRule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.CreateQuotaRuleRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "quota_rule", - "type": "google.cloud.netapp_v1.types.QuotaRule" - }, - { - "name": "quota_rule_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_quota_rule" - }, - "description": "Sample for CreateQuotaRule", - "file": "netapp_v1_generated_net_app_create_quota_rule_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_CreateQuotaRule_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": "netapp_v1_generated_net_app_create_quota_rule_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.create_quota_rule", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.CreateQuotaRule", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "CreateQuotaRule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.CreateQuotaRuleRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "quota_rule", - "type": "google.cloud.netapp_v1.types.QuotaRule" - }, - { - "name": "quota_rule_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_quota_rule" - }, - "description": "Sample for CreateQuotaRule", - "file": "netapp_v1_generated_net_app_create_quota_rule_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_CreateQuotaRule_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": "netapp_v1_generated_net_app_create_quota_rule_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.create_replication", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.CreateReplication", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "CreateReplication" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.CreateReplicationRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "replication", - "type": "google.cloud.netapp_v1.types.Replication" - }, - { - "name": "replication_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_replication" - }, - "description": "Sample for CreateReplication", - "file": "netapp_v1_generated_net_app_create_replication_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_CreateReplication_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": "netapp_v1_generated_net_app_create_replication_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.create_replication", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.CreateReplication", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "CreateReplication" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.CreateReplicationRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "replication", - "type": "google.cloud.netapp_v1.types.Replication" - }, - { - "name": "replication_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_replication" - }, - "description": "Sample for CreateReplication", - "file": "netapp_v1_generated_net_app_create_replication_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_CreateReplication_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": "netapp_v1_generated_net_app_create_replication_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.create_snapshot", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.CreateSnapshot", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "CreateSnapshot" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.CreateSnapshotRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "snapshot", - "type": "google.cloud.netapp_v1.types.Snapshot" - }, - { - "name": "snapshot_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_snapshot" - }, - "description": "Sample for CreateSnapshot", - "file": "netapp_v1_generated_net_app_create_snapshot_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_CreateSnapshot_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": "netapp_v1_generated_net_app_create_snapshot_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.create_snapshot", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.CreateSnapshot", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "CreateSnapshot" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.CreateSnapshotRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "snapshot", - "type": "google.cloud.netapp_v1.types.Snapshot" - }, - { - "name": "snapshot_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_snapshot" - }, - "description": "Sample for CreateSnapshot", - "file": "netapp_v1_generated_net_app_create_snapshot_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_CreateSnapshot_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": "netapp_v1_generated_net_app_create_snapshot_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.create_storage_pool", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.CreateStoragePool", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "CreateStoragePool" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.CreateStoragePoolRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "storage_pool", - "type": "google.cloud.netapp_v1.types.StoragePool" - }, - { - "name": "storage_pool_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_storage_pool" - }, - "description": "Sample for CreateStoragePool", - "file": "netapp_v1_generated_net_app_create_storage_pool_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_CreateStoragePool_async", - "segments": [ - { - "end": 62, - "start": 27, - "type": "FULL" - }, - { - "end": 62, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 52, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 59, - "start": 53, - "type": "REQUEST_EXECUTION" - }, - { - "end": 63, - "start": 60, - "type": "RESPONSE_HANDLING" - } - ], - "title": "netapp_v1_generated_net_app_create_storage_pool_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.create_storage_pool", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.CreateStoragePool", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "CreateStoragePool" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.CreateStoragePoolRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "storage_pool", - "type": "google.cloud.netapp_v1.types.StoragePool" - }, - { - "name": "storage_pool_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_storage_pool" - }, - "description": "Sample for CreateStoragePool", - "file": "netapp_v1_generated_net_app_create_storage_pool_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_CreateStoragePool_sync", - "segments": [ - { - "end": 62, - "start": 27, - "type": "FULL" - }, - { - "end": 62, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 52, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 59, - "start": 53, - "type": "REQUEST_EXECUTION" - }, - { - "end": 63, - "start": 60, - "type": "RESPONSE_HANDLING" - } - ], - "title": "netapp_v1_generated_net_app_create_storage_pool_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.create_volume", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.CreateVolume", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "CreateVolume" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.CreateVolumeRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "volume", - "type": "google.cloud.netapp_v1.types.Volume" - }, - { - "name": "volume_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_volume" - }, - "description": "Sample for CreateVolume", - "file": "netapp_v1_generated_net_app_create_volume_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_CreateVolume_async", - "segments": [ - { - "end": 63, - "start": 27, - "type": "FULL" - }, - { - "end": 63, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 53, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 60, - "start": 54, - "type": "REQUEST_EXECUTION" - }, - { - "end": 64, - "start": 61, - "type": "RESPONSE_HANDLING" - } - ], - "title": "netapp_v1_generated_net_app_create_volume_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.create_volume", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.CreateVolume", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "CreateVolume" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.CreateVolumeRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "volume", - "type": "google.cloud.netapp_v1.types.Volume" - }, - { - "name": "volume_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_volume" - }, - "description": "Sample for CreateVolume", - "file": "netapp_v1_generated_net_app_create_volume_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_CreateVolume_sync", - "segments": [ - { - "end": 63, - "start": 27, - "type": "FULL" - }, - { - "end": 63, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 53, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 60, - "start": 54, - "type": "REQUEST_EXECUTION" - }, - { - "end": 64, - "start": 61, - "type": "RESPONSE_HANDLING" - } - ], - "title": "netapp_v1_generated_net_app_create_volume_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.delete_active_directory", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.DeleteActiveDirectory", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "DeleteActiveDirectory" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.DeleteActiveDirectoryRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_active_directory" - }, - "description": "Sample for DeleteActiveDirectory", - "file": "netapp_v1_generated_net_app_delete_active_directory_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_DeleteActiveDirectory_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": "netapp_v1_generated_net_app_delete_active_directory_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.delete_active_directory", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.DeleteActiveDirectory", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "DeleteActiveDirectory" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.DeleteActiveDirectoryRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_active_directory" - }, - "description": "Sample for DeleteActiveDirectory", - "file": "netapp_v1_generated_net_app_delete_active_directory_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_DeleteActiveDirectory_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": "netapp_v1_generated_net_app_delete_active_directory_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.delete_backup_policy", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.DeleteBackupPolicy", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "DeleteBackupPolicy" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.DeleteBackupPolicyRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_backup_policy" - }, - "description": "Sample for DeleteBackupPolicy", - "file": "netapp_v1_generated_net_app_delete_backup_policy_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_DeleteBackupPolicy_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": "netapp_v1_generated_net_app_delete_backup_policy_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.delete_backup_policy", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.DeleteBackupPolicy", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "DeleteBackupPolicy" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.DeleteBackupPolicyRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_backup_policy" - }, - "description": "Sample for DeleteBackupPolicy", - "file": "netapp_v1_generated_net_app_delete_backup_policy_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_DeleteBackupPolicy_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": "netapp_v1_generated_net_app_delete_backup_policy_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.delete_backup_vault", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.DeleteBackupVault", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "DeleteBackupVault" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.DeleteBackupVaultRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_backup_vault" - }, - "description": "Sample for DeleteBackupVault", - "file": "netapp_v1_generated_net_app_delete_backup_vault_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_DeleteBackupVault_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": "netapp_v1_generated_net_app_delete_backup_vault_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.delete_backup_vault", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.DeleteBackupVault", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "DeleteBackupVault" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.DeleteBackupVaultRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_backup_vault" - }, - "description": "Sample for DeleteBackupVault", - "file": "netapp_v1_generated_net_app_delete_backup_vault_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_DeleteBackupVault_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": "netapp_v1_generated_net_app_delete_backup_vault_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.delete_backup", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.DeleteBackup", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "DeleteBackup" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.DeleteBackupRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_backup" - }, - "description": "Sample for DeleteBackup", - "file": "netapp_v1_generated_net_app_delete_backup_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_DeleteBackup_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": "netapp_v1_generated_net_app_delete_backup_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.delete_backup", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.DeleteBackup", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "DeleteBackup" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.DeleteBackupRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_backup" - }, - "description": "Sample for DeleteBackup", - "file": "netapp_v1_generated_net_app_delete_backup_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_DeleteBackup_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": "netapp_v1_generated_net_app_delete_backup_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.delete_kms_config", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.DeleteKmsConfig", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "DeleteKmsConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.DeleteKmsConfigRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_kms_config" - }, - "description": "Sample for DeleteKmsConfig", - "file": "netapp_v1_generated_net_app_delete_kms_config_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_DeleteKmsConfig_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": "netapp_v1_generated_net_app_delete_kms_config_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.delete_kms_config", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.DeleteKmsConfig", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "DeleteKmsConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.DeleteKmsConfigRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_kms_config" - }, - "description": "Sample for DeleteKmsConfig", - "file": "netapp_v1_generated_net_app_delete_kms_config_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_DeleteKmsConfig_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": "netapp_v1_generated_net_app_delete_kms_config_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.delete_quota_rule", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.DeleteQuotaRule", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "DeleteQuotaRule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.DeleteQuotaRuleRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_quota_rule" - }, - "description": "Sample for DeleteQuotaRule", - "file": "netapp_v1_generated_net_app_delete_quota_rule_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_DeleteQuotaRule_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": "netapp_v1_generated_net_app_delete_quota_rule_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.delete_quota_rule", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.DeleteQuotaRule", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "DeleteQuotaRule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.DeleteQuotaRuleRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_quota_rule" - }, - "description": "Sample for DeleteQuotaRule", - "file": "netapp_v1_generated_net_app_delete_quota_rule_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_DeleteQuotaRule_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": "netapp_v1_generated_net_app_delete_quota_rule_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.delete_replication", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.DeleteReplication", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "DeleteReplication" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.DeleteReplicationRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_replication" - }, - "description": "Sample for DeleteReplication", - "file": "netapp_v1_generated_net_app_delete_replication_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_DeleteReplication_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": "netapp_v1_generated_net_app_delete_replication_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.delete_replication", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.DeleteReplication", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "DeleteReplication" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.DeleteReplicationRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_replication" - }, - "description": "Sample for DeleteReplication", - "file": "netapp_v1_generated_net_app_delete_replication_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_DeleteReplication_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": "netapp_v1_generated_net_app_delete_replication_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.delete_snapshot", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.DeleteSnapshot", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "DeleteSnapshot" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.DeleteSnapshotRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_snapshot" - }, - "description": "Sample for DeleteSnapshot", - "file": "netapp_v1_generated_net_app_delete_snapshot_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_DeleteSnapshot_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": "netapp_v1_generated_net_app_delete_snapshot_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.delete_snapshot", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.DeleteSnapshot", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "DeleteSnapshot" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.DeleteSnapshotRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_snapshot" - }, - "description": "Sample for DeleteSnapshot", - "file": "netapp_v1_generated_net_app_delete_snapshot_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_DeleteSnapshot_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": "netapp_v1_generated_net_app_delete_snapshot_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.delete_storage_pool", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.DeleteStoragePool", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "DeleteStoragePool" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.DeleteStoragePoolRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_storage_pool" - }, - "description": "Sample for DeleteStoragePool", - "file": "netapp_v1_generated_net_app_delete_storage_pool_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_DeleteStoragePool_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": "netapp_v1_generated_net_app_delete_storage_pool_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.delete_storage_pool", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.DeleteStoragePool", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "DeleteStoragePool" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.DeleteStoragePoolRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_storage_pool" - }, - "description": "Sample for DeleteStoragePool", - "file": "netapp_v1_generated_net_app_delete_storage_pool_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_DeleteStoragePool_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": "netapp_v1_generated_net_app_delete_storage_pool_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.delete_volume", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.DeleteVolume", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "DeleteVolume" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.DeleteVolumeRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_volume" - }, - "description": "Sample for DeleteVolume", - "file": "netapp_v1_generated_net_app_delete_volume_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_DeleteVolume_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": "netapp_v1_generated_net_app_delete_volume_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.delete_volume", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.DeleteVolume", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "DeleteVolume" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.DeleteVolumeRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_volume" - }, - "description": "Sample for DeleteVolume", - "file": "netapp_v1_generated_net_app_delete_volume_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_DeleteVolume_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": "netapp_v1_generated_net_app_delete_volume_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.encrypt_volumes", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.EncryptVolumes", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "EncryptVolumes" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.EncryptVolumesRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "encrypt_volumes" - }, - "description": "Sample for EncryptVolumes", - "file": "netapp_v1_generated_net_app_encrypt_volumes_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_EncryptVolumes_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": "netapp_v1_generated_net_app_encrypt_volumes_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.encrypt_volumes", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.EncryptVolumes", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "EncryptVolumes" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.EncryptVolumesRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "encrypt_volumes" - }, - "description": "Sample for EncryptVolumes", - "file": "netapp_v1_generated_net_app_encrypt_volumes_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_EncryptVolumes_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": "netapp_v1_generated_net_app_encrypt_volumes_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.establish_peering", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.EstablishPeering", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "EstablishPeering" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.EstablishPeeringRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "establish_peering" - }, - "description": "Sample for EstablishPeering", - "file": "netapp_v1_generated_net_app_establish_peering_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_EstablishPeering_async", - "segments": [ - { - "end": 58, - "start": 27, - "type": "FULL" - }, - { - "end": 58, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 48, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 55, - "start": 49, - "type": "REQUEST_EXECUTION" - }, - { - "end": 59, - "start": 56, - "type": "RESPONSE_HANDLING" - } - ], - "title": "netapp_v1_generated_net_app_establish_peering_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.establish_peering", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.EstablishPeering", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "EstablishPeering" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.EstablishPeeringRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "establish_peering" - }, - "description": "Sample for EstablishPeering", - "file": "netapp_v1_generated_net_app_establish_peering_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_EstablishPeering_sync", - "segments": [ - { - "end": 58, - "start": 27, - "type": "FULL" - }, - { - "end": 58, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 48, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 55, - "start": 49, - "type": "REQUEST_EXECUTION" - }, - { - "end": 59, - "start": 56, - "type": "RESPONSE_HANDLING" - } - ], - "title": "netapp_v1_generated_net_app_establish_peering_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.get_active_directory", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.GetActiveDirectory", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "GetActiveDirectory" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.GetActiveDirectoryRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.ActiveDirectory", - "shortName": "get_active_directory" - }, - "description": "Sample for GetActiveDirectory", - "file": "netapp_v1_generated_net_app_get_active_directory_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_GetActiveDirectory_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": "netapp_v1_generated_net_app_get_active_directory_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.get_active_directory", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.GetActiveDirectory", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "GetActiveDirectory" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.GetActiveDirectoryRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.ActiveDirectory", - "shortName": "get_active_directory" - }, - "description": "Sample for GetActiveDirectory", - "file": "netapp_v1_generated_net_app_get_active_directory_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_GetActiveDirectory_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": "netapp_v1_generated_net_app_get_active_directory_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.get_backup_policy", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.GetBackupPolicy", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "GetBackupPolicy" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.GetBackupPolicyRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.BackupPolicy", - "shortName": "get_backup_policy" - }, - "description": "Sample for GetBackupPolicy", - "file": "netapp_v1_generated_net_app_get_backup_policy_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_GetBackupPolicy_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": "netapp_v1_generated_net_app_get_backup_policy_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.get_backup_policy", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.GetBackupPolicy", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "GetBackupPolicy" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.GetBackupPolicyRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.BackupPolicy", - "shortName": "get_backup_policy" - }, - "description": "Sample for GetBackupPolicy", - "file": "netapp_v1_generated_net_app_get_backup_policy_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_GetBackupPolicy_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": "netapp_v1_generated_net_app_get_backup_policy_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.get_backup_vault", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.GetBackupVault", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "GetBackupVault" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.GetBackupVaultRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.BackupVault", - "shortName": "get_backup_vault" - }, - "description": "Sample for GetBackupVault", - "file": "netapp_v1_generated_net_app_get_backup_vault_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_GetBackupVault_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": "netapp_v1_generated_net_app_get_backup_vault_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.get_backup_vault", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.GetBackupVault", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "GetBackupVault" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.GetBackupVaultRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.BackupVault", - "shortName": "get_backup_vault" - }, - "description": "Sample for GetBackupVault", - "file": "netapp_v1_generated_net_app_get_backup_vault_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_GetBackupVault_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": "netapp_v1_generated_net_app_get_backup_vault_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.get_backup", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.GetBackup", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "GetBackup" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.GetBackupRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.Backup", - "shortName": "get_backup" - }, - "description": "Sample for GetBackup", - "file": "netapp_v1_generated_net_app_get_backup_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_GetBackup_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": "netapp_v1_generated_net_app_get_backup_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.get_backup", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.GetBackup", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "GetBackup" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.GetBackupRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.Backup", - "shortName": "get_backup" - }, - "description": "Sample for GetBackup", - "file": "netapp_v1_generated_net_app_get_backup_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_GetBackup_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": "netapp_v1_generated_net_app_get_backup_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.get_kms_config", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.GetKmsConfig", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "GetKmsConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.GetKmsConfigRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.KmsConfig", - "shortName": "get_kms_config" - }, - "description": "Sample for GetKmsConfig", - "file": "netapp_v1_generated_net_app_get_kms_config_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_GetKmsConfig_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": "netapp_v1_generated_net_app_get_kms_config_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.get_kms_config", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.GetKmsConfig", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "GetKmsConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.GetKmsConfigRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.KmsConfig", - "shortName": "get_kms_config" - }, - "description": "Sample for GetKmsConfig", - "file": "netapp_v1_generated_net_app_get_kms_config_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_GetKmsConfig_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": "netapp_v1_generated_net_app_get_kms_config_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.get_quota_rule", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.GetQuotaRule", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "GetQuotaRule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.GetQuotaRuleRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.QuotaRule", - "shortName": "get_quota_rule" - }, - "description": "Sample for GetQuotaRule", - "file": "netapp_v1_generated_net_app_get_quota_rule_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_GetQuotaRule_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": "netapp_v1_generated_net_app_get_quota_rule_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.get_quota_rule", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.GetQuotaRule", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "GetQuotaRule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.GetQuotaRuleRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.QuotaRule", - "shortName": "get_quota_rule" - }, - "description": "Sample for GetQuotaRule", - "file": "netapp_v1_generated_net_app_get_quota_rule_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_GetQuotaRule_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": "netapp_v1_generated_net_app_get_quota_rule_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.get_replication", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.GetReplication", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "GetReplication" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.GetReplicationRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.Replication", - "shortName": "get_replication" - }, - "description": "Sample for GetReplication", - "file": "netapp_v1_generated_net_app_get_replication_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_GetReplication_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": "netapp_v1_generated_net_app_get_replication_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.get_replication", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.GetReplication", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "GetReplication" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.GetReplicationRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.Replication", - "shortName": "get_replication" - }, - "description": "Sample for GetReplication", - "file": "netapp_v1_generated_net_app_get_replication_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_GetReplication_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": "netapp_v1_generated_net_app_get_replication_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.get_snapshot", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.GetSnapshot", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "GetSnapshot" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.GetSnapshotRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.Snapshot", - "shortName": "get_snapshot" - }, - "description": "Sample for GetSnapshot", - "file": "netapp_v1_generated_net_app_get_snapshot_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_GetSnapshot_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": "netapp_v1_generated_net_app_get_snapshot_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.get_snapshot", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.GetSnapshot", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "GetSnapshot" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.GetSnapshotRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.Snapshot", - "shortName": "get_snapshot" - }, - "description": "Sample for GetSnapshot", - "file": "netapp_v1_generated_net_app_get_snapshot_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_GetSnapshot_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": "netapp_v1_generated_net_app_get_snapshot_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.get_storage_pool", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.GetStoragePool", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "GetStoragePool" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.GetStoragePoolRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.StoragePool", - "shortName": "get_storage_pool" - }, - "description": "Sample for GetStoragePool", - "file": "netapp_v1_generated_net_app_get_storage_pool_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_GetStoragePool_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": "netapp_v1_generated_net_app_get_storage_pool_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.get_storage_pool", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.GetStoragePool", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "GetStoragePool" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.GetStoragePoolRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.StoragePool", - "shortName": "get_storage_pool" - }, - "description": "Sample for GetStoragePool", - "file": "netapp_v1_generated_net_app_get_storage_pool_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_GetStoragePool_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": "netapp_v1_generated_net_app_get_storage_pool_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.get_volume", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.GetVolume", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "GetVolume" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.GetVolumeRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.Volume", - "shortName": "get_volume" - }, - "description": "Sample for GetVolume", - "file": "netapp_v1_generated_net_app_get_volume_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_GetVolume_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": "netapp_v1_generated_net_app_get_volume_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.get_volume", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.GetVolume", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "GetVolume" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.GetVolumeRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.Volume", - "shortName": "get_volume" - }, - "description": "Sample for GetVolume", - "file": "netapp_v1_generated_net_app_get_volume_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_GetVolume_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": "netapp_v1_generated_net_app_get_volume_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.list_active_directories", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ListActiveDirectories", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ListActiveDirectories" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ListActiveDirectoriesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListActiveDirectoriesAsyncPager", - "shortName": "list_active_directories" - }, - "description": "Sample for ListActiveDirectories", - "file": "netapp_v1_generated_net_app_list_active_directories_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ListActiveDirectories_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": "netapp_v1_generated_net_app_list_active_directories_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.list_active_directories", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ListActiveDirectories", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ListActiveDirectories" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ListActiveDirectoriesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListActiveDirectoriesPager", - "shortName": "list_active_directories" - }, - "description": "Sample for ListActiveDirectories", - "file": "netapp_v1_generated_net_app_list_active_directories_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ListActiveDirectories_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": "netapp_v1_generated_net_app_list_active_directories_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.list_backup_policies", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ListBackupPolicies", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ListBackupPolicies" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ListBackupPoliciesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListBackupPoliciesAsyncPager", - "shortName": "list_backup_policies" - }, - "description": "Sample for ListBackupPolicies", - "file": "netapp_v1_generated_net_app_list_backup_policies_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ListBackupPolicies_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": "netapp_v1_generated_net_app_list_backup_policies_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.list_backup_policies", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ListBackupPolicies", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ListBackupPolicies" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ListBackupPoliciesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListBackupPoliciesPager", - "shortName": "list_backup_policies" - }, - "description": "Sample for ListBackupPolicies", - "file": "netapp_v1_generated_net_app_list_backup_policies_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ListBackupPolicies_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": "netapp_v1_generated_net_app_list_backup_policies_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.list_backup_vaults", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ListBackupVaults", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ListBackupVaults" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ListBackupVaultsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListBackupVaultsAsyncPager", - "shortName": "list_backup_vaults" - }, - "description": "Sample for ListBackupVaults", - "file": "netapp_v1_generated_net_app_list_backup_vaults_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ListBackupVaults_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": "netapp_v1_generated_net_app_list_backup_vaults_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.list_backup_vaults", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ListBackupVaults", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ListBackupVaults" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ListBackupVaultsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListBackupVaultsPager", - "shortName": "list_backup_vaults" - }, - "description": "Sample for ListBackupVaults", - "file": "netapp_v1_generated_net_app_list_backup_vaults_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ListBackupVaults_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": "netapp_v1_generated_net_app_list_backup_vaults_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.list_backups", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ListBackups", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ListBackups" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ListBackupsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListBackupsAsyncPager", - "shortName": "list_backups" - }, - "description": "Sample for ListBackups", - "file": "netapp_v1_generated_net_app_list_backups_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ListBackups_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": "netapp_v1_generated_net_app_list_backups_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.list_backups", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ListBackups", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ListBackups" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ListBackupsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListBackupsPager", - "shortName": "list_backups" - }, - "description": "Sample for ListBackups", - "file": "netapp_v1_generated_net_app_list_backups_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ListBackups_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": "netapp_v1_generated_net_app_list_backups_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.list_kms_configs", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ListKmsConfigs", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ListKmsConfigs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ListKmsConfigsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListKmsConfigsAsyncPager", - "shortName": "list_kms_configs" - }, - "description": "Sample for ListKmsConfigs", - "file": "netapp_v1_generated_net_app_list_kms_configs_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ListKmsConfigs_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": "netapp_v1_generated_net_app_list_kms_configs_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.list_kms_configs", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ListKmsConfigs", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ListKmsConfigs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ListKmsConfigsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListKmsConfigsPager", - "shortName": "list_kms_configs" - }, - "description": "Sample for ListKmsConfigs", - "file": "netapp_v1_generated_net_app_list_kms_configs_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ListKmsConfigs_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": "netapp_v1_generated_net_app_list_kms_configs_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.list_quota_rules", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ListQuotaRules", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ListQuotaRules" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ListQuotaRulesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListQuotaRulesAsyncPager", - "shortName": "list_quota_rules" - }, - "description": "Sample for ListQuotaRules", - "file": "netapp_v1_generated_net_app_list_quota_rules_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ListQuotaRules_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": "netapp_v1_generated_net_app_list_quota_rules_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.list_quota_rules", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ListQuotaRules", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ListQuotaRules" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ListQuotaRulesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListQuotaRulesPager", - "shortName": "list_quota_rules" - }, - "description": "Sample for ListQuotaRules", - "file": "netapp_v1_generated_net_app_list_quota_rules_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ListQuotaRules_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": "netapp_v1_generated_net_app_list_quota_rules_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.list_replications", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ListReplications", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ListReplications" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ListReplicationsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListReplicationsAsyncPager", - "shortName": "list_replications" - }, - "description": "Sample for ListReplications", - "file": "netapp_v1_generated_net_app_list_replications_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ListReplications_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": "netapp_v1_generated_net_app_list_replications_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.list_replications", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ListReplications", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ListReplications" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ListReplicationsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListReplicationsPager", - "shortName": "list_replications" - }, - "description": "Sample for ListReplications", - "file": "netapp_v1_generated_net_app_list_replications_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ListReplications_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": "netapp_v1_generated_net_app_list_replications_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.list_snapshots", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ListSnapshots", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ListSnapshots" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ListSnapshotsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListSnapshotsAsyncPager", - "shortName": "list_snapshots" - }, - "description": "Sample for ListSnapshots", - "file": "netapp_v1_generated_net_app_list_snapshots_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ListSnapshots_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": "netapp_v1_generated_net_app_list_snapshots_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.list_snapshots", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ListSnapshots", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ListSnapshots" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ListSnapshotsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListSnapshotsPager", - "shortName": "list_snapshots" - }, - "description": "Sample for ListSnapshots", - "file": "netapp_v1_generated_net_app_list_snapshots_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ListSnapshots_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": "netapp_v1_generated_net_app_list_snapshots_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.list_storage_pools", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ListStoragePools", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ListStoragePools" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ListStoragePoolsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListStoragePoolsAsyncPager", - "shortName": "list_storage_pools" - }, - "description": "Sample for ListStoragePools", - "file": "netapp_v1_generated_net_app_list_storage_pools_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ListStoragePools_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": "netapp_v1_generated_net_app_list_storage_pools_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.list_storage_pools", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ListStoragePools", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ListStoragePools" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ListStoragePoolsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListStoragePoolsPager", - "shortName": "list_storage_pools" - }, - "description": "Sample for ListStoragePools", - "file": "netapp_v1_generated_net_app_list_storage_pools_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ListStoragePools_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": "netapp_v1_generated_net_app_list_storage_pools_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.list_volumes", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ListVolumes", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ListVolumes" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ListVolumesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListVolumesAsyncPager", - "shortName": "list_volumes" - }, - "description": "Sample for ListVolumes", - "file": "netapp_v1_generated_net_app_list_volumes_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ListVolumes_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": "netapp_v1_generated_net_app_list_volumes_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.list_volumes", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ListVolumes", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ListVolumes" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ListVolumesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.services.net_app.pagers.ListVolumesPager", - "shortName": "list_volumes" - }, - "description": "Sample for ListVolumes", - "file": "netapp_v1_generated_net_app_list_volumes_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ListVolumes_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": "netapp_v1_generated_net_app_list_volumes_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.resume_replication", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ResumeReplication", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ResumeReplication" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ResumeReplicationRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "resume_replication" - }, - "description": "Sample for ResumeReplication", - "file": "netapp_v1_generated_net_app_resume_replication_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ResumeReplication_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": "netapp_v1_generated_net_app_resume_replication_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.resume_replication", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ResumeReplication", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ResumeReplication" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ResumeReplicationRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "resume_replication" - }, - "description": "Sample for ResumeReplication", - "file": "netapp_v1_generated_net_app_resume_replication_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ResumeReplication_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": "netapp_v1_generated_net_app_resume_replication_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.reverse_replication_direction", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ReverseReplicationDirection", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ReverseReplicationDirection" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ReverseReplicationDirectionRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "reverse_replication_direction" - }, - "description": "Sample for ReverseReplicationDirection", - "file": "netapp_v1_generated_net_app_reverse_replication_direction_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ReverseReplicationDirection_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": "netapp_v1_generated_net_app_reverse_replication_direction_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.reverse_replication_direction", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ReverseReplicationDirection", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ReverseReplicationDirection" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ReverseReplicationDirectionRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "reverse_replication_direction" - }, - "description": "Sample for ReverseReplicationDirection", - "file": "netapp_v1_generated_net_app_reverse_replication_direction_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ReverseReplicationDirection_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": "netapp_v1_generated_net_app_reverse_replication_direction_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.revert_volume", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.RevertVolume", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "RevertVolume" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.RevertVolumeRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "revert_volume" - }, - "description": "Sample for RevertVolume", - "file": "netapp_v1_generated_net_app_revert_volume_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_RevertVolume_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": "netapp_v1_generated_net_app_revert_volume_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.revert_volume", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.RevertVolume", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "RevertVolume" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.RevertVolumeRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "revert_volume" - }, - "description": "Sample for RevertVolume", - "file": "netapp_v1_generated_net_app_revert_volume_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_RevertVolume_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": "netapp_v1_generated_net_app_revert_volume_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.stop_replication", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.StopReplication", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "StopReplication" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.StopReplicationRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "stop_replication" - }, - "description": "Sample for StopReplication", - "file": "netapp_v1_generated_net_app_stop_replication_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_StopReplication_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": "netapp_v1_generated_net_app_stop_replication_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.stop_replication", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.StopReplication", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "StopReplication" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.StopReplicationRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "stop_replication" - }, - "description": "Sample for StopReplication", - "file": "netapp_v1_generated_net_app_stop_replication_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_StopReplication_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": "netapp_v1_generated_net_app_stop_replication_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.switch_active_replica_zone", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.SwitchActiveReplicaZone", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "SwitchActiveReplicaZone" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.SwitchActiveReplicaZoneRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "switch_active_replica_zone" - }, - "description": "Sample for SwitchActiveReplicaZone", - "file": "netapp_v1_generated_net_app_switch_active_replica_zone_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_SwitchActiveReplicaZone_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": "netapp_v1_generated_net_app_switch_active_replica_zone_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.switch_active_replica_zone", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.SwitchActiveReplicaZone", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "SwitchActiveReplicaZone" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.SwitchActiveReplicaZoneRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "switch_active_replica_zone" - }, - "description": "Sample for SwitchActiveReplicaZone", - "file": "netapp_v1_generated_net_app_switch_active_replica_zone_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_SwitchActiveReplicaZone_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": "netapp_v1_generated_net_app_switch_active_replica_zone_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.sync_replication", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.SyncReplication", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "SyncReplication" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.SyncReplicationRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "sync_replication" - }, - "description": "Sample for SyncReplication", - "file": "netapp_v1_generated_net_app_sync_replication_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_SyncReplication_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": "netapp_v1_generated_net_app_sync_replication_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.sync_replication", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.SyncReplication", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "SyncReplication" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.SyncReplicationRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "sync_replication" - }, - "description": "Sample for SyncReplication", - "file": "netapp_v1_generated_net_app_sync_replication_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_SyncReplication_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": "netapp_v1_generated_net_app_sync_replication_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.update_active_directory", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.UpdateActiveDirectory", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "UpdateActiveDirectory" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.UpdateActiveDirectoryRequest" - }, - { - "name": "active_directory", - "type": "google.cloud.netapp_v1.types.ActiveDirectory" - }, - { - "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, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "update_active_directory" - }, - "description": "Sample for UpdateActiveDirectory", - "file": "netapp_v1_generated_net_app_update_active_directory_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_UpdateActiveDirectory_async", - "segments": [ - { - "end": 62, - "start": 27, - "type": "FULL" - }, - { - "end": 62, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 52, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 59, - "start": 53, - "type": "REQUEST_EXECUTION" - }, - { - "end": 63, - "start": 60, - "type": "RESPONSE_HANDLING" - } - ], - "title": "netapp_v1_generated_net_app_update_active_directory_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.update_active_directory", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.UpdateActiveDirectory", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "UpdateActiveDirectory" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.UpdateActiveDirectoryRequest" - }, - { - "name": "active_directory", - "type": "google.cloud.netapp_v1.types.ActiveDirectory" - }, - { - "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, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "update_active_directory" - }, - "description": "Sample for UpdateActiveDirectory", - "file": "netapp_v1_generated_net_app_update_active_directory_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_UpdateActiveDirectory_sync", - "segments": [ - { - "end": 62, - "start": 27, - "type": "FULL" - }, - { - "end": 62, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 52, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 59, - "start": 53, - "type": "REQUEST_EXECUTION" - }, - { - "end": 63, - "start": 60, - "type": "RESPONSE_HANDLING" - } - ], - "title": "netapp_v1_generated_net_app_update_active_directory_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.update_backup_policy", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.UpdateBackupPolicy", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "UpdateBackupPolicy" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.UpdateBackupPolicyRequest" - }, - { - "name": "backup_policy", - "type": "google.cloud.netapp_v1.types.BackupPolicy" - }, - { - "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, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "update_backup_policy" - }, - "description": "Sample for UpdateBackupPolicy", - "file": "netapp_v1_generated_net_app_update_backup_policy_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_UpdateBackupPolicy_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": "netapp_v1_generated_net_app_update_backup_policy_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.update_backup_policy", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.UpdateBackupPolicy", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "UpdateBackupPolicy" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.UpdateBackupPolicyRequest" - }, - { - "name": "backup_policy", - "type": "google.cloud.netapp_v1.types.BackupPolicy" - }, - { - "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, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "update_backup_policy" - }, - "description": "Sample for UpdateBackupPolicy", - "file": "netapp_v1_generated_net_app_update_backup_policy_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_UpdateBackupPolicy_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": "netapp_v1_generated_net_app_update_backup_policy_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.update_backup_vault", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.UpdateBackupVault", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "UpdateBackupVault" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.UpdateBackupVaultRequest" - }, - { - "name": "backup_vault", - "type": "google.cloud.netapp_v1.types.BackupVault" - }, - { - "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, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "update_backup_vault" - }, - "description": "Sample for UpdateBackupVault", - "file": "netapp_v1_generated_net_app_update_backup_vault_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_UpdateBackupVault_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": "netapp_v1_generated_net_app_update_backup_vault_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.update_backup_vault", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.UpdateBackupVault", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "UpdateBackupVault" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.UpdateBackupVaultRequest" - }, - { - "name": "backup_vault", - "type": "google.cloud.netapp_v1.types.BackupVault" - }, - { - "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, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "update_backup_vault" - }, - "description": "Sample for UpdateBackupVault", - "file": "netapp_v1_generated_net_app_update_backup_vault_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_UpdateBackupVault_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": "netapp_v1_generated_net_app_update_backup_vault_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.update_backup", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.UpdateBackup", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "UpdateBackup" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.UpdateBackupRequest" - }, - { - "name": "backup", - "type": "google.cloud.netapp_v1.types.Backup" - }, - { - "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, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "update_backup" - }, - "description": "Sample for UpdateBackup", - "file": "netapp_v1_generated_net_app_update_backup_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_UpdateBackup_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": "netapp_v1_generated_net_app_update_backup_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.update_backup", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.UpdateBackup", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "UpdateBackup" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.UpdateBackupRequest" - }, - { - "name": "backup", - "type": "google.cloud.netapp_v1.types.Backup" - }, - { - "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, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "update_backup" - }, - "description": "Sample for UpdateBackup", - "file": "netapp_v1_generated_net_app_update_backup_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_UpdateBackup_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": "netapp_v1_generated_net_app_update_backup_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.update_kms_config", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.UpdateKmsConfig", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "UpdateKmsConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.UpdateKmsConfigRequest" - }, - { - "name": "kms_config", - "type": "google.cloud.netapp_v1.types.KmsConfig" - }, - { - "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, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "update_kms_config" - }, - "description": "Sample for UpdateKmsConfig", - "file": "netapp_v1_generated_net_app_update_kms_config_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_UpdateKmsConfig_async", - "segments": [ - { - "end": 58, - "start": 27, - "type": "FULL" - }, - { - "end": 58, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 48, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 55, - "start": 49, - "type": "REQUEST_EXECUTION" - }, - { - "end": 59, - "start": 56, - "type": "RESPONSE_HANDLING" - } - ], - "title": "netapp_v1_generated_net_app_update_kms_config_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.update_kms_config", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.UpdateKmsConfig", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "UpdateKmsConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.UpdateKmsConfigRequest" - }, - { - "name": "kms_config", - "type": "google.cloud.netapp_v1.types.KmsConfig" - }, - { - "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, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "update_kms_config" - }, - "description": "Sample for UpdateKmsConfig", - "file": "netapp_v1_generated_net_app_update_kms_config_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_UpdateKmsConfig_sync", - "segments": [ - { - "end": 58, - "start": 27, - "type": "FULL" - }, - { - "end": 58, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 48, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 55, - "start": 49, - "type": "REQUEST_EXECUTION" - }, - { - "end": 59, - "start": 56, - "type": "RESPONSE_HANDLING" - } - ], - "title": "netapp_v1_generated_net_app_update_kms_config_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.update_quota_rule", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.UpdateQuotaRule", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "UpdateQuotaRule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.UpdateQuotaRuleRequest" - }, - { - "name": "quota_rule", - "type": "google.cloud.netapp_v1.types.QuotaRule" - }, - { - "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, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "update_quota_rule" - }, - "description": "Sample for UpdateQuotaRule", - "file": "netapp_v1_generated_net_app_update_quota_rule_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_UpdateQuotaRule_async", - "segments": [ - { - "end": 59, - "start": 27, - "type": "FULL" - }, - { - "end": 59, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 56, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 60, - "start": 57, - "type": "RESPONSE_HANDLING" - } - ], - "title": "netapp_v1_generated_net_app_update_quota_rule_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.update_quota_rule", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.UpdateQuotaRule", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "UpdateQuotaRule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.UpdateQuotaRuleRequest" - }, - { - "name": "quota_rule", - "type": "google.cloud.netapp_v1.types.QuotaRule" - }, - { - "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, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "update_quota_rule" - }, - "description": "Sample for UpdateQuotaRule", - "file": "netapp_v1_generated_net_app_update_quota_rule_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_UpdateQuotaRule_sync", - "segments": [ - { - "end": 59, - "start": 27, - "type": "FULL" - }, - { - "end": 59, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 56, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 60, - "start": 57, - "type": "RESPONSE_HANDLING" - } - ], - "title": "netapp_v1_generated_net_app_update_quota_rule_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.update_replication", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.UpdateReplication", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "UpdateReplication" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.UpdateReplicationRequest" - }, - { - "name": "replication", - "type": "google.cloud.netapp_v1.types.Replication" - }, - { - "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, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "update_replication" - }, - "description": "Sample for UpdateReplication", - "file": "netapp_v1_generated_net_app_update_replication_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_UpdateReplication_async", - "segments": [ - { - "end": 59, - "start": 27, - "type": "FULL" - }, - { - "end": 59, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 56, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 60, - "start": 57, - "type": "RESPONSE_HANDLING" - } - ], - "title": "netapp_v1_generated_net_app_update_replication_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.update_replication", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.UpdateReplication", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "UpdateReplication" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.UpdateReplicationRequest" - }, - { - "name": "replication", - "type": "google.cloud.netapp_v1.types.Replication" - }, - { - "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, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "update_replication" - }, - "description": "Sample for UpdateReplication", - "file": "netapp_v1_generated_net_app_update_replication_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_UpdateReplication_sync", - "segments": [ - { - "end": 59, - "start": 27, - "type": "FULL" - }, - { - "end": 59, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 56, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 60, - "start": 57, - "type": "RESPONSE_HANDLING" - } - ], - "title": "netapp_v1_generated_net_app_update_replication_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.update_snapshot", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.UpdateSnapshot", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "UpdateSnapshot" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.UpdateSnapshotRequest" - }, - { - "name": "snapshot", - "type": "google.cloud.netapp_v1.types.Snapshot" - }, - { - "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, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "update_snapshot" - }, - "description": "Sample for UpdateSnapshot", - "file": "netapp_v1_generated_net_app_update_snapshot_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_UpdateSnapshot_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": "netapp_v1_generated_net_app_update_snapshot_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.update_snapshot", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.UpdateSnapshot", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "UpdateSnapshot" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.UpdateSnapshotRequest" - }, - { - "name": "snapshot", - "type": "google.cloud.netapp_v1.types.Snapshot" - }, - { - "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, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "update_snapshot" - }, - "description": "Sample for UpdateSnapshot", - "file": "netapp_v1_generated_net_app_update_snapshot_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_UpdateSnapshot_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": "netapp_v1_generated_net_app_update_snapshot_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.update_storage_pool", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.UpdateStoragePool", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "UpdateStoragePool" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.UpdateStoragePoolRequest" - }, - { - "name": "storage_pool", - "type": "google.cloud.netapp_v1.types.StoragePool" - }, - { - "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, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "update_storage_pool" - }, - "description": "Sample for UpdateStoragePool", - "file": "netapp_v1_generated_net_app_update_storage_pool_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_UpdateStoragePool_async", - "segments": [ - { - "end": 60, - "start": 27, - "type": "FULL" - }, - { - "end": 60, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 50, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 57, - "start": 51, - "type": "REQUEST_EXECUTION" - }, - { - "end": 61, - "start": 58, - "type": "RESPONSE_HANDLING" - } - ], - "title": "netapp_v1_generated_net_app_update_storage_pool_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.update_storage_pool", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.UpdateStoragePool", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "UpdateStoragePool" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.UpdateStoragePoolRequest" - }, - { - "name": "storage_pool", - "type": "google.cloud.netapp_v1.types.StoragePool" - }, - { - "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, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "update_storage_pool" - }, - "description": "Sample for UpdateStoragePool", - "file": "netapp_v1_generated_net_app_update_storage_pool_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_UpdateStoragePool_sync", - "segments": [ - { - "end": 60, - "start": 27, - "type": "FULL" - }, - { - "end": 60, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 50, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 57, - "start": 51, - "type": "REQUEST_EXECUTION" - }, - { - "end": 61, - "start": 58, - "type": "RESPONSE_HANDLING" - } - ], - "title": "netapp_v1_generated_net_app_update_storage_pool_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.update_volume", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.UpdateVolume", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "UpdateVolume" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.UpdateVolumeRequest" - }, - { - "name": "volume", - "type": "google.cloud.netapp_v1.types.Volume" - }, - { - "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, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "update_volume" - }, - "description": "Sample for UpdateVolume", - "file": "netapp_v1_generated_net_app_update_volume_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_UpdateVolume_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": "netapp_v1_generated_net_app_update_volume_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.update_volume", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.UpdateVolume", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "UpdateVolume" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.UpdateVolumeRequest" - }, - { - "name": "volume", - "type": "google.cloud.netapp_v1.types.Volume" - }, - { - "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, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "update_volume" - }, - "description": "Sample for UpdateVolume", - "file": "netapp_v1_generated_net_app_update_volume_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_UpdateVolume_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": "netapp_v1_generated_net_app_update_volume_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.validate_directory_service", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ValidateDirectoryService", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ValidateDirectoryService" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ValidateDirectoryServiceRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "validate_directory_service" - }, - "description": "Sample for ValidateDirectoryService", - "file": "netapp_v1_generated_net_app_validate_directory_service_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ValidateDirectoryService_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": "netapp_v1_generated_net_app_validate_directory_service_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.validate_directory_service", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.ValidateDirectoryService", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "ValidateDirectoryService" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.ValidateDirectoryServiceRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "validate_directory_service" - }, - "description": "Sample for ValidateDirectoryService", - "file": "netapp_v1_generated_net_app_validate_directory_service_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_ValidateDirectoryService_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": "netapp_v1_generated_net_app_validate_directory_service_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient", - "shortName": "NetAppAsyncClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppAsyncClient.verify_kms_config", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.VerifyKmsConfig", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "VerifyKmsConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.VerifyKmsConfigRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.VerifyKmsConfigResponse", - "shortName": "verify_kms_config" - }, - "description": "Sample for VerifyKmsConfig", - "file": "netapp_v1_generated_net_app_verify_kms_config_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_VerifyKmsConfig_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": "netapp_v1_generated_net_app_verify_kms_config_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.netapp_v1.NetAppClient", - "shortName": "NetAppClient" - }, - "fullName": "google.cloud.netapp_v1.NetAppClient.verify_kms_config", - "method": { - "fullName": "google.cloud.netapp.v1.NetApp.VerifyKmsConfig", - "service": { - "fullName": "google.cloud.netapp.v1.NetApp", - "shortName": "NetApp" - }, - "shortName": "VerifyKmsConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.netapp_v1.types.VerifyKmsConfigRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.netapp_v1.types.VerifyKmsConfigResponse", - "shortName": "verify_kms_config" - }, - "description": "Sample for VerifyKmsConfig", - "file": "netapp_v1_generated_net_app_verify_kms_config_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "netapp_v1_generated_NetApp_VerifyKmsConfig_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": "netapp_v1_generated_net_app_verify_kms_config_sync.py" - } - ] -} diff --git a/owl-bot-staging/google-cloud-netapp/v1/scripts/fixup_netapp_v1_keywords.py b/owl-bot-staging/google-cloud-netapp/v1/scripts/fixup_netapp_v1_keywords.py deleted file mode 100644 index c8c3b6032598..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/scripts/fixup_netapp_v1_keywords.py +++ /dev/null @@ -1,235 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2025 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 netappCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'create_active_directory': ('parent', 'active_directory', 'active_directory_id', ), - 'create_backup': ('parent', 'backup_id', 'backup', ), - 'create_backup_policy': ('parent', 'backup_policy', 'backup_policy_id', ), - 'create_backup_vault': ('parent', 'backup_vault_id', 'backup_vault', ), - 'create_kms_config': ('parent', 'kms_config_id', 'kms_config', ), - 'create_quota_rule': ('parent', 'quota_rule', 'quota_rule_id', ), - 'create_replication': ('parent', 'replication', 'replication_id', ), - 'create_snapshot': ('parent', 'snapshot', 'snapshot_id', ), - 'create_storage_pool': ('parent', 'storage_pool_id', 'storage_pool', ), - 'create_volume': ('parent', 'volume_id', 'volume', ), - 'delete_active_directory': ('name', ), - 'delete_backup': ('name', ), - 'delete_backup_policy': ('name', ), - 'delete_backup_vault': ('name', ), - 'delete_kms_config': ('name', ), - 'delete_quota_rule': ('name', ), - 'delete_replication': ('name', ), - 'delete_snapshot': ('name', ), - 'delete_storage_pool': ('name', ), - 'delete_volume': ('name', 'force', ), - 'encrypt_volumes': ('name', ), - 'establish_peering': ('name', 'peer_cluster_name', 'peer_svm_name', 'peer_volume_name', 'peer_ip_addresses', ), - 'get_active_directory': ('name', ), - 'get_backup': ('name', ), - 'get_backup_policy': ('name', ), - 'get_backup_vault': ('name', ), - 'get_kms_config': ('name', ), - 'get_quota_rule': ('name', ), - 'get_replication': ('name', ), - 'get_snapshot': ('name', ), - 'get_storage_pool': ('name', ), - 'get_volume': ('name', ), - 'list_active_directories': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_backup_policies': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_backups': ('parent', 'page_size', 'page_token', 'order_by', 'filter', ), - 'list_backup_vaults': ('parent', 'page_size', 'page_token', 'order_by', 'filter', ), - 'list_kms_configs': ('parent', 'page_size', 'page_token', 'order_by', 'filter', ), - 'list_quota_rules': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_replications': ('parent', 'page_size', 'page_token', 'order_by', 'filter', ), - 'list_snapshots': ('parent', 'page_size', 'page_token', 'order_by', 'filter', ), - 'list_storage_pools': ('parent', 'page_size', 'page_token', 'order_by', 'filter', ), - 'list_volumes': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'resume_replication': ('name', ), - 'reverse_replication_direction': ('name', ), - 'revert_volume': ('name', 'snapshot_id', ), - 'stop_replication': ('name', 'force', ), - 'switch_active_replica_zone': ('name', ), - 'sync_replication': ('name', ), - 'update_active_directory': ('update_mask', 'active_directory', ), - 'update_backup': ('update_mask', 'backup', ), - 'update_backup_policy': ('update_mask', 'backup_policy', ), - 'update_backup_vault': ('update_mask', 'backup_vault', ), - 'update_kms_config': ('update_mask', 'kms_config', ), - 'update_quota_rule': ('quota_rule', 'update_mask', ), - 'update_replication': ('update_mask', 'replication', ), - 'update_snapshot': ('update_mask', 'snapshot', ), - 'update_storage_pool': ('update_mask', 'storage_pool', ), - 'update_volume': ('update_mask', 'volume', ), - 'validate_directory_service': ('name', 'directory_service_type', ), - 'verify_kms_config': ('name', ), - } - - 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=netappCallTransformer(), -): - """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 netapp 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-netapp/v1/setup.py b/owl-bot-staging/google-cloud-netapp/v1/setup.py deleted file mode 100644 index bdf343c39ab4..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/setup.py +++ /dev/null @@ -1,98 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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-netapp' - - -description = "Google Cloud Netapp API client library" - -version = None - -with open(os.path.join(package_root, 'google/cloud/netapp/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.0,!=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.0,!=2.24.0,!=2.25.0", - "proto-plus >= 1.22.3, <2.0.0", - "proto-plus >= 1.25.0, <2.0.0; python_version >= '3.13'", - "protobuf>=3.20.2,<7.0.0,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", -] -extras = { -} -url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-netapp" - -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-netapp/v1/testing/constraints-3.10.txt b/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.10.txt deleted file mode 100644 index ed7f9aed2559..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.10.txt +++ /dev/null @@ -1,6 +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 diff --git a/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.11.txt b/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.11.txt deleted file mode 100644 index ed7f9aed2559..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.11.txt +++ /dev/null @@ -1,6 +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 diff --git a/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.12.txt b/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.12.txt deleted file mode 100644 index ed7f9aed2559..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.12.txt +++ /dev/null @@ -1,6 +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 diff --git a/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.13.txt b/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.13.txt deleted file mode 100644 index c20a77817caa..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.13.txt +++ /dev/null @@ -1,11 +0,0 @@ -# We use the constraints file for the latest Python version -# (currently this file) to check that the latest -# major versions of dependencies are supported in setup.py. -# List all library dependencies and extras in this file. -# Require the latest major version be installed for each dependency. -# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0", -# Then this file should have google-cloud-foo>=1 -google-api-core>=2 -google-auth>=2 -proto-plus>=1 -protobuf>=6 diff --git a/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.7.txt b/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.7.txt deleted file mode 100644 index a77f12bc13e4..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.7.txt +++ /dev/null @@ -1,10 +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.0", -# 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 diff --git a/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.8.txt b/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.8.txt deleted file mode 100644 index ed7f9aed2559..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.8.txt +++ /dev/null @@ -1,6 +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 diff --git a/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.9.txt b/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.9.txt deleted file mode 100644 index ed7f9aed2559..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/testing/constraints-3.9.txt +++ /dev/null @@ -1,6 +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 diff --git a/owl-bot-staging/google-cloud-netapp/v1/tests/__init__.py b/owl-bot-staging/google-cloud-netapp/v1/tests/__init__.py deleted file mode 100644 index 191773d5572d..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/tests/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2025 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-netapp/v1/tests/unit/__init__.py b/owl-bot-staging/google-cloud-netapp/v1/tests/unit/__init__.py deleted file mode 100644 index 191773d5572d..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/tests/unit/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2025 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-netapp/v1/tests/unit/gapic/__init__.py b/owl-bot-staging/google-cloud-netapp/v1/tests/unit/gapic/__init__.py deleted file mode 100644 index 191773d5572d..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/tests/unit/gapic/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2025 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-netapp/v1/tests/unit/gapic/netapp_v1/__init__.py b/owl-bot-staging/google-cloud-netapp/v1/tests/unit/gapic/netapp_v1/__init__.py deleted file mode 100644 index 191773d5572d..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/tests/unit/gapic/netapp_v1/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2025 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-netapp/v1/tests/unit/gapic/netapp_v1/test_net_app.py b/owl-bot-staging/google-cloud-netapp/v1/tests/unit/gapic/netapp_v1/test_net_app.py deleted file mode 100644 index 7068978e200f..000000000000 --- a/owl-bot-staging/google-cloud-netapp/v1/tests/unit/gapic/netapp_v1/test_net_app.py +++ /dev/null @@ -1,46391 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 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.location import locations_pb2 -from google.cloud.netapp_v1.services.net_app import NetAppAsyncClient -from google.cloud.netapp_v1.services.net_app import NetAppClient -from google.cloud.netapp_v1.services.net_app import pagers -from google.cloud.netapp_v1.services.net_app import transports -from google.cloud.netapp_v1.types import active_directory -from google.cloud.netapp_v1.types import active_directory as gcn_active_directory -from google.cloud.netapp_v1.types import backup -from google.cloud.netapp_v1.types import backup as gcn_backup -from google.cloud.netapp_v1.types import backup_policy -from google.cloud.netapp_v1.types import backup_policy as gcn_backup_policy -from google.cloud.netapp_v1.types import backup_vault -from google.cloud.netapp_v1.types import backup_vault as gcn_backup_vault -from google.cloud.netapp_v1.types import cloud_netapp_service -from google.cloud.netapp_v1.types import common -from google.cloud.netapp_v1.types import kms -from google.cloud.netapp_v1.types import quota_rule -from google.cloud.netapp_v1.types import quota_rule as gcn_quota_rule -from google.cloud.netapp_v1.types import replication -from google.cloud.netapp_v1.types import replication as gcn_replication -from google.cloud.netapp_v1.types import snapshot -from google.cloud.netapp_v1.types import snapshot as gcn_snapshot -from google.cloud.netapp_v1.types import storage_pool -from google.cloud.netapp_v1.types import storage_pool as gcn_storage_pool -from google.cloud.netapp_v1.types import volume -from google.cloud.netapp_v1.types import volume as gcn_volume -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 timestamp_pb2 # type: ignore -import google.auth - - - -CRED_INFO_JSON = { - "credential_source": "/path/to/file", - "credential_type": "service account credentials", - "principal": "service-account@example.com", -} -CRED_INFO_STRING = json.dumps(CRED_INFO_JSON) - - -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 NetAppClient._get_default_mtls_endpoint(None) is None - assert NetAppClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert NetAppClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert NetAppClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert NetAppClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert NetAppClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - -def test__read_environment_variables(): - assert NetAppClient._read_environment_variables() == (False, "auto", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - assert NetAppClient._read_environment_variables() == (True, "auto", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): - assert NetAppClient._read_environment_variables() == (False, "auto", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): - with pytest.raises(ValueError) as excinfo: - NetAppClient._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 NetAppClient._read_environment_variables() == (False, "never", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - assert NetAppClient._read_environment_variables() == (False, "always", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}): - assert NetAppClient._read_environment_variables() == (False, "auto", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError) as excinfo: - NetAppClient._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 NetAppClient._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 NetAppClient._get_client_cert_source(None, False) is None - assert NetAppClient._get_client_cert_source(mock_provided_cert_source, False) is None - assert NetAppClient._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 NetAppClient._get_client_cert_source(None, True) is mock_default_cert_source - assert NetAppClient._get_client_cert_source(mock_provided_cert_source, "true") is mock_provided_cert_source - -@mock.patch.object(NetAppClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(NetAppClient)) -@mock.patch.object(NetAppAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(NetAppAsyncClient)) -def test__get_api_endpoint(): - api_override = "foo.com" - mock_client_cert_source = mock.Mock() - default_universe = NetAppClient._DEFAULT_UNIVERSE - default_endpoint = NetAppClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=default_universe) - mock_universe = "bar.com" - mock_endpoint = NetAppClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=mock_universe) - - assert NetAppClient._get_api_endpoint(api_override, mock_client_cert_source, default_universe, "always") == api_override - assert NetAppClient._get_api_endpoint(None, mock_client_cert_source, default_universe, "auto") == NetAppClient.DEFAULT_MTLS_ENDPOINT - assert NetAppClient._get_api_endpoint(None, None, default_universe, "auto") == default_endpoint - assert NetAppClient._get_api_endpoint(None, None, default_universe, "always") == NetAppClient.DEFAULT_MTLS_ENDPOINT - assert NetAppClient._get_api_endpoint(None, mock_client_cert_source, default_universe, "always") == NetAppClient.DEFAULT_MTLS_ENDPOINT - assert NetAppClient._get_api_endpoint(None, None, mock_universe, "never") == mock_endpoint - assert NetAppClient._get_api_endpoint(None, None, default_universe, "never") == default_endpoint - - with pytest.raises(MutualTLSChannelError) as excinfo: - NetAppClient._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 NetAppClient._get_universe_domain(client_universe_domain, universe_domain_env) == client_universe_domain - assert NetAppClient._get_universe_domain(None, universe_domain_env) == universe_domain_env - assert NetAppClient._get_universe_domain(None, None) == NetAppClient._DEFAULT_UNIVERSE - - with pytest.raises(ValueError) as excinfo: - NetAppClient._get_universe_domain("", None) - assert str(excinfo.value) == "Universe Domain cannot be an empty string." - -@pytest.mark.parametrize("error_code,cred_info_json,show_cred_info", [ - (401, CRED_INFO_JSON, True), - (403, CRED_INFO_JSON, True), - (404, CRED_INFO_JSON, True), - (500, CRED_INFO_JSON, False), - (401, None, False), - (403, None, False), - (404, None, False), - (500, None, False) -]) -def test__add_cred_info_for_auth_errors(error_code, cred_info_json, show_cred_info): - cred = mock.Mock(["get_cred_info"]) - cred.get_cred_info = mock.Mock(return_value=cred_info_json) - client = NetAppClient(credentials=cred) - client._transport._credentials = cred - - error = core_exceptions.GoogleAPICallError("message", details=["foo"]) - error.code = error_code - - client._add_cred_info_for_auth_errors(error) - if show_cred_info: - assert error.details == ["foo", CRED_INFO_STRING] - else: - assert error.details == ["foo"] - -@pytest.mark.parametrize("error_code", [401,403,404,500]) -def test__add_cred_info_for_auth_errors_no_get_cred_info(error_code): - cred = mock.Mock([]) - assert not hasattr(cred, "get_cred_info") - client = NetAppClient(credentials=cred) - client._transport._credentials = cred - - error = core_exceptions.GoogleAPICallError("message", details=[]) - error.code = error_code - - client._add_cred_info_for_auth_errors(error) - assert error.details == [] - -@pytest.mark.parametrize("client_class,transport_name", [ - (NetAppClient, "grpc"), - (NetAppAsyncClient, "grpc_asyncio"), - (NetAppClient, "rest"), -]) -def test_net_app_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 == ( - 'netapp.googleapis.com:443' - if transport_name in ['grpc', 'grpc_asyncio'] - else - 'https://netapp.googleapis.com' - ) - - -@pytest.mark.parametrize("transport_class,transport_name", [ - (transports.NetAppGrpcTransport, "grpc"), - (transports.NetAppGrpcAsyncIOTransport, "grpc_asyncio"), - (transports.NetAppRestTransport, "rest"), -]) -def test_net_app_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", [ - (NetAppClient, "grpc"), - (NetAppAsyncClient, "grpc_asyncio"), - (NetAppClient, "rest"), -]) -def test_net_app_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 == ( - 'netapp.googleapis.com:443' - if transport_name in ['grpc', 'grpc_asyncio'] - else - 'https://netapp.googleapis.com' - ) - - -def test_net_app_client_get_transport_class(): - transport = NetAppClient.get_transport_class() - available_transports = [ - transports.NetAppGrpcTransport, - transports.NetAppRestTransport, - ] - assert transport in available_transports - - transport = NetAppClient.get_transport_class("grpc") - assert transport == transports.NetAppGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (NetAppClient, transports.NetAppGrpcTransport, "grpc"), - (NetAppAsyncClient, transports.NetAppGrpcAsyncIOTransport, "grpc_asyncio"), - (NetAppClient, transports.NetAppRestTransport, "rest"), -]) -@mock.patch.object(NetAppClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(NetAppClient)) -@mock.patch.object(NetAppAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(NetAppAsyncClient)) -def test_net_app_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(NetAppClient, '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(NetAppClient, '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", [ - (NetAppClient, transports.NetAppGrpcTransport, "grpc", "true"), - (NetAppAsyncClient, transports.NetAppGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (NetAppClient, transports.NetAppGrpcTransport, "grpc", "false"), - (NetAppAsyncClient, transports.NetAppGrpcAsyncIOTransport, "grpc_asyncio", "false"), - (NetAppClient, transports.NetAppRestTransport, "rest", "true"), - (NetAppClient, transports.NetAppRestTransport, "rest", "false"), -]) -@mock.patch.object(NetAppClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(NetAppClient)) -@mock.patch.object(NetAppAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(NetAppAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_net_app_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", [ - NetAppClient, NetAppAsyncClient -]) -@mock.patch.object(NetAppClient, "DEFAULT_ENDPOINT", modify_default_endpoint(NetAppClient)) -@mock.patch.object(NetAppAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(NetAppAsyncClient)) -def test_net_app_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", [ - NetAppClient, NetAppAsyncClient -]) -@mock.patch.object(NetAppClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(NetAppClient)) -@mock.patch.object(NetAppAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(NetAppAsyncClient)) -def test_net_app_client_client_api_endpoint(client_class): - mock_client_cert_source = client_cert_source_callback - api_override = "foo.com" - default_universe = NetAppClient._DEFAULT_UNIVERSE - default_endpoint = NetAppClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=default_universe) - mock_universe = "bar.com" - mock_endpoint = NetAppClient._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", [ - (NetAppClient, transports.NetAppGrpcTransport, "grpc"), - (NetAppAsyncClient, transports.NetAppGrpcAsyncIOTransport, "grpc_asyncio"), - (NetAppClient, transports.NetAppRestTransport, "rest"), -]) -def test_net_app_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", [ - (NetAppClient, transports.NetAppGrpcTransport, "grpc", grpc_helpers), - (NetAppAsyncClient, transports.NetAppGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), - (NetAppClient, transports.NetAppRestTransport, "rest", None), -]) -def test_net_app_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_net_app_client_client_options_from_dict(): - with mock.patch('google.cloud.netapp_v1.services.net_app.transports.NetAppGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = NetAppClient( - 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", [ - (NetAppClient, transports.NetAppGrpcTransport, "grpc", grpc_helpers), - (NetAppAsyncClient, transports.NetAppGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_net_app_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( - "netapp.googleapis.com:443", - credentials=file_creds, - credentials_file=None, - quota_project_id=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - scopes=None, - default_host="netapp.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize("request_type", [ - storage_pool.ListStoragePoolsRequest, - dict, -]) -def test_list_storage_pools(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_storage_pools), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = storage_pool.ListStoragePoolsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_storage_pools(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = storage_pool.ListStoragePoolsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListStoragePoolsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_storage_pools_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 = NetAppClient( - 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 = storage_pool.ListStoragePoolsRequest( - 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_storage_pools), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_storage_pools(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == storage_pool.ListStoragePoolsRequest( - parent='parent_value', - page_token='page_token_value', - order_by='order_by_value', - filter='filter_value', - ) - -def test_list_storage_pools_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 = NetAppClient( - 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_storage_pools 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_storage_pools] = mock_rpc - request = {} - client.list_storage_pools(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_storage_pools(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_storage_pools_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 = NetAppAsyncClient( - 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_storage_pools 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_storage_pools] = mock_rpc - - request = {} - await client.list_storage_pools(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_storage_pools(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_storage_pools_async(transport: str = 'grpc_asyncio', request_type=storage_pool.ListStoragePoolsRequest): - client = NetAppAsyncClient( - 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_storage_pools), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(storage_pool.ListStoragePoolsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_storage_pools(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = storage_pool.ListStoragePoolsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListStoragePoolsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_storage_pools_async_from_dict(): - await test_list_storage_pools_async(request_type=dict) - -def test_list_storage_pools_field_headers(): - client = NetAppClient( - 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 = storage_pool.ListStoragePoolsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_storage_pools), - '__call__') as call: - call.return_value = storage_pool.ListStoragePoolsResponse() - client.list_storage_pools(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_storage_pools_field_headers_async(): - client = NetAppAsyncClient( - 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 = storage_pool.ListStoragePoolsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_storage_pools), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(storage_pool.ListStoragePoolsResponse()) - await client.list_storage_pools(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_storage_pools_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_storage_pools), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = storage_pool.ListStoragePoolsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_storage_pools( - 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_storage_pools_flattened_error(): - client = NetAppClient( - 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_storage_pools( - storage_pool.ListStoragePoolsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_storage_pools_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_storage_pools), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = storage_pool.ListStoragePoolsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(storage_pool.ListStoragePoolsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_storage_pools( - 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_storage_pools_flattened_error_async(): - client = NetAppAsyncClient( - 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_storage_pools( - storage_pool.ListStoragePoolsRequest(), - parent='parent_value', - ) - - -def test_list_storage_pools_pager(transport_name: str = "grpc"): - client = NetAppClient( - 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_storage_pools), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - storage_pool.ListStoragePoolsResponse( - storage_pools=[ - storage_pool.StoragePool(), - storage_pool.StoragePool(), - storage_pool.StoragePool(), - ], - next_page_token='abc', - ), - storage_pool.ListStoragePoolsResponse( - storage_pools=[], - next_page_token='def', - ), - storage_pool.ListStoragePoolsResponse( - storage_pools=[ - storage_pool.StoragePool(), - ], - next_page_token='ghi', - ), - storage_pool.ListStoragePoolsResponse( - storage_pools=[ - storage_pool.StoragePool(), - storage_pool.StoragePool(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_storage_pools(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, storage_pool.StoragePool) - for i in results) -def test_list_storage_pools_pages(transport_name: str = "grpc"): - client = NetAppClient( - 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_storage_pools), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - storage_pool.ListStoragePoolsResponse( - storage_pools=[ - storage_pool.StoragePool(), - storage_pool.StoragePool(), - storage_pool.StoragePool(), - ], - next_page_token='abc', - ), - storage_pool.ListStoragePoolsResponse( - storage_pools=[], - next_page_token='def', - ), - storage_pool.ListStoragePoolsResponse( - storage_pools=[ - storage_pool.StoragePool(), - ], - next_page_token='ghi', - ), - storage_pool.ListStoragePoolsResponse( - storage_pools=[ - storage_pool.StoragePool(), - storage_pool.StoragePool(), - ], - ), - RuntimeError, - ) - pages = list(client.list_storage_pools(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_storage_pools_async_pager(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_storage_pools), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - storage_pool.ListStoragePoolsResponse( - storage_pools=[ - storage_pool.StoragePool(), - storage_pool.StoragePool(), - storage_pool.StoragePool(), - ], - next_page_token='abc', - ), - storage_pool.ListStoragePoolsResponse( - storage_pools=[], - next_page_token='def', - ), - storage_pool.ListStoragePoolsResponse( - storage_pools=[ - storage_pool.StoragePool(), - ], - next_page_token='ghi', - ), - storage_pool.ListStoragePoolsResponse( - storage_pools=[ - storage_pool.StoragePool(), - storage_pool.StoragePool(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_storage_pools(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, storage_pool.StoragePool) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_storage_pools_async_pages(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_storage_pools), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - storage_pool.ListStoragePoolsResponse( - storage_pools=[ - storage_pool.StoragePool(), - storage_pool.StoragePool(), - storage_pool.StoragePool(), - ], - next_page_token='abc', - ), - storage_pool.ListStoragePoolsResponse( - storage_pools=[], - next_page_token='def', - ), - storage_pool.ListStoragePoolsResponse( - storage_pools=[ - storage_pool.StoragePool(), - ], - next_page_token='ghi', - ), - storage_pool.ListStoragePoolsResponse( - storage_pools=[ - storage_pool.StoragePool(), - storage_pool.StoragePool(), - ], - ), - 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_storage_pools(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", [ - gcn_storage_pool.CreateStoragePoolRequest, - dict, -]) -def test_create_storage_pool(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_storage_pool), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_storage_pool(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gcn_storage_pool.CreateStoragePoolRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_storage_pool_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 = NetAppClient( - 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 = gcn_storage_pool.CreateStoragePoolRequest( - parent='parent_value', - storage_pool_id='storage_pool_id_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_storage_pool), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_storage_pool(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gcn_storage_pool.CreateStoragePoolRequest( - parent='parent_value', - storage_pool_id='storage_pool_id_value', - ) - -def test_create_storage_pool_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 = NetAppClient( - 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_storage_pool 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_storage_pool] = mock_rpc - request = {} - client.create_storage_pool(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_storage_pool(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_storage_pool_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 = NetAppAsyncClient( - 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_storage_pool 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_storage_pool] = mock_rpc - - request = {} - await client.create_storage_pool(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_storage_pool(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_storage_pool_async(transport: str = 'grpc_asyncio', request_type=gcn_storage_pool.CreateStoragePoolRequest): - client = NetAppAsyncClient( - 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_storage_pool), - '__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_storage_pool(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gcn_storage_pool.CreateStoragePoolRequest() - 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_storage_pool_async_from_dict(): - await test_create_storage_pool_async(request_type=dict) - -def test_create_storage_pool_field_headers(): - client = NetAppClient( - 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 = gcn_storage_pool.CreateStoragePoolRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_storage_pool), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_storage_pool(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_storage_pool_field_headers_async(): - client = NetAppAsyncClient( - 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 = gcn_storage_pool.CreateStoragePoolRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_storage_pool), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_storage_pool(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_storage_pool_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_storage_pool), - '__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_storage_pool( - parent='parent_value', - storage_pool=gcn_storage_pool.StoragePool(name='name_value'), - storage_pool_id='storage_pool_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].storage_pool - mock_val = gcn_storage_pool.StoragePool(name='name_value') - assert arg == mock_val - arg = args[0].storage_pool_id - mock_val = 'storage_pool_id_value' - assert arg == mock_val - - -def test_create_storage_pool_flattened_error(): - client = NetAppClient( - 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_storage_pool( - gcn_storage_pool.CreateStoragePoolRequest(), - parent='parent_value', - storage_pool=gcn_storage_pool.StoragePool(name='name_value'), - storage_pool_id='storage_pool_id_value', - ) - -@pytest.mark.asyncio -async def test_create_storage_pool_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_storage_pool), - '__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_storage_pool( - parent='parent_value', - storage_pool=gcn_storage_pool.StoragePool(name='name_value'), - storage_pool_id='storage_pool_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].storage_pool - mock_val = gcn_storage_pool.StoragePool(name='name_value') - assert arg == mock_val - arg = args[0].storage_pool_id - mock_val = 'storage_pool_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_storage_pool_flattened_error_async(): - client = NetAppAsyncClient( - 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_storage_pool( - gcn_storage_pool.CreateStoragePoolRequest(), - parent='parent_value', - storage_pool=gcn_storage_pool.StoragePool(name='name_value'), - storage_pool_id='storage_pool_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - storage_pool.GetStoragePoolRequest, - dict, -]) -def test_get_storage_pool(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_storage_pool), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = storage_pool.StoragePool( - name='name_value', - service_level=common.ServiceLevel.PREMIUM, - capacity_gib=1247, - volume_capacity_gib=2006, - volume_count=1312, - state=storage_pool.StoragePool.State.READY, - state_details='state_details_value', - description='description_value', - network='network_value', - active_directory='active_directory_value', - kms_config='kms_config_value', - ldap_enabled=True, - psa_range='psa_range_value', - encryption_type=common.EncryptionType.SERVICE_MANAGED, - global_access_allowed=True, - allow_auto_tiering=True, - replica_zone='replica_zone_value', - zone='zone_value', - satisfies_pzs=True, - satisfies_pzi=True, - ) - response = client.get_storage_pool(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = storage_pool.GetStoragePoolRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, storage_pool.StoragePool) - assert response.name == 'name_value' - assert response.service_level == common.ServiceLevel.PREMIUM - assert response.capacity_gib == 1247 - assert response.volume_capacity_gib == 2006 - assert response.volume_count == 1312 - assert response.state == storage_pool.StoragePool.State.READY - assert response.state_details == 'state_details_value' - assert response.description == 'description_value' - assert response.network == 'network_value' - assert response.active_directory == 'active_directory_value' - assert response.kms_config == 'kms_config_value' - assert response.ldap_enabled is True - assert response.psa_range == 'psa_range_value' - assert response.encryption_type == common.EncryptionType.SERVICE_MANAGED - assert response.global_access_allowed is True - assert response.allow_auto_tiering is True - assert response.replica_zone == 'replica_zone_value' - assert response.zone == 'zone_value' - assert response.satisfies_pzs is True - assert response.satisfies_pzi is True - - -def test_get_storage_pool_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 = NetAppClient( - 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 = storage_pool.GetStoragePoolRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_storage_pool), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_storage_pool(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == storage_pool.GetStoragePoolRequest( - name='name_value', - ) - -def test_get_storage_pool_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 = NetAppClient( - 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_storage_pool 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_storage_pool] = mock_rpc - request = {} - client.get_storage_pool(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_storage_pool(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_storage_pool_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 = NetAppAsyncClient( - 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_storage_pool 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_storage_pool] = mock_rpc - - request = {} - await client.get_storage_pool(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_storage_pool(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_storage_pool_async(transport: str = 'grpc_asyncio', request_type=storage_pool.GetStoragePoolRequest): - client = NetAppAsyncClient( - 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_storage_pool), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(storage_pool.StoragePool( - name='name_value', - service_level=common.ServiceLevel.PREMIUM, - capacity_gib=1247, - volume_capacity_gib=2006, - volume_count=1312, - state=storage_pool.StoragePool.State.READY, - state_details='state_details_value', - description='description_value', - network='network_value', - active_directory='active_directory_value', - kms_config='kms_config_value', - ldap_enabled=True, - psa_range='psa_range_value', - encryption_type=common.EncryptionType.SERVICE_MANAGED, - global_access_allowed=True, - allow_auto_tiering=True, - replica_zone='replica_zone_value', - zone='zone_value', - satisfies_pzs=True, - satisfies_pzi=True, - )) - response = await client.get_storage_pool(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = storage_pool.GetStoragePoolRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, storage_pool.StoragePool) - assert response.name == 'name_value' - assert response.service_level == common.ServiceLevel.PREMIUM - assert response.capacity_gib == 1247 - assert response.volume_capacity_gib == 2006 - assert response.volume_count == 1312 - assert response.state == storage_pool.StoragePool.State.READY - assert response.state_details == 'state_details_value' - assert response.description == 'description_value' - assert response.network == 'network_value' - assert response.active_directory == 'active_directory_value' - assert response.kms_config == 'kms_config_value' - assert response.ldap_enabled is True - assert response.psa_range == 'psa_range_value' - assert response.encryption_type == common.EncryptionType.SERVICE_MANAGED - assert response.global_access_allowed is True - assert response.allow_auto_tiering is True - assert response.replica_zone == 'replica_zone_value' - assert response.zone == 'zone_value' - assert response.satisfies_pzs is True - assert response.satisfies_pzi is True - - -@pytest.mark.asyncio -async def test_get_storage_pool_async_from_dict(): - await test_get_storage_pool_async(request_type=dict) - -def test_get_storage_pool_field_headers(): - client = NetAppClient( - 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 = storage_pool.GetStoragePoolRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_storage_pool), - '__call__') as call: - call.return_value = storage_pool.StoragePool() - client.get_storage_pool(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_storage_pool_field_headers_async(): - client = NetAppAsyncClient( - 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 = storage_pool.GetStoragePoolRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_storage_pool), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(storage_pool.StoragePool()) - await client.get_storage_pool(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_storage_pool_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_storage_pool), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = storage_pool.StoragePool() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_storage_pool( - 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_storage_pool_flattened_error(): - client = NetAppClient( - 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_storage_pool( - storage_pool.GetStoragePoolRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_storage_pool_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_storage_pool), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = storage_pool.StoragePool() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(storage_pool.StoragePool()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_storage_pool( - 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_storage_pool_flattened_error_async(): - client = NetAppAsyncClient( - 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_storage_pool( - storage_pool.GetStoragePoolRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - gcn_storage_pool.UpdateStoragePoolRequest, - dict, -]) -def test_update_storage_pool(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_storage_pool), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_storage_pool(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gcn_storage_pool.UpdateStoragePoolRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_storage_pool_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 = NetAppClient( - 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 = gcn_storage_pool.UpdateStoragePoolRequest( - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_storage_pool), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_storage_pool(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gcn_storage_pool.UpdateStoragePoolRequest( - ) - -def test_update_storage_pool_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 = NetAppClient( - 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_storage_pool 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_storage_pool] = mock_rpc - request = {} - client.update_storage_pool(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.update_storage_pool(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_storage_pool_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 = NetAppAsyncClient( - 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_storage_pool 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_storage_pool] = mock_rpc - - request = {} - await client.update_storage_pool(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.update_storage_pool(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_storage_pool_async(transport: str = 'grpc_asyncio', request_type=gcn_storage_pool.UpdateStoragePoolRequest): - client = NetAppAsyncClient( - 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_storage_pool), - '__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.update_storage_pool(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gcn_storage_pool.UpdateStoragePoolRequest() - 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_update_storage_pool_async_from_dict(): - await test_update_storage_pool_async(request_type=dict) - -def test_update_storage_pool_field_headers(): - client = NetAppClient( - 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 = gcn_storage_pool.UpdateStoragePoolRequest() - - request.storage_pool.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_storage_pool), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_storage_pool(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', - 'storage_pool.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_storage_pool_field_headers_async(): - client = NetAppAsyncClient( - 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 = gcn_storage_pool.UpdateStoragePoolRequest() - - request.storage_pool.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_storage_pool), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_storage_pool(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', - 'storage_pool.name=name_value', - ) in kw['metadata'] - - -def test_update_storage_pool_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_storage_pool), - '__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.update_storage_pool( - storage_pool=gcn_storage_pool.StoragePool(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].storage_pool - mock_val = gcn_storage_pool.StoragePool(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_storage_pool_flattened_error(): - client = NetAppClient( - 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_storage_pool( - gcn_storage_pool.UpdateStoragePoolRequest(), - storage_pool=gcn_storage_pool.StoragePool(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_storage_pool_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_storage_pool), - '__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.update_storage_pool( - storage_pool=gcn_storage_pool.StoragePool(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].storage_pool - mock_val = gcn_storage_pool.StoragePool(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_storage_pool_flattened_error_async(): - client = NetAppAsyncClient( - 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_storage_pool( - gcn_storage_pool.UpdateStoragePoolRequest(), - storage_pool=gcn_storage_pool.StoragePool(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - storage_pool.DeleteStoragePoolRequest, - dict, -]) -def test_delete_storage_pool(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_storage_pool), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_storage_pool(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = storage_pool.DeleteStoragePoolRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_storage_pool_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 = NetAppClient( - 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 = storage_pool.DeleteStoragePoolRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_storage_pool), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_storage_pool(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == storage_pool.DeleteStoragePoolRequest( - name='name_value', - ) - -def test_delete_storage_pool_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 = NetAppClient( - 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_storage_pool 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_storage_pool] = mock_rpc - request = {} - client.delete_storage_pool(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_storage_pool(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_storage_pool_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 = NetAppAsyncClient( - 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_storage_pool 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_storage_pool] = mock_rpc - - request = {} - await client.delete_storage_pool(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_storage_pool(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_storage_pool_async(transport: str = 'grpc_asyncio', request_type=storage_pool.DeleteStoragePoolRequest): - client = NetAppAsyncClient( - 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_storage_pool), - '__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_storage_pool(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = storage_pool.DeleteStoragePoolRequest() - 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_storage_pool_async_from_dict(): - await test_delete_storage_pool_async(request_type=dict) - -def test_delete_storage_pool_field_headers(): - client = NetAppClient( - 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 = storage_pool.DeleteStoragePoolRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_storage_pool), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_storage_pool(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_storage_pool_field_headers_async(): - client = NetAppAsyncClient( - 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 = storage_pool.DeleteStoragePoolRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_storage_pool), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_storage_pool(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_storage_pool_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_storage_pool), - '__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_storage_pool( - 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_storage_pool_flattened_error(): - client = NetAppClient( - 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_storage_pool( - storage_pool.DeleteStoragePoolRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_storage_pool_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_storage_pool), - '__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_storage_pool( - 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_storage_pool_flattened_error_async(): - client = NetAppAsyncClient( - 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_storage_pool( - storage_pool.DeleteStoragePoolRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - storage_pool.ValidateDirectoryServiceRequest, - dict, -]) -def test_validate_directory_service(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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.validate_directory_service), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.validate_directory_service(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = storage_pool.ValidateDirectoryServiceRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_validate_directory_service_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 = NetAppClient( - 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 = storage_pool.ValidateDirectoryServiceRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.validate_directory_service), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.validate_directory_service(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == storage_pool.ValidateDirectoryServiceRequest( - name='name_value', - ) - -def test_validate_directory_service_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 = NetAppClient( - 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.validate_directory_service 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.validate_directory_service] = mock_rpc - request = {} - client.validate_directory_service(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.validate_directory_service(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_validate_directory_service_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 = NetAppAsyncClient( - 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.validate_directory_service 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.validate_directory_service] = mock_rpc - - request = {} - await client.validate_directory_service(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.validate_directory_service(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_validate_directory_service_async(transport: str = 'grpc_asyncio', request_type=storage_pool.ValidateDirectoryServiceRequest): - client = NetAppAsyncClient( - 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.validate_directory_service), - '__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.validate_directory_service(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = storage_pool.ValidateDirectoryServiceRequest() - 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_validate_directory_service_async_from_dict(): - await test_validate_directory_service_async(request_type=dict) - -def test_validate_directory_service_field_headers(): - client = NetAppClient( - 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 = storage_pool.ValidateDirectoryServiceRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.validate_directory_service), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.validate_directory_service(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_validate_directory_service_field_headers_async(): - client = NetAppAsyncClient( - 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 = storage_pool.ValidateDirectoryServiceRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.validate_directory_service), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.validate_directory_service(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'] - - -@pytest.mark.parametrize("request_type", [ - storage_pool.SwitchActiveReplicaZoneRequest, - dict, -]) -def test_switch_active_replica_zone(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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.switch_active_replica_zone), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.switch_active_replica_zone(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = storage_pool.SwitchActiveReplicaZoneRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_switch_active_replica_zone_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 = NetAppClient( - 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 = storage_pool.SwitchActiveReplicaZoneRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.switch_active_replica_zone), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.switch_active_replica_zone(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == storage_pool.SwitchActiveReplicaZoneRequest( - name='name_value', - ) - -def test_switch_active_replica_zone_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 = NetAppClient( - 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.switch_active_replica_zone 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.switch_active_replica_zone] = mock_rpc - request = {} - client.switch_active_replica_zone(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.switch_active_replica_zone(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_switch_active_replica_zone_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 = NetAppAsyncClient( - 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.switch_active_replica_zone 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.switch_active_replica_zone] = mock_rpc - - request = {} - await client.switch_active_replica_zone(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.switch_active_replica_zone(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_switch_active_replica_zone_async(transport: str = 'grpc_asyncio', request_type=storage_pool.SwitchActiveReplicaZoneRequest): - client = NetAppAsyncClient( - 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.switch_active_replica_zone), - '__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.switch_active_replica_zone(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = storage_pool.SwitchActiveReplicaZoneRequest() - 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_switch_active_replica_zone_async_from_dict(): - await test_switch_active_replica_zone_async(request_type=dict) - -def test_switch_active_replica_zone_field_headers(): - client = NetAppClient( - 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 = storage_pool.SwitchActiveReplicaZoneRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.switch_active_replica_zone), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.switch_active_replica_zone(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_switch_active_replica_zone_field_headers_async(): - client = NetAppAsyncClient( - 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 = storage_pool.SwitchActiveReplicaZoneRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.switch_active_replica_zone), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.switch_active_replica_zone(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'] - - -@pytest.mark.parametrize("request_type", [ - volume.ListVolumesRequest, - dict, -]) -def test_list_volumes(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_volumes), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = volume.ListVolumesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_volumes(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = volume.ListVolumesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListVolumesPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_volumes_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 = NetAppClient( - 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 = volume.ListVolumesRequest( - 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_volumes), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_volumes(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == volume.ListVolumesRequest( - parent='parent_value', - page_token='page_token_value', - filter='filter_value', - order_by='order_by_value', - ) - -def test_list_volumes_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 = NetAppClient( - 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_volumes 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_volumes] = mock_rpc - request = {} - client.list_volumes(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_volumes(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_volumes_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 = NetAppAsyncClient( - 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_volumes 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_volumes] = mock_rpc - - request = {} - await client.list_volumes(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_volumes(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_volumes_async(transport: str = 'grpc_asyncio', request_type=volume.ListVolumesRequest): - client = NetAppAsyncClient( - 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_volumes), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(volume.ListVolumesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_volumes(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = volume.ListVolumesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListVolumesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_volumes_async_from_dict(): - await test_list_volumes_async(request_type=dict) - -def test_list_volumes_field_headers(): - client = NetAppClient( - 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 = volume.ListVolumesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_volumes), - '__call__') as call: - call.return_value = volume.ListVolumesResponse() - client.list_volumes(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_volumes_field_headers_async(): - client = NetAppAsyncClient( - 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 = volume.ListVolumesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_volumes), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(volume.ListVolumesResponse()) - await client.list_volumes(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_volumes_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_volumes), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = volume.ListVolumesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_volumes( - 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_volumes_flattened_error(): - client = NetAppClient( - 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_volumes( - volume.ListVolumesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_volumes_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_volumes), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = volume.ListVolumesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(volume.ListVolumesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_volumes( - 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_volumes_flattened_error_async(): - client = NetAppAsyncClient( - 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_volumes( - volume.ListVolumesRequest(), - parent='parent_value', - ) - - -def test_list_volumes_pager(transport_name: str = "grpc"): - client = NetAppClient( - 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_volumes), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - volume.ListVolumesResponse( - volumes=[ - volume.Volume(), - volume.Volume(), - volume.Volume(), - ], - next_page_token='abc', - ), - volume.ListVolumesResponse( - volumes=[], - next_page_token='def', - ), - volume.ListVolumesResponse( - volumes=[ - volume.Volume(), - ], - next_page_token='ghi', - ), - volume.ListVolumesResponse( - volumes=[ - volume.Volume(), - volume.Volume(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_volumes(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, volume.Volume) - for i in results) -def test_list_volumes_pages(transport_name: str = "grpc"): - client = NetAppClient( - 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_volumes), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - volume.ListVolumesResponse( - volumes=[ - volume.Volume(), - volume.Volume(), - volume.Volume(), - ], - next_page_token='abc', - ), - volume.ListVolumesResponse( - volumes=[], - next_page_token='def', - ), - volume.ListVolumesResponse( - volumes=[ - volume.Volume(), - ], - next_page_token='ghi', - ), - volume.ListVolumesResponse( - volumes=[ - volume.Volume(), - volume.Volume(), - ], - ), - RuntimeError, - ) - pages = list(client.list_volumes(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_volumes_async_pager(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_volumes), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - volume.ListVolumesResponse( - volumes=[ - volume.Volume(), - volume.Volume(), - volume.Volume(), - ], - next_page_token='abc', - ), - volume.ListVolumesResponse( - volumes=[], - next_page_token='def', - ), - volume.ListVolumesResponse( - volumes=[ - volume.Volume(), - ], - next_page_token='ghi', - ), - volume.ListVolumesResponse( - volumes=[ - volume.Volume(), - volume.Volume(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_volumes(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, volume.Volume) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_volumes_async_pages(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_volumes), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - volume.ListVolumesResponse( - volumes=[ - volume.Volume(), - volume.Volume(), - volume.Volume(), - ], - next_page_token='abc', - ), - volume.ListVolumesResponse( - volumes=[], - next_page_token='def', - ), - volume.ListVolumesResponse( - volumes=[ - volume.Volume(), - ], - next_page_token='ghi', - ), - volume.ListVolumesResponse( - volumes=[ - volume.Volume(), - volume.Volume(), - ], - ), - 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_volumes(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", [ - volume.GetVolumeRequest, - dict, -]) -def test_get_volume(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_volume), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = volume.Volume( - name='name_value', - state=volume.Volume.State.READY, - state_details='state_details_value', - share_name='share_name_value', - psa_range='psa_range_value', - storage_pool='storage_pool_value', - network='network_value', - service_level=common.ServiceLevel.PREMIUM, - capacity_gib=1247, - protocols=[volume.Protocols.NFSV3], - smb_settings=[volume.SMBSettings.ENCRYPT_DATA], - unix_permissions='unix_permissions_value', - description='description_value', - snap_reserve=0.1293, - snapshot_directory=True, - used_gib=834, - security_style=volume.SecurityStyle.NTFS, - kerberos_enabled=True, - ldap_enabled=True, - active_directory='active_directory_value', - kms_config='kms_config_value', - encryption_type=common.EncryptionType.SERVICE_MANAGED, - has_replication=True, - restricted_actions=[volume.RestrictedAction.DELETE], - large_capacity=True, - multiple_endpoints=True, - replica_zone='replica_zone_value', - zone='zone_value', - cold_tier_size_gib=1888, - ) - response = client.get_volume(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = volume.GetVolumeRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, volume.Volume) - assert response.name == 'name_value' - assert response.state == volume.Volume.State.READY - assert response.state_details == 'state_details_value' - assert response.share_name == 'share_name_value' - assert response.psa_range == 'psa_range_value' - assert response.storage_pool == 'storage_pool_value' - assert response.network == 'network_value' - assert response.service_level == common.ServiceLevel.PREMIUM - assert response.capacity_gib == 1247 - assert response.protocols == [volume.Protocols.NFSV3] - assert response.smb_settings == [volume.SMBSettings.ENCRYPT_DATA] - assert response.unix_permissions == 'unix_permissions_value' - assert response.description == 'description_value' - assert math.isclose(response.snap_reserve, 0.1293, rel_tol=1e-6) - assert response.snapshot_directory is True - assert response.used_gib == 834 - assert response.security_style == volume.SecurityStyle.NTFS - assert response.kerberos_enabled is True - assert response.ldap_enabled is True - assert response.active_directory == 'active_directory_value' - assert response.kms_config == 'kms_config_value' - assert response.encryption_type == common.EncryptionType.SERVICE_MANAGED - assert response.has_replication is True - assert response.restricted_actions == [volume.RestrictedAction.DELETE] - assert response.large_capacity is True - assert response.multiple_endpoints is True - assert response.replica_zone == 'replica_zone_value' - assert response.zone == 'zone_value' - assert response.cold_tier_size_gib == 1888 - - -def test_get_volume_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 = NetAppClient( - 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 = volume.GetVolumeRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_volume), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_volume(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == volume.GetVolumeRequest( - name='name_value', - ) - -def test_get_volume_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 = NetAppClient( - 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_volume 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_volume] = mock_rpc - request = {} - client.get_volume(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_volume(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_volume_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 = NetAppAsyncClient( - 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_volume 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_volume] = mock_rpc - - request = {} - await client.get_volume(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_volume(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_volume_async(transport: str = 'grpc_asyncio', request_type=volume.GetVolumeRequest): - client = NetAppAsyncClient( - 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_volume), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(volume.Volume( - name='name_value', - state=volume.Volume.State.READY, - state_details='state_details_value', - share_name='share_name_value', - psa_range='psa_range_value', - storage_pool='storage_pool_value', - network='network_value', - service_level=common.ServiceLevel.PREMIUM, - capacity_gib=1247, - protocols=[volume.Protocols.NFSV3], - smb_settings=[volume.SMBSettings.ENCRYPT_DATA], - unix_permissions='unix_permissions_value', - description='description_value', - snap_reserve=0.1293, - snapshot_directory=True, - used_gib=834, - security_style=volume.SecurityStyle.NTFS, - kerberos_enabled=True, - ldap_enabled=True, - active_directory='active_directory_value', - kms_config='kms_config_value', - encryption_type=common.EncryptionType.SERVICE_MANAGED, - has_replication=True, - restricted_actions=[volume.RestrictedAction.DELETE], - large_capacity=True, - multiple_endpoints=True, - replica_zone='replica_zone_value', - zone='zone_value', - cold_tier_size_gib=1888, - )) - response = await client.get_volume(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = volume.GetVolumeRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, volume.Volume) - assert response.name == 'name_value' - assert response.state == volume.Volume.State.READY - assert response.state_details == 'state_details_value' - assert response.share_name == 'share_name_value' - assert response.psa_range == 'psa_range_value' - assert response.storage_pool == 'storage_pool_value' - assert response.network == 'network_value' - assert response.service_level == common.ServiceLevel.PREMIUM - assert response.capacity_gib == 1247 - assert response.protocols == [volume.Protocols.NFSV3] - assert response.smb_settings == [volume.SMBSettings.ENCRYPT_DATA] - assert response.unix_permissions == 'unix_permissions_value' - assert response.description == 'description_value' - assert math.isclose(response.snap_reserve, 0.1293, rel_tol=1e-6) - assert response.snapshot_directory is True - assert response.used_gib == 834 - assert response.security_style == volume.SecurityStyle.NTFS - assert response.kerberos_enabled is True - assert response.ldap_enabled is True - assert response.active_directory == 'active_directory_value' - assert response.kms_config == 'kms_config_value' - assert response.encryption_type == common.EncryptionType.SERVICE_MANAGED - assert response.has_replication is True - assert response.restricted_actions == [volume.RestrictedAction.DELETE] - assert response.large_capacity is True - assert response.multiple_endpoints is True - assert response.replica_zone == 'replica_zone_value' - assert response.zone == 'zone_value' - assert response.cold_tier_size_gib == 1888 - - -@pytest.mark.asyncio -async def test_get_volume_async_from_dict(): - await test_get_volume_async(request_type=dict) - -def test_get_volume_field_headers(): - client = NetAppClient( - 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 = volume.GetVolumeRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_volume), - '__call__') as call: - call.return_value = volume.Volume() - client.get_volume(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_volume_field_headers_async(): - client = NetAppAsyncClient( - 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 = volume.GetVolumeRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_volume), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(volume.Volume()) - await client.get_volume(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_volume_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_volume), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = volume.Volume() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_volume( - 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_volume_flattened_error(): - client = NetAppClient( - 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_volume( - volume.GetVolumeRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_volume_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_volume), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = volume.Volume() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(volume.Volume()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_volume( - 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_volume_flattened_error_async(): - client = NetAppAsyncClient( - 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_volume( - volume.GetVolumeRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - gcn_volume.CreateVolumeRequest, - dict, -]) -def test_create_volume(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_volume), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_volume(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gcn_volume.CreateVolumeRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_volume_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 = NetAppClient( - 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 = gcn_volume.CreateVolumeRequest( - parent='parent_value', - volume_id='volume_id_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_volume), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_volume(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gcn_volume.CreateVolumeRequest( - parent='parent_value', - volume_id='volume_id_value', - ) - -def test_create_volume_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 = NetAppClient( - 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_volume 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_volume] = mock_rpc - request = {} - client.create_volume(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_volume(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_volume_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 = NetAppAsyncClient( - 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_volume 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_volume] = mock_rpc - - request = {} - await client.create_volume(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_volume(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_volume_async(transport: str = 'grpc_asyncio', request_type=gcn_volume.CreateVolumeRequest): - client = NetAppAsyncClient( - 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_volume), - '__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_volume(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gcn_volume.CreateVolumeRequest() - 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_volume_async_from_dict(): - await test_create_volume_async(request_type=dict) - -def test_create_volume_field_headers(): - client = NetAppClient( - 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 = gcn_volume.CreateVolumeRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_volume), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_volume(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_volume_field_headers_async(): - client = NetAppAsyncClient( - 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 = gcn_volume.CreateVolumeRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_volume), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_volume(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_volume_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_volume), - '__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_volume( - parent='parent_value', - volume=gcn_volume.Volume(name='name_value'), - volume_id='volume_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].volume - mock_val = gcn_volume.Volume(name='name_value') - assert arg == mock_val - arg = args[0].volume_id - mock_val = 'volume_id_value' - assert arg == mock_val - - -def test_create_volume_flattened_error(): - client = NetAppClient( - 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_volume( - gcn_volume.CreateVolumeRequest(), - parent='parent_value', - volume=gcn_volume.Volume(name='name_value'), - volume_id='volume_id_value', - ) - -@pytest.mark.asyncio -async def test_create_volume_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_volume), - '__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_volume( - parent='parent_value', - volume=gcn_volume.Volume(name='name_value'), - volume_id='volume_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].volume - mock_val = gcn_volume.Volume(name='name_value') - assert arg == mock_val - arg = args[0].volume_id - mock_val = 'volume_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_volume_flattened_error_async(): - client = NetAppAsyncClient( - 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_volume( - gcn_volume.CreateVolumeRequest(), - parent='parent_value', - volume=gcn_volume.Volume(name='name_value'), - volume_id='volume_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - gcn_volume.UpdateVolumeRequest, - dict, -]) -def test_update_volume(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_volume), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_volume(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gcn_volume.UpdateVolumeRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_volume_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 = NetAppClient( - 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 = gcn_volume.UpdateVolumeRequest( - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_volume), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_volume(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gcn_volume.UpdateVolumeRequest( - ) - -def test_update_volume_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 = NetAppClient( - 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_volume 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_volume] = mock_rpc - request = {} - client.update_volume(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.update_volume(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_volume_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 = NetAppAsyncClient( - 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_volume 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_volume] = mock_rpc - - request = {} - await client.update_volume(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.update_volume(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_volume_async(transport: str = 'grpc_asyncio', request_type=gcn_volume.UpdateVolumeRequest): - client = NetAppAsyncClient( - 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_volume), - '__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.update_volume(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gcn_volume.UpdateVolumeRequest() - 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_update_volume_async_from_dict(): - await test_update_volume_async(request_type=dict) - -def test_update_volume_field_headers(): - client = NetAppClient( - 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 = gcn_volume.UpdateVolumeRequest() - - request.volume.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_volume), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_volume(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', - 'volume.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_volume_field_headers_async(): - client = NetAppAsyncClient( - 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 = gcn_volume.UpdateVolumeRequest() - - request.volume.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_volume), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_volume(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', - 'volume.name=name_value', - ) in kw['metadata'] - - -def test_update_volume_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_volume), - '__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.update_volume( - volume=gcn_volume.Volume(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].volume - mock_val = gcn_volume.Volume(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_volume_flattened_error(): - client = NetAppClient( - 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_volume( - gcn_volume.UpdateVolumeRequest(), - volume=gcn_volume.Volume(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_volume_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_volume), - '__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.update_volume( - volume=gcn_volume.Volume(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].volume - mock_val = gcn_volume.Volume(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_volume_flattened_error_async(): - client = NetAppAsyncClient( - 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_volume( - gcn_volume.UpdateVolumeRequest(), - volume=gcn_volume.Volume(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - volume.DeleteVolumeRequest, - dict, -]) -def test_delete_volume(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_volume), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_volume(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = volume.DeleteVolumeRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_volume_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 = NetAppClient( - 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 = volume.DeleteVolumeRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_volume), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_volume(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == volume.DeleteVolumeRequest( - name='name_value', - ) - -def test_delete_volume_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 = NetAppClient( - 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_volume 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_volume] = mock_rpc - request = {} - client.delete_volume(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_volume(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_volume_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 = NetAppAsyncClient( - 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_volume 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_volume] = mock_rpc - - request = {} - await client.delete_volume(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_volume(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_volume_async(transport: str = 'grpc_asyncio', request_type=volume.DeleteVolumeRequest): - client = NetAppAsyncClient( - 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_volume), - '__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_volume(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = volume.DeleteVolumeRequest() - 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_volume_async_from_dict(): - await test_delete_volume_async(request_type=dict) - -def test_delete_volume_field_headers(): - client = NetAppClient( - 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 = volume.DeleteVolumeRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_volume), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_volume(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_volume_field_headers_async(): - client = NetAppAsyncClient( - 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 = volume.DeleteVolumeRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_volume), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_volume(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_volume_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_volume), - '__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_volume( - 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_volume_flattened_error(): - client = NetAppClient( - 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_volume( - volume.DeleteVolumeRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_volume_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_volume), - '__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_volume( - 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_volume_flattened_error_async(): - client = NetAppAsyncClient( - 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_volume( - volume.DeleteVolumeRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - volume.RevertVolumeRequest, - dict, -]) -def test_revert_volume(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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.revert_volume), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.revert_volume(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = volume.RevertVolumeRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_revert_volume_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 = NetAppClient( - 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 = volume.RevertVolumeRequest( - name='name_value', - snapshot_id='snapshot_id_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.revert_volume), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.revert_volume(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == volume.RevertVolumeRequest( - name='name_value', - snapshot_id='snapshot_id_value', - ) - -def test_revert_volume_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 = NetAppClient( - 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.revert_volume 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.revert_volume] = mock_rpc - request = {} - client.revert_volume(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.revert_volume(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_revert_volume_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 = NetAppAsyncClient( - 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.revert_volume 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.revert_volume] = mock_rpc - - request = {} - await client.revert_volume(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.revert_volume(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_revert_volume_async(transport: str = 'grpc_asyncio', request_type=volume.RevertVolumeRequest): - client = NetAppAsyncClient( - 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.revert_volume), - '__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.revert_volume(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = volume.RevertVolumeRequest() - 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_revert_volume_async_from_dict(): - await test_revert_volume_async(request_type=dict) - -def test_revert_volume_field_headers(): - client = NetAppClient( - 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 = volume.RevertVolumeRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.revert_volume), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.revert_volume(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_revert_volume_field_headers_async(): - client = NetAppAsyncClient( - 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 = volume.RevertVolumeRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.revert_volume), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.revert_volume(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'] - - -@pytest.mark.parametrize("request_type", [ - snapshot.ListSnapshotsRequest, - dict, -]) -def test_list_snapshots(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_snapshots), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = snapshot.ListSnapshotsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_snapshots(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = snapshot.ListSnapshotsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListSnapshotsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_snapshots_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 = NetAppClient( - 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 = snapshot.ListSnapshotsRequest( - 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_snapshots), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_snapshots(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == snapshot.ListSnapshotsRequest( - parent='parent_value', - page_token='page_token_value', - order_by='order_by_value', - filter='filter_value', - ) - -def test_list_snapshots_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 = NetAppClient( - 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_snapshots 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_snapshots] = mock_rpc - request = {} - client.list_snapshots(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_snapshots(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_snapshots_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 = NetAppAsyncClient( - 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_snapshots 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_snapshots] = mock_rpc - - request = {} - await client.list_snapshots(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_snapshots(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_snapshots_async(transport: str = 'grpc_asyncio', request_type=snapshot.ListSnapshotsRequest): - client = NetAppAsyncClient( - 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_snapshots), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(snapshot.ListSnapshotsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_snapshots(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = snapshot.ListSnapshotsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListSnapshotsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_snapshots_async_from_dict(): - await test_list_snapshots_async(request_type=dict) - -def test_list_snapshots_field_headers(): - client = NetAppClient( - 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 = snapshot.ListSnapshotsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_snapshots), - '__call__') as call: - call.return_value = snapshot.ListSnapshotsResponse() - client.list_snapshots(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_snapshots_field_headers_async(): - client = NetAppAsyncClient( - 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 = snapshot.ListSnapshotsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_snapshots), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(snapshot.ListSnapshotsResponse()) - await client.list_snapshots(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_snapshots_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_snapshots), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = snapshot.ListSnapshotsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_snapshots( - 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_snapshots_flattened_error(): - client = NetAppClient( - 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_snapshots( - snapshot.ListSnapshotsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_snapshots_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_snapshots), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = snapshot.ListSnapshotsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(snapshot.ListSnapshotsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_snapshots( - 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_snapshots_flattened_error_async(): - client = NetAppAsyncClient( - 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_snapshots( - snapshot.ListSnapshotsRequest(), - parent='parent_value', - ) - - -def test_list_snapshots_pager(transport_name: str = "grpc"): - client = NetAppClient( - 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_snapshots), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - snapshot.ListSnapshotsResponse( - snapshots=[ - snapshot.Snapshot(), - snapshot.Snapshot(), - snapshot.Snapshot(), - ], - next_page_token='abc', - ), - snapshot.ListSnapshotsResponse( - snapshots=[], - next_page_token='def', - ), - snapshot.ListSnapshotsResponse( - snapshots=[ - snapshot.Snapshot(), - ], - next_page_token='ghi', - ), - snapshot.ListSnapshotsResponse( - snapshots=[ - snapshot.Snapshot(), - snapshot.Snapshot(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_snapshots(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, snapshot.Snapshot) - for i in results) -def test_list_snapshots_pages(transport_name: str = "grpc"): - client = NetAppClient( - 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_snapshots), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - snapshot.ListSnapshotsResponse( - snapshots=[ - snapshot.Snapshot(), - snapshot.Snapshot(), - snapshot.Snapshot(), - ], - next_page_token='abc', - ), - snapshot.ListSnapshotsResponse( - snapshots=[], - next_page_token='def', - ), - snapshot.ListSnapshotsResponse( - snapshots=[ - snapshot.Snapshot(), - ], - next_page_token='ghi', - ), - snapshot.ListSnapshotsResponse( - snapshots=[ - snapshot.Snapshot(), - snapshot.Snapshot(), - ], - ), - RuntimeError, - ) - pages = list(client.list_snapshots(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_snapshots_async_pager(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_snapshots), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - snapshot.ListSnapshotsResponse( - snapshots=[ - snapshot.Snapshot(), - snapshot.Snapshot(), - snapshot.Snapshot(), - ], - next_page_token='abc', - ), - snapshot.ListSnapshotsResponse( - snapshots=[], - next_page_token='def', - ), - snapshot.ListSnapshotsResponse( - snapshots=[ - snapshot.Snapshot(), - ], - next_page_token='ghi', - ), - snapshot.ListSnapshotsResponse( - snapshots=[ - snapshot.Snapshot(), - snapshot.Snapshot(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_snapshots(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, snapshot.Snapshot) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_snapshots_async_pages(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_snapshots), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - snapshot.ListSnapshotsResponse( - snapshots=[ - snapshot.Snapshot(), - snapshot.Snapshot(), - snapshot.Snapshot(), - ], - next_page_token='abc', - ), - snapshot.ListSnapshotsResponse( - snapshots=[], - next_page_token='def', - ), - snapshot.ListSnapshotsResponse( - snapshots=[ - snapshot.Snapshot(), - ], - next_page_token='ghi', - ), - snapshot.ListSnapshotsResponse( - snapshots=[ - snapshot.Snapshot(), - snapshot.Snapshot(), - ], - ), - 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_snapshots(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", [ - snapshot.GetSnapshotRequest, - dict, -]) -def test_get_snapshot(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_snapshot), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = snapshot.Snapshot( - name='name_value', - state=snapshot.Snapshot.State.READY, - state_details='state_details_value', - description='description_value', - used_bytes=0.10790000000000001, - ) - response = client.get_snapshot(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = snapshot.GetSnapshotRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, snapshot.Snapshot) - assert response.name == 'name_value' - assert response.state == snapshot.Snapshot.State.READY - assert response.state_details == 'state_details_value' - assert response.description == 'description_value' - assert math.isclose(response.used_bytes, 0.10790000000000001, rel_tol=1e-6) - - -def test_get_snapshot_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 = NetAppClient( - 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 = snapshot.GetSnapshotRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_snapshot), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_snapshot(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == snapshot.GetSnapshotRequest( - name='name_value', - ) - -def test_get_snapshot_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 = NetAppClient( - 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_snapshot 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_snapshot] = mock_rpc - request = {} - client.get_snapshot(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_snapshot(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_snapshot_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 = NetAppAsyncClient( - 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_snapshot 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_snapshot] = mock_rpc - - request = {} - await client.get_snapshot(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_snapshot(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_snapshot_async(transport: str = 'grpc_asyncio', request_type=snapshot.GetSnapshotRequest): - client = NetAppAsyncClient( - 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_snapshot), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(snapshot.Snapshot( - name='name_value', - state=snapshot.Snapshot.State.READY, - state_details='state_details_value', - description='description_value', - used_bytes=0.10790000000000001, - )) - response = await client.get_snapshot(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = snapshot.GetSnapshotRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, snapshot.Snapshot) - assert response.name == 'name_value' - assert response.state == snapshot.Snapshot.State.READY - assert response.state_details == 'state_details_value' - assert response.description == 'description_value' - assert math.isclose(response.used_bytes, 0.10790000000000001, rel_tol=1e-6) - - -@pytest.mark.asyncio -async def test_get_snapshot_async_from_dict(): - await test_get_snapshot_async(request_type=dict) - -def test_get_snapshot_field_headers(): - client = NetAppClient( - 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 = snapshot.GetSnapshotRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_snapshot), - '__call__') as call: - call.return_value = snapshot.Snapshot() - client.get_snapshot(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_snapshot_field_headers_async(): - client = NetAppAsyncClient( - 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 = snapshot.GetSnapshotRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_snapshot), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(snapshot.Snapshot()) - await client.get_snapshot(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_snapshot_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_snapshot), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = snapshot.Snapshot() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_snapshot( - 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_snapshot_flattened_error(): - client = NetAppClient( - 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_snapshot( - snapshot.GetSnapshotRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_snapshot_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_snapshot), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = snapshot.Snapshot() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(snapshot.Snapshot()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_snapshot( - 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_snapshot_flattened_error_async(): - client = NetAppAsyncClient( - 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_snapshot( - snapshot.GetSnapshotRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - gcn_snapshot.CreateSnapshotRequest, - dict, -]) -def test_create_snapshot(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_snapshot), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_snapshot(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gcn_snapshot.CreateSnapshotRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_snapshot_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 = NetAppClient( - 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 = gcn_snapshot.CreateSnapshotRequest( - parent='parent_value', - snapshot_id='snapshot_id_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_snapshot), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_snapshot(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gcn_snapshot.CreateSnapshotRequest( - parent='parent_value', - snapshot_id='snapshot_id_value', - ) - -def test_create_snapshot_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 = NetAppClient( - 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_snapshot 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_snapshot] = mock_rpc - request = {} - client.create_snapshot(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_snapshot(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_snapshot_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 = NetAppAsyncClient( - 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_snapshot 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_snapshot] = mock_rpc - - request = {} - await client.create_snapshot(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_snapshot(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_snapshot_async(transport: str = 'grpc_asyncio', request_type=gcn_snapshot.CreateSnapshotRequest): - client = NetAppAsyncClient( - 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_snapshot), - '__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_snapshot(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gcn_snapshot.CreateSnapshotRequest() - 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_snapshot_async_from_dict(): - await test_create_snapshot_async(request_type=dict) - -def test_create_snapshot_field_headers(): - client = NetAppClient( - 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 = gcn_snapshot.CreateSnapshotRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_snapshot), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_snapshot(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_snapshot_field_headers_async(): - client = NetAppAsyncClient( - 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 = gcn_snapshot.CreateSnapshotRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_snapshot), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_snapshot(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_snapshot_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_snapshot), - '__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_snapshot( - parent='parent_value', - snapshot=gcn_snapshot.Snapshot(name='name_value'), - snapshot_id='snapshot_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].snapshot - mock_val = gcn_snapshot.Snapshot(name='name_value') - assert arg == mock_val - arg = args[0].snapshot_id - mock_val = 'snapshot_id_value' - assert arg == mock_val - - -def test_create_snapshot_flattened_error(): - client = NetAppClient( - 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_snapshot( - gcn_snapshot.CreateSnapshotRequest(), - parent='parent_value', - snapshot=gcn_snapshot.Snapshot(name='name_value'), - snapshot_id='snapshot_id_value', - ) - -@pytest.mark.asyncio -async def test_create_snapshot_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_snapshot), - '__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_snapshot( - parent='parent_value', - snapshot=gcn_snapshot.Snapshot(name='name_value'), - snapshot_id='snapshot_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].snapshot - mock_val = gcn_snapshot.Snapshot(name='name_value') - assert arg == mock_val - arg = args[0].snapshot_id - mock_val = 'snapshot_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_snapshot_flattened_error_async(): - client = NetAppAsyncClient( - 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_snapshot( - gcn_snapshot.CreateSnapshotRequest(), - parent='parent_value', - snapshot=gcn_snapshot.Snapshot(name='name_value'), - snapshot_id='snapshot_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - snapshot.DeleteSnapshotRequest, - dict, -]) -def test_delete_snapshot(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_snapshot), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_snapshot(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = snapshot.DeleteSnapshotRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_snapshot_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 = NetAppClient( - 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 = snapshot.DeleteSnapshotRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_snapshot), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_snapshot(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == snapshot.DeleteSnapshotRequest( - name='name_value', - ) - -def test_delete_snapshot_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 = NetAppClient( - 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_snapshot 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_snapshot] = mock_rpc - request = {} - client.delete_snapshot(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_snapshot(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_snapshot_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 = NetAppAsyncClient( - 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_snapshot 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_snapshot] = mock_rpc - - request = {} - await client.delete_snapshot(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_snapshot(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_snapshot_async(transport: str = 'grpc_asyncio', request_type=snapshot.DeleteSnapshotRequest): - client = NetAppAsyncClient( - 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_snapshot), - '__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_snapshot(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = snapshot.DeleteSnapshotRequest() - 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_snapshot_async_from_dict(): - await test_delete_snapshot_async(request_type=dict) - -def test_delete_snapshot_field_headers(): - client = NetAppClient( - 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 = snapshot.DeleteSnapshotRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_snapshot), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_snapshot(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_snapshot_field_headers_async(): - client = NetAppAsyncClient( - 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 = snapshot.DeleteSnapshotRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_snapshot), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_snapshot(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_snapshot_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_snapshot), - '__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_snapshot( - 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_snapshot_flattened_error(): - client = NetAppClient( - 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_snapshot( - snapshot.DeleteSnapshotRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_snapshot_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_snapshot), - '__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_snapshot( - 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_snapshot_flattened_error_async(): - client = NetAppAsyncClient( - 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_snapshot( - snapshot.DeleteSnapshotRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - gcn_snapshot.UpdateSnapshotRequest, - dict, -]) -def test_update_snapshot(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_snapshot), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_snapshot(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gcn_snapshot.UpdateSnapshotRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_snapshot_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 = NetAppClient( - 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 = gcn_snapshot.UpdateSnapshotRequest( - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_snapshot), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_snapshot(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gcn_snapshot.UpdateSnapshotRequest( - ) - -def test_update_snapshot_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 = NetAppClient( - 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_snapshot 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_snapshot] = mock_rpc - request = {} - client.update_snapshot(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.update_snapshot(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_snapshot_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 = NetAppAsyncClient( - 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_snapshot 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_snapshot] = mock_rpc - - request = {} - await client.update_snapshot(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.update_snapshot(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_snapshot_async(transport: str = 'grpc_asyncio', request_type=gcn_snapshot.UpdateSnapshotRequest): - client = NetAppAsyncClient( - 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_snapshot), - '__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.update_snapshot(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gcn_snapshot.UpdateSnapshotRequest() - 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_update_snapshot_async_from_dict(): - await test_update_snapshot_async(request_type=dict) - -def test_update_snapshot_field_headers(): - client = NetAppClient( - 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 = gcn_snapshot.UpdateSnapshotRequest() - - request.snapshot.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_snapshot), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_snapshot(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', - 'snapshot.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_snapshot_field_headers_async(): - client = NetAppAsyncClient( - 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 = gcn_snapshot.UpdateSnapshotRequest() - - request.snapshot.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_snapshot), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_snapshot(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', - 'snapshot.name=name_value', - ) in kw['metadata'] - - -def test_update_snapshot_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_snapshot), - '__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.update_snapshot( - snapshot=gcn_snapshot.Snapshot(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].snapshot - mock_val = gcn_snapshot.Snapshot(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_snapshot_flattened_error(): - client = NetAppClient( - 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_snapshot( - gcn_snapshot.UpdateSnapshotRequest(), - snapshot=gcn_snapshot.Snapshot(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_snapshot_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_snapshot), - '__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.update_snapshot( - snapshot=gcn_snapshot.Snapshot(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].snapshot - mock_val = gcn_snapshot.Snapshot(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_snapshot_flattened_error_async(): - client = NetAppAsyncClient( - 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_snapshot( - gcn_snapshot.UpdateSnapshotRequest(), - snapshot=gcn_snapshot.Snapshot(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - active_directory.ListActiveDirectoriesRequest, - dict, -]) -def test_list_active_directories(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_active_directories), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = active_directory.ListActiveDirectoriesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_active_directories(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = active_directory.ListActiveDirectoriesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListActiveDirectoriesPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_active_directories_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 = NetAppClient( - 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 = active_directory.ListActiveDirectoriesRequest( - 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_active_directories), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_active_directories(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == active_directory.ListActiveDirectoriesRequest( - parent='parent_value', - page_token='page_token_value', - filter='filter_value', - order_by='order_by_value', - ) - -def test_list_active_directories_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 = NetAppClient( - 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_active_directories 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_active_directories] = mock_rpc - request = {} - client.list_active_directories(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_active_directories(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_active_directories_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 = NetAppAsyncClient( - 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_active_directories 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_active_directories] = mock_rpc - - request = {} - await client.list_active_directories(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_active_directories(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_active_directories_async(transport: str = 'grpc_asyncio', request_type=active_directory.ListActiveDirectoriesRequest): - client = NetAppAsyncClient( - 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_active_directories), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(active_directory.ListActiveDirectoriesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_active_directories(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = active_directory.ListActiveDirectoriesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListActiveDirectoriesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_active_directories_async_from_dict(): - await test_list_active_directories_async(request_type=dict) - -def test_list_active_directories_field_headers(): - client = NetAppClient( - 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 = active_directory.ListActiveDirectoriesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_active_directories), - '__call__') as call: - call.return_value = active_directory.ListActiveDirectoriesResponse() - client.list_active_directories(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_active_directories_field_headers_async(): - client = NetAppAsyncClient( - 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 = active_directory.ListActiveDirectoriesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_active_directories), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(active_directory.ListActiveDirectoriesResponse()) - await client.list_active_directories(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_active_directories_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_active_directories), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = active_directory.ListActiveDirectoriesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_active_directories( - 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_active_directories_flattened_error(): - client = NetAppClient( - 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_active_directories( - active_directory.ListActiveDirectoriesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_active_directories_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_active_directories), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = active_directory.ListActiveDirectoriesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(active_directory.ListActiveDirectoriesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_active_directories( - 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_active_directories_flattened_error_async(): - client = NetAppAsyncClient( - 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_active_directories( - active_directory.ListActiveDirectoriesRequest(), - parent='parent_value', - ) - - -def test_list_active_directories_pager(transport_name: str = "grpc"): - client = NetAppClient( - 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_active_directories), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - active_directory.ListActiveDirectoriesResponse( - active_directories=[ - active_directory.ActiveDirectory(), - active_directory.ActiveDirectory(), - active_directory.ActiveDirectory(), - ], - next_page_token='abc', - ), - active_directory.ListActiveDirectoriesResponse( - active_directories=[], - next_page_token='def', - ), - active_directory.ListActiveDirectoriesResponse( - active_directories=[ - active_directory.ActiveDirectory(), - ], - next_page_token='ghi', - ), - active_directory.ListActiveDirectoriesResponse( - active_directories=[ - active_directory.ActiveDirectory(), - active_directory.ActiveDirectory(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_active_directories(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, active_directory.ActiveDirectory) - for i in results) -def test_list_active_directories_pages(transport_name: str = "grpc"): - client = NetAppClient( - 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_active_directories), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - active_directory.ListActiveDirectoriesResponse( - active_directories=[ - active_directory.ActiveDirectory(), - active_directory.ActiveDirectory(), - active_directory.ActiveDirectory(), - ], - next_page_token='abc', - ), - active_directory.ListActiveDirectoriesResponse( - active_directories=[], - next_page_token='def', - ), - active_directory.ListActiveDirectoriesResponse( - active_directories=[ - active_directory.ActiveDirectory(), - ], - next_page_token='ghi', - ), - active_directory.ListActiveDirectoriesResponse( - active_directories=[ - active_directory.ActiveDirectory(), - active_directory.ActiveDirectory(), - ], - ), - RuntimeError, - ) - pages = list(client.list_active_directories(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_active_directories_async_pager(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_active_directories), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - active_directory.ListActiveDirectoriesResponse( - active_directories=[ - active_directory.ActiveDirectory(), - active_directory.ActiveDirectory(), - active_directory.ActiveDirectory(), - ], - next_page_token='abc', - ), - active_directory.ListActiveDirectoriesResponse( - active_directories=[], - next_page_token='def', - ), - active_directory.ListActiveDirectoriesResponse( - active_directories=[ - active_directory.ActiveDirectory(), - ], - next_page_token='ghi', - ), - active_directory.ListActiveDirectoriesResponse( - active_directories=[ - active_directory.ActiveDirectory(), - active_directory.ActiveDirectory(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_active_directories(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, active_directory.ActiveDirectory) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_active_directories_async_pages(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_active_directories), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - active_directory.ListActiveDirectoriesResponse( - active_directories=[ - active_directory.ActiveDirectory(), - active_directory.ActiveDirectory(), - active_directory.ActiveDirectory(), - ], - next_page_token='abc', - ), - active_directory.ListActiveDirectoriesResponse( - active_directories=[], - next_page_token='def', - ), - active_directory.ListActiveDirectoriesResponse( - active_directories=[ - active_directory.ActiveDirectory(), - ], - next_page_token='ghi', - ), - active_directory.ListActiveDirectoriesResponse( - active_directories=[ - active_directory.ActiveDirectory(), - active_directory.ActiveDirectory(), - ], - ), - 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_active_directories(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", [ - active_directory.GetActiveDirectoryRequest, - dict, -]) -def test_get_active_directory(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_active_directory), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = active_directory.ActiveDirectory( - name='name_value', - state=active_directory.ActiveDirectory.State.CREATING, - domain='domain_value', - site='site_value', - dns='dns_value', - net_bios_prefix='net_bios_prefix_value', - organizational_unit='organizational_unit_value', - aes_encryption=True, - username='username_value', - password='password_value', - backup_operators=['backup_operators_value'], - administrators=['administrators_value'], - security_operators=['security_operators_value'], - kdc_hostname='kdc_hostname_value', - kdc_ip='kdc_ip_value', - nfs_users_with_ldap=True, - description='description_value', - ldap_signing=True, - encrypt_dc_connections=True, - state_details='state_details_value', - ) - response = client.get_active_directory(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = active_directory.GetActiveDirectoryRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, active_directory.ActiveDirectory) - assert response.name == 'name_value' - assert response.state == active_directory.ActiveDirectory.State.CREATING - assert response.domain == 'domain_value' - assert response.site == 'site_value' - assert response.dns == 'dns_value' - assert response.net_bios_prefix == 'net_bios_prefix_value' - assert response.organizational_unit == 'organizational_unit_value' - assert response.aes_encryption is True - assert response.username == 'username_value' - assert response.password == 'password_value' - assert response.backup_operators == ['backup_operators_value'] - assert response.administrators == ['administrators_value'] - assert response.security_operators == ['security_operators_value'] - assert response.kdc_hostname == 'kdc_hostname_value' - assert response.kdc_ip == 'kdc_ip_value' - assert response.nfs_users_with_ldap is True - assert response.description == 'description_value' - assert response.ldap_signing is True - assert response.encrypt_dc_connections is True - assert response.state_details == 'state_details_value' - - -def test_get_active_directory_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 = NetAppClient( - 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 = active_directory.GetActiveDirectoryRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_active_directory), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_active_directory(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == active_directory.GetActiveDirectoryRequest( - name='name_value', - ) - -def test_get_active_directory_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 = NetAppClient( - 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_active_directory 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_active_directory] = mock_rpc - request = {} - client.get_active_directory(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_active_directory(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_active_directory_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 = NetAppAsyncClient( - 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_active_directory 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_active_directory] = mock_rpc - - request = {} - await client.get_active_directory(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_active_directory(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_active_directory_async(transport: str = 'grpc_asyncio', request_type=active_directory.GetActiveDirectoryRequest): - client = NetAppAsyncClient( - 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_active_directory), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(active_directory.ActiveDirectory( - name='name_value', - state=active_directory.ActiveDirectory.State.CREATING, - domain='domain_value', - site='site_value', - dns='dns_value', - net_bios_prefix='net_bios_prefix_value', - organizational_unit='organizational_unit_value', - aes_encryption=True, - username='username_value', - password='password_value', - backup_operators=['backup_operators_value'], - administrators=['administrators_value'], - security_operators=['security_operators_value'], - kdc_hostname='kdc_hostname_value', - kdc_ip='kdc_ip_value', - nfs_users_with_ldap=True, - description='description_value', - ldap_signing=True, - encrypt_dc_connections=True, - state_details='state_details_value', - )) - response = await client.get_active_directory(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = active_directory.GetActiveDirectoryRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, active_directory.ActiveDirectory) - assert response.name == 'name_value' - assert response.state == active_directory.ActiveDirectory.State.CREATING - assert response.domain == 'domain_value' - assert response.site == 'site_value' - assert response.dns == 'dns_value' - assert response.net_bios_prefix == 'net_bios_prefix_value' - assert response.organizational_unit == 'organizational_unit_value' - assert response.aes_encryption is True - assert response.username == 'username_value' - assert response.password == 'password_value' - assert response.backup_operators == ['backup_operators_value'] - assert response.administrators == ['administrators_value'] - assert response.security_operators == ['security_operators_value'] - assert response.kdc_hostname == 'kdc_hostname_value' - assert response.kdc_ip == 'kdc_ip_value' - assert response.nfs_users_with_ldap is True - assert response.description == 'description_value' - assert response.ldap_signing is True - assert response.encrypt_dc_connections is True - assert response.state_details == 'state_details_value' - - -@pytest.mark.asyncio -async def test_get_active_directory_async_from_dict(): - await test_get_active_directory_async(request_type=dict) - -def test_get_active_directory_field_headers(): - client = NetAppClient( - 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 = active_directory.GetActiveDirectoryRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_active_directory), - '__call__') as call: - call.return_value = active_directory.ActiveDirectory() - client.get_active_directory(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_active_directory_field_headers_async(): - client = NetAppAsyncClient( - 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 = active_directory.GetActiveDirectoryRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_active_directory), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(active_directory.ActiveDirectory()) - await client.get_active_directory(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_active_directory_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_active_directory), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = active_directory.ActiveDirectory() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_active_directory( - 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_active_directory_flattened_error(): - client = NetAppClient( - 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_active_directory( - active_directory.GetActiveDirectoryRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_active_directory_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_active_directory), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = active_directory.ActiveDirectory() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(active_directory.ActiveDirectory()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_active_directory( - 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_active_directory_flattened_error_async(): - client = NetAppAsyncClient( - 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_active_directory( - active_directory.GetActiveDirectoryRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - gcn_active_directory.CreateActiveDirectoryRequest, - dict, -]) -def test_create_active_directory(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_active_directory), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_active_directory(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gcn_active_directory.CreateActiveDirectoryRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_active_directory_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 = NetAppClient( - 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 = gcn_active_directory.CreateActiveDirectoryRequest( - parent='parent_value', - active_directory_id='active_directory_id_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_active_directory), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_active_directory(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gcn_active_directory.CreateActiveDirectoryRequest( - parent='parent_value', - active_directory_id='active_directory_id_value', - ) - -def test_create_active_directory_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 = NetAppClient( - 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_active_directory 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_active_directory] = mock_rpc - request = {} - client.create_active_directory(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_active_directory(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_active_directory_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 = NetAppAsyncClient( - 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_active_directory 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_active_directory] = mock_rpc - - request = {} - await client.create_active_directory(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_active_directory(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_active_directory_async(transport: str = 'grpc_asyncio', request_type=gcn_active_directory.CreateActiveDirectoryRequest): - client = NetAppAsyncClient( - 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_active_directory), - '__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_active_directory(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gcn_active_directory.CreateActiveDirectoryRequest() - 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_active_directory_async_from_dict(): - await test_create_active_directory_async(request_type=dict) - -def test_create_active_directory_field_headers(): - client = NetAppClient( - 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 = gcn_active_directory.CreateActiveDirectoryRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_active_directory), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_active_directory(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_active_directory_field_headers_async(): - client = NetAppAsyncClient( - 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 = gcn_active_directory.CreateActiveDirectoryRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_active_directory), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_active_directory(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_active_directory_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_active_directory), - '__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_active_directory( - parent='parent_value', - active_directory=gcn_active_directory.ActiveDirectory(name='name_value'), - active_directory_id='active_directory_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].active_directory - mock_val = gcn_active_directory.ActiveDirectory(name='name_value') - assert arg == mock_val - arg = args[0].active_directory_id - mock_val = 'active_directory_id_value' - assert arg == mock_val - - -def test_create_active_directory_flattened_error(): - client = NetAppClient( - 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_active_directory( - gcn_active_directory.CreateActiveDirectoryRequest(), - parent='parent_value', - active_directory=gcn_active_directory.ActiveDirectory(name='name_value'), - active_directory_id='active_directory_id_value', - ) - -@pytest.mark.asyncio -async def test_create_active_directory_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_active_directory), - '__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_active_directory( - parent='parent_value', - active_directory=gcn_active_directory.ActiveDirectory(name='name_value'), - active_directory_id='active_directory_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].active_directory - mock_val = gcn_active_directory.ActiveDirectory(name='name_value') - assert arg == mock_val - arg = args[0].active_directory_id - mock_val = 'active_directory_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_active_directory_flattened_error_async(): - client = NetAppAsyncClient( - 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_active_directory( - gcn_active_directory.CreateActiveDirectoryRequest(), - parent='parent_value', - active_directory=gcn_active_directory.ActiveDirectory(name='name_value'), - active_directory_id='active_directory_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - gcn_active_directory.UpdateActiveDirectoryRequest, - dict, -]) -def test_update_active_directory(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_active_directory), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_active_directory(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gcn_active_directory.UpdateActiveDirectoryRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_active_directory_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 = NetAppClient( - 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 = gcn_active_directory.UpdateActiveDirectoryRequest( - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_active_directory), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_active_directory(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gcn_active_directory.UpdateActiveDirectoryRequest( - ) - -def test_update_active_directory_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 = NetAppClient( - 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_active_directory 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_active_directory] = mock_rpc - request = {} - client.update_active_directory(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.update_active_directory(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_active_directory_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 = NetAppAsyncClient( - 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_active_directory 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_active_directory] = mock_rpc - - request = {} - await client.update_active_directory(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.update_active_directory(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_active_directory_async(transport: str = 'grpc_asyncio', request_type=gcn_active_directory.UpdateActiveDirectoryRequest): - client = NetAppAsyncClient( - 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_active_directory), - '__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.update_active_directory(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gcn_active_directory.UpdateActiveDirectoryRequest() - 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_update_active_directory_async_from_dict(): - await test_update_active_directory_async(request_type=dict) - -def test_update_active_directory_field_headers(): - client = NetAppClient( - 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 = gcn_active_directory.UpdateActiveDirectoryRequest() - - request.active_directory.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_active_directory), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_active_directory(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', - 'active_directory.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_active_directory_field_headers_async(): - client = NetAppAsyncClient( - 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 = gcn_active_directory.UpdateActiveDirectoryRequest() - - request.active_directory.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_active_directory), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_active_directory(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', - 'active_directory.name=name_value', - ) in kw['metadata'] - - -def test_update_active_directory_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_active_directory), - '__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.update_active_directory( - active_directory=gcn_active_directory.ActiveDirectory(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].active_directory - mock_val = gcn_active_directory.ActiveDirectory(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_active_directory_flattened_error(): - client = NetAppClient( - 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_active_directory( - gcn_active_directory.UpdateActiveDirectoryRequest(), - active_directory=gcn_active_directory.ActiveDirectory(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_active_directory_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_active_directory), - '__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.update_active_directory( - active_directory=gcn_active_directory.ActiveDirectory(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].active_directory - mock_val = gcn_active_directory.ActiveDirectory(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_active_directory_flattened_error_async(): - client = NetAppAsyncClient( - 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_active_directory( - gcn_active_directory.UpdateActiveDirectoryRequest(), - active_directory=gcn_active_directory.ActiveDirectory(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - active_directory.DeleteActiveDirectoryRequest, - dict, -]) -def test_delete_active_directory(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_active_directory), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_active_directory(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = active_directory.DeleteActiveDirectoryRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_active_directory_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 = NetAppClient( - 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 = active_directory.DeleteActiveDirectoryRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_active_directory), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_active_directory(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == active_directory.DeleteActiveDirectoryRequest( - name='name_value', - ) - -def test_delete_active_directory_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 = NetAppClient( - 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_active_directory 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_active_directory] = mock_rpc - request = {} - client.delete_active_directory(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_active_directory(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_active_directory_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 = NetAppAsyncClient( - 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_active_directory 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_active_directory] = mock_rpc - - request = {} - await client.delete_active_directory(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_active_directory(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_active_directory_async(transport: str = 'grpc_asyncio', request_type=active_directory.DeleteActiveDirectoryRequest): - client = NetAppAsyncClient( - 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_active_directory), - '__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_active_directory(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = active_directory.DeleteActiveDirectoryRequest() - 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_active_directory_async_from_dict(): - await test_delete_active_directory_async(request_type=dict) - -def test_delete_active_directory_field_headers(): - client = NetAppClient( - 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 = active_directory.DeleteActiveDirectoryRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_active_directory), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_active_directory(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_active_directory_field_headers_async(): - client = NetAppAsyncClient( - 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 = active_directory.DeleteActiveDirectoryRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_active_directory), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_active_directory(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_active_directory_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_active_directory), - '__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_active_directory( - 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_active_directory_flattened_error(): - client = NetAppClient( - 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_active_directory( - active_directory.DeleteActiveDirectoryRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_active_directory_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_active_directory), - '__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_active_directory( - 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_active_directory_flattened_error_async(): - client = NetAppAsyncClient( - 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_active_directory( - active_directory.DeleteActiveDirectoryRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - kms.ListKmsConfigsRequest, - dict, -]) -def test_list_kms_configs(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_kms_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = kms.ListKmsConfigsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_kms_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = kms.ListKmsConfigsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListKmsConfigsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_kms_configs_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 = NetAppClient( - 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 = kms.ListKmsConfigsRequest( - 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_kms_configs), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_kms_configs(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == kms.ListKmsConfigsRequest( - parent='parent_value', - page_token='page_token_value', - order_by='order_by_value', - filter='filter_value', - ) - -def test_list_kms_configs_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 = NetAppClient( - 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_kms_configs 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_kms_configs] = mock_rpc - request = {} - client.list_kms_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_kms_configs(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_kms_configs_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 = NetAppAsyncClient( - 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_kms_configs 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_kms_configs] = mock_rpc - - request = {} - await client.list_kms_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_kms_configs(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_kms_configs_async(transport: str = 'grpc_asyncio', request_type=kms.ListKmsConfigsRequest): - client = NetAppAsyncClient( - 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_kms_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(kms.ListKmsConfigsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_kms_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = kms.ListKmsConfigsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListKmsConfigsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_kms_configs_async_from_dict(): - await test_list_kms_configs_async(request_type=dict) - -def test_list_kms_configs_field_headers(): - client = NetAppClient( - 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 = kms.ListKmsConfigsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_kms_configs), - '__call__') as call: - call.return_value = kms.ListKmsConfigsResponse() - client.list_kms_configs(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_kms_configs_field_headers_async(): - client = NetAppAsyncClient( - 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 = kms.ListKmsConfigsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_kms_configs), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(kms.ListKmsConfigsResponse()) - await client.list_kms_configs(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_kms_configs_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_kms_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = kms.ListKmsConfigsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_kms_configs( - 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_kms_configs_flattened_error(): - client = NetAppClient( - 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_kms_configs( - kms.ListKmsConfigsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_kms_configs_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_kms_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = kms.ListKmsConfigsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(kms.ListKmsConfigsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_kms_configs( - 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_kms_configs_flattened_error_async(): - client = NetAppAsyncClient( - 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_kms_configs( - kms.ListKmsConfigsRequest(), - parent='parent_value', - ) - - -def test_list_kms_configs_pager(transport_name: str = "grpc"): - client = NetAppClient( - 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_kms_configs), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - kms.ListKmsConfigsResponse( - kms_configs=[ - kms.KmsConfig(), - kms.KmsConfig(), - kms.KmsConfig(), - ], - next_page_token='abc', - ), - kms.ListKmsConfigsResponse( - kms_configs=[], - next_page_token='def', - ), - kms.ListKmsConfigsResponse( - kms_configs=[ - kms.KmsConfig(), - ], - next_page_token='ghi', - ), - kms.ListKmsConfigsResponse( - kms_configs=[ - kms.KmsConfig(), - kms.KmsConfig(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_kms_configs(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, kms.KmsConfig) - for i in results) -def test_list_kms_configs_pages(transport_name: str = "grpc"): - client = NetAppClient( - 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_kms_configs), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - kms.ListKmsConfigsResponse( - kms_configs=[ - kms.KmsConfig(), - kms.KmsConfig(), - kms.KmsConfig(), - ], - next_page_token='abc', - ), - kms.ListKmsConfigsResponse( - kms_configs=[], - next_page_token='def', - ), - kms.ListKmsConfigsResponse( - kms_configs=[ - kms.KmsConfig(), - ], - next_page_token='ghi', - ), - kms.ListKmsConfigsResponse( - kms_configs=[ - kms.KmsConfig(), - kms.KmsConfig(), - ], - ), - RuntimeError, - ) - pages = list(client.list_kms_configs(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_kms_configs_async_pager(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_kms_configs), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - kms.ListKmsConfigsResponse( - kms_configs=[ - kms.KmsConfig(), - kms.KmsConfig(), - kms.KmsConfig(), - ], - next_page_token='abc', - ), - kms.ListKmsConfigsResponse( - kms_configs=[], - next_page_token='def', - ), - kms.ListKmsConfigsResponse( - kms_configs=[ - kms.KmsConfig(), - ], - next_page_token='ghi', - ), - kms.ListKmsConfigsResponse( - kms_configs=[ - kms.KmsConfig(), - kms.KmsConfig(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_kms_configs(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, kms.KmsConfig) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_kms_configs_async_pages(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_kms_configs), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - kms.ListKmsConfigsResponse( - kms_configs=[ - kms.KmsConfig(), - kms.KmsConfig(), - kms.KmsConfig(), - ], - next_page_token='abc', - ), - kms.ListKmsConfigsResponse( - kms_configs=[], - next_page_token='def', - ), - kms.ListKmsConfigsResponse( - kms_configs=[ - kms.KmsConfig(), - ], - next_page_token='ghi', - ), - kms.ListKmsConfigsResponse( - kms_configs=[ - kms.KmsConfig(), - kms.KmsConfig(), - ], - ), - 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_kms_configs(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", [ - kms.CreateKmsConfigRequest, - dict, -]) -def test_create_kms_config(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_kms_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_kms_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = kms.CreateKmsConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_kms_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 = NetAppClient( - 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 = kms.CreateKmsConfigRequest( - parent='parent_value', - kms_config_id='kms_config_id_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_kms_config), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_kms_config(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == kms.CreateKmsConfigRequest( - parent='parent_value', - kms_config_id='kms_config_id_value', - ) - -def test_create_kms_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 = NetAppClient( - 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_kms_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.create_kms_config] = mock_rpc - request = {} - client.create_kms_config(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_kms_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_create_kms_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 = NetAppAsyncClient( - 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_kms_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.create_kms_config] = mock_rpc - - request = {} - await client.create_kms_config(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_kms_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_create_kms_config_async(transport: str = 'grpc_asyncio', request_type=kms.CreateKmsConfigRequest): - client = NetAppAsyncClient( - 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_kms_config), - '__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_kms_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = kms.CreateKmsConfigRequest() - 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_kms_config_async_from_dict(): - await test_create_kms_config_async(request_type=dict) - -def test_create_kms_config_field_headers(): - client = NetAppClient( - 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 = kms.CreateKmsConfigRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_kms_config), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_kms_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', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_create_kms_config_field_headers_async(): - client = NetAppAsyncClient( - 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 = kms.CreateKmsConfigRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_kms_config), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_kms_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', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_create_kms_config_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_kms_config), - '__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_kms_config( - parent='parent_value', - kms_config=kms.KmsConfig(name='name_value'), - kms_config_id='kms_config_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].kms_config - mock_val = kms.KmsConfig(name='name_value') - assert arg == mock_val - arg = args[0].kms_config_id - mock_val = 'kms_config_id_value' - assert arg == mock_val - - -def test_create_kms_config_flattened_error(): - client = NetAppClient( - 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_kms_config( - kms.CreateKmsConfigRequest(), - parent='parent_value', - kms_config=kms.KmsConfig(name='name_value'), - kms_config_id='kms_config_id_value', - ) - -@pytest.mark.asyncio -async def test_create_kms_config_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_kms_config), - '__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_kms_config( - parent='parent_value', - kms_config=kms.KmsConfig(name='name_value'), - kms_config_id='kms_config_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].kms_config - mock_val = kms.KmsConfig(name='name_value') - assert arg == mock_val - arg = args[0].kms_config_id - mock_val = 'kms_config_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_kms_config_flattened_error_async(): - client = NetAppAsyncClient( - 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_kms_config( - kms.CreateKmsConfigRequest(), - parent='parent_value', - kms_config=kms.KmsConfig(name='name_value'), - kms_config_id='kms_config_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - kms.GetKmsConfigRequest, - dict, -]) -def test_get_kms_config(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_kms_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = kms.KmsConfig( - name='name_value', - crypto_key_name='crypto_key_name_value', - state=kms.KmsConfig.State.READY, - state_details='state_details_value', - description='description_value', - instructions='instructions_value', - service_account='service_account_value', - ) - response = client.get_kms_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = kms.GetKmsConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, kms.KmsConfig) - assert response.name == 'name_value' - assert response.crypto_key_name == 'crypto_key_name_value' - assert response.state == kms.KmsConfig.State.READY - assert response.state_details == 'state_details_value' - assert response.description == 'description_value' - assert response.instructions == 'instructions_value' - assert response.service_account == 'service_account_value' - - -def test_get_kms_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 = NetAppClient( - 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 = kms.GetKmsConfigRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_kms_config), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_kms_config(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == kms.GetKmsConfigRequest( - name='name_value', - ) - -def test_get_kms_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 = NetAppClient( - 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_kms_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_kms_config] = mock_rpc - request = {} - client.get_kms_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_kms_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_kms_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 = NetAppAsyncClient( - 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_kms_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_kms_config] = mock_rpc - - request = {} - await client.get_kms_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_kms_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_kms_config_async(transport: str = 'grpc_asyncio', request_type=kms.GetKmsConfigRequest): - client = NetAppAsyncClient( - 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_kms_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(kms.KmsConfig( - name='name_value', - crypto_key_name='crypto_key_name_value', - state=kms.KmsConfig.State.READY, - state_details='state_details_value', - description='description_value', - instructions='instructions_value', - service_account='service_account_value', - )) - response = await client.get_kms_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = kms.GetKmsConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, kms.KmsConfig) - assert response.name == 'name_value' - assert response.crypto_key_name == 'crypto_key_name_value' - assert response.state == kms.KmsConfig.State.READY - assert response.state_details == 'state_details_value' - assert response.description == 'description_value' - assert response.instructions == 'instructions_value' - assert response.service_account == 'service_account_value' - - -@pytest.mark.asyncio -async def test_get_kms_config_async_from_dict(): - await test_get_kms_config_async(request_type=dict) - -def test_get_kms_config_field_headers(): - client = NetAppClient( - 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 = kms.GetKmsConfigRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_kms_config), - '__call__') as call: - call.return_value = kms.KmsConfig() - client.get_kms_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_kms_config_field_headers_async(): - client = NetAppAsyncClient( - 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 = kms.GetKmsConfigRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_kms_config), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(kms.KmsConfig()) - await client.get_kms_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_kms_config_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_kms_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = kms.KmsConfig() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_kms_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_kms_config_flattened_error(): - client = NetAppClient( - 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_kms_config( - kms.GetKmsConfigRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_kms_config_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_kms_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = kms.KmsConfig() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(kms.KmsConfig()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_kms_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_kms_config_flattened_error_async(): - client = NetAppAsyncClient( - 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_kms_config( - kms.GetKmsConfigRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - kms.UpdateKmsConfigRequest, - dict, -]) -def test_update_kms_config(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_kms_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_kms_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = kms.UpdateKmsConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_kms_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 = NetAppClient( - 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 = kms.UpdateKmsConfigRequest( - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_kms_config), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_kms_config(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == kms.UpdateKmsConfigRequest( - ) - -def test_update_kms_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 = NetAppClient( - 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_kms_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_kms_config] = mock_rpc - request = {} - client.update_kms_config(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.update_kms_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_kms_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 = NetAppAsyncClient( - 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_kms_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_kms_config] = mock_rpc - - request = {} - await client.update_kms_config(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.update_kms_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_kms_config_async(transport: str = 'grpc_asyncio', request_type=kms.UpdateKmsConfigRequest): - client = NetAppAsyncClient( - 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_kms_config), - '__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.update_kms_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = kms.UpdateKmsConfigRequest() - 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_update_kms_config_async_from_dict(): - await test_update_kms_config_async(request_type=dict) - -def test_update_kms_config_field_headers(): - client = NetAppClient( - 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 = kms.UpdateKmsConfigRequest() - - request.kms_config.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_kms_config), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_kms_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', - 'kms_config.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_kms_config_field_headers_async(): - client = NetAppAsyncClient( - 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 = kms.UpdateKmsConfigRequest() - - request.kms_config.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_kms_config), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_kms_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', - 'kms_config.name=name_value', - ) in kw['metadata'] - - -def test_update_kms_config_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_kms_config), - '__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.update_kms_config( - kms_config=kms.KmsConfig(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].kms_config - mock_val = kms.KmsConfig(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_kms_config_flattened_error(): - client = NetAppClient( - 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_kms_config( - kms.UpdateKmsConfigRequest(), - kms_config=kms.KmsConfig(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_kms_config_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_kms_config), - '__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.update_kms_config( - kms_config=kms.KmsConfig(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].kms_config - mock_val = kms.KmsConfig(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_kms_config_flattened_error_async(): - client = NetAppAsyncClient( - 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_kms_config( - kms.UpdateKmsConfigRequest(), - kms_config=kms.KmsConfig(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - kms.EncryptVolumesRequest, - dict, -]) -def test_encrypt_volumes(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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.encrypt_volumes), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.encrypt_volumes(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = kms.EncryptVolumesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_encrypt_volumes_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 = NetAppClient( - 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 = kms.EncryptVolumesRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.encrypt_volumes), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.encrypt_volumes(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == kms.EncryptVolumesRequest( - name='name_value', - ) - -def test_encrypt_volumes_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 = NetAppClient( - 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.encrypt_volumes 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.encrypt_volumes] = mock_rpc - request = {} - client.encrypt_volumes(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.encrypt_volumes(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_encrypt_volumes_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 = NetAppAsyncClient( - 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.encrypt_volumes 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.encrypt_volumes] = mock_rpc - - request = {} - await client.encrypt_volumes(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.encrypt_volumes(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_encrypt_volumes_async(transport: str = 'grpc_asyncio', request_type=kms.EncryptVolumesRequest): - client = NetAppAsyncClient( - 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.encrypt_volumes), - '__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.encrypt_volumes(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = kms.EncryptVolumesRequest() - 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_encrypt_volumes_async_from_dict(): - await test_encrypt_volumes_async(request_type=dict) - -def test_encrypt_volumes_field_headers(): - client = NetAppClient( - 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 = kms.EncryptVolumesRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.encrypt_volumes), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.encrypt_volumes(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_encrypt_volumes_field_headers_async(): - client = NetAppAsyncClient( - 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 = kms.EncryptVolumesRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.encrypt_volumes), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.encrypt_volumes(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'] - - -@pytest.mark.parametrize("request_type", [ - kms.VerifyKmsConfigRequest, - dict, -]) -def test_verify_kms_config(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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.verify_kms_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = kms.VerifyKmsConfigResponse( - healthy=True, - health_error='health_error_value', - instructions='instructions_value', - ) - response = client.verify_kms_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = kms.VerifyKmsConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, kms.VerifyKmsConfigResponse) - assert response.healthy is True - assert response.health_error == 'health_error_value' - assert response.instructions == 'instructions_value' - - -def test_verify_kms_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 = NetAppClient( - 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 = kms.VerifyKmsConfigRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.verify_kms_config), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.verify_kms_config(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == kms.VerifyKmsConfigRequest( - name='name_value', - ) - -def test_verify_kms_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 = NetAppClient( - 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.verify_kms_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.verify_kms_config] = mock_rpc - request = {} - client.verify_kms_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.verify_kms_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_verify_kms_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 = NetAppAsyncClient( - 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.verify_kms_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.verify_kms_config] = mock_rpc - - request = {} - await client.verify_kms_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.verify_kms_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_verify_kms_config_async(transport: str = 'grpc_asyncio', request_type=kms.VerifyKmsConfigRequest): - client = NetAppAsyncClient( - 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.verify_kms_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(kms.VerifyKmsConfigResponse( - healthy=True, - health_error='health_error_value', - instructions='instructions_value', - )) - response = await client.verify_kms_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = kms.VerifyKmsConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, kms.VerifyKmsConfigResponse) - assert response.healthy is True - assert response.health_error == 'health_error_value' - assert response.instructions == 'instructions_value' - - -@pytest.mark.asyncio -async def test_verify_kms_config_async_from_dict(): - await test_verify_kms_config_async(request_type=dict) - -def test_verify_kms_config_field_headers(): - client = NetAppClient( - 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 = kms.VerifyKmsConfigRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.verify_kms_config), - '__call__') as call: - call.return_value = kms.VerifyKmsConfigResponse() - client.verify_kms_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_verify_kms_config_field_headers_async(): - client = NetAppAsyncClient( - 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 = kms.VerifyKmsConfigRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.verify_kms_config), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(kms.VerifyKmsConfigResponse()) - await client.verify_kms_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'] - - -@pytest.mark.parametrize("request_type", [ - kms.DeleteKmsConfigRequest, - dict, -]) -def test_delete_kms_config(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_kms_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_kms_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = kms.DeleteKmsConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_kms_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 = NetAppClient( - 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 = kms.DeleteKmsConfigRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_kms_config), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_kms_config(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == kms.DeleteKmsConfigRequest( - name='name_value', - ) - -def test_delete_kms_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 = NetAppClient( - 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_kms_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.delete_kms_config] = mock_rpc - request = {} - client.delete_kms_config(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_kms_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_delete_kms_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 = NetAppAsyncClient( - 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_kms_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.delete_kms_config] = mock_rpc - - request = {} - await client.delete_kms_config(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_kms_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_delete_kms_config_async(transport: str = 'grpc_asyncio', request_type=kms.DeleteKmsConfigRequest): - client = NetAppAsyncClient( - 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_kms_config), - '__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_kms_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = kms.DeleteKmsConfigRequest() - 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_kms_config_async_from_dict(): - await test_delete_kms_config_async(request_type=dict) - -def test_delete_kms_config_field_headers(): - client = NetAppClient( - 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 = kms.DeleteKmsConfigRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_kms_config), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_kms_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_delete_kms_config_field_headers_async(): - client = NetAppAsyncClient( - 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 = kms.DeleteKmsConfigRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_kms_config), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_kms_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_delete_kms_config_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_kms_config), - '__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_kms_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_delete_kms_config_flattened_error(): - client = NetAppClient( - 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_kms_config( - kms.DeleteKmsConfigRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_kms_config_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_kms_config), - '__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_kms_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_delete_kms_config_flattened_error_async(): - client = NetAppAsyncClient( - 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_kms_config( - kms.DeleteKmsConfigRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - replication.ListReplicationsRequest, - dict, -]) -def test_list_replications(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_replications), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = replication.ListReplicationsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_replications(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = replication.ListReplicationsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListReplicationsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_replications_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 = NetAppClient( - 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 = replication.ListReplicationsRequest( - 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_replications), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_replications(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == replication.ListReplicationsRequest( - parent='parent_value', - page_token='page_token_value', - order_by='order_by_value', - filter='filter_value', - ) - -def test_list_replications_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 = NetAppClient( - 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_replications 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_replications] = mock_rpc - request = {} - client.list_replications(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_replications(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_replications_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 = NetAppAsyncClient( - 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_replications 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_replications] = mock_rpc - - request = {} - await client.list_replications(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_replications(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_replications_async(transport: str = 'grpc_asyncio', request_type=replication.ListReplicationsRequest): - client = NetAppAsyncClient( - 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_replications), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(replication.ListReplicationsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_replications(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = replication.ListReplicationsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListReplicationsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_replications_async_from_dict(): - await test_list_replications_async(request_type=dict) - -def test_list_replications_field_headers(): - client = NetAppClient( - 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 = replication.ListReplicationsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_replications), - '__call__') as call: - call.return_value = replication.ListReplicationsResponse() - client.list_replications(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_replications_field_headers_async(): - client = NetAppAsyncClient( - 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 = replication.ListReplicationsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_replications), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(replication.ListReplicationsResponse()) - await client.list_replications(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_replications_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_replications), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = replication.ListReplicationsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_replications( - 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_replications_flattened_error(): - client = NetAppClient( - 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_replications( - replication.ListReplicationsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_replications_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_replications), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = replication.ListReplicationsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(replication.ListReplicationsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_replications( - 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_replications_flattened_error_async(): - client = NetAppAsyncClient( - 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_replications( - replication.ListReplicationsRequest(), - parent='parent_value', - ) - - -def test_list_replications_pager(transport_name: str = "grpc"): - client = NetAppClient( - 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_replications), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - replication.ListReplicationsResponse( - replications=[ - replication.Replication(), - replication.Replication(), - replication.Replication(), - ], - next_page_token='abc', - ), - replication.ListReplicationsResponse( - replications=[], - next_page_token='def', - ), - replication.ListReplicationsResponse( - replications=[ - replication.Replication(), - ], - next_page_token='ghi', - ), - replication.ListReplicationsResponse( - replications=[ - replication.Replication(), - replication.Replication(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_replications(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, replication.Replication) - for i in results) -def test_list_replications_pages(transport_name: str = "grpc"): - client = NetAppClient( - 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_replications), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - replication.ListReplicationsResponse( - replications=[ - replication.Replication(), - replication.Replication(), - replication.Replication(), - ], - next_page_token='abc', - ), - replication.ListReplicationsResponse( - replications=[], - next_page_token='def', - ), - replication.ListReplicationsResponse( - replications=[ - replication.Replication(), - ], - next_page_token='ghi', - ), - replication.ListReplicationsResponse( - replications=[ - replication.Replication(), - replication.Replication(), - ], - ), - RuntimeError, - ) - pages = list(client.list_replications(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_replications_async_pager(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_replications), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - replication.ListReplicationsResponse( - replications=[ - replication.Replication(), - replication.Replication(), - replication.Replication(), - ], - next_page_token='abc', - ), - replication.ListReplicationsResponse( - replications=[], - next_page_token='def', - ), - replication.ListReplicationsResponse( - replications=[ - replication.Replication(), - ], - next_page_token='ghi', - ), - replication.ListReplicationsResponse( - replications=[ - replication.Replication(), - replication.Replication(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_replications(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, replication.Replication) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_replications_async_pages(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_replications), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - replication.ListReplicationsResponse( - replications=[ - replication.Replication(), - replication.Replication(), - replication.Replication(), - ], - next_page_token='abc', - ), - replication.ListReplicationsResponse( - replications=[], - next_page_token='def', - ), - replication.ListReplicationsResponse( - replications=[ - replication.Replication(), - ], - next_page_token='ghi', - ), - replication.ListReplicationsResponse( - replications=[ - replication.Replication(), - replication.Replication(), - ], - ), - 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_replications(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", [ - replication.GetReplicationRequest, - dict, -]) -def test_get_replication(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_replication), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = replication.Replication( - name='name_value', - state=replication.Replication.State.CREATING, - state_details='state_details_value', - role=replication.Replication.ReplicationRole.SOURCE, - replication_schedule=replication.Replication.ReplicationSchedule.EVERY_10_MINUTES, - mirror_state=replication.Replication.MirrorState.PREPARING, - healthy=True, - destination_volume='destination_volume_value', - description='description_value', - source_volume='source_volume_value', - cluster_location='cluster_location_value', - hybrid_replication_type=replication.Replication.HybridReplicationType.MIGRATION, - ) - response = client.get_replication(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = replication.GetReplicationRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, replication.Replication) - assert response.name == 'name_value' - assert response.state == replication.Replication.State.CREATING - assert response.state_details == 'state_details_value' - assert response.role == replication.Replication.ReplicationRole.SOURCE - assert response.replication_schedule == replication.Replication.ReplicationSchedule.EVERY_10_MINUTES - assert response.mirror_state == replication.Replication.MirrorState.PREPARING - assert response.healthy is True - assert response.destination_volume == 'destination_volume_value' - assert response.description == 'description_value' - assert response.source_volume == 'source_volume_value' - assert response.cluster_location == 'cluster_location_value' - assert response.hybrid_replication_type == replication.Replication.HybridReplicationType.MIGRATION - - -def test_get_replication_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 = NetAppClient( - 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 = replication.GetReplicationRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_replication), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_replication(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == replication.GetReplicationRequest( - name='name_value', - ) - -def test_get_replication_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 = NetAppClient( - 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_replication 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_replication] = mock_rpc - request = {} - client.get_replication(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_replication(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_replication_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 = NetAppAsyncClient( - 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_replication 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_replication] = mock_rpc - - request = {} - await client.get_replication(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_replication(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_replication_async(transport: str = 'grpc_asyncio', request_type=replication.GetReplicationRequest): - client = NetAppAsyncClient( - 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_replication), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(replication.Replication( - name='name_value', - state=replication.Replication.State.CREATING, - state_details='state_details_value', - role=replication.Replication.ReplicationRole.SOURCE, - replication_schedule=replication.Replication.ReplicationSchedule.EVERY_10_MINUTES, - mirror_state=replication.Replication.MirrorState.PREPARING, - healthy=True, - destination_volume='destination_volume_value', - description='description_value', - source_volume='source_volume_value', - cluster_location='cluster_location_value', - hybrid_replication_type=replication.Replication.HybridReplicationType.MIGRATION, - )) - response = await client.get_replication(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = replication.GetReplicationRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, replication.Replication) - assert response.name == 'name_value' - assert response.state == replication.Replication.State.CREATING - assert response.state_details == 'state_details_value' - assert response.role == replication.Replication.ReplicationRole.SOURCE - assert response.replication_schedule == replication.Replication.ReplicationSchedule.EVERY_10_MINUTES - assert response.mirror_state == replication.Replication.MirrorState.PREPARING - assert response.healthy is True - assert response.destination_volume == 'destination_volume_value' - assert response.description == 'description_value' - assert response.source_volume == 'source_volume_value' - assert response.cluster_location == 'cluster_location_value' - assert response.hybrid_replication_type == replication.Replication.HybridReplicationType.MIGRATION - - -@pytest.mark.asyncio -async def test_get_replication_async_from_dict(): - await test_get_replication_async(request_type=dict) - -def test_get_replication_field_headers(): - client = NetAppClient( - 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 = replication.GetReplicationRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_replication), - '__call__') as call: - call.return_value = replication.Replication() - client.get_replication(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_replication_field_headers_async(): - client = NetAppAsyncClient( - 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 = replication.GetReplicationRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_replication), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(replication.Replication()) - await client.get_replication(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_replication_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_replication), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = replication.Replication() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_replication( - 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_replication_flattened_error(): - client = NetAppClient( - 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_replication( - replication.GetReplicationRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_replication_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_replication), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = replication.Replication() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(replication.Replication()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_replication( - 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_replication_flattened_error_async(): - client = NetAppAsyncClient( - 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_replication( - replication.GetReplicationRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - gcn_replication.CreateReplicationRequest, - dict, -]) -def test_create_replication(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_replication), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_replication(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gcn_replication.CreateReplicationRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_replication_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 = NetAppClient( - 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 = gcn_replication.CreateReplicationRequest( - parent='parent_value', - replication_id='replication_id_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_replication), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_replication(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gcn_replication.CreateReplicationRequest( - parent='parent_value', - replication_id='replication_id_value', - ) - -def test_create_replication_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 = NetAppClient( - 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_replication 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_replication] = mock_rpc - request = {} - client.create_replication(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_replication(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_replication_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 = NetAppAsyncClient( - 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_replication 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_replication] = mock_rpc - - request = {} - await client.create_replication(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_replication(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_replication_async(transport: str = 'grpc_asyncio', request_type=gcn_replication.CreateReplicationRequest): - client = NetAppAsyncClient( - 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_replication), - '__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_replication(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gcn_replication.CreateReplicationRequest() - 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_replication_async_from_dict(): - await test_create_replication_async(request_type=dict) - -def test_create_replication_field_headers(): - client = NetAppClient( - 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 = gcn_replication.CreateReplicationRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_replication), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_replication(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_replication_field_headers_async(): - client = NetAppAsyncClient( - 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 = gcn_replication.CreateReplicationRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_replication), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_replication(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_replication_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_replication), - '__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_replication( - parent='parent_value', - replication=gcn_replication.Replication(name='name_value'), - replication_id='replication_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].replication - mock_val = gcn_replication.Replication(name='name_value') - assert arg == mock_val - arg = args[0].replication_id - mock_val = 'replication_id_value' - assert arg == mock_val - - -def test_create_replication_flattened_error(): - client = NetAppClient( - 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_replication( - gcn_replication.CreateReplicationRequest(), - parent='parent_value', - replication=gcn_replication.Replication(name='name_value'), - replication_id='replication_id_value', - ) - -@pytest.mark.asyncio -async def test_create_replication_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_replication), - '__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_replication( - parent='parent_value', - replication=gcn_replication.Replication(name='name_value'), - replication_id='replication_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].replication - mock_val = gcn_replication.Replication(name='name_value') - assert arg == mock_val - arg = args[0].replication_id - mock_val = 'replication_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_replication_flattened_error_async(): - client = NetAppAsyncClient( - 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_replication( - gcn_replication.CreateReplicationRequest(), - parent='parent_value', - replication=gcn_replication.Replication(name='name_value'), - replication_id='replication_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - replication.DeleteReplicationRequest, - dict, -]) -def test_delete_replication(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_replication), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_replication(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = replication.DeleteReplicationRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_replication_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 = NetAppClient( - 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 = replication.DeleteReplicationRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_replication), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_replication(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == replication.DeleteReplicationRequest( - name='name_value', - ) - -def test_delete_replication_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 = NetAppClient( - 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_replication 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_replication] = mock_rpc - request = {} - client.delete_replication(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_replication(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_replication_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 = NetAppAsyncClient( - 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_replication 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_replication] = mock_rpc - - request = {} - await client.delete_replication(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_replication(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_replication_async(transport: str = 'grpc_asyncio', request_type=replication.DeleteReplicationRequest): - client = NetAppAsyncClient( - 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_replication), - '__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_replication(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = replication.DeleteReplicationRequest() - 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_replication_async_from_dict(): - await test_delete_replication_async(request_type=dict) - -def test_delete_replication_field_headers(): - client = NetAppClient( - 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 = replication.DeleteReplicationRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_replication), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_replication(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_replication_field_headers_async(): - client = NetAppAsyncClient( - 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 = replication.DeleteReplicationRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_replication), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_replication(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_replication_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_replication), - '__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_replication( - 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_replication_flattened_error(): - client = NetAppClient( - 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_replication( - replication.DeleteReplicationRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_replication_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_replication), - '__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_replication( - 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_replication_flattened_error_async(): - client = NetAppAsyncClient( - 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_replication( - replication.DeleteReplicationRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - gcn_replication.UpdateReplicationRequest, - dict, -]) -def test_update_replication(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_replication), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_replication(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gcn_replication.UpdateReplicationRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_replication_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 = NetAppClient( - 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 = gcn_replication.UpdateReplicationRequest( - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_replication), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_replication(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gcn_replication.UpdateReplicationRequest( - ) - -def test_update_replication_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 = NetAppClient( - 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_replication 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_replication] = mock_rpc - request = {} - client.update_replication(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.update_replication(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_replication_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 = NetAppAsyncClient( - 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_replication 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_replication] = mock_rpc - - request = {} - await client.update_replication(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.update_replication(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_replication_async(transport: str = 'grpc_asyncio', request_type=gcn_replication.UpdateReplicationRequest): - client = NetAppAsyncClient( - 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_replication), - '__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.update_replication(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gcn_replication.UpdateReplicationRequest() - 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_update_replication_async_from_dict(): - await test_update_replication_async(request_type=dict) - -def test_update_replication_field_headers(): - client = NetAppClient( - 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 = gcn_replication.UpdateReplicationRequest() - - request.replication.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_replication), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_replication(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', - 'replication.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_replication_field_headers_async(): - client = NetAppAsyncClient( - 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 = gcn_replication.UpdateReplicationRequest() - - request.replication.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_replication), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_replication(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', - 'replication.name=name_value', - ) in kw['metadata'] - - -def test_update_replication_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_replication), - '__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.update_replication( - replication=gcn_replication.Replication(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].replication - mock_val = gcn_replication.Replication(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_replication_flattened_error(): - client = NetAppClient( - 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_replication( - gcn_replication.UpdateReplicationRequest(), - replication=gcn_replication.Replication(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_replication_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_replication), - '__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.update_replication( - replication=gcn_replication.Replication(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].replication - mock_val = gcn_replication.Replication(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_replication_flattened_error_async(): - client = NetAppAsyncClient( - 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_replication( - gcn_replication.UpdateReplicationRequest(), - replication=gcn_replication.Replication(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - replication.StopReplicationRequest, - dict, -]) -def test_stop_replication(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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.stop_replication), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.stop_replication(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = replication.StopReplicationRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_stop_replication_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 = NetAppClient( - 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 = replication.StopReplicationRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.stop_replication), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.stop_replication(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == replication.StopReplicationRequest( - name='name_value', - ) - -def test_stop_replication_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 = NetAppClient( - 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.stop_replication 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.stop_replication] = mock_rpc - request = {} - client.stop_replication(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.stop_replication(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_stop_replication_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 = NetAppAsyncClient( - 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.stop_replication 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.stop_replication] = mock_rpc - - request = {} - await client.stop_replication(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.stop_replication(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_stop_replication_async(transport: str = 'grpc_asyncio', request_type=replication.StopReplicationRequest): - client = NetAppAsyncClient( - 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.stop_replication), - '__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.stop_replication(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = replication.StopReplicationRequest() - 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_stop_replication_async_from_dict(): - await test_stop_replication_async(request_type=dict) - -def test_stop_replication_field_headers(): - client = NetAppClient( - 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 = replication.StopReplicationRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.stop_replication), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.stop_replication(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_stop_replication_field_headers_async(): - client = NetAppAsyncClient( - 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 = replication.StopReplicationRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.stop_replication), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.stop_replication(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'] - - -@pytest.mark.parametrize("request_type", [ - replication.ResumeReplicationRequest, - dict, -]) -def test_resume_replication(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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.resume_replication), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.resume_replication(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = replication.ResumeReplicationRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_resume_replication_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 = NetAppClient( - 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 = replication.ResumeReplicationRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.resume_replication), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.resume_replication(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == replication.ResumeReplicationRequest( - name='name_value', - ) - -def test_resume_replication_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 = NetAppClient( - 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.resume_replication 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.resume_replication] = mock_rpc - request = {} - client.resume_replication(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.resume_replication(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_resume_replication_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 = NetAppAsyncClient( - 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.resume_replication 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.resume_replication] = mock_rpc - - request = {} - await client.resume_replication(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.resume_replication(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_resume_replication_async(transport: str = 'grpc_asyncio', request_type=replication.ResumeReplicationRequest): - client = NetAppAsyncClient( - 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.resume_replication), - '__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.resume_replication(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = replication.ResumeReplicationRequest() - 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_resume_replication_async_from_dict(): - await test_resume_replication_async(request_type=dict) - -def test_resume_replication_field_headers(): - client = NetAppClient( - 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 = replication.ResumeReplicationRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.resume_replication), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.resume_replication(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_resume_replication_field_headers_async(): - client = NetAppAsyncClient( - 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 = replication.ResumeReplicationRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.resume_replication), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.resume_replication(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'] - - -@pytest.mark.parametrize("request_type", [ - replication.ReverseReplicationDirectionRequest, - dict, -]) -def test_reverse_replication_direction(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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.reverse_replication_direction), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.reverse_replication_direction(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = replication.ReverseReplicationDirectionRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_reverse_replication_direction_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 = NetAppClient( - 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 = replication.ReverseReplicationDirectionRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.reverse_replication_direction), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.reverse_replication_direction(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == replication.ReverseReplicationDirectionRequest( - name='name_value', - ) - -def test_reverse_replication_direction_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 = NetAppClient( - 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.reverse_replication_direction 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.reverse_replication_direction] = mock_rpc - request = {} - client.reverse_replication_direction(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.reverse_replication_direction(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_reverse_replication_direction_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 = NetAppAsyncClient( - 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.reverse_replication_direction 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.reverse_replication_direction] = mock_rpc - - request = {} - await client.reverse_replication_direction(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.reverse_replication_direction(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_reverse_replication_direction_async(transport: str = 'grpc_asyncio', request_type=replication.ReverseReplicationDirectionRequest): - client = NetAppAsyncClient( - 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.reverse_replication_direction), - '__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.reverse_replication_direction(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = replication.ReverseReplicationDirectionRequest() - 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_reverse_replication_direction_async_from_dict(): - await test_reverse_replication_direction_async(request_type=dict) - -def test_reverse_replication_direction_field_headers(): - client = NetAppClient( - 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 = replication.ReverseReplicationDirectionRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.reverse_replication_direction), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.reverse_replication_direction(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_reverse_replication_direction_field_headers_async(): - client = NetAppAsyncClient( - 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 = replication.ReverseReplicationDirectionRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.reverse_replication_direction), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.reverse_replication_direction(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'] - - -@pytest.mark.parametrize("request_type", [ - replication.EstablishPeeringRequest, - dict, -]) -def test_establish_peering(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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.establish_peering), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.establish_peering(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = replication.EstablishPeeringRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_establish_peering_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 = NetAppClient( - 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 = replication.EstablishPeeringRequest( - name='name_value', - peer_cluster_name='peer_cluster_name_value', - peer_svm_name='peer_svm_name_value', - peer_volume_name='peer_volume_name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.establish_peering), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.establish_peering(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == replication.EstablishPeeringRequest( - name='name_value', - peer_cluster_name='peer_cluster_name_value', - peer_svm_name='peer_svm_name_value', - peer_volume_name='peer_volume_name_value', - ) - -def test_establish_peering_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 = NetAppClient( - 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.establish_peering 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.establish_peering] = mock_rpc - request = {} - client.establish_peering(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.establish_peering(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_establish_peering_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 = NetAppAsyncClient( - 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.establish_peering 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.establish_peering] = mock_rpc - - request = {} - await client.establish_peering(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.establish_peering(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_establish_peering_async(transport: str = 'grpc_asyncio', request_type=replication.EstablishPeeringRequest): - client = NetAppAsyncClient( - 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.establish_peering), - '__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.establish_peering(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = replication.EstablishPeeringRequest() - 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_establish_peering_async_from_dict(): - await test_establish_peering_async(request_type=dict) - -def test_establish_peering_field_headers(): - client = NetAppClient( - 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 = replication.EstablishPeeringRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.establish_peering), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.establish_peering(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_establish_peering_field_headers_async(): - client = NetAppAsyncClient( - 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 = replication.EstablishPeeringRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.establish_peering), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.establish_peering(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'] - - -@pytest.mark.parametrize("request_type", [ - replication.SyncReplicationRequest, - dict, -]) -def test_sync_replication(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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.sync_replication), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.sync_replication(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = replication.SyncReplicationRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_sync_replication_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 = NetAppClient( - 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 = replication.SyncReplicationRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.sync_replication), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.sync_replication(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == replication.SyncReplicationRequest( - name='name_value', - ) - -def test_sync_replication_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 = NetAppClient( - 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.sync_replication 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.sync_replication] = mock_rpc - request = {} - client.sync_replication(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.sync_replication(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_sync_replication_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 = NetAppAsyncClient( - 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.sync_replication 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.sync_replication] = mock_rpc - - request = {} - await client.sync_replication(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.sync_replication(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_sync_replication_async(transport: str = 'grpc_asyncio', request_type=replication.SyncReplicationRequest): - client = NetAppAsyncClient( - 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.sync_replication), - '__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.sync_replication(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = replication.SyncReplicationRequest() - 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_sync_replication_async_from_dict(): - await test_sync_replication_async(request_type=dict) - -def test_sync_replication_field_headers(): - client = NetAppClient( - 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 = replication.SyncReplicationRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.sync_replication), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.sync_replication(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_sync_replication_field_headers_async(): - client = NetAppAsyncClient( - 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 = replication.SyncReplicationRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.sync_replication), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.sync_replication(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'] - - -@pytest.mark.parametrize("request_type", [ - gcn_backup_vault.CreateBackupVaultRequest, - dict, -]) -def test_create_backup_vault(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_backup_vault), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_backup_vault(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gcn_backup_vault.CreateBackupVaultRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_backup_vault_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 = NetAppClient( - 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 = gcn_backup_vault.CreateBackupVaultRequest( - parent='parent_value', - backup_vault_id='backup_vault_id_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_backup_vault), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_backup_vault(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gcn_backup_vault.CreateBackupVaultRequest( - parent='parent_value', - backup_vault_id='backup_vault_id_value', - ) - -def test_create_backup_vault_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 = NetAppClient( - 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_backup_vault 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_backup_vault] = mock_rpc - request = {} - client.create_backup_vault(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_backup_vault(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_backup_vault_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 = NetAppAsyncClient( - 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_backup_vault 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_backup_vault] = mock_rpc - - request = {} - await client.create_backup_vault(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_backup_vault(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_backup_vault_async(transport: str = 'grpc_asyncio', request_type=gcn_backup_vault.CreateBackupVaultRequest): - client = NetAppAsyncClient( - 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_backup_vault), - '__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_backup_vault(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gcn_backup_vault.CreateBackupVaultRequest() - 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_backup_vault_async_from_dict(): - await test_create_backup_vault_async(request_type=dict) - -def test_create_backup_vault_field_headers(): - client = NetAppClient( - 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 = gcn_backup_vault.CreateBackupVaultRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_backup_vault), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_backup_vault(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_backup_vault_field_headers_async(): - client = NetAppAsyncClient( - 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 = gcn_backup_vault.CreateBackupVaultRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_backup_vault), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_backup_vault(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_backup_vault_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_backup_vault), - '__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_backup_vault( - parent='parent_value', - backup_vault=gcn_backup_vault.BackupVault(name='name_value'), - backup_vault_id='backup_vault_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].backup_vault - mock_val = gcn_backup_vault.BackupVault(name='name_value') - assert arg == mock_val - arg = args[0].backup_vault_id - mock_val = 'backup_vault_id_value' - assert arg == mock_val - - -def test_create_backup_vault_flattened_error(): - client = NetAppClient( - 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_backup_vault( - gcn_backup_vault.CreateBackupVaultRequest(), - parent='parent_value', - backup_vault=gcn_backup_vault.BackupVault(name='name_value'), - backup_vault_id='backup_vault_id_value', - ) - -@pytest.mark.asyncio -async def test_create_backup_vault_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_backup_vault), - '__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_backup_vault( - parent='parent_value', - backup_vault=gcn_backup_vault.BackupVault(name='name_value'), - backup_vault_id='backup_vault_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].backup_vault - mock_val = gcn_backup_vault.BackupVault(name='name_value') - assert arg == mock_val - arg = args[0].backup_vault_id - mock_val = 'backup_vault_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_backup_vault_flattened_error_async(): - client = NetAppAsyncClient( - 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_backup_vault( - gcn_backup_vault.CreateBackupVaultRequest(), - parent='parent_value', - backup_vault=gcn_backup_vault.BackupVault(name='name_value'), - backup_vault_id='backup_vault_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - backup_vault.GetBackupVaultRequest, - dict, -]) -def test_get_backup_vault(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_backup_vault), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = backup_vault.BackupVault( - name='name_value', - state=backup_vault.BackupVault.State.CREATING, - description='description_value', - ) - response = client.get_backup_vault(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = backup_vault.GetBackupVaultRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, backup_vault.BackupVault) - assert response.name == 'name_value' - assert response.state == backup_vault.BackupVault.State.CREATING - assert response.description == 'description_value' - - -def test_get_backup_vault_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 = NetAppClient( - 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 = backup_vault.GetBackupVaultRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_backup_vault), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_backup_vault(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == backup_vault.GetBackupVaultRequest( - name='name_value', - ) - -def test_get_backup_vault_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 = NetAppClient( - 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_backup_vault 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_backup_vault] = mock_rpc - request = {} - client.get_backup_vault(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_backup_vault(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_backup_vault_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 = NetAppAsyncClient( - 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_backup_vault 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_backup_vault] = mock_rpc - - request = {} - await client.get_backup_vault(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_backup_vault(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_backup_vault_async(transport: str = 'grpc_asyncio', request_type=backup_vault.GetBackupVaultRequest): - client = NetAppAsyncClient( - 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_backup_vault), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(backup_vault.BackupVault( - name='name_value', - state=backup_vault.BackupVault.State.CREATING, - description='description_value', - )) - response = await client.get_backup_vault(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = backup_vault.GetBackupVaultRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, backup_vault.BackupVault) - assert response.name == 'name_value' - assert response.state == backup_vault.BackupVault.State.CREATING - assert response.description == 'description_value' - - -@pytest.mark.asyncio -async def test_get_backup_vault_async_from_dict(): - await test_get_backup_vault_async(request_type=dict) - -def test_get_backup_vault_field_headers(): - client = NetAppClient( - 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 = backup_vault.GetBackupVaultRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_backup_vault), - '__call__') as call: - call.return_value = backup_vault.BackupVault() - client.get_backup_vault(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_backup_vault_field_headers_async(): - client = NetAppAsyncClient( - 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 = backup_vault.GetBackupVaultRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_backup_vault), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_vault.BackupVault()) - await client.get_backup_vault(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_backup_vault_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_backup_vault), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = backup_vault.BackupVault() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_backup_vault( - 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_backup_vault_flattened_error(): - client = NetAppClient( - 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_backup_vault( - backup_vault.GetBackupVaultRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_backup_vault_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_backup_vault), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = backup_vault.BackupVault() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_vault.BackupVault()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_backup_vault( - 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_backup_vault_flattened_error_async(): - client = NetAppAsyncClient( - 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_backup_vault( - backup_vault.GetBackupVaultRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - backup_vault.ListBackupVaultsRequest, - dict, -]) -def test_list_backup_vaults(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_backup_vaults), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = backup_vault.ListBackupVaultsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_backup_vaults(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = backup_vault.ListBackupVaultsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListBackupVaultsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_backup_vaults_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 = NetAppClient( - 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 = backup_vault.ListBackupVaultsRequest( - 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_backup_vaults), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_backup_vaults(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == backup_vault.ListBackupVaultsRequest( - parent='parent_value', - page_token='page_token_value', - order_by='order_by_value', - filter='filter_value', - ) - -def test_list_backup_vaults_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 = NetAppClient( - 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_backup_vaults 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_backup_vaults] = mock_rpc - request = {} - client.list_backup_vaults(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_backup_vaults(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_backup_vaults_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 = NetAppAsyncClient( - 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_backup_vaults 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_backup_vaults] = mock_rpc - - request = {} - await client.list_backup_vaults(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_backup_vaults(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_backup_vaults_async(transport: str = 'grpc_asyncio', request_type=backup_vault.ListBackupVaultsRequest): - client = NetAppAsyncClient( - 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_backup_vaults), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(backup_vault.ListBackupVaultsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_backup_vaults(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = backup_vault.ListBackupVaultsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListBackupVaultsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_backup_vaults_async_from_dict(): - await test_list_backup_vaults_async(request_type=dict) - -def test_list_backup_vaults_field_headers(): - client = NetAppClient( - 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 = backup_vault.ListBackupVaultsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_backup_vaults), - '__call__') as call: - call.return_value = backup_vault.ListBackupVaultsResponse() - client.list_backup_vaults(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_backup_vaults_field_headers_async(): - client = NetAppAsyncClient( - 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 = backup_vault.ListBackupVaultsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_backup_vaults), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_vault.ListBackupVaultsResponse()) - await client.list_backup_vaults(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_backup_vaults_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_backup_vaults), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = backup_vault.ListBackupVaultsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_backup_vaults( - 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_backup_vaults_flattened_error(): - client = NetAppClient( - 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_backup_vaults( - backup_vault.ListBackupVaultsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_backup_vaults_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_backup_vaults), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = backup_vault.ListBackupVaultsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_vault.ListBackupVaultsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_backup_vaults( - 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_backup_vaults_flattened_error_async(): - client = NetAppAsyncClient( - 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_backup_vaults( - backup_vault.ListBackupVaultsRequest(), - parent='parent_value', - ) - - -def test_list_backup_vaults_pager(transport_name: str = "grpc"): - client = NetAppClient( - 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_backup_vaults), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - backup_vault.ListBackupVaultsResponse( - backup_vaults=[ - backup_vault.BackupVault(), - backup_vault.BackupVault(), - backup_vault.BackupVault(), - ], - next_page_token='abc', - ), - backup_vault.ListBackupVaultsResponse( - backup_vaults=[], - next_page_token='def', - ), - backup_vault.ListBackupVaultsResponse( - backup_vaults=[ - backup_vault.BackupVault(), - ], - next_page_token='ghi', - ), - backup_vault.ListBackupVaultsResponse( - backup_vaults=[ - backup_vault.BackupVault(), - backup_vault.BackupVault(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_backup_vaults(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, backup_vault.BackupVault) - for i in results) -def test_list_backup_vaults_pages(transport_name: str = "grpc"): - client = NetAppClient( - 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_backup_vaults), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - backup_vault.ListBackupVaultsResponse( - backup_vaults=[ - backup_vault.BackupVault(), - backup_vault.BackupVault(), - backup_vault.BackupVault(), - ], - next_page_token='abc', - ), - backup_vault.ListBackupVaultsResponse( - backup_vaults=[], - next_page_token='def', - ), - backup_vault.ListBackupVaultsResponse( - backup_vaults=[ - backup_vault.BackupVault(), - ], - next_page_token='ghi', - ), - backup_vault.ListBackupVaultsResponse( - backup_vaults=[ - backup_vault.BackupVault(), - backup_vault.BackupVault(), - ], - ), - RuntimeError, - ) - pages = list(client.list_backup_vaults(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_backup_vaults_async_pager(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_backup_vaults), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - backup_vault.ListBackupVaultsResponse( - backup_vaults=[ - backup_vault.BackupVault(), - backup_vault.BackupVault(), - backup_vault.BackupVault(), - ], - next_page_token='abc', - ), - backup_vault.ListBackupVaultsResponse( - backup_vaults=[], - next_page_token='def', - ), - backup_vault.ListBackupVaultsResponse( - backup_vaults=[ - backup_vault.BackupVault(), - ], - next_page_token='ghi', - ), - backup_vault.ListBackupVaultsResponse( - backup_vaults=[ - backup_vault.BackupVault(), - backup_vault.BackupVault(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_backup_vaults(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, backup_vault.BackupVault) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_backup_vaults_async_pages(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_backup_vaults), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - backup_vault.ListBackupVaultsResponse( - backup_vaults=[ - backup_vault.BackupVault(), - backup_vault.BackupVault(), - backup_vault.BackupVault(), - ], - next_page_token='abc', - ), - backup_vault.ListBackupVaultsResponse( - backup_vaults=[], - next_page_token='def', - ), - backup_vault.ListBackupVaultsResponse( - backup_vaults=[ - backup_vault.BackupVault(), - ], - next_page_token='ghi', - ), - backup_vault.ListBackupVaultsResponse( - backup_vaults=[ - backup_vault.BackupVault(), - backup_vault.BackupVault(), - ], - ), - 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_backup_vaults(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", [ - gcn_backup_vault.UpdateBackupVaultRequest, - dict, -]) -def test_update_backup_vault(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_backup_vault), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_backup_vault(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gcn_backup_vault.UpdateBackupVaultRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_backup_vault_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 = NetAppClient( - 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 = gcn_backup_vault.UpdateBackupVaultRequest( - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_backup_vault), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_backup_vault(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gcn_backup_vault.UpdateBackupVaultRequest( - ) - -def test_update_backup_vault_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 = NetAppClient( - 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_backup_vault 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_backup_vault] = mock_rpc - request = {} - client.update_backup_vault(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.update_backup_vault(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_backup_vault_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 = NetAppAsyncClient( - 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_backup_vault 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_backup_vault] = mock_rpc - - request = {} - await client.update_backup_vault(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.update_backup_vault(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_backup_vault_async(transport: str = 'grpc_asyncio', request_type=gcn_backup_vault.UpdateBackupVaultRequest): - client = NetAppAsyncClient( - 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_backup_vault), - '__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.update_backup_vault(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gcn_backup_vault.UpdateBackupVaultRequest() - 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_update_backup_vault_async_from_dict(): - await test_update_backup_vault_async(request_type=dict) - -def test_update_backup_vault_field_headers(): - client = NetAppClient( - 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 = gcn_backup_vault.UpdateBackupVaultRequest() - - request.backup_vault.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_backup_vault), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_backup_vault(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', - 'backup_vault.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_backup_vault_field_headers_async(): - client = NetAppAsyncClient( - 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 = gcn_backup_vault.UpdateBackupVaultRequest() - - request.backup_vault.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_backup_vault), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_backup_vault(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', - 'backup_vault.name=name_value', - ) in kw['metadata'] - - -def test_update_backup_vault_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_backup_vault), - '__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.update_backup_vault( - backup_vault=gcn_backup_vault.BackupVault(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].backup_vault - mock_val = gcn_backup_vault.BackupVault(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_backup_vault_flattened_error(): - client = NetAppClient( - 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_backup_vault( - gcn_backup_vault.UpdateBackupVaultRequest(), - backup_vault=gcn_backup_vault.BackupVault(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_backup_vault_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_backup_vault), - '__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.update_backup_vault( - backup_vault=gcn_backup_vault.BackupVault(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].backup_vault - mock_val = gcn_backup_vault.BackupVault(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_backup_vault_flattened_error_async(): - client = NetAppAsyncClient( - 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_backup_vault( - gcn_backup_vault.UpdateBackupVaultRequest(), - backup_vault=gcn_backup_vault.BackupVault(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - backup_vault.DeleteBackupVaultRequest, - dict, -]) -def test_delete_backup_vault(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_backup_vault), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_backup_vault(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = backup_vault.DeleteBackupVaultRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_backup_vault_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 = NetAppClient( - 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 = backup_vault.DeleteBackupVaultRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup_vault), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_backup_vault(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == backup_vault.DeleteBackupVaultRequest( - name='name_value', - ) - -def test_delete_backup_vault_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 = NetAppClient( - 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_backup_vault 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_backup_vault] = mock_rpc - request = {} - client.delete_backup_vault(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_backup_vault(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_backup_vault_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 = NetAppAsyncClient( - 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_backup_vault 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_backup_vault] = mock_rpc - - request = {} - await client.delete_backup_vault(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_backup_vault(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_backup_vault_async(transport: str = 'grpc_asyncio', request_type=backup_vault.DeleteBackupVaultRequest): - client = NetAppAsyncClient( - 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_backup_vault), - '__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_backup_vault(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = backup_vault.DeleteBackupVaultRequest() - 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_backup_vault_async_from_dict(): - await test_delete_backup_vault_async(request_type=dict) - -def test_delete_backup_vault_field_headers(): - client = NetAppClient( - 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 = backup_vault.DeleteBackupVaultRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup_vault), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_backup_vault(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_backup_vault_field_headers_async(): - client = NetAppAsyncClient( - 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 = backup_vault.DeleteBackupVaultRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup_vault), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_backup_vault(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_backup_vault_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup_vault), - '__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_backup_vault( - 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_backup_vault_flattened_error(): - client = NetAppClient( - 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_backup_vault( - backup_vault.DeleteBackupVaultRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_backup_vault_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup_vault), - '__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_backup_vault( - 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_backup_vault_flattened_error_async(): - client = NetAppAsyncClient( - 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_backup_vault( - backup_vault.DeleteBackupVaultRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - gcn_backup.CreateBackupRequest, - dict, -]) -def test_create_backup(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_backup), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_backup(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gcn_backup.CreateBackupRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_backup_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 = NetAppClient( - 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 = gcn_backup.CreateBackupRequest( - parent='parent_value', - backup_id='backup_id_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_backup), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_backup(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gcn_backup.CreateBackupRequest( - parent='parent_value', - backup_id='backup_id_value', - ) - -def test_create_backup_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 = NetAppClient( - 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_backup 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_backup] = mock_rpc - request = {} - client.create_backup(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_backup(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_backup_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 = NetAppAsyncClient( - 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_backup 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_backup] = mock_rpc - - request = {} - await client.create_backup(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_backup(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_backup_async(transport: str = 'grpc_asyncio', request_type=gcn_backup.CreateBackupRequest): - client = NetAppAsyncClient( - 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_backup), - '__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_backup(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gcn_backup.CreateBackupRequest() - 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_backup_async_from_dict(): - await test_create_backup_async(request_type=dict) - -def test_create_backup_field_headers(): - client = NetAppClient( - 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 = gcn_backup.CreateBackupRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_backup), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_backup(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_backup_field_headers_async(): - client = NetAppAsyncClient( - 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 = gcn_backup.CreateBackupRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_backup), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_backup(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_backup_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_backup), - '__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_backup( - parent='parent_value', - backup=gcn_backup.Backup(name='name_value'), - backup_id='backup_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].backup - mock_val = gcn_backup.Backup(name='name_value') - assert arg == mock_val - arg = args[0].backup_id - mock_val = 'backup_id_value' - assert arg == mock_val - - -def test_create_backup_flattened_error(): - client = NetAppClient( - 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_backup( - gcn_backup.CreateBackupRequest(), - parent='parent_value', - backup=gcn_backup.Backup(name='name_value'), - backup_id='backup_id_value', - ) - -@pytest.mark.asyncio -async def test_create_backup_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_backup), - '__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_backup( - parent='parent_value', - backup=gcn_backup.Backup(name='name_value'), - backup_id='backup_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].backup - mock_val = gcn_backup.Backup(name='name_value') - assert arg == mock_val - arg = args[0].backup_id - mock_val = 'backup_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_backup_flattened_error_async(): - client = NetAppAsyncClient( - 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_backup( - gcn_backup.CreateBackupRequest(), - parent='parent_value', - backup=gcn_backup.Backup(name='name_value'), - backup_id='backup_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - backup.GetBackupRequest, - dict, -]) -def test_get_backup(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_backup), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = backup.Backup( - name='name_value', - state=backup.Backup.State.CREATING, - description='description_value', - volume_usage_bytes=1938, - backup_type=backup.Backup.Type.MANUAL, - source_volume='source_volume_value', - source_snapshot='source_snapshot_value', - chain_storage_bytes=2013, - satisfies_pzs=True, - satisfies_pzi=True, - ) - response = client.get_backup(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = backup.GetBackupRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, backup.Backup) - assert response.name == 'name_value' - assert response.state == backup.Backup.State.CREATING - assert response.description == 'description_value' - assert response.volume_usage_bytes == 1938 - assert response.backup_type == backup.Backup.Type.MANUAL - assert response.source_volume == 'source_volume_value' - assert response.source_snapshot == 'source_snapshot_value' - assert response.chain_storage_bytes == 2013 - assert response.satisfies_pzs is True - assert response.satisfies_pzi is True - - -def test_get_backup_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 = NetAppClient( - 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 = backup.GetBackupRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_backup), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_backup(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == backup.GetBackupRequest( - name='name_value', - ) - -def test_get_backup_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 = NetAppClient( - 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_backup 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_backup] = mock_rpc - request = {} - client.get_backup(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_backup(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_backup_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 = NetAppAsyncClient( - 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_backup 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_backup] = mock_rpc - - request = {} - await client.get_backup(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_backup(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_backup_async(transport: str = 'grpc_asyncio', request_type=backup.GetBackupRequest): - client = NetAppAsyncClient( - 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_backup), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(backup.Backup( - name='name_value', - state=backup.Backup.State.CREATING, - description='description_value', - volume_usage_bytes=1938, - backup_type=backup.Backup.Type.MANUAL, - source_volume='source_volume_value', - source_snapshot='source_snapshot_value', - chain_storage_bytes=2013, - satisfies_pzs=True, - satisfies_pzi=True, - )) - response = await client.get_backup(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = backup.GetBackupRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, backup.Backup) - assert response.name == 'name_value' - assert response.state == backup.Backup.State.CREATING - assert response.description == 'description_value' - assert response.volume_usage_bytes == 1938 - assert response.backup_type == backup.Backup.Type.MANUAL - assert response.source_volume == 'source_volume_value' - assert response.source_snapshot == 'source_snapshot_value' - assert response.chain_storage_bytes == 2013 - assert response.satisfies_pzs is True - assert response.satisfies_pzi is True - - -@pytest.mark.asyncio -async def test_get_backup_async_from_dict(): - await test_get_backup_async(request_type=dict) - -def test_get_backup_field_headers(): - client = NetAppClient( - 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 = backup.GetBackupRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_backup), - '__call__') as call: - call.return_value = backup.Backup() - client.get_backup(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_backup_field_headers_async(): - client = NetAppAsyncClient( - 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 = backup.GetBackupRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_backup), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup.Backup()) - await client.get_backup(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_backup_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_backup), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = backup.Backup() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_backup( - 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_backup_flattened_error(): - client = NetAppClient( - 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_backup( - backup.GetBackupRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_backup_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_backup), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = backup.Backup() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup.Backup()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_backup( - 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_backup_flattened_error_async(): - client = NetAppAsyncClient( - 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_backup( - backup.GetBackupRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - backup.ListBackupsRequest, - dict, -]) -def test_list_backups(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_backups), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = backup.ListBackupsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_backups(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = backup.ListBackupsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListBackupsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_backups_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 = NetAppClient( - 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 = backup.ListBackupsRequest( - 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_backups), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_backups(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == backup.ListBackupsRequest( - parent='parent_value', - page_token='page_token_value', - order_by='order_by_value', - filter='filter_value', - ) - -def test_list_backups_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 = NetAppClient( - 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_backups 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_backups] = mock_rpc - request = {} - client.list_backups(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_backups(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_backups_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 = NetAppAsyncClient( - 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_backups 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_backups] = mock_rpc - - request = {} - await client.list_backups(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_backups(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_backups_async(transport: str = 'grpc_asyncio', request_type=backup.ListBackupsRequest): - client = NetAppAsyncClient( - 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_backups), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(backup.ListBackupsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_backups(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = backup.ListBackupsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListBackupsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_backups_async_from_dict(): - await test_list_backups_async(request_type=dict) - -def test_list_backups_field_headers(): - client = NetAppClient( - 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 = backup.ListBackupsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_backups), - '__call__') as call: - call.return_value = backup.ListBackupsResponse() - client.list_backups(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_backups_field_headers_async(): - client = NetAppAsyncClient( - 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 = backup.ListBackupsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_backups), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup.ListBackupsResponse()) - await client.list_backups(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_backups_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_backups), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = backup.ListBackupsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_backups( - 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_backups_flattened_error(): - client = NetAppClient( - 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_backups( - backup.ListBackupsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_backups_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_backups), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = backup.ListBackupsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup.ListBackupsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_backups( - 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_backups_flattened_error_async(): - client = NetAppAsyncClient( - 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_backups( - backup.ListBackupsRequest(), - parent='parent_value', - ) - - -def test_list_backups_pager(transport_name: str = "grpc"): - client = NetAppClient( - 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_backups), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - backup.ListBackupsResponse( - backups=[ - backup.Backup(), - backup.Backup(), - backup.Backup(), - ], - next_page_token='abc', - ), - backup.ListBackupsResponse( - backups=[], - next_page_token='def', - ), - backup.ListBackupsResponse( - backups=[ - backup.Backup(), - ], - next_page_token='ghi', - ), - backup.ListBackupsResponse( - backups=[ - backup.Backup(), - backup.Backup(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_backups(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, backup.Backup) - for i in results) -def test_list_backups_pages(transport_name: str = "grpc"): - client = NetAppClient( - 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_backups), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - backup.ListBackupsResponse( - backups=[ - backup.Backup(), - backup.Backup(), - backup.Backup(), - ], - next_page_token='abc', - ), - backup.ListBackupsResponse( - backups=[], - next_page_token='def', - ), - backup.ListBackupsResponse( - backups=[ - backup.Backup(), - ], - next_page_token='ghi', - ), - backup.ListBackupsResponse( - backups=[ - backup.Backup(), - backup.Backup(), - ], - ), - RuntimeError, - ) - pages = list(client.list_backups(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_backups_async_pager(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_backups), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - backup.ListBackupsResponse( - backups=[ - backup.Backup(), - backup.Backup(), - backup.Backup(), - ], - next_page_token='abc', - ), - backup.ListBackupsResponse( - backups=[], - next_page_token='def', - ), - backup.ListBackupsResponse( - backups=[ - backup.Backup(), - ], - next_page_token='ghi', - ), - backup.ListBackupsResponse( - backups=[ - backup.Backup(), - backup.Backup(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_backups(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, backup.Backup) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_backups_async_pages(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_backups), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - backup.ListBackupsResponse( - backups=[ - backup.Backup(), - backup.Backup(), - backup.Backup(), - ], - next_page_token='abc', - ), - backup.ListBackupsResponse( - backups=[], - next_page_token='def', - ), - backup.ListBackupsResponse( - backups=[ - backup.Backup(), - ], - next_page_token='ghi', - ), - backup.ListBackupsResponse( - backups=[ - backup.Backup(), - backup.Backup(), - ], - ), - 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_backups(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", [ - backup.DeleteBackupRequest, - dict, -]) -def test_delete_backup(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_backup), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_backup(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = backup.DeleteBackupRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_backup_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 = NetAppClient( - 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 = backup.DeleteBackupRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_backup(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == backup.DeleteBackupRequest( - name='name_value', - ) - -def test_delete_backup_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 = NetAppClient( - 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_backup 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_backup] = mock_rpc - request = {} - client.delete_backup(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_backup(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_backup_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 = NetAppAsyncClient( - 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_backup 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_backup] = mock_rpc - - request = {} - await client.delete_backup(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_backup(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_backup_async(transport: str = 'grpc_asyncio', request_type=backup.DeleteBackupRequest): - client = NetAppAsyncClient( - 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_backup), - '__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_backup(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = backup.DeleteBackupRequest() - 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_backup_async_from_dict(): - await test_delete_backup_async(request_type=dict) - -def test_delete_backup_field_headers(): - client = NetAppClient( - 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 = backup.DeleteBackupRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_backup(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_backup_field_headers_async(): - client = NetAppAsyncClient( - 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 = backup.DeleteBackupRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_backup(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_backup_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup), - '__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_backup( - 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_backup_flattened_error(): - client = NetAppClient( - 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_backup( - backup.DeleteBackupRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_backup_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup), - '__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_backup( - 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_backup_flattened_error_async(): - client = NetAppAsyncClient( - 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_backup( - backup.DeleteBackupRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - gcn_backup.UpdateBackupRequest, - dict, -]) -def test_update_backup(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_backup), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_backup(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gcn_backup.UpdateBackupRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_backup_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 = NetAppClient( - 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 = gcn_backup.UpdateBackupRequest( - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_backup), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_backup(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gcn_backup.UpdateBackupRequest( - ) - -def test_update_backup_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 = NetAppClient( - 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_backup 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_backup] = mock_rpc - request = {} - client.update_backup(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.update_backup(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_backup_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 = NetAppAsyncClient( - 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_backup 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_backup] = mock_rpc - - request = {} - await client.update_backup(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.update_backup(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_backup_async(transport: str = 'grpc_asyncio', request_type=gcn_backup.UpdateBackupRequest): - client = NetAppAsyncClient( - 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_backup), - '__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.update_backup(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gcn_backup.UpdateBackupRequest() - 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_update_backup_async_from_dict(): - await test_update_backup_async(request_type=dict) - -def test_update_backup_field_headers(): - client = NetAppClient( - 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 = gcn_backup.UpdateBackupRequest() - - request.backup.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_backup), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_backup(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', - 'backup.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_backup_field_headers_async(): - client = NetAppAsyncClient( - 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 = gcn_backup.UpdateBackupRequest() - - request.backup.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_backup), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_backup(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', - 'backup.name=name_value', - ) in kw['metadata'] - - -def test_update_backup_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_backup), - '__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.update_backup( - backup=gcn_backup.Backup(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].backup - mock_val = gcn_backup.Backup(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_backup_flattened_error(): - client = NetAppClient( - 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_backup( - gcn_backup.UpdateBackupRequest(), - backup=gcn_backup.Backup(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_backup_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_backup), - '__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.update_backup( - backup=gcn_backup.Backup(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].backup - mock_val = gcn_backup.Backup(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_backup_flattened_error_async(): - client = NetAppAsyncClient( - 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_backup( - gcn_backup.UpdateBackupRequest(), - backup=gcn_backup.Backup(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - gcn_backup_policy.CreateBackupPolicyRequest, - dict, -]) -def test_create_backup_policy(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_backup_policy), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_backup_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gcn_backup_policy.CreateBackupPolicyRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_backup_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 = NetAppClient( - 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 = gcn_backup_policy.CreateBackupPolicyRequest( - parent='parent_value', - backup_policy_id='backup_policy_id_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_backup_policy), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_backup_policy(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gcn_backup_policy.CreateBackupPolicyRequest( - parent='parent_value', - backup_policy_id='backup_policy_id_value', - ) - -def test_create_backup_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 = NetAppClient( - 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_backup_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.create_backup_policy] = mock_rpc - request = {} - client.create_backup_policy(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_backup_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_create_backup_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 = NetAppAsyncClient( - 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_backup_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.create_backup_policy] = mock_rpc - - request = {} - await client.create_backup_policy(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_backup_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_create_backup_policy_async(transport: str = 'grpc_asyncio', request_type=gcn_backup_policy.CreateBackupPolicyRequest): - client = NetAppAsyncClient( - 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_backup_policy), - '__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_backup_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gcn_backup_policy.CreateBackupPolicyRequest() - 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_backup_policy_async_from_dict(): - await test_create_backup_policy_async(request_type=dict) - -def test_create_backup_policy_field_headers(): - client = NetAppClient( - 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 = gcn_backup_policy.CreateBackupPolicyRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_backup_policy), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_backup_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', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_create_backup_policy_field_headers_async(): - client = NetAppAsyncClient( - 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 = gcn_backup_policy.CreateBackupPolicyRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_backup_policy), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_backup_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', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_create_backup_policy_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_backup_policy), - '__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_backup_policy( - parent='parent_value', - backup_policy=gcn_backup_policy.BackupPolicy(name='name_value'), - backup_policy_id='backup_policy_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].backup_policy - mock_val = gcn_backup_policy.BackupPolicy(name='name_value') - assert arg == mock_val - arg = args[0].backup_policy_id - mock_val = 'backup_policy_id_value' - assert arg == mock_val - - -def test_create_backup_policy_flattened_error(): - client = NetAppClient( - 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_backup_policy( - gcn_backup_policy.CreateBackupPolicyRequest(), - parent='parent_value', - backup_policy=gcn_backup_policy.BackupPolicy(name='name_value'), - backup_policy_id='backup_policy_id_value', - ) - -@pytest.mark.asyncio -async def test_create_backup_policy_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_backup_policy), - '__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_backup_policy( - parent='parent_value', - backup_policy=gcn_backup_policy.BackupPolicy(name='name_value'), - backup_policy_id='backup_policy_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].backup_policy - mock_val = gcn_backup_policy.BackupPolicy(name='name_value') - assert arg == mock_val - arg = args[0].backup_policy_id - mock_val = 'backup_policy_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_backup_policy_flattened_error_async(): - client = NetAppAsyncClient( - 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_backup_policy( - gcn_backup_policy.CreateBackupPolicyRequest(), - parent='parent_value', - backup_policy=gcn_backup_policy.BackupPolicy(name='name_value'), - backup_policy_id='backup_policy_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - backup_policy.GetBackupPolicyRequest, - dict, -]) -def test_get_backup_policy(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_backup_policy), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = backup_policy.BackupPolicy( - name='name_value', - daily_backup_limit=1894, - weekly_backup_limit=2020, - monthly_backup_limit=2142, - description='description_value', - enabled=True, - assigned_volume_count=2253, - state=backup_policy.BackupPolicy.State.CREATING, - ) - response = client.get_backup_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = backup_policy.GetBackupPolicyRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, backup_policy.BackupPolicy) - assert response.name == 'name_value' - assert response.daily_backup_limit == 1894 - assert response.weekly_backup_limit == 2020 - assert response.monthly_backup_limit == 2142 - assert response.description == 'description_value' - assert response.enabled is True - assert response.assigned_volume_count == 2253 - assert response.state == backup_policy.BackupPolicy.State.CREATING - - -def test_get_backup_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 = NetAppClient( - 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 = backup_policy.GetBackupPolicyRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_backup_policy), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_backup_policy(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == backup_policy.GetBackupPolicyRequest( - name='name_value', - ) - -def test_get_backup_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 = NetAppClient( - 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_backup_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_backup_policy] = mock_rpc - request = {} - client.get_backup_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_backup_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_backup_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 = NetAppAsyncClient( - 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_backup_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_backup_policy] = mock_rpc - - request = {} - await client.get_backup_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_backup_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_backup_policy_async(transport: str = 'grpc_asyncio', request_type=backup_policy.GetBackupPolicyRequest): - client = NetAppAsyncClient( - 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_backup_policy), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(backup_policy.BackupPolicy( - name='name_value', - daily_backup_limit=1894, - weekly_backup_limit=2020, - monthly_backup_limit=2142, - description='description_value', - enabled=True, - assigned_volume_count=2253, - state=backup_policy.BackupPolicy.State.CREATING, - )) - response = await client.get_backup_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = backup_policy.GetBackupPolicyRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, backup_policy.BackupPolicy) - assert response.name == 'name_value' - assert response.daily_backup_limit == 1894 - assert response.weekly_backup_limit == 2020 - assert response.monthly_backup_limit == 2142 - assert response.description == 'description_value' - assert response.enabled is True - assert response.assigned_volume_count == 2253 - assert response.state == backup_policy.BackupPolicy.State.CREATING - - -@pytest.mark.asyncio -async def test_get_backup_policy_async_from_dict(): - await test_get_backup_policy_async(request_type=dict) - -def test_get_backup_policy_field_headers(): - client = NetAppClient( - 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 = backup_policy.GetBackupPolicyRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_backup_policy), - '__call__') as call: - call.return_value = backup_policy.BackupPolicy() - client.get_backup_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', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_backup_policy_field_headers_async(): - client = NetAppAsyncClient( - 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 = backup_policy.GetBackupPolicyRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_backup_policy), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_policy.BackupPolicy()) - await client.get_backup_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', - 'name=name_value', - ) in kw['metadata'] - - -def test_get_backup_policy_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_backup_policy), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = backup_policy.BackupPolicy() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_backup_policy( - 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_backup_policy_flattened_error(): - client = NetAppClient( - 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_backup_policy( - backup_policy.GetBackupPolicyRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_backup_policy_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_backup_policy), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = backup_policy.BackupPolicy() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_policy.BackupPolicy()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_backup_policy( - 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_backup_policy_flattened_error_async(): - client = NetAppAsyncClient( - 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_backup_policy( - backup_policy.GetBackupPolicyRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - backup_policy.ListBackupPoliciesRequest, - dict, -]) -def test_list_backup_policies(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_backup_policies), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = backup_policy.ListBackupPoliciesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_backup_policies(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = backup_policy.ListBackupPoliciesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListBackupPoliciesPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_backup_policies_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 = NetAppClient( - 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 = backup_policy.ListBackupPoliciesRequest( - 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_backup_policies), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_backup_policies(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == backup_policy.ListBackupPoliciesRequest( - parent='parent_value', - page_token='page_token_value', - filter='filter_value', - order_by='order_by_value', - ) - -def test_list_backup_policies_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 = NetAppClient( - 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_backup_policies 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_backup_policies] = mock_rpc - request = {} - client.list_backup_policies(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_backup_policies(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_backup_policies_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 = NetAppAsyncClient( - 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_backup_policies 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_backup_policies] = mock_rpc - - request = {} - await client.list_backup_policies(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_backup_policies(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_backup_policies_async(transport: str = 'grpc_asyncio', request_type=backup_policy.ListBackupPoliciesRequest): - client = NetAppAsyncClient( - 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_backup_policies), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(backup_policy.ListBackupPoliciesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_backup_policies(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = backup_policy.ListBackupPoliciesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListBackupPoliciesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_backup_policies_async_from_dict(): - await test_list_backup_policies_async(request_type=dict) - -def test_list_backup_policies_field_headers(): - client = NetAppClient( - 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 = backup_policy.ListBackupPoliciesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_backup_policies), - '__call__') as call: - call.return_value = backup_policy.ListBackupPoliciesResponse() - client.list_backup_policies(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_backup_policies_field_headers_async(): - client = NetAppAsyncClient( - 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 = backup_policy.ListBackupPoliciesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_backup_policies), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_policy.ListBackupPoliciesResponse()) - await client.list_backup_policies(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_backup_policies_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_backup_policies), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = backup_policy.ListBackupPoliciesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_backup_policies( - 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_backup_policies_flattened_error(): - client = NetAppClient( - 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_backup_policies( - backup_policy.ListBackupPoliciesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_backup_policies_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_backup_policies), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = backup_policy.ListBackupPoliciesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_policy.ListBackupPoliciesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_backup_policies( - 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_backup_policies_flattened_error_async(): - client = NetAppAsyncClient( - 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_backup_policies( - backup_policy.ListBackupPoliciesRequest(), - parent='parent_value', - ) - - -def test_list_backup_policies_pager(transport_name: str = "grpc"): - client = NetAppClient( - 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_backup_policies), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - backup_policy.ListBackupPoliciesResponse( - backup_policies=[ - backup_policy.BackupPolicy(), - backup_policy.BackupPolicy(), - backup_policy.BackupPolicy(), - ], - next_page_token='abc', - ), - backup_policy.ListBackupPoliciesResponse( - backup_policies=[], - next_page_token='def', - ), - backup_policy.ListBackupPoliciesResponse( - backup_policies=[ - backup_policy.BackupPolicy(), - ], - next_page_token='ghi', - ), - backup_policy.ListBackupPoliciesResponse( - backup_policies=[ - backup_policy.BackupPolicy(), - backup_policy.BackupPolicy(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_backup_policies(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, backup_policy.BackupPolicy) - for i in results) -def test_list_backup_policies_pages(transport_name: str = "grpc"): - client = NetAppClient( - 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_backup_policies), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - backup_policy.ListBackupPoliciesResponse( - backup_policies=[ - backup_policy.BackupPolicy(), - backup_policy.BackupPolicy(), - backup_policy.BackupPolicy(), - ], - next_page_token='abc', - ), - backup_policy.ListBackupPoliciesResponse( - backup_policies=[], - next_page_token='def', - ), - backup_policy.ListBackupPoliciesResponse( - backup_policies=[ - backup_policy.BackupPolicy(), - ], - next_page_token='ghi', - ), - backup_policy.ListBackupPoliciesResponse( - backup_policies=[ - backup_policy.BackupPolicy(), - backup_policy.BackupPolicy(), - ], - ), - RuntimeError, - ) - pages = list(client.list_backup_policies(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_backup_policies_async_pager(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_backup_policies), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - backup_policy.ListBackupPoliciesResponse( - backup_policies=[ - backup_policy.BackupPolicy(), - backup_policy.BackupPolicy(), - backup_policy.BackupPolicy(), - ], - next_page_token='abc', - ), - backup_policy.ListBackupPoliciesResponse( - backup_policies=[], - next_page_token='def', - ), - backup_policy.ListBackupPoliciesResponse( - backup_policies=[ - backup_policy.BackupPolicy(), - ], - next_page_token='ghi', - ), - backup_policy.ListBackupPoliciesResponse( - backup_policies=[ - backup_policy.BackupPolicy(), - backup_policy.BackupPolicy(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_backup_policies(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, backup_policy.BackupPolicy) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_backup_policies_async_pages(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_backup_policies), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - backup_policy.ListBackupPoliciesResponse( - backup_policies=[ - backup_policy.BackupPolicy(), - backup_policy.BackupPolicy(), - backup_policy.BackupPolicy(), - ], - next_page_token='abc', - ), - backup_policy.ListBackupPoliciesResponse( - backup_policies=[], - next_page_token='def', - ), - backup_policy.ListBackupPoliciesResponse( - backup_policies=[ - backup_policy.BackupPolicy(), - ], - next_page_token='ghi', - ), - backup_policy.ListBackupPoliciesResponse( - backup_policies=[ - backup_policy.BackupPolicy(), - backup_policy.BackupPolicy(), - ], - ), - 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_backup_policies(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", [ - gcn_backup_policy.UpdateBackupPolicyRequest, - dict, -]) -def test_update_backup_policy(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_backup_policy), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_backup_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gcn_backup_policy.UpdateBackupPolicyRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_backup_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 = NetAppClient( - 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 = gcn_backup_policy.UpdateBackupPolicyRequest( - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_backup_policy), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_backup_policy(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gcn_backup_policy.UpdateBackupPolicyRequest( - ) - -def test_update_backup_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 = NetAppClient( - 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_backup_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.update_backup_policy] = mock_rpc - request = {} - client.update_backup_policy(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.update_backup_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_update_backup_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 = NetAppAsyncClient( - 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_backup_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.update_backup_policy] = mock_rpc - - request = {} - await client.update_backup_policy(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.update_backup_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_update_backup_policy_async(transport: str = 'grpc_asyncio', request_type=gcn_backup_policy.UpdateBackupPolicyRequest): - client = NetAppAsyncClient( - 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_backup_policy), - '__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.update_backup_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gcn_backup_policy.UpdateBackupPolicyRequest() - 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_update_backup_policy_async_from_dict(): - await test_update_backup_policy_async(request_type=dict) - -def test_update_backup_policy_field_headers(): - client = NetAppClient( - 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 = gcn_backup_policy.UpdateBackupPolicyRequest() - - request.backup_policy.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_backup_policy), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_backup_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', - 'backup_policy.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_backup_policy_field_headers_async(): - client = NetAppAsyncClient( - 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 = gcn_backup_policy.UpdateBackupPolicyRequest() - - request.backup_policy.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_backup_policy), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_backup_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', - 'backup_policy.name=name_value', - ) in kw['metadata'] - - -def test_update_backup_policy_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_backup_policy), - '__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.update_backup_policy( - backup_policy=gcn_backup_policy.BackupPolicy(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].backup_policy - mock_val = gcn_backup_policy.BackupPolicy(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_backup_policy_flattened_error(): - client = NetAppClient( - 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_backup_policy( - gcn_backup_policy.UpdateBackupPolicyRequest(), - backup_policy=gcn_backup_policy.BackupPolicy(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_backup_policy_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_backup_policy), - '__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.update_backup_policy( - backup_policy=gcn_backup_policy.BackupPolicy(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].backup_policy - mock_val = gcn_backup_policy.BackupPolicy(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_backup_policy_flattened_error_async(): - client = NetAppAsyncClient( - 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_backup_policy( - gcn_backup_policy.UpdateBackupPolicyRequest(), - backup_policy=gcn_backup_policy.BackupPolicy(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - backup_policy.DeleteBackupPolicyRequest, - dict, -]) -def test_delete_backup_policy(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_backup_policy), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_backup_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = backup_policy.DeleteBackupPolicyRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_backup_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 = NetAppClient( - 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 = backup_policy.DeleteBackupPolicyRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup_policy), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_backup_policy(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == backup_policy.DeleteBackupPolicyRequest( - name='name_value', - ) - -def test_delete_backup_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 = NetAppClient( - 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_backup_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.delete_backup_policy] = mock_rpc - request = {} - client.delete_backup_policy(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_backup_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_delete_backup_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 = NetAppAsyncClient( - 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_backup_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.delete_backup_policy] = mock_rpc - - request = {} - await client.delete_backup_policy(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_backup_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_delete_backup_policy_async(transport: str = 'grpc_asyncio', request_type=backup_policy.DeleteBackupPolicyRequest): - client = NetAppAsyncClient( - 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_backup_policy), - '__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_backup_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = backup_policy.DeleteBackupPolicyRequest() - 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_backup_policy_async_from_dict(): - await test_delete_backup_policy_async(request_type=dict) - -def test_delete_backup_policy_field_headers(): - client = NetAppClient( - 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 = backup_policy.DeleteBackupPolicyRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup_policy), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_backup_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', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_delete_backup_policy_field_headers_async(): - client = NetAppAsyncClient( - 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 = backup_policy.DeleteBackupPolicyRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup_policy), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_backup_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', - 'name=name_value', - ) in kw['metadata'] - - -def test_delete_backup_policy_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup_policy), - '__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_backup_policy( - 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_backup_policy_flattened_error(): - client = NetAppClient( - 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_backup_policy( - backup_policy.DeleteBackupPolicyRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_backup_policy_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup_policy), - '__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_backup_policy( - 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_backup_policy_flattened_error_async(): - client = NetAppAsyncClient( - 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_backup_policy( - backup_policy.DeleteBackupPolicyRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - quota_rule.ListQuotaRulesRequest, - dict, -]) -def test_list_quota_rules(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_quota_rules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = quota_rule.ListQuotaRulesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_quota_rules(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = quota_rule.ListQuotaRulesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListQuotaRulesPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_quota_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 = NetAppClient( - 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 = quota_rule.ListQuotaRulesRequest( - 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_quota_rules), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_quota_rules(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == quota_rule.ListQuotaRulesRequest( - parent='parent_value', - page_token='page_token_value', - filter='filter_value', - order_by='order_by_value', - ) - -def test_list_quota_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 = NetAppClient( - 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_quota_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_quota_rules] = mock_rpc - request = {} - client.list_quota_rules(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_quota_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_quota_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 = NetAppAsyncClient( - 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_quota_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_quota_rules] = mock_rpc - - request = {} - await client.list_quota_rules(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_quota_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_quota_rules_async(transport: str = 'grpc_asyncio', request_type=quota_rule.ListQuotaRulesRequest): - client = NetAppAsyncClient( - 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_quota_rules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(quota_rule.ListQuotaRulesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_quota_rules(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = quota_rule.ListQuotaRulesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListQuotaRulesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_quota_rules_async_from_dict(): - await test_list_quota_rules_async(request_type=dict) - -def test_list_quota_rules_field_headers(): - client = NetAppClient( - 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 = quota_rule.ListQuotaRulesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_quota_rules), - '__call__') as call: - call.return_value = quota_rule.ListQuotaRulesResponse() - client.list_quota_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_quota_rules_field_headers_async(): - client = NetAppAsyncClient( - 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 = quota_rule.ListQuotaRulesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_quota_rules), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(quota_rule.ListQuotaRulesResponse()) - await client.list_quota_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_quota_rules_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_quota_rules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = quota_rule.ListQuotaRulesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_quota_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_quota_rules_flattened_error(): - client = NetAppClient( - 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_quota_rules( - quota_rule.ListQuotaRulesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_quota_rules_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_quota_rules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = quota_rule.ListQuotaRulesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(quota_rule.ListQuotaRulesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_quota_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_quota_rules_flattened_error_async(): - client = NetAppAsyncClient( - 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_quota_rules( - quota_rule.ListQuotaRulesRequest(), - parent='parent_value', - ) - - -def test_list_quota_rules_pager(transport_name: str = "grpc"): - client = NetAppClient( - 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_quota_rules), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - quota_rule.ListQuotaRulesResponse( - quota_rules=[ - quota_rule.QuotaRule(), - quota_rule.QuotaRule(), - quota_rule.QuotaRule(), - ], - next_page_token='abc', - ), - quota_rule.ListQuotaRulesResponse( - quota_rules=[], - next_page_token='def', - ), - quota_rule.ListQuotaRulesResponse( - quota_rules=[ - quota_rule.QuotaRule(), - ], - next_page_token='ghi', - ), - quota_rule.ListQuotaRulesResponse( - quota_rules=[ - quota_rule.QuotaRule(), - quota_rule.QuotaRule(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_quota_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, quota_rule.QuotaRule) - for i in results) -def test_list_quota_rules_pages(transport_name: str = "grpc"): - client = NetAppClient( - 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_quota_rules), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - quota_rule.ListQuotaRulesResponse( - quota_rules=[ - quota_rule.QuotaRule(), - quota_rule.QuotaRule(), - quota_rule.QuotaRule(), - ], - next_page_token='abc', - ), - quota_rule.ListQuotaRulesResponse( - quota_rules=[], - next_page_token='def', - ), - quota_rule.ListQuotaRulesResponse( - quota_rules=[ - quota_rule.QuotaRule(), - ], - next_page_token='ghi', - ), - quota_rule.ListQuotaRulesResponse( - quota_rules=[ - quota_rule.QuotaRule(), - quota_rule.QuotaRule(), - ], - ), - RuntimeError, - ) - pages = list(client.list_quota_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_quota_rules_async_pager(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_quota_rules), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - quota_rule.ListQuotaRulesResponse( - quota_rules=[ - quota_rule.QuotaRule(), - quota_rule.QuotaRule(), - quota_rule.QuotaRule(), - ], - next_page_token='abc', - ), - quota_rule.ListQuotaRulesResponse( - quota_rules=[], - next_page_token='def', - ), - quota_rule.ListQuotaRulesResponse( - quota_rules=[ - quota_rule.QuotaRule(), - ], - next_page_token='ghi', - ), - quota_rule.ListQuotaRulesResponse( - quota_rules=[ - quota_rule.QuotaRule(), - quota_rule.QuotaRule(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_quota_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, quota_rule.QuotaRule) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_quota_rules_async_pages(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_quota_rules), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - quota_rule.ListQuotaRulesResponse( - quota_rules=[ - quota_rule.QuotaRule(), - quota_rule.QuotaRule(), - quota_rule.QuotaRule(), - ], - next_page_token='abc', - ), - quota_rule.ListQuotaRulesResponse( - quota_rules=[], - next_page_token='def', - ), - quota_rule.ListQuotaRulesResponse( - quota_rules=[ - quota_rule.QuotaRule(), - ], - next_page_token='ghi', - ), - quota_rule.ListQuotaRulesResponse( - quota_rules=[ - quota_rule.QuotaRule(), - quota_rule.QuotaRule(), - ], - ), - 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_quota_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", [ - quota_rule.GetQuotaRuleRequest, - dict, -]) -def test_get_quota_rule(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_quota_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = quota_rule.QuotaRule( - name='name_value', - target='target_value', - type_=quota_rule.QuotaRule.Type.INDIVIDUAL_USER_QUOTA, - disk_limit_mib=1472, - state=quota_rule.QuotaRule.State.CREATING, - state_details='state_details_value', - description='description_value', - ) - response = client.get_quota_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = quota_rule.GetQuotaRuleRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, quota_rule.QuotaRule) - assert response.name == 'name_value' - assert response.target == 'target_value' - assert response.type_ == quota_rule.QuotaRule.Type.INDIVIDUAL_USER_QUOTA - assert response.disk_limit_mib == 1472 - assert response.state == quota_rule.QuotaRule.State.CREATING - assert response.state_details == 'state_details_value' - assert response.description == 'description_value' - - -def test_get_quota_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 = NetAppClient( - 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 = quota_rule.GetQuotaRuleRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_quota_rule), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_quota_rule(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == quota_rule.GetQuotaRuleRequest( - name='name_value', - ) - -def test_get_quota_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 = NetAppClient( - 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_quota_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_quota_rule] = mock_rpc - request = {} - client.get_quota_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_quota_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_quota_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 = NetAppAsyncClient( - 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_quota_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_quota_rule] = mock_rpc - - request = {} - await client.get_quota_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_quota_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_quota_rule_async(transport: str = 'grpc_asyncio', request_type=quota_rule.GetQuotaRuleRequest): - client = NetAppAsyncClient( - 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_quota_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(quota_rule.QuotaRule( - name='name_value', - target='target_value', - type_=quota_rule.QuotaRule.Type.INDIVIDUAL_USER_QUOTA, - disk_limit_mib=1472, - state=quota_rule.QuotaRule.State.CREATING, - state_details='state_details_value', - description='description_value', - )) - response = await client.get_quota_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = quota_rule.GetQuotaRuleRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, quota_rule.QuotaRule) - assert response.name == 'name_value' - assert response.target == 'target_value' - assert response.type_ == quota_rule.QuotaRule.Type.INDIVIDUAL_USER_QUOTA - assert response.disk_limit_mib == 1472 - assert response.state == quota_rule.QuotaRule.State.CREATING - assert response.state_details == 'state_details_value' - assert response.description == 'description_value' - - -@pytest.mark.asyncio -async def test_get_quota_rule_async_from_dict(): - await test_get_quota_rule_async(request_type=dict) - -def test_get_quota_rule_field_headers(): - client = NetAppClient( - 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 = quota_rule.GetQuotaRuleRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_quota_rule), - '__call__') as call: - call.return_value = quota_rule.QuotaRule() - client.get_quota_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_quota_rule_field_headers_async(): - client = NetAppAsyncClient( - 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 = quota_rule.GetQuotaRuleRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_quota_rule), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(quota_rule.QuotaRule()) - await client.get_quota_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_quota_rule_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_quota_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = quota_rule.QuotaRule() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_quota_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_quota_rule_flattened_error(): - client = NetAppClient( - 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_quota_rule( - quota_rule.GetQuotaRuleRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_quota_rule_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_quota_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = quota_rule.QuotaRule() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(quota_rule.QuotaRule()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_quota_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_quota_rule_flattened_error_async(): - client = NetAppAsyncClient( - 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_quota_rule( - quota_rule.GetQuotaRuleRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - gcn_quota_rule.CreateQuotaRuleRequest, - dict, -]) -def test_create_quota_rule(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_quota_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_quota_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gcn_quota_rule.CreateQuotaRuleRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_quota_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 = NetAppClient( - 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 = gcn_quota_rule.CreateQuotaRuleRequest( - parent='parent_value', - quota_rule_id='quota_rule_id_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_quota_rule), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_quota_rule(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gcn_quota_rule.CreateQuotaRuleRequest( - parent='parent_value', - quota_rule_id='quota_rule_id_value', - ) - -def test_create_quota_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 = NetAppClient( - 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_quota_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_quota_rule] = mock_rpc - request = {} - client.create_quota_rule(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_quota_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_quota_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 = NetAppAsyncClient( - 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_quota_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_quota_rule] = mock_rpc - - request = {} - await client.create_quota_rule(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_quota_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_quota_rule_async(transport: str = 'grpc_asyncio', request_type=gcn_quota_rule.CreateQuotaRuleRequest): - client = NetAppAsyncClient( - 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_quota_rule), - '__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_quota_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gcn_quota_rule.CreateQuotaRuleRequest() - 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_quota_rule_async_from_dict(): - await test_create_quota_rule_async(request_type=dict) - -def test_create_quota_rule_field_headers(): - client = NetAppClient( - 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 = gcn_quota_rule.CreateQuotaRuleRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_quota_rule), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_quota_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_quota_rule_field_headers_async(): - client = NetAppAsyncClient( - 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 = gcn_quota_rule.CreateQuotaRuleRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_quota_rule), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_quota_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_quota_rule_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_quota_rule), - '__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_quota_rule( - parent='parent_value', - quota_rule=gcn_quota_rule.QuotaRule(name='name_value'), - quota_rule_id='quota_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].quota_rule - mock_val = gcn_quota_rule.QuotaRule(name='name_value') - assert arg == mock_val - arg = args[0].quota_rule_id - mock_val = 'quota_rule_id_value' - assert arg == mock_val - - -def test_create_quota_rule_flattened_error(): - client = NetAppClient( - 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_quota_rule( - gcn_quota_rule.CreateQuotaRuleRequest(), - parent='parent_value', - quota_rule=gcn_quota_rule.QuotaRule(name='name_value'), - quota_rule_id='quota_rule_id_value', - ) - -@pytest.mark.asyncio -async def test_create_quota_rule_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_quota_rule), - '__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_quota_rule( - parent='parent_value', - quota_rule=gcn_quota_rule.QuotaRule(name='name_value'), - quota_rule_id='quota_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].quota_rule - mock_val = gcn_quota_rule.QuotaRule(name='name_value') - assert arg == mock_val - arg = args[0].quota_rule_id - mock_val = 'quota_rule_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_quota_rule_flattened_error_async(): - client = NetAppAsyncClient( - 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_quota_rule( - gcn_quota_rule.CreateQuotaRuleRequest(), - parent='parent_value', - quota_rule=gcn_quota_rule.QuotaRule(name='name_value'), - quota_rule_id='quota_rule_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - gcn_quota_rule.UpdateQuotaRuleRequest, - dict, -]) -def test_update_quota_rule(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_quota_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_quota_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gcn_quota_rule.UpdateQuotaRuleRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_quota_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 = NetAppClient( - 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 = gcn_quota_rule.UpdateQuotaRuleRequest( - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_quota_rule), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_quota_rule(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gcn_quota_rule.UpdateQuotaRuleRequest( - ) - -def test_update_quota_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 = NetAppClient( - 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_quota_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_quota_rule] = mock_rpc - request = {} - client.update_quota_rule(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.update_quota_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_quota_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 = NetAppAsyncClient( - 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_quota_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_quota_rule] = mock_rpc - - request = {} - await client.update_quota_rule(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.update_quota_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_quota_rule_async(transport: str = 'grpc_asyncio', request_type=gcn_quota_rule.UpdateQuotaRuleRequest): - client = NetAppAsyncClient( - 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_quota_rule), - '__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.update_quota_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gcn_quota_rule.UpdateQuotaRuleRequest() - 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_update_quota_rule_async_from_dict(): - await test_update_quota_rule_async(request_type=dict) - -def test_update_quota_rule_field_headers(): - client = NetAppClient( - 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 = gcn_quota_rule.UpdateQuotaRuleRequest() - - request.quota_rule.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_quota_rule), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_quota_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', - 'quota_rule.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_quota_rule_field_headers_async(): - client = NetAppAsyncClient( - 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 = gcn_quota_rule.UpdateQuotaRuleRequest() - - request.quota_rule.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_quota_rule), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_quota_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', - 'quota_rule.name=name_value', - ) in kw['metadata'] - - -def test_update_quota_rule_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_quota_rule), - '__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.update_quota_rule( - quota_rule=gcn_quota_rule.QuotaRule(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].quota_rule - mock_val = gcn_quota_rule.QuotaRule(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_quota_rule_flattened_error(): - client = NetAppClient( - 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_quota_rule( - gcn_quota_rule.UpdateQuotaRuleRequest(), - quota_rule=gcn_quota_rule.QuotaRule(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_quota_rule_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_quota_rule), - '__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.update_quota_rule( - quota_rule=gcn_quota_rule.QuotaRule(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].quota_rule - mock_val = gcn_quota_rule.QuotaRule(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_quota_rule_flattened_error_async(): - client = NetAppAsyncClient( - 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_quota_rule( - gcn_quota_rule.UpdateQuotaRuleRequest(), - quota_rule=gcn_quota_rule.QuotaRule(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - quota_rule.DeleteQuotaRuleRequest, - dict, -]) -def test_delete_quota_rule(request_type, transport: str = 'grpc'): - client = NetAppClient( - 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_quota_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_quota_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = quota_rule.DeleteQuotaRuleRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_quota_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 = NetAppClient( - 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 = quota_rule.DeleteQuotaRuleRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_quota_rule), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_quota_rule(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == quota_rule.DeleteQuotaRuleRequest( - name='name_value', - ) - -def test_delete_quota_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 = NetAppClient( - 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_quota_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_quota_rule] = mock_rpc - request = {} - client.delete_quota_rule(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_quota_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_quota_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 = NetAppAsyncClient( - 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_quota_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_quota_rule] = mock_rpc - - request = {} - await client.delete_quota_rule(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_quota_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_quota_rule_async(transport: str = 'grpc_asyncio', request_type=quota_rule.DeleteQuotaRuleRequest): - client = NetAppAsyncClient( - 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_quota_rule), - '__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_quota_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = quota_rule.DeleteQuotaRuleRequest() - 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_quota_rule_async_from_dict(): - await test_delete_quota_rule_async(request_type=dict) - -def test_delete_quota_rule_field_headers(): - client = NetAppClient( - 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 = quota_rule.DeleteQuotaRuleRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_quota_rule), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_quota_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_quota_rule_field_headers_async(): - client = NetAppAsyncClient( - 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 = quota_rule.DeleteQuotaRuleRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_quota_rule), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_quota_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_quota_rule_flattened(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_quota_rule), - '__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_quota_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_quota_rule_flattened_error(): - client = NetAppClient( - 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_quota_rule( - quota_rule.DeleteQuotaRuleRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_quota_rule_flattened_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_quota_rule), - '__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_quota_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_quota_rule_flattened_error_async(): - client = NetAppAsyncClient( - 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_quota_rule( - quota_rule.DeleteQuotaRuleRequest(), - name='name_value', - ) - - -def test_list_storage_pools_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 = NetAppClient( - 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_storage_pools 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_storage_pools] = mock_rpc - - request = {} - client.list_storage_pools(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_storage_pools(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_storage_pools_rest_required_fields(request_type=storage_pool.ListStoragePoolsRequest): - transport_class = transports.NetAppRestTransport - - 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_storage_pools._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_storage_pools._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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = storage_pool.ListStoragePoolsResponse() - # 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 = storage_pool.ListStoragePoolsResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_storage_pools(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_storage_pools_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_storage_pools._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_storage_pools_rest_flattened(): - client = NetAppClient( - 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 = storage_pool.ListStoragePoolsResponse() - - # 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 = storage_pool.ListStoragePoolsResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.list_storage_pools(**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/*}/storagePools" % client.transport._host, args[1]) - - -def test_list_storage_pools_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_storage_pools( - storage_pool.ListStoragePoolsRequest(), - parent='parent_value', - ) - - -def test_list_storage_pools_rest_pager(transport: str = 'rest'): - client = NetAppClient( - 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 = ( - storage_pool.ListStoragePoolsResponse( - storage_pools=[ - storage_pool.StoragePool(), - storage_pool.StoragePool(), - storage_pool.StoragePool(), - ], - next_page_token='abc', - ), - storage_pool.ListStoragePoolsResponse( - storage_pools=[], - next_page_token='def', - ), - storage_pool.ListStoragePoolsResponse( - storage_pools=[ - storage_pool.StoragePool(), - ], - next_page_token='ghi', - ), - storage_pool.ListStoragePoolsResponse( - storage_pools=[ - storage_pool.StoragePool(), - storage_pool.StoragePool(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(storage_pool.ListStoragePoolsResponse.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_storage_pools(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, storage_pool.StoragePool) - for i in results) - - pages = list(client.list_storage_pools(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_create_storage_pool_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 = NetAppClient( - 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_storage_pool 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_storage_pool] = mock_rpc - - request = {} - client.create_storage_pool(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_storage_pool(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_storage_pool_rest_required_fields(request_type=gcn_storage_pool.CreateStoragePoolRequest): - transport_class = transports.NetAppRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["storage_pool_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 "storagePoolId" not in jsonified_request - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_storage_pool._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "storagePoolId" in jsonified_request - assert jsonified_request["storagePoolId"] == request_init["storage_pool_id"] - - jsonified_request["parent"] = 'parent_value' - jsonified_request["storagePoolId"] = 'storage_pool_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_storage_pool._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("storage_pool_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 "storagePoolId" in jsonified_request - assert jsonified_request["storagePoolId"] == 'storage_pool_id_value' - - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.create_storage_pool(request) - - expected_params = [ - ( - "storagePoolId", - "", - ), - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_storage_pool_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_storage_pool._get_unset_required_fields({}) - assert set(unset_fields) == (set(("storagePoolId", )) & set(("parent", "storagePoolId", "storagePool", ))) - - -def test_create_storage_pool_rest_flattened(): - client = NetAppClient( - 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', - storage_pool=gcn_storage_pool.StoragePool(name='name_value'), - storage_pool_id='storage_pool_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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.create_storage_pool(**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/*}/storagePools" % client.transport._host, args[1]) - - -def test_create_storage_pool_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_storage_pool( - gcn_storage_pool.CreateStoragePoolRequest(), - parent='parent_value', - storage_pool=gcn_storage_pool.StoragePool(name='name_value'), - storage_pool_id='storage_pool_id_value', - ) - - -def test_get_storage_pool_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 = NetAppClient( - 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_storage_pool 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_storage_pool] = mock_rpc - - request = {} - client.get_storage_pool(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_storage_pool(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_storage_pool_rest_required_fields(request_type=storage_pool.GetStoragePoolRequest): - transport_class = transports.NetAppRestTransport - - 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_storage_pool._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_storage_pool._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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = storage_pool.StoragePool() - # 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 = storage_pool.StoragePool.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_storage_pool(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_storage_pool_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_storage_pool._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_storage_pool_rest_flattened(): - client = NetAppClient( - 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 = storage_pool.StoragePool() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/storagePools/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 = storage_pool.StoragePool.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.get_storage_pool(**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/*/storagePools/*}" % client.transport._host, args[1]) - - -def test_get_storage_pool_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_storage_pool( - storage_pool.GetStoragePoolRequest(), - name='name_value', - ) - - -def test_update_storage_pool_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 = NetAppClient( - 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_storage_pool 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_storage_pool] = mock_rpc - - request = {} - client.update_storage_pool(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.update_storage_pool(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_storage_pool_rest_required_fields(request_type=gcn_storage_pool.UpdateStoragePoolRequest): - transport_class = transports.NetAppRestTransport - - 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_storage_pool._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_storage_pool._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 = NetAppClient( - 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': "patch", - '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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.update_storage_pool(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_storage_pool_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_storage_pool._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("updateMask", "storagePool", ))) - - -def test_update_storage_pool_rest_flattened(): - client = NetAppClient( - 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 = {'storage_pool': {'name': 'projects/sample1/locations/sample2/storagePools/sample3'}} - - # get truthy value for each flattened field - mock_args = dict( - storage_pool=gcn_storage_pool.StoragePool(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 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.update_storage_pool(**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/{storage_pool.name=projects/*/locations/*/storagePools/*}" % client.transport._host, args[1]) - - -def test_update_storage_pool_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_storage_pool( - gcn_storage_pool.UpdateStoragePoolRequest(), - storage_pool=gcn_storage_pool.StoragePool(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_delete_storage_pool_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 = NetAppClient( - 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_storage_pool 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_storage_pool] = mock_rpc - - request = {} - client.delete_storage_pool(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_storage_pool(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_storage_pool_rest_required_fields(request_type=storage_pool.DeleteStoragePoolRequest): - transport_class = transports.NetAppRestTransport - - 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_storage_pool._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_storage_pool._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 = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.delete_storage_pool(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_storage_pool_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_storage_pool._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_delete_storage_pool_rest_flattened(): - client = NetAppClient( - 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/storagePools/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.delete_storage_pool(**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/*/storagePools/*}" % client.transport._host, args[1]) - - -def test_delete_storage_pool_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_storage_pool( - storage_pool.DeleteStoragePoolRequest(), - name='name_value', - ) - - -def test_validate_directory_service_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 = NetAppClient( - 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.validate_directory_service 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.validate_directory_service] = mock_rpc - - request = {} - client.validate_directory_service(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.validate_directory_service(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_validate_directory_service_rest_required_fields(request_type=storage_pool.ValidateDirectoryServiceRequest): - transport_class = transports.NetAppRestTransport - - 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()).validate_directory_service._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()).validate_directory_service._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 = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.validate_directory_service(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_validate_directory_service_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.validate_directory_service._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_switch_active_replica_zone_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 = NetAppClient( - 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.switch_active_replica_zone 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.switch_active_replica_zone] = mock_rpc - - request = {} - client.switch_active_replica_zone(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.switch_active_replica_zone(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_switch_active_replica_zone_rest_required_fields(request_type=storage_pool.SwitchActiveReplicaZoneRequest): - transport_class = transports.NetAppRestTransport - - 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()).switch_active_replica_zone._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()).switch_active_replica_zone._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 = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.switch_active_replica_zone(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_switch_active_replica_zone_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.switch_active_replica_zone._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_list_volumes_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 = NetAppClient( - 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_volumes 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_volumes] = mock_rpc - - request = {} - client.list_volumes(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_volumes(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_volumes_rest_required_fields(request_type=volume.ListVolumesRequest): - transport_class = transports.NetAppRestTransport - - 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_volumes._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_volumes._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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = volume.ListVolumesResponse() - # 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 = volume.ListVolumesResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_volumes(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_volumes_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_volumes._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_volumes_rest_flattened(): - client = NetAppClient( - 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 = volume.ListVolumesResponse() - - # 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 = volume.ListVolumesResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.list_volumes(**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/*}/volumes" % client.transport._host, args[1]) - - -def test_list_volumes_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_volumes( - volume.ListVolumesRequest(), - parent='parent_value', - ) - - -def test_list_volumes_rest_pager(transport: str = 'rest'): - client = NetAppClient( - 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 = ( - volume.ListVolumesResponse( - volumes=[ - volume.Volume(), - volume.Volume(), - volume.Volume(), - ], - next_page_token='abc', - ), - volume.ListVolumesResponse( - volumes=[], - next_page_token='def', - ), - volume.ListVolumesResponse( - volumes=[ - volume.Volume(), - ], - next_page_token='ghi', - ), - volume.ListVolumesResponse( - volumes=[ - volume.Volume(), - volume.Volume(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(volume.ListVolumesResponse.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_volumes(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, volume.Volume) - for i in results) - - pages = list(client.list_volumes(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_volume_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 = NetAppClient( - 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_volume 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_volume] = mock_rpc - - request = {} - client.get_volume(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_volume(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_volume_rest_required_fields(request_type=volume.GetVolumeRequest): - transport_class = transports.NetAppRestTransport - - 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_volume._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_volume._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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = volume.Volume() - # 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 = volume.Volume.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_volume(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_volume_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_volume._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_volume_rest_flattened(): - client = NetAppClient( - 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 = volume.Volume() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/volumes/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 = volume.Volume.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.get_volume(**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/*/volumes/*}" % client.transport._host, args[1]) - - -def test_get_volume_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_volume( - volume.GetVolumeRequest(), - name='name_value', - ) - - -def test_create_volume_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 = NetAppClient( - 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_volume 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_volume] = mock_rpc - - request = {} - client.create_volume(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_volume(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_volume_rest_required_fields(request_type=gcn_volume.CreateVolumeRequest): - transport_class = transports.NetAppRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["volume_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 "volumeId" not in jsonified_request - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_volume._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "volumeId" in jsonified_request - assert jsonified_request["volumeId"] == request_init["volume_id"] - - jsonified_request["parent"] = 'parent_value' - jsonified_request["volumeId"] = 'volume_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_volume._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("volume_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 "volumeId" in jsonified_request - assert jsonified_request["volumeId"] == 'volume_id_value' - - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.create_volume(request) - - expected_params = [ - ( - "volumeId", - "", - ), - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_volume_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_volume._get_unset_required_fields({}) - assert set(unset_fields) == (set(("volumeId", )) & set(("parent", "volumeId", "volume", ))) - - -def test_create_volume_rest_flattened(): - client = NetAppClient( - 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', - volume=gcn_volume.Volume(name='name_value'), - volume_id='volume_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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.create_volume(**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/*}/volumes" % client.transport._host, args[1]) - - -def test_create_volume_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_volume( - gcn_volume.CreateVolumeRequest(), - parent='parent_value', - volume=gcn_volume.Volume(name='name_value'), - volume_id='volume_id_value', - ) - - -def test_update_volume_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 = NetAppClient( - 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_volume 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_volume] = mock_rpc - - request = {} - client.update_volume(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.update_volume(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_volume_rest_required_fields(request_type=gcn_volume.UpdateVolumeRequest): - transport_class = transports.NetAppRestTransport - - 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_volume._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_volume._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 = NetAppClient( - 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': "patch", - '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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.update_volume(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_volume_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_volume._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("updateMask", "volume", ))) - - -def test_update_volume_rest_flattened(): - client = NetAppClient( - 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 = {'volume': {'name': 'projects/sample1/locations/sample2/volumes/sample3'}} - - # get truthy value for each flattened field - mock_args = dict( - volume=gcn_volume.Volume(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 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.update_volume(**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/{volume.name=projects/*/locations/*/volumes/*}" % client.transport._host, args[1]) - - -def test_update_volume_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_volume( - gcn_volume.UpdateVolumeRequest(), - volume=gcn_volume.Volume(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_delete_volume_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 = NetAppClient( - 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_volume 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_volume] = mock_rpc - - request = {} - client.delete_volume(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_volume(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_volume_rest_required_fields(request_type=volume.DeleteVolumeRequest): - transport_class = transports.NetAppRestTransport - - 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_volume._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_volume._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("force", )) - 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 = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.delete_volume(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_volume_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_volume._get_unset_required_fields({}) - assert set(unset_fields) == (set(("force", )) & set(("name", ))) - - -def test_delete_volume_rest_flattened(): - client = NetAppClient( - 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/volumes/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.delete_volume(**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/*/volumes/*}" % client.transport._host, args[1]) - - -def test_delete_volume_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_volume( - volume.DeleteVolumeRequest(), - name='name_value', - ) - - -def test_revert_volume_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 = NetAppClient( - 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.revert_volume 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.revert_volume] = mock_rpc - - request = {} - client.revert_volume(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.revert_volume(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_revert_volume_rest_required_fields(request_type=volume.RevertVolumeRequest): - transport_class = transports.NetAppRestTransport - - request_init = {} - request_init["name"] = "" - request_init["snapshot_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 - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).revert_volume._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["snapshotId"] = 'snapshot_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).revert_volume._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' - assert "snapshotId" in jsonified_request - assert jsonified_request["snapshotId"] == 'snapshot_id_value' - - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.revert_volume(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_revert_volume_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.revert_volume._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", "snapshotId", ))) - - -def test_list_snapshots_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 = NetAppClient( - 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_snapshots 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_snapshots] = mock_rpc - - request = {} - client.list_snapshots(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_snapshots(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_snapshots_rest_required_fields(request_type=snapshot.ListSnapshotsRequest): - transport_class = transports.NetAppRestTransport - - 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_snapshots._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_snapshots._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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = snapshot.ListSnapshotsResponse() - # 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 = snapshot.ListSnapshotsResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_snapshots(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_snapshots_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_snapshots._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_snapshots_rest_flattened(): - client = NetAppClient( - 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 = snapshot.ListSnapshotsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/volumes/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 = snapshot.ListSnapshotsResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.list_snapshots(**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/*/volumes/*}/snapshots" % client.transport._host, args[1]) - - -def test_list_snapshots_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_snapshots( - snapshot.ListSnapshotsRequest(), - parent='parent_value', - ) - - -def test_list_snapshots_rest_pager(transport: str = 'rest'): - client = NetAppClient( - 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 = ( - snapshot.ListSnapshotsResponse( - snapshots=[ - snapshot.Snapshot(), - snapshot.Snapshot(), - snapshot.Snapshot(), - ], - next_page_token='abc', - ), - snapshot.ListSnapshotsResponse( - snapshots=[], - next_page_token='def', - ), - snapshot.ListSnapshotsResponse( - snapshots=[ - snapshot.Snapshot(), - ], - next_page_token='ghi', - ), - snapshot.ListSnapshotsResponse( - snapshots=[ - snapshot.Snapshot(), - snapshot.Snapshot(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(snapshot.ListSnapshotsResponse.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/volumes/sample3'} - - pager = client.list_snapshots(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, snapshot.Snapshot) - for i in results) - - pages = list(client.list_snapshots(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_snapshot_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 = NetAppClient( - 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_snapshot 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_snapshot] = mock_rpc - - request = {} - client.get_snapshot(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_snapshot(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_snapshot_rest_required_fields(request_type=snapshot.GetSnapshotRequest): - transport_class = transports.NetAppRestTransport - - 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_snapshot._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_snapshot._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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = snapshot.Snapshot() - # 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 = snapshot.Snapshot.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_snapshot(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_snapshot_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_snapshot._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_snapshot_rest_flattened(): - client = NetAppClient( - 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 = snapshot.Snapshot() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/volumes/sample3/snapshots/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 = snapshot.Snapshot.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.get_snapshot(**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/*/volumes/*/snapshots/*}" % client.transport._host, args[1]) - - -def test_get_snapshot_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_snapshot( - snapshot.GetSnapshotRequest(), - name='name_value', - ) - - -def test_create_snapshot_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 = NetAppClient( - 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_snapshot 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_snapshot] = mock_rpc - - request = {} - client.create_snapshot(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_snapshot(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_snapshot_rest_required_fields(request_type=gcn_snapshot.CreateSnapshotRequest): - transport_class = transports.NetAppRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["snapshot_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 "snapshotId" not in jsonified_request - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_snapshot._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "snapshotId" in jsonified_request - assert jsonified_request["snapshotId"] == request_init["snapshot_id"] - - jsonified_request["parent"] = 'parent_value' - jsonified_request["snapshotId"] = 'snapshot_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_snapshot._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("snapshot_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 "snapshotId" in jsonified_request - assert jsonified_request["snapshotId"] == 'snapshot_id_value' - - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.create_snapshot(request) - - expected_params = [ - ( - "snapshotId", - "", - ), - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_snapshot_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_snapshot._get_unset_required_fields({}) - assert set(unset_fields) == (set(("snapshotId", )) & set(("parent", "snapshot", "snapshotId", ))) - - -def test_create_snapshot_rest_flattened(): - client = NetAppClient( - 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/volumes/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - snapshot=gcn_snapshot.Snapshot(name='name_value'), - snapshot_id='snapshot_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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.create_snapshot(**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/*/volumes/*}/snapshots" % client.transport._host, args[1]) - - -def test_create_snapshot_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_snapshot( - gcn_snapshot.CreateSnapshotRequest(), - parent='parent_value', - snapshot=gcn_snapshot.Snapshot(name='name_value'), - snapshot_id='snapshot_id_value', - ) - - -def test_delete_snapshot_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 = NetAppClient( - 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_snapshot 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_snapshot] = mock_rpc - - request = {} - client.delete_snapshot(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_snapshot(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_snapshot_rest_required_fields(request_type=snapshot.DeleteSnapshotRequest): - transport_class = transports.NetAppRestTransport - - 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_snapshot._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_snapshot._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 = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.delete_snapshot(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_snapshot_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_snapshot._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_delete_snapshot_rest_flattened(): - client = NetAppClient( - 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/volumes/sample3/snapshots/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.delete_snapshot(**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/*/volumes/*/snapshots/*}" % client.transport._host, args[1]) - - -def test_delete_snapshot_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_snapshot( - snapshot.DeleteSnapshotRequest(), - name='name_value', - ) - - -def test_update_snapshot_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 = NetAppClient( - 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_snapshot 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_snapshot] = mock_rpc - - request = {} - client.update_snapshot(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.update_snapshot(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_snapshot_rest_required_fields(request_type=gcn_snapshot.UpdateSnapshotRequest): - transport_class = transports.NetAppRestTransport - - 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_snapshot._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_snapshot._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 = NetAppClient( - 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': "patch", - '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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.update_snapshot(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_snapshot_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_snapshot._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("updateMask", "snapshot", ))) - - -def test_update_snapshot_rest_flattened(): - client = NetAppClient( - 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 = {'snapshot': {'name': 'projects/sample1/locations/sample2/volumes/sample3/snapshots/sample4'}} - - # get truthy value for each flattened field - mock_args = dict( - snapshot=gcn_snapshot.Snapshot(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 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.update_snapshot(**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/{snapshot.name=projects/*/locations/*/volumes/*/snapshots/*}" % client.transport._host, args[1]) - - -def test_update_snapshot_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_snapshot( - gcn_snapshot.UpdateSnapshotRequest(), - snapshot=gcn_snapshot.Snapshot(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_list_active_directories_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 = NetAppClient( - 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_active_directories 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_active_directories] = mock_rpc - - request = {} - client.list_active_directories(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_active_directories(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_active_directories_rest_required_fields(request_type=active_directory.ListActiveDirectoriesRequest): - transport_class = transports.NetAppRestTransport - - 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_active_directories._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_active_directories._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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = active_directory.ListActiveDirectoriesResponse() - # 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 = active_directory.ListActiveDirectoriesResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_active_directories(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_active_directories_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_active_directories._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_active_directories_rest_flattened(): - client = NetAppClient( - 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 = active_directory.ListActiveDirectoriesResponse() - - # 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 = active_directory.ListActiveDirectoriesResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.list_active_directories(**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/*}/activeDirectories" % client.transport._host, args[1]) - - -def test_list_active_directories_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_active_directories( - active_directory.ListActiveDirectoriesRequest(), - parent='parent_value', - ) - - -def test_list_active_directories_rest_pager(transport: str = 'rest'): - client = NetAppClient( - 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 = ( - active_directory.ListActiveDirectoriesResponse( - active_directories=[ - active_directory.ActiveDirectory(), - active_directory.ActiveDirectory(), - active_directory.ActiveDirectory(), - ], - next_page_token='abc', - ), - active_directory.ListActiveDirectoriesResponse( - active_directories=[], - next_page_token='def', - ), - active_directory.ListActiveDirectoriesResponse( - active_directories=[ - active_directory.ActiveDirectory(), - ], - next_page_token='ghi', - ), - active_directory.ListActiveDirectoriesResponse( - active_directories=[ - active_directory.ActiveDirectory(), - active_directory.ActiveDirectory(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(active_directory.ListActiveDirectoriesResponse.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_active_directories(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, active_directory.ActiveDirectory) - for i in results) - - pages = list(client.list_active_directories(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_active_directory_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 = NetAppClient( - 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_active_directory 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_active_directory] = mock_rpc - - request = {} - client.get_active_directory(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_active_directory(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_active_directory_rest_required_fields(request_type=active_directory.GetActiveDirectoryRequest): - transport_class = transports.NetAppRestTransport - - 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_active_directory._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_active_directory._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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = active_directory.ActiveDirectory() - # 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 = active_directory.ActiveDirectory.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_active_directory(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_active_directory_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_active_directory._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_active_directory_rest_flattened(): - client = NetAppClient( - 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 = active_directory.ActiveDirectory() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/activeDirectories/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 = active_directory.ActiveDirectory.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.get_active_directory(**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/*/activeDirectories/*}" % client.transport._host, args[1]) - - -def test_get_active_directory_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_active_directory( - active_directory.GetActiveDirectoryRequest(), - name='name_value', - ) - - -def test_create_active_directory_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 = NetAppClient( - 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_active_directory 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_active_directory] = mock_rpc - - request = {} - client.create_active_directory(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_active_directory(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_active_directory_rest_required_fields(request_type=gcn_active_directory.CreateActiveDirectoryRequest): - transport_class = transports.NetAppRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["active_directory_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 "activeDirectoryId" not in jsonified_request - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_active_directory._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "activeDirectoryId" in jsonified_request - assert jsonified_request["activeDirectoryId"] == request_init["active_directory_id"] - - jsonified_request["parent"] = 'parent_value' - jsonified_request["activeDirectoryId"] = 'active_directory_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_active_directory._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("active_directory_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 "activeDirectoryId" in jsonified_request - assert jsonified_request["activeDirectoryId"] == 'active_directory_id_value' - - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.create_active_directory(request) - - expected_params = [ - ( - "activeDirectoryId", - "", - ), - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_active_directory_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_active_directory._get_unset_required_fields({}) - assert set(unset_fields) == (set(("activeDirectoryId", )) & set(("parent", "activeDirectory", "activeDirectoryId", ))) - - -def test_create_active_directory_rest_flattened(): - client = NetAppClient( - 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', - active_directory=gcn_active_directory.ActiveDirectory(name='name_value'), - active_directory_id='active_directory_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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.create_active_directory(**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/*}/activeDirectories" % client.transport._host, args[1]) - - -def test_create_active_directory_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_active_directory( - gcn_active_directory.CreateActiveDirectoryRequest(), - parent='parent_value', - active_directory=gcn_active_directory.ActiveDirectory(name='name_value'), - active_directory_id='active_directory_id_value', - ) - - -def test_update_active_directory_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 = NetAppClient( - 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_active_directory 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_active_directory] = mock_rpc - - request = {} - client.update_active_directory(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.update_active_directory(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_active_directory_rest_required_fields(request_type=gcn_active_directory.UpdateActiveDirectoryRequest): - transport_class = transports.NetAppRestTransport - - 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_active_directory._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_active_directory._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 = NetAppClient( - 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': "patch", - '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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.update_active_directory(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_active_directory_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_active_directory._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("updateMask", "activeDirectory", ))) - - -def test_update_active_directory_rest_flattened(): - client = NetAppClient( - 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 = {'active_directory': {'name': 'projects/sample1/locations/sample2/activeDirectories/sample3'}} - - # get truthy value for each flattened field - mock_args = dict( - active_directory=gcn_active_directory.ActiveDirectory(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 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.update_active_directory(**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/{active_directory.name=projects/*/locations/*/activeDirectories/*}" % client.transport._host, args[1]) - - -def test_update_active_directory_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_active_directory( - gcn_active_directory.UpdateActiveDirectoryRequest(), - active_directory=gcn_active_directory.ActiveDirectory(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_delete_active_directory_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 = NetAppClient( - 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_active_directory 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_active_directory] = mock_rpc - - request = {} - client.delete_active_directory(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_active_directory(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_active_directory_rest_required_fields(request_type=active_directory.DeleteActiveDirectoryRequest): - transport_class = transports.NetAppRestTransport - - 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_active_directory._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_active_directory._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 = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.delete_active_directory(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_active_directory_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_active_directory._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_delete_active_directory_rest_flattened(): - client = NetAppClient( - 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/activeDirectories/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.delete_active_directory(**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/*/activeDirectories/*}" % client.transport._host, args[1]) - - -def test_delete_active_directory_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_active_directory( - active_directory.DeleteActiveDirectoryRequest(), - name='name_value', - ) - - -def test_list_kms_configs_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 = NetAppClient( - 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_kms_configs 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_kms_configs] = mock_rpc - - request = {} - client.list_kms_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_kms_configs(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_kms_configs_rest_required_fields(request_type=kms.ListKmsConfigsRequest): - transport_class = transports.NetAppRestTransport - - 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_kms_configs._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_kms_configs._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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = kms.ListKmsConfigsResponse() - # 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 = kms.ListKmsConfigsResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_kms_configs(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_kms_configs_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_kms_configs._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_kms_configs_rest_flattened(): - client = NetAppClient( - 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 = kms.ListKmsConfigsResponse() - - # 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 = kms.ListKmsConfigsResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.list_kms_configs(**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/*}/kmsConfigs" % client.transport._host, args[1]) - - -def test_list_kms_configs_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_kms_configs( - kms.ListKmsConfigsRequest(), - parent='parent_value', - ) - - -def test_list_kms_configs_rest_pager(transport: str = 'rest'): - client = NetAppClient( - 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 = ( - kms.ListKmsConfigsResponse( - kms_configs=[ - kms.KmsConfig(), - kms.KmsConfig(), - kms.KmsConfig(), - ], - next_page_token='abc', - ), - kms.ListKmsConfigsResponse( - kms_configs=[], - next_page_token='def', - ), - kms.ListKmsConfigsResponse( - kms_configs=[ - kms.KmsConfig(), - ], - next_page_token='ghi', - ), - kms.ListKmsConfigsResponse( - kms_configs=[ - kms.KmsConfig(), - kms.KmsConfig(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(kms.ListKmsConfigsResponse.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_kms_configs(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, kms.KmsConfig) - for i in results) - - pages = list(client.list_kms_configs(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_create_kms_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 = NetAppClient( - 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_kms_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.create_kms_config] = mock_rpc - - request = {} - client.create_kms_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.create_kms_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_create_kms_config_rest_required_fields(request_type=kms.CreateKmsConfigRequest): - transport_class = transports.NetAppRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["kms_config_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 "kmsConfigId" not in jsonified_request - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_kms_config._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "kmsConfigId" in jsonified_request - assert jsonified_request["kmsConfigId"] == request_init["kms_config_id"] - - jsonified_request["parent"] = 'parent_value' - jsonified_request["kmsConfigId"] = 'kms_config_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_kms_config._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("kms_config_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 "kmsConfigId" in jsonified_request - assert jsonified_request["kmsConfigId"] == 'kms_config_id_value' - - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.create_kms_config(request) - - expected_params = [ - ( - "kmsConfigId", - "", - ), - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_kms_config_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_kms_config._get_unset_required_fields({}) - assert set(unset_fields) == (set(("kmsConfigId", )) & set(("parent", "kmsConfigId", "kmsConfig", ))) - - -def test_create_kms_config_rest_flattened(): - client = NetAppClient( - 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', - kms_config=kms.KmsConfig(name='name_value'), - kms_config_id='kms_config_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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.create_kms_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/{parent=projects/*/locations/*}/kmsConfigs" % client.transport._host, args[1]) - - -def test_create_kms_config_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_kms_config( - kms.CreateKmsConfigRequest(), - parent='parent_value', - kms_config=kms.KmsConfig(name='name_value'), - kms_config_id='kms_config_id_value', - ) - - -def test_get_kms_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 = NetAppClient( - 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_kms_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_kms_config] = mock_rpc - - request = {} - client.get_kms_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_kms_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_kms_config_rest_required_fields(request_type=kms.GetKmsConfigRequest): - transport_class = transports.NetAppRestTransport - - 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_kms_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_kms_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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = kms.KmsConfig() - # 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 = kms.KmsConfig.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_kms_config(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_kms_config_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_kms_config._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_kms_config_rest_flattened(): - client = NetAppClient( - 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 = kms.KmsConfig() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/kmsConfigs/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 = kms.KmsConfig.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.get_kms_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/*/kmsConfigs/*}" % client.transport._host, args[1]) - - -def test_get_kms_config_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_kms_config( - kms.GetKmsConfigRequest(), - name='name_value', - ) - - -def test_update_kms_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 = NetAppClient( - 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_kms_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_kms_config] = mock_rpc - - request = {} - client.update_kms_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.update_kms_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_kms_config_rest_required_fields(request_type=kms.UpdateKmsConfigRequest): - transport_class = transports.NetAppRestTransport - - 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_kms_config._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_kms_config._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 = NetAppClient( - 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': "patch", - '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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.update_kms_config(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_kms_config_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_kms_config._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("updateMask", "kmsConfig", ))) - - -def test_update_kms_config_rest_flattened(): - client = NetAppClient( - 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 = {'kms_config': {'name': 'projects/sample1/locations/sample2/kmsConfigs/sample3'}} - - # get truthy value for each flattened field - mock_args = dict( - kms_config=kms.KmsConfig(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 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.update_kms_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/{kms_config.name=projects/*/locations/*/kmsConfigs/*}" % client.transport._host, args[1]) - - -def test_update_kms_config_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_kms_config( - kms.UpdateKmsConfigRequest(), - kms_config=kms.KmsConfig(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_encrypt_volumes_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 = NetAppClient( - 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.encrypt_volumes 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.encrypt_volumes] = mock_rpc - - request = {} - client.encrypt_volumes(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.encrypt_volumes(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_encrypt_volumes_rest_required_fields(request_type=kms.EncryptVolumesRequest): - transport_class = transports.NetAppRestTransport - - 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()).encrypt_volumes._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()).encrypt_volumes._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 = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.encrypt_volumes(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_encrypt_volumes_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.encrypt_volumes._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_verify_kms_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 = NetAppClient( - 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.verify_kms_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.verify_kms_config] = mock_rpc - - request = {} - client.verify_kms_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.verify_kms_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_verify_kms_config_rest_required_fields(request_type=kms.VerifyKmsConfigRequest): - transport_class = transports.NetAppRestTransport - - 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()).verify_kms_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()).verify_kms_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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = kms.VerifyKmsConfigResponse() - # 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 = kms.VerifyKmsConfigResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.verify_kms_config(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_verify_kms_config_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.verify_kms_config._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_delete_kms_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 = NetAppClient( - 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_kms_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.delete_kms_config] = mock_rpc - - request = {} - client.delete_kms_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.delete_kms_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_delete_kms_config_rest_required_fields(request_type=kms.DeleteKmsConfigRequest): - transport_class = transports.NetAppRestTransport - - 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_kms_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()).delete_kms_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 = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.delete_kms_config(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_kms_config_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_kms_config._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_delete_kms_config_rest_flattened(): - client = NetAppClient( - 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/kmsConfigs/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.delete_kms_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/*/kmsConfigs/*}" % client.transport._host, args[1]) - - -def test_delete_kms_config_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_kms_config( - kms.DeleteKmsConfigRequest(), - name='name_value', - ) - - -def test_list_replications_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 = NetAppClient( - 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_replications 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_replications] = mock_rpc - - request = {} - client.list_replications(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_replications(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_replications_rest_required_fields(request_type=replication.ListReplicationsRequest): - transport_class = transports.NetAppRestTransport - - 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_replications._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_replications._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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = replication.ListReplicationsResponse() - # 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 = replication.ListReplicationsResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_replications(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_replications_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_replications._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_replications_rest_flattened(): - client = NetAppClient( - 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 = replication.ListReplicationsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/volumes/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 = replication.ListReplicationsResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.list_replications(**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/*/volumes/*}/replications" % client.transport._host, args[1]) - - -def test_list_replications_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_replications( - replication.ListReplicationsRequest(), - parent='parent_value', - ) - - -def test_list_replications_rest_pager(transport: str = 'rest'): - client = NetAppClient( - 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 = ( - replication.ListReplicationsResponse( - replications=[ - replication.Replication(), - replication.Replication(), - replication.Replication(), - ], - next_page_token='abc', - ), - replication.ListReplicationsResponse( - replications=[], - next_page_token='def', - ), - replication.ListReplicationsResponse( - replications=[ - replication.Replication(), - ], - next_page_token='ghi', - ), - replication.ListReplicationsResponse( - replications=[ - replication.Replication(), - replication.Replication(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(replication.ListReplicationsResponse.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/volumes/sample3'} - - pager = client.list_replications(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, replication.Replication) - for i in results) - - pages = list(client.list_replications(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_replication_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 = NetAppClient( - 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_replication 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_replication] = mock_rpc - - request = {} - client.get_replication(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_replication(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_replication_rest_required_fields(request_type=replication.GetReplicationRequest): - transport_class = transports.NetAppRestTransport - - 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_replication._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_replication._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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = replication.Replication() - # 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 = replication.Replication.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_replication(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_replication_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_replication._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_replication_rest_flattened(): - client = NetAppClient( - 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 = replication.Replication() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 = replication.Replication.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.get_replication(**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/*/volumes/*/replications/*}" % client.transport._host, args[1]) - - -def test_get_replication_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_replication( - replication.GetReplicationRequest(), - name='name_value', - ) - - -def test_create_replication_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 = NetAppClient( - 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_replication 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_replication] = mock_rpc - - request = {} - client.create_replication(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_replication(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_replication_rest_required_fields(request_type=gcn_replication.CreateReplicationRequest): - transport_class = transports.NetAppRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["replication_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 "replicationId" not in jsonified_request - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_replication._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "replicationId" in jsonified_request - assert jsonified_request["replicationId"] == request_init["replication_id"] - - jsonified_request["parent"] = 'parent_value' - jsonified_request["replicationId"] = 'replication_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_replication._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("replication_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 "replicationId" in jsonified_request - assert jsonified_request["replicationId"] == 'replication_id_value' - - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.create_replication(request) - - expected_params = [ - ( - "replicationId", - "", - ), - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_replication_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_replication._get_unset_required_fields({}) - assert set(unset_fields) == (set(("replicationId", )) & set(("parent", "replication", "replicationId", ))) - - -def test_create_replication_rest_flattened(): - client = NetAppClient( - 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/volumes/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - replication=gcn_replication.Replication(name='name_value'), - replication_id='replication_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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.create_replication(**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/*/volumes/*}/replications" % client.transport._host, args[1]) - - -def test_create_replication_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_replication( - gcn_replication.CreateReplicationRequest(), - parent='parent_value', - replication=gcn_replication.Replication(name='name_value'), - replication_id='replication_id_value', - ) - - -def test_delete_replication_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 = NetAppClient( - 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_replication 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_replication] = mock_rpc - - request = {} - client.delete_replication(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_replication(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_replication_rest_required_fields(request_type=replication.DeleteReplicationRequest): - transport_class = transports.NetAppRestTransport - - 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_replication._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_replication._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 = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.delete_replication(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_replication_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_replication._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_delete_replication_rest_flattened(): - client = NetAppClient( - 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/volumes/sample3/replications/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.delete_replication(**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/*/volumes/*/replications/*}" % client.transport._host, args[1]) - - -def test_delete_replication_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_replication( - replication.DeleteReplicationRequest(), - name='name_value', - ) - - -def test_update_replication_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 = NetAppClient( - 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_replication 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_replication] = mock_rpc - - request = {} - client.update_replication(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.update_replication(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_replication_rest_required_fields(request_type=gcn_replication.UpdateReplicationRequest): - transport_class = transports.NetAppRestTransport - - 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_replication._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_replication._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 = NetAppClient( - 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': "patch", - '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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.update_replication(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_replication_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_replication._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("updateMask", "replication", ))) - - -def test_update_replication_rest_flattened(): - client = NetAppClient( - 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 = {'replication': {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/sample4'}} - - # get truthy value for each flattened field - mock_args = dict( - replication=gcn_replication.Replication(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 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.update_replication(**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/{replication.name=projects/*/locations/*/volumes/*/replications/*}" % client.transport._host, args[1]) - - -def test_update_replication_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_replication( - gcn_replication.UpdateReplicationRequest(), - replication=gcn_replication.Replication(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_stop_replication_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 = NetAppClient( - 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.stop_replication 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.stop_replication] = mock_rpc - - request = {} - client.stop_replication(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.stop_replication(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_stop_replication_rest_required_fields(request_type=replication.StopReplicationRequest): - transport_class = transports.NetAppRestTransport - - 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()).stop_replication._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()).stop_replication._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 = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.stop_replication(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_stop_replication_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.stop_replication._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_resume_replication_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 = NetAppClient( - 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.resume_replication 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.resume_replication] = mock_rpc - - request = {} - client.resume_replication(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.resume_replication(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_resume_replication_rest_required_fields(request_type=replication.ResumeReplicationRequest): - transport_class = transports.NetAppRestTransport - - 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()).resume_replication._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()).resume_replication._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 = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.resume_replication(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_resume_replication_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.resume_replication._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_reverse_replication_direction_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 = NetAppClient( - 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.reverse_replication_direction 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.reverse_replication_direction] = mock_rpc - - request = {} - client.reverse_replication_direction(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.reverse_replication_direction(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_reverse_replication_direction_rest_required_fields(request_type=replication.ReverseReplicationDirectionRequest): - transport_class = transports.NetAppRestTransport - - 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()).reverse_replication_direction._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()).reverse_replication_direction._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 = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.reverse_replication_direction(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_reverse_replication_direction_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.reverse_replication_direction._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_establish_peering_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 = NetAppClient( - 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.establish_peering 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.establish_peering] = mock_rpc - - request = {} - client.establish_peering(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.establish_peering(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_establish_peering_rest_required_fields(request_type=replication.EstablishPeeringRequest): - transport_class = transports.NetAppRestTransport - - request_init = {} - request_init["name"] = "" - request_init["peer_cluster_name"] = "" - request_init["peer_svm_name"] = "" - request_init["peer_volume_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()).establish_peering._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["peerClusterName"] = 'peer_cluster_name_value' - jsonified_request["peerSvmName"] = 'peer_svm_name_value' - jsonified_request["peerVolumeName"] = 'peer_volume_name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).establish_peering._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' - assert "peerClusterName" in jsonified_request - assert jsonified_request["peerClusterName"] == 'peer_cluster_name_value' - assert "peerSvmName" in jsonified_request - assert jsonified_request["peerSvmName"] == 'peer_svm_name_value' - assert "peerVolumeName" in jsonified_request - assert jsonified_request["peerVolumeName"] == 'peer_volume_name_value' - - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.establish_peering(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_establish_peering_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.establish_peering._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", "peerClusterName", "peerSvmName", "peerVolumeName", ))) - - -def test_sync_replication_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 = NetAppClient( - 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.sync_replication 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.sync_replication] = mock_rpc - - request = {} - client.sync_replication(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.sync_replication(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_sync_replication_rest_required_fields(request_type=replication.SyncReplicationRequest): - transport_class = transports.NetAppRestTransport - - 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()).sync_replication._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()).sync_replication._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 = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.sync_replication(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_sync_replication_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.sync_replication._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_create_backup_vault_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 = NetAppClient( - 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_backup_vault 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_backup_vault] = mock_rpc - - request = {} - client.create_backup_vault(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_backup_vault(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_backup_vault_rest_required_fields(request_type=gcn_backup_vault.CreateBackupVaultRequest): - transport_class = transports.NetAppRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["backup_vault_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 "backupVaultId" not in jsonified_request - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_backup_vault._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "backupVaultId" in jsonified_request - assert jsonified_request["backupVaultId"] == request_init["backup_vault_id"] - - jsonified_request["parent"] = 'parent_value' - jsonified_request["backupVaultId"] = 'backup_vault_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_backup_vault._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("backup_vault_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 "backupVaultId" in jsonified_request - assert jsonified_request["backupVaultId"] == 'backup_vault_id_value' - - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.create_backup_vault(request) - - expected_params = [ - ( - "backupVaultId", - "", - ), - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_backup_vault_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_backup_vault._get_unset_required_fields({}) - assert set(unset_fields) == (set(("backupVaultId", )) & set(("parent", "backupVaultId", "backupVault", ))) - - -def test_create_backup_vault_rest_flattened(): - client = NetAppClient( - 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', - backup_vault=gcn_backup_vault.BackupVault(name='name_value'), - backup_vault_id='backup_vault_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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.create_backup_vault(**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/*}/backupVaults" % client.transport._host, args[1]) - - -def test_create_backup_vault_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_backup_vault( - gcn_backup_vault.CreateBackupVaultRequest(), - parent='parent_value', - backup_vault=gcn_backup_vault.BackupVault(name='name_value'), - backup_vault_id='backup_vault_id_value', - ) - - -def test_get_backup_vault_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 = NetAppClient( - 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_backup_vault 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_backup_vault] = mock_rpc - - request = {} - client.get_backup_vault(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_backup_vault(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_backup_vault_rest_required_fields(request_type=backup_vault.GetBackupVaultRequest): - transport_class = transports.NetAppRestTransport - - 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_backup_vault._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_backup_vault._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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = backup_vault.BackupVault() - # 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 = backup_vault.BackupVault.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_backup_vault(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_backup_vault_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_backup_vault._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_backup_vault_rest_flattened(): - client = NetAppClient( - 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 = backup_vault.BackupVault() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/backupVaults/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 = backup_vault.BackupVault.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.get_backup_vault(**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/*/backupVaults/*}" % client.transport._host, args[1]) - - -def test_get_backup_vault_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_backup_vault( - backup_vault.GetBackupVaultRequest(), - name='name_value', - ) - - -def test_list_backup_vaults_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 = NetAppClient( - 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_backup_vaults 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_backup_vaults] = mock_rpc - - request = {} - client.list_backup_vaults(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_backup_vaults(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_backup_vaults_rest_required_fields(request_type=backup_vault.ListBackupVaultsRequest): - transport_class = transports.NetAppRestTransport - - 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_backup_vaults._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_backup_vaults._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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = backup_vault.ListBackupVaultsResponse() - # 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 = backup_vault.ListBackupVaultsResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_backup_vaults(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_backup_vaults_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_backup_vaults._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_backup_vaults_rest_flattened(): - client = NetAppClient( - 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 = backup_vault.ListBackupVaultsResponse() - - # 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 = backup_vault.ListBackupVaultsResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.list_backup_vaults(**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/*}/backupVaults" % client.transport._host, args[1]) - - -def test_list_backup_vaults_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_backup_vaults( - backup_vault.ListBackupVaultsRequest(), - parent='parent_value', - ) - - -def test_list_backup_vaults_rest_pager(transport: str = 'rest'): - client = NetAppClient( - 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 = ( - backup_vault.ListBackupVaultsResponse( - backup_vaults=[ - backup_vault.BackupVault(), - backup_vault.BackupVault(), - backup_vault.BackupVault(), - ], - next_page_token='abc', - ), - backup_vault.ListBackupVaultsResponse( - backup_vaults=[], - next_page_token='def', - ), - backup_vault.ListBackupVaultsResponse( - backup_vaults=[ - backup_vault.BackupVault(), - ], - next_page_token='ghi', - ), - backup_vault.ListBackupVaultsResponse( - backup_vaults=[ - backup_vault.BackupVault(), - backup_vault.BackupVault(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(backup_vault.ListBackupVaultsResponse.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_backup_vaults(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, backup_vault.BackupVault) - for i in results) - - pages = list(client.list_backup_vaults(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_update_backup_vault_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 = NetAppClient( - 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_backup_vault 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_backup_vault] = mock_rpc - - request = {} - client.update_backup_vault(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.update_backup_vault(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_backup_vault_rest_required_fields(request_type=gcn_backup_vault.UpdateBackupVaultRequest): - transport_class = transports.NetAppRestTransport - - 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_backup_vault._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_backup_vault._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 = NetAppClient( - 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': "patch", - '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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.update_backup_vault(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_backup_vault_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_backup_vault._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("updateMask", "backupVault", ))) - - -def test_update_backup_vault_rest_flattened(): - client = NetAppClient( - 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 = {'backup_vault': {'name': 'projects/sample1/locations/sample2/backupVaults/sample3'}} - - # get truthy value for each flattened field - mock_args = dict( - backup_vault=gcn_backup_vault.BackupVault(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 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.update_backup_vault(**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/{backup_vault.name=projects/*/locations/*/backupVaults/*}" % client.transport._host, args[1]) - - -def test_update_backup_vault_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_backup_vault( - gcn_backup_vault.UpdateBackupVaultRequest(), - backup_vault=gcn_backup_vault.BackupVault(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_delete_backup_vault_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 = NetAppClient( - 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_backup_vault 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_backup_vault] = mock_rpc - - request = {} - client.delete_backup_vault(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_backup_vault(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_backup_vault_rest_required_fields(request_type=backup_vault.DeleteBackupVaultRequest): - transport_class = transports.NetAppRestTransport - - 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_backup_vault._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_backup_vault._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 = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.delete_backup_vault(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_backup_vault_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_backup_vault._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_delete_backup_vault_rest_flattened(): - client = NetAppClient( - 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/backupVaults/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.delete_backup_vault(**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/*/backupVaults/*}" % client.transport._host, args[1]) - - -def test_delete_backup_vault_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_backup_vault( - backup_vault.DeleteBackupVaultRequest(), - name='name_value', - ) - - -def test_create_backup_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 = NetAppClient( - 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_backup 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_backup] = mock_rpc - - request = {} - client.create_backup(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_backup(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_backup_rest_required_fields(request_type=gcn_backup.CreateBackupRequest): - transport_class = transports.NetAppRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["backup_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 "backupId" not in jsonified_request - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_backup._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "backupId" in jsonified_request - assert jsonified_request["backupId"] == request_init["backup_id"] - - jsonified_request["parent"] = 'parent_value' - jsonified_request["backupId"] = 'backup_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_backup._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("backup_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 "backupId" in jsonified_request - assert jsonified_request["backupId"] == 'backup_id_value' - - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.create_backup(request) - - expected_params = [ - ( - "backupId", - "", - ), - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_backup_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_backup._get_unset_required_fields({}) - assert set(unset_fields) == (set(("backupId", )) & set(("parent", "backupId", "backup", ))) - - -def test_create_backup_rest_flattened(): - client = NetAppClient( - 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/backupVaults/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - backup=gcn_backup.Backup(name='name_value'), - backup_id='backup_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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.create_backup(**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/*/backupVaults/*}/backups" % client.transport._host, args[1]) - - -def test_create_backup_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_backup( - gcn_backup.CreateBackupRequest(), - parent='parent_value', - backup=gcn_backup.Backup(name='name_value'), - backup_id='backup_id_value', - ) - - -def test_get_backup_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 = NetAppClient( - 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_backup 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_backup] = mock_rpc - - request = {} - client.get_backup(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_backup(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_backup_rest_required_fields(request_type=backup.GetBackupRequest): - transport_class = transports.NetAppRestTransport - - 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_backup._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_backup._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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = backup.Backup() - # 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 = backup.Backup.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_backup(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_backup_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_backup._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_backup_rest_flattened(): - client = NetAppClient( - 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 = backup.Backup() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/backupVaults/sample3/backups/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 = backup.Backup.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.get_backup(**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/*/backupVaults/*/backups/*}" % client.transport._host, args[1]) - - -def test_get_backup_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_backup( - backup.GetBackupRequest(), - name='name_value', - ) - - -def test_list_backups_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 = NetAppClient( - 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_backups 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_backups] = mock_rpc - - request = {} - client.list_backups(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_backups(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_backups_rest_required_fields(request_type=backup.ListBackupsRequest): - transport_class = transports.NetAppRestTransport - - 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_backups._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_backups._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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = backup.ListBackupsResponse() - # 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 = backup.ListBackupsResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_backups(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_backups_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_backups._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_backups_rest_flattened(): - client = NetAppClient( - 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 = backup.ListBackupsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/backupVaults/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 = backup.ListBackupsResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.list_backups(**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/*/backupVaults/*}/backups" % client.transport._host, args[1]) - - -def test_list_backups_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_backups( - backup.ListBackupsRequest(), - parent='parent_value', - ) - - -def test_list_backups_rest_pager(transport: str = 'rest'): - client = NetAppClient( - 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 = ( - backup.ListBackupsResponse( - backups=[ - backup.Backup(), - backup.Backup(), - backup.Backup(), - ], - next_page_token='abc', - ), - backup.ListBackupsResponse( - backups=[], - next_page_token='def', - ), - backup.ListBackupsResponse( - backups=[ - backup.Backup(), - ], - next_page_token='ghi', - ), - backup.ListBackupsResponse( - backups=[ - backup.Backup(), - backup.Backup(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(backup.ListBackupsResponse.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/backupVaults/sample3'} - - pager = client.list_backups(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, backup.Backup) - for i in results) - - pages = list(client.list_backups(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_delete_backup_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 = NetAppClient( - 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_backup 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_backup] = mock_rpc - - request = {} - client.delete_backup(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_backup(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_backup_rest_required_fields(request_type=backup.DeleteBackupRequest): - transport_class = transports.NetAppRestTransport - - 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_backup._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_backup._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 = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.delete_backup(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_backup_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_backup._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_delete_backup_rest_flattened(): - client = NetAppClient( - 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/backupVaults/sample3/backups/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.delete_backup(**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/*/backupVaults/*/backups/*}" % client.transport._host, args[1]) - - -def test_delete_backup_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_backup( - backup.DeleteBackupRequest(), - name='name_value', - ) - - -def test_update_backup_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 = NetAppClient( - 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_backup 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_backup] = mock_rpc - - request = {} - client.update_backup(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.update_backup(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_backup_rest_required_fields(request_type=gcn_backup.UpdateBackupRequest): - transport_class = transports.NetAppRestTransport - - 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_backup._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_backup._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 = NetAppClient( - 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': "patch", - '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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.update_backup(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_backup_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_backup._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("updateMask", "backup", ))) - - -def test_update_backup_rest_flattened(): - client = NetAppClient( - 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 = {'backup': {'name': 'projects/sample1/locations/sample2/backupVaults/sample3/backups/sample4'}} - - # get truthy value for each flattened field - mock_args = dict( - backup=gcn_backup.Backup(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 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.update_backup(**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/{backup.name=projects/*/locations/*/backupVaults/*/backups/*}" % client.transport._host, args[1]) - - -def test_update_backup_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_backup( - gcn_backup.UpdateBackupRequest(), - backup=gcn_backup.Backup(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_create_backup_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 = NetAppClient( - 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_backup_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.create_backup_policy] = mock_rpc - - request = {} - client.create_backup_policy(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_backup_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_create_backup_policy_rest_required_fields(request_type=gcn_backup_policy.CreateBackupPolicyRequest): - transport_class = transports.NetAppRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["backup_policy_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 "backupPolicyId" not in jsonified_request - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_backup_policy._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "backupPolicyId" in jsonified_request - assert jsonified_request["backupPolicyId"] == request_init["backup_policy_id"] - - jsonified_request["parent"] = 'parent_value' - jsonified_request["backupPolicyId"] = 'backup_policy_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_backup_policy._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("backup_policy_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 "backupPolicyId" in jsonified_request - assert jsonified_request["backupPolicyId"] == 'backup_policy_id_value' - - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.create_backup_policy(request) - - expected_params = [ - ( - "backupPolicyId", - "", - ), - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_backup_policy_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_backup_policy._get_unset_required_fields({}) - assert set(unset_fields) == (set(("backupPolicyId", )) & set(("parent", "backupPolicy", "backupPolicyId", ))) - - -def test_create_backup_policy_rest_flattened(): - client = NetAppClient( - 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', - backup_policy=gcn_backup_policy.BackupPolicy(name='name_value'), - backup_policy_id='backup_policy_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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.create_backup_policy(**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/*}/backupPolicies" % client.transport._host, args[1]) - - -def test_create_backup_policy_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_backup_policy( - gcn_backup_policy.CreateBackupPolicyRequest(), - parent='parent_value', - backup_policy=gcn_backup_policy.BackupPolicy(name='name_value'), - backup_policy_id='backup_policy_id_value', - ) - - -def test_get_backup_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 = NetAppClient( - 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_backup_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_backup_policy] = mock_rpc - - request = {} - client.get_backup_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_backup_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_backup_policy_rest_required_fields(request_type=backup_policy.GetBackupPolicyRequest): - transport_class = transports.NetAppRestTransport - - 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_backup_policy._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_backup_policy._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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = backup_policy.BackupPolicy() - # 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 = backup_policy.BackupPolicy.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_backup_policy(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_backup_policy_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_backup_policy._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_backup_policy_rest_flattened(): - client = NetAppClient( - 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 = backup_policy.BackupPolicy() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/backupPolicies/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 = backup_policy.BackupPolicy.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.get_backup_policy(**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/*/backupPolicies/*}" % client.transport._host, args[1]) - - -def test_get_backup_policy_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_backup_policy( - backup_policy.GetBackupPolicyRequest(), - name='name_value', - ) - - -def test_list_backup_policies_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 = NetAppClient( - 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_backup_policies 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_backup_policies] = mock_rpc - - request = {} - client.list_backup_policies(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_backup_policies(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_backup_policies_rest_required_fields(request_type=backup_policy.ListBackupPoliciesRequest): - transport_class = transports.NetAppRestTransport - - 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_backup_policies._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_backup_policies._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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = backup_policy.ListBackupPoliciesResponse() - # 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 = backup_policy.ListBackupPoliciesResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_backup_policies(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_backup_policies_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_backup_policies._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_backup_policies_rest_flattened(): - client = NetAppClient( - 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 = backup_policy.ListBackupPoliciesResponse() - - # 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 = backup_policy.ListBackupPoliciesResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.list_backup_policies(**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/*}/backupPolicies" % client.transport._host, args[1]) - - -def test_list_backup_policies_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_backup_policies( - backup_policy.ListBackupPoliciesRequest(), - parent='parent_value', - ) - - -def test_list_backup_policies_rest_pager(transport: str = 'rest'): - client = NetAppClient( - 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 = ( - backup_policy.ListBackupPoliciesResponse( - backup_policies=[ - backup_policy.BackupPolicy(), - backup_policy.BackupPolicy(), - backup_policy.BackupPolicy(), - ], - next_page_token='abc', - ), - backup_policy.ListBackupPoliciesResponse( - backup_policies=[], - next_page_token='def', - ), - backup_policy.ListBackupPoliciesResponse( - backup_policies=[ - backup_policy.BackupPolicy(), - ], - next_page_token='ghi', - ), - backup_policy.ListBackupPoliciesResponse( - backup_policies=[ - backup_policy.BackupPolicy(), - backup_policy.BackupPolicy(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(backup_policy.ListBackupPoliciesResponse.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_backup_policies(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, backup_policy.BackupPolicy) - for i in results) - - pages = list(client.list_backup_policies(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_update_backup_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 = NetAppClient( - 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_backup_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.update_backup_policy] = mock_rpc - - request = {} - client.update_backup_policy(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.update_backup_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_update_backup_policy_rest_required_fields(request_type=gcn_backup_policy.UpdateBackupPolicyRequest): - transport_class = transports.NetAppRestTransport - - 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_backup_policy._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_backup_policy._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 = NetAppClient( - 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': "patch", - '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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.update_backup_policy(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_backup_policy_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_backup_policy._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("updateMask", "backupPolicy", ))) - - -def test_update_backup_policy_rest_flattened(): - client = NetAppClient( - 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 = {'backup_policy': {'name': 'projects/sample1/locations/sample2/backupPolicies/sample3'}} - - # get truthy value for each flattened field - mock_args = dict( - backup_policy=gcn_backup_policy.BackupPolicy(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 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.update_backup_policy(**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/{backup_policy.name=projects/*/locations/*/backupPolicies/*}" % client.transport._host, args[1]) - - -def test_update_backup_policy_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_backup_policy( - gcn_backup_policy.UpdateBackupPolicyRequest(), - backup_policy=gcn_backup_policy.BackupPolicy(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_delete_backup_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 = NetAppClient( - 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_backup_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.delete_backup_policy] = mock_rpc - - request = {} - client.delete_backup_policy(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_backup_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_delete_backup_policy_rest_required_fields(request_type=backup_policy.DeleteBackupPolicyRequest): - transport_class = transports.NetAppRestTransport - - 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_backup_policy._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_backup_policy._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 = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.delete_backup_policy(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_backup_policy_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_backup_policy._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_delete_backup_policy_rest_flattened(): - client = NetAppClient( - 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/backupPolicies/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.delete_backup_policy(**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/*/backupPolicies/*}" % client.transport._host, args[1]) - - -def test_delete_backup_policy_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_backup_policy( - backup_policy.DeleteBackupPolicyRequest(), - name='name_value', - ) - - -def test_list_quota_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 = NetAppClient( - 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_quota_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_quota_rules] = mock_rpc - - request = {} - client.list_quota_rules(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_quota_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_quota_rules_rest_required_fields(request_type=quota_rule.ListQuotaRulesRequest): - transport_class = transports.NetAppRestTransport - - 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_quota_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_quota_rules._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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = quota_rule.ListQuotaRulesResponse() - # 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 = quota_rule.ListQuotaRulesResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_quota_rules(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_quota_rules_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_quota_rules._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_quota_rules_rest_flattened(): - client = NetAppClient( - 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 = quota_rule.ListQuotaRulesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/volumes/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 = quota_rule.ListQuotaRulesResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.list_quota_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/*/volumes/*}/quotaRules" % client.transport._host, args[1]) - - -def test_list_quota_rules_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_quota_rules( - quota_rule.ListQuotaRulesRequest(), - parent='parent_value', - ) - - -def test_list_quota_rules_rest_pager(transport: str = 'rest'): - client = NetAppClient( - 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 = ( - quota_rule.ListQuotaRulesResponse( - quota_rules=[ - quota_rule.QuotaRule(), - quota_rule.QuotaRule(), - quota_rule.QuotaRule(), - ], - next_page_token='abc', - ), - quota_rule.ListQuotaRulesResponse( - quota_rules=[], - next_page_token='def', - ), - quota_rule.ListQuotaRulesResponse( - quota_rules=[ - quota_rule.QuotaRule(), - ], - next_page_token='ghi', - ), - quota_rule.ListQuotaRulesResponse( - quota_rules=[ - quota_rule.QuotaRule(), - quota_rule.QuotaRule(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(quota_rule.ListQuotaRulesResponse.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/volumes/sample3'} - - pager = client.list_quota_rules(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, quota_rule.QuotaRule) - for i in results) - - pages = list(client.list_quota_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_quota_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 = NetAppClient( - 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_quota_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_quota_rule] = mock_rpc - - request = {} - client.get_quota_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_quota_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_quota_rule_rest_required_fields(request_type=quota_rule.GetQuotaRuleRequest): - transport_class = transports.NetAppRestTransport - - 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_quota_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_quota_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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = quota_rule.QuotaRule() - # 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 = quota_rule.QuotaRule.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_quota_rule(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_quota_rule_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_quota_rule._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_quota_rule_rest_flattened(): - client = NetAppClient( - 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 = quota_rule.QuotaRule() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/volumes/sample3/quotaRules/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 = quota_rule.QuotaRule.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.get_quota_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/*/volumes/*/quotaRules/*}" % client.transport._host, args[1]) - - -def test_get_quota_rule_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_quota_rule( - quota_rule.GetQuotaRuleRequest(), - name='name_value', - ) - - -def test_create_quota_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 = NetAppClient( - 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_quota_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_quota_rule] = mock_rpc - - request = {} - client.create_quota_rule(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_quota_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_quota_rule_rest_required_fields(request_type=gcn_quota_rule.CreateQuotaRuleRequest): - transport_class = transports.NetAppRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["quota_rule_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 "quotaRuleId" not in jsonified_request - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_quota_rule._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "quotaRuleId" in jsonified_request - assert jsonified_request["quotaRuleId"] == request_init["quota_rule_id"] - - jsonified_request["parent"] = 'parent_value' - jsonified_request["quotaRuleId"] = 'quota_rule_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_quota_rule._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("quota_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' - assert "quotaRuleId" in jsonified_request - assert jsonified_request["quotaRuleId"] == 'quota_rule_id_value' - - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.create_quota_rule(request) - - expected_params = [ - ( - "quotaRuleId", - "", - ), - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_quota_rule_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_quota_rule._get_unset_required_fields({}) - assert set(unset_fields) == (set(("quotaRuleId", )) & set(("parent", "quotaRule", "quotaRuleId", ))) - - -def test_create_quota_rule_rest_flattened(): - client = NetAppClient( - 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/volumes/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - quota_rule=gcn_quota_rule.QuotaRule(name='name_value'), - quota_rule_id='quota_rule_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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.create_quota_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/*/volumes/*}/quotaRules" % client.transport._host, args[1]) - - -def test_create_quota_rule_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_quota_rule( - gcn_quota_rule.CreateQuotaRuleRequest(), - parent='parent_value', - quota_rule=gcn_quota_rule.QuotaRule(name='name_value'), - quota_rule_id='quota_rule_id_value', - ) - - -def test_update_quota_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 = NetAppClient( - 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_quota_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_quota_rule] = mock_rpc - - request = {} - client.update_quota_rule(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.update_quota_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_quota_rule_rest_required_fields(request_type=gcn_quota_rule.UpdateQuotaRuleRequest): - transport_class = transports.NetAppRestTransport - - 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_quota_rule._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_quota_rule._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 = NetAppClient( - 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': "patch", - '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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.update_quota_rule(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_quota_rule_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_quota_rule._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("quotaRule", ))) - - -def test_update_quota_rule_rest_flattened(): - client = NetAppClient( - 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 = {'quota_rule': {'name': 'projects/sample1/locations/sample2/volumes/sample3/quotaRules/sample4'}} - - # get truthy value for each flattened field - mock_args = dict( - quota_rule=gcn_quota_rule.QuotaRule(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 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.update_quota_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/{quota_rule.name=projects/*/locations/*/volumes/*/quotaRules/*}" % client.transport._host, args[1]) - - -def test_update_quota_rule_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_quota_rule( - gcn_quota_rule.UpdateQuotaRuleRequest(), - quota_rule=gcn_quota_rule.QuotaRule(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_delete_quota_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 = NetAppClient( - 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_quota_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_quota_rule] = mock_rpc - - request = {} - client.delete_quota_rule(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_quota_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_quota_rule_rest_required_fields(request_type=quota_rule.DeleteQuotaRuleRequest): - transport_class = transports.NetAppRestTransport - - 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_quota_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_quota_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 = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.delete_quota_rule(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_quota_rule_rest_unset_required_fields(): - transport = transports.NetAppRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_quota_rule._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_delete_quota_rule_rest_flattened(): - client = NetAppClient( - 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/volumes/sample3/quotaRules/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.delete_quota_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/*/volumes/*/quotaRules/*}" % client.transport._host, args[1]) - - -def test_delete_quota_rule_rest_flattened_error(transport: str = 'rest'): - client = NetAppClient( - 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_quota_rule( - quota_rule.DeleteQuotaRuleRequest(), - name='name_value', - ) - - -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.NetAppGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.NetAppGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = NetAppClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide an api_key and a transport instance. - transport = transports.NetAppGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = NetAppClient( - 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 = NetAppClient( - client_options=options, - credentials=ga_credentials.AnonymousCredentials() - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.NetAppGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = NetAppClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.NetAppGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = NetAppClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.NetAppGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.NetAppGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.NetAppGrpcTransport, - transports.NetAppGrpcAsyncIOTransport, - transports.NetAppRestTransport, -]) -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 = NetAppClient.get_transport_class("grpc")( - credentials=ga_credentials.AnonymousCredentials() - ) - assert transport.kind == "grpc" - - -def test_initialize_client_w_grpc(): - client = NetAppClient( - 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_storage_pools_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_storage_pools), - '__call__') as call: - call.return_value = storage_pool.ListStoragePoolsResponse() - client.list_storage_pools(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = storage_pool.ListStoragePoolsRequest() - - assert args[0] == request_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_storage_pool_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_storage_pool), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_storage_pool(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_storage_pool.CreateStoragePoolRequest() - - assert args[0] == request_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_storage_pool_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_storage_pool), - '__call__') as call: - call.return_value = storage_pool.StoragePool() - client.get_storage_pool(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = storage_pool.GetStoragePoolRequest() - - assert args[0] == request_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_storage_pool_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_storage_pool), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_storage_pool(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_storage_pool.UpdateStoragePoolRequest() - - assert args[0] == request_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_storage_pool_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_storage_pool), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_storage_pool(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = storage_pool.DeleteStoragePoolRequest() - - assert args[0] == request_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_validate_directory_service_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.validate_directory_service), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.validate_directory_service(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = storage_pool.ValidateDirectoryServiceRequest() - - assert args[0] == request_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_switch_active_replica_zone_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.switch_active_replica_zone), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.switch_active_replica_zone(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = storage_pool.SwitchActiveReplicaZoneRequest() - - assert args[0] == request_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_volumes_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_volumes), - '__call__') as call: - call.return_value = volume.ListVolumesResponse() - client.list_volumes(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = volume.ListVolumesRequest() - - assert args[0] == request_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_volume_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_volume), - '__call__') as call: - call.return_value = volume.Volume() - client.get_volume(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = volume.GetVolumeRequest() - - assert args[0] == request_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_volume_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_volume), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_volume(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_volume.CreateVolumeRequest() - - assert args[0] == request_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_volume_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_volume), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_volume(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_volume.UpdateVolumeRequest() - - assert args[0] == request_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_volume_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_volume), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_volume(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = volume.DeleteVolumeRequest() - - assert args[0] == request_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_revert_volume_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.revert_volume), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.revert_volume(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = volume.RevertVolumeRequest() - - assert args[0] == request_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_snapshots_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_snapshots), - '__call__') as call: - call.return_value = snapshot.ListSnapshotsResponse() - client.list_snapshots(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = snapshot.ListSnapshotsRequest() - - assert args[0] == request_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_snapshot_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_snapshot), - '__call__') as call: - call.return_value = snapshot.Snapshot() - client.get_snapshot(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = snapshot.GetSnapshotRequest() - - assert args[0] == request_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_snapshot_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_snapshot), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_snapshot(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_snapshot.CreateSnapshotRequest() - - assert args[0] == request_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_snapshot_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_snapshot), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_snapshot(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = snapshot.DeleteSnapshotRequest() - - assert args[0] == request_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_snapshot_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_snapshot), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_snapshot(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_snapshot.UpdateSnapshotRequest() - - assert args[0] == request_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_active_directories_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_active_directories), - '__call__') as call: - call.return_value = active_directory.ListActiveDirectoriesResponse() - client.list_active_directories(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = active_directory.ListActiveDirectoriesRequest() - - assert args[0] == request_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_active_directory_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_active_directory), - '__call__') as call: - call.return_value = active_directory.ActiveDirectory() - client.get_active_directory(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = active_directory.GetActiveDirectoryRequest() - - assert args[0] == request_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_active_directory_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_active_directory), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_active_directory(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_active_directory.CreateActiveDirectoryRequest() - - assert args[0] == request_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_active_directory_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_active_directory), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_active_directory(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_active_directory.UpdateActiveDirectoryRequest() - - assert args[0] == request_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_active_directory_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_active_directory), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_active_directory(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = active_directory.DeleteActiveDirectoryRequest() - - assert args[0] == request_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_kms_configs_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_kms_configs), - '__call__') as call: - call.return_value = kms.ListKmsConfigsResponse() - client.list_kms_configs(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = kms.ListKmsConfigsRequest() - - assert args[0] == request_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_kms_config_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_kms_config), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_kms_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = kms.CreateKmsConfigRequest() - - assert args[0] == request_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_kms_config_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_kms_config), - '__call__') as call: - call.return_value = kms.KmsConfig() - client.get_kms_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = kms.GetKmsConfigRequest() - - assert args[0] == request_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_kms_config_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_kms_config), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_kms_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = kms.UpdateKmsConfigRequest() - - assert args[0] == request_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_encrypt_volumes_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.encrypt_volumes), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.encrypt_volumes(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = kms.EncryptVolumesRequest() - - assert args[0] == request_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_verify_kms_config_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.verify_kms_config), - '__call__') as call: - call.return_value = kms.VerifyKmsConfigResponse() - client.verify_kms_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = kms.VerifyKmsConfigRequest() - - assert args[0] == request_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_kms_config_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_kms_config), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_kms_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = kms.DeleteKmsConfigRequest() - - assert args[0] == request_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_replications_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_replications), - '__call__') as call: - call.return_value = replication.ListReplicationsResponse() - client.list_replications(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.ListReplicationsRequest() - - assert args[0] == request_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_replication_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_replication), - '__call__') as call: - call.return_value = replication.Replication() - client.get_replication(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.GetReplicationRequest() - - assert args[0] == request_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_replication_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_replication), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_replication(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_replication.CreateReplicationRequest() - - assert args[0] == request_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_replication_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_replication), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_replication(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.DeleteReplicationRequest() - - assert args[0] == request_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_replication_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_replication), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_replication(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_replication.UpdateReplicationRequest() - - assert args[0] == request_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_stop_replication_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.stop_replication), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.stop_replication(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.StopReplicationRequest() - - assert args[0] == request_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_resume_replication_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.resume_replication), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.resume_replication(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.ResumeReplicationRequest() - - assert args[0] == request_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_reverse_replication_direction_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.reverse_replication_direction), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.reverse_replication_direction(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.ReverseReplicationDirectionRequest() - - assert args[0] == request_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_establish_peering_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.establish_peering), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.establish_peering(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.EstablishPeeringRequest() - - assert args[0] == request_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_sync_replication_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.sync_replication), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.sync_replication(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.SyncReplicationRequest() - - assert args[0] == request_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_backup_vault_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_backup_vault), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_backup_vault(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_backup_vault.CreateBackupVaultRequest() - - assert args[0] == request_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_backup_vault_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_backup_vault), - '__call__') as call: - call.return_value = backup_vault.BackupVault() - client.get_backup_vault(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup_vault.GetBackupVaultRequest() - - assert args[0] == request_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_backup_vaults_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_backup_vaults), - '__call__') as call: - call.return_value = backup_vault.ListBackupVaultsResponse() - client.list_backup_vaults(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup_vault.ListBackupVaultsRequest() - - assert args[0] == request_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_backup_vault_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_backup_vault), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_backup_vault(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_backup_vault.UpdateBackupVaultRequest() - - assert args[0] == request_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_backup_vault_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup_vault), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_backup_vault(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup_vault.DeleteBackupVaultRequest() - - assert args[0] == request_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_backup_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_backup), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_backup(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_backup.CreateBackupRequest() - - assert args[0] == request_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_backup_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_backup), - '__call__') as call: - call.return_value = backup.Backup() - client.get_backup(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup.GetBackupRequest() - - assert args[0] == request_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_backups_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_backups), - '__call__') as call: - call.return_value = backup.ListBackupsResponse() - client.list_backups(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup.ListBackupsRequest() - - assert args[0] == request_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_backup_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_backup(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup.DeleteBackupRequest() - - assert args[0] == request_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_backup_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_backup), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_backup(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_backup.UpdateBackupRequest() - - assert args[0] == request_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_backup_policy_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_backup_policy), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_backup_policy(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_backup_policy.CreateBackupPolicyRequest() - - assert args[0] == request_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_backup_policy_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_backup_policy), - '__call__') as call: - call.return_value = backup_policy.BackupPolicy() - client.get_backup_policy(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup_policy.GetBackupPolicyRequest() - - assert args[0] == request_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_backup_policies_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_backup_policies), - '__call__') as call: - call.return_value = backup_policy.ListBackupPoliciesResponse() - client.list_backup_policies(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup_policy.ListBackupPoliciesRequest() - - assert args[0] == request_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_backup_policy_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_backup_policy), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_backup_policy(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_backup_policy.UpdateBackupPolicyRequest() - - assert args[0] == request_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_backup_policy_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup_policy), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_backup_policy(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup_policy.DeleteBackupPolicyRequest() - - assert args[0] == request_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_quota_rules_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_quota_rules), - '__call__') as call: - call.return_value = quota_rule.ListQuotaRulesResponse() - client.list_quota_rules(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = quota_rule.ListQuotaRulesRequest() - - assert args[0] == request_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_quota_rule_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_quota_rule), - '__call__') as call: - call.return_value = quota_rule.QuotaRule() - client.get_quota_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = quota_rule.GetQuotaRuleRequest() - - assert args[0] == request_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_quota_rule_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_quota_rule), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_quota_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_quota_rule.CreateQuotaRuleRequest() - - assert args[0] == request_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_quota_rule_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_quota_rule), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_quota_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_quota_rule.UpdateQuotaRuleRequest() - - assert args[0] == request_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_quota_rule_empty_call_grpc(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_quota_rule), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_quota_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = quota_rule.DeleteQuotaRuleRequest() - - assert args[0] == request_msg - - -def test_transport_kind_grpc_asyncio(): - transport = NetAppAsyncClient.get_transport_class("grpc_asyncio")( - credentials=async_anonymous_credentials() - ) - assert transport.kind == "grpc_asyncio" - - -def test_initialize_client_w_grpc_asyncio(): - client = NetAppAsyncClient( - 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_storage_pools_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_storage_pools), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(storage_pool.ListStoragePoolsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - await client.list_storage_pools(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = storage_pool.ListStoragePoolsRequest() - - assert args[0] == request_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_storage_pool_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_storage_pool), - '__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_storage_pool(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_storage_pool.CreateStoragePoolRequest() - - assert args[0] == request_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_storage_pool_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_storage_pool), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(storage_pool.StoragePool( - name='name_value', - service_level=common.ServiceLevel.PREMIUM, - capacity_gib=1247, - volume_capacity_gib=2006, - volume_count=1312, - state=storage_pool.StoragePool.State.READY, - state_details='state_details_value', - description='description_value', - network='network_value', - active_directory='active_directory_value', - kms_config='kms_config_value', - ldap_enabled=True, - psa_range='psa_range_value', - encryption_type=common.EncryptionType.SERVICE_MANAGED, - global_access_allowed=True, - allow_auto_tiering=True, - replica_zone='replica_zone_value', - zone='zone_value', - satisfies_pzs=True, - satisfies_pzi=True, - )) - await client.get_storage_pool(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = storage_pool.GetStoragePoolRequest() - - assert args[0] == request_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_storage_pool_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_storage_pool), - '__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.update_storage_pool(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_storage_pool.UpdateStoragePoolRequest() - - assert args[0] == request_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_storage_pool_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_storage_pool), - '__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_storage_pool(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = storage_pool.DeleteStoragePoolRequest() - - assert args[0] == request_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_validate_directory_service_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.validate_directory_service), - '__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.validate_directory_service(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = storage_pool.ValidateDirectoryServiceRequest() - - assert args[0] == request_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_switch_active_replica_zone_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.switch_active_replica_zone), - '__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.switch_active_replica_zone(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = storage_pool.SwitchActiveReplicaZoneRequest() - - assert args[0] == request_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_volumes_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_volumes), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(volume.ListVolumesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - await client.list_volumes(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = volume.ListVolumesRequest() - - assert args[0] == request_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_volume_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_volume), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(volume.Volume( - name='name_value', - state=volume.Volume.State.READY, - state_details='state_details_value', - share_name='share_name_value', - psa_range='psa_range_value', - storage_pool='storage_pool_value', - network='network_value', - service_level=common.ServiceLevel.PREMIUM, - capacity_gib=1247, - protocols=[volume.Protocols.NFSV3], - smb_settings=[volume.SMBSettings.ENCRYPT_DATA], - unix_permissions='unix_permissions_value', - description='description_value', - snap_reserve=0.1293, - snapshot_directory=True, - used_gib=834, - security_style=volume.SecurityStyle.NTFS, - kerberos_enabled=True, - ldap_enabled=True, - active_directory='active_directory_value', - kms_config='kms_config_value', - encryption_type=common.EncryptionType.SERVICE_MANAGED, - has_replication=True, - restricted_actions=[volume.RestrictedAction.DELETE], - large_capacity=True, - multiple_endpoints=True, - replica_zone='replica_zone_value', - zone='zone_value', - cold_tier_size_gib=1888, - )) - await client.get_volume(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = volume.GetVolumeRequest() - - assert args[0] == request_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_volume_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_volume), - '__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_volume(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_volume.CreateVolumeRequest() - - assert args[0] == request_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_volume_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_volume), - '__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.update_volume(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_volume.UpdateVolumeRequest() - - assert args[0] == request_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_volume_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_volume), - '__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_volume(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = volume.DeleteVolumeRequest() - - assert args[0] == request_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_revert_volume_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.revert_volume), - '__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.revert_volume(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = volume.RevertVolumeRequest() - - assert args[0] == request_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_snapshots_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_snapshots), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(snapshot.ListSnapshotsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - await client.list_snapshots(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = snapshot.ListSnapshotsRequest() - - assert args[0] == request_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_snapshot_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_snapshot), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(snapshot.Snapshot( - name='name_value', - state=snapshot.Snapshot.State.READY, - state_details='state_details_value', - description='description_value', - used_bytes=0.10790000000000001, - )) - await client.get_snapshot(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = snapshot.GetSnapshotRequest() - - assert args[0] == request_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_snapshot_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_snapshot), - '__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_snapshot(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_snapshot.CreateSnapshotRequest() - - assert args[0] == request_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_snapshot_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_snapshot), - '__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_snapshot(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = snapshot.DeleteSnapshotRequest() - - assert args[0] == request_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_snapshot_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_snapshot), - '__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.update_snapshot(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_snapshot.UpdateSnapshotRequest() - - assert args[0] == request_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_active_directories_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_active_directories), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(active_directory.ListActiveDirectoriesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - await client.list_active_directories(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = active_directory.ListActiveDirectoriesRequest() - - assert args[0] == request_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_active_directory_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_active_directory), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(active_directory.ActiveDirectory( - name='name_value', - state=active_directory.ActiveDirectory.State.CREATING, - domain='domain_value', - site='site_value', - dns='dns_value', - net_bios_prefix='net_bios_prefix_value', - organizational_unit='organizational_unit_value', - aes_encryption=True, - username='username_value', - password='password_value', - backup_operators=['backup_operators_value'], - administrators=['administrators_value'], - security_operators=['security_operators_value'], - kdc_hostname='kdc_hostname_value', - kdc_ip='kdc_ip_value', - nfs_users_with_ldap=True, - description='description_value', - ldap_signing=True, - encrypt_dc_connections=True, - state_details='state_details_value', - )) - await client.get_active_directory(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = active_directory.GetActiveDirectoryRequest() - - assert args[0] == request_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_active_directory_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_active_directory), - '__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_active_directory(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_active_directory.CreateActiveDirectoryRequest() - - assert args[0] == request_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_active_directory_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_active_directory), - '__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.update_active_directory(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_active_directory.UpdateActiveDirectoryRequest() - - assert args[0] == request_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_active_directory_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_active_directory), - '__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_active_directory(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = active_directory.DeleteActiveDirectoryRequest() - - assert args[0] == request_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_kms_configs_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_kms_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(kms.ListKmsConfigsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - await client.list_kms_configs(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = kms.ListKmsConfigsRequest() - - assert args[0] == request_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_kms_config_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_kms_config), - '__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_kms_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = kms.CreateKmsConfigRequest() - - assert args[0] == request_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_kms_config_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_kms_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(kms.KmsConfig( - name='name_value', - crypto_key_name='crypto_key_name_value', - state=kms.KmsConfig.State.READY, - state_details='state_details_value', - description='description_value', - instructions='instructions_value', - service_account='service_account_value', - )) - await client.get_kms_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = kms.GetKmsConfigRequest() - - assert args[0] == request_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_kms_config_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_kms_config), - '__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.update_kms_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = kms.UpdateKmsConfigRequest() - - assert args[0] == request_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_encrypt_volumes_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.encrypt_volumes), - '__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.encrypt_volumes(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = kms.EncryptVolumesRequest() - - assert args[0] == request_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_verify_kms_config_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.verify_kms_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(kms.VerifyKmsConfigResponse( - healthy=True, - health_error='health_error_value', - instructions='instructions_value', - )) - await client.verify_kms_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = kms.VerifyKmsConfigRequest() - - assert args[0] == request_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_kms_config_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_kms_config), - '__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_kms_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = kms.DeleteKmsConfigRequest() - - assert args[0] == request_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_replications_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_replications), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(replication.ListReplicationsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - await client.list_replications(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.ListReplicationsRequest() - - assert args[0] == request_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_replication_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_replication), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(replication.Replication( - name='name_value', - state=replication.Replication.State.CREATING, - state_details='state_details_value', - role=replication.Replication.ReplicationRole.SOURCE, - replication_schedule=replication.Replication.ReplicationSchedule.EVERY_10_MINUTES, - mirror_state=replication.Replication.MirrorState.PREPARING, - healthy=True, - destination_volume='destination_volume_value', - description='description_value', - source_volume='source_volume_value', - cluster_location='cluster_location_value', - hybrid_replication_type=replication.Replication.HybridReplicationType.MIGRATION, - )) - await client.get_replication(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.GetReplicationRequest() - - assert args[0] == request_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_replication_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_replication), - '__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_replication(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_replication.CreateReplicationRequest() - - assert args[0] == request_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_replication_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_replication), - '__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_replication(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.DeleteReplicationRequest() - - assert args[0] == request_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_replication_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_replication), - '__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.update_replication(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_replication.UpdateReplicationRequest() - - assert args[0] == request_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_stop_replication_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.stop_replication), - '__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.stop_replication(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.StopReplicationRequest() - - assert args[0] == request_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_resume_replication_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.resume_replication), - '__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.resume_replication(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.ResumeReplicationRequest() - - assert args[0] == request_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_reverse_replication_direction_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.reverse_replication_direction), - '__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.reverse_replication_direction(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.ReverseReplicationDirectionRequest() - - assert args[0] == request_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_establish_peering_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.establish_peering), - '__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.establish_peering(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.EstablishPeeringRequest() - - assert args[0] == request_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_sync_replication_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.sync_replication), - '__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.sync_replication(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.SyncReplicationRequest() - - assert args[0] == request_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_backup_vault_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_backup_vault), - '__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_backup_vault(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_backup_vault.CreateBackupVaultRequest() - - assert args[0] == request_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_backup_vault_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_backup_vault), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_vault.BackupVault( - name='name_value', - state=backup_vault.BackupVault.State.CREATING, - description='description_value', - )) - await client.get_backup_vault(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup_vault.GetBackupVaultRequest() - - assert args[0] == request_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_backup_vaults_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_backup_vaults), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_vault.ListBackupVaultsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - await client.list_backup_vaults(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup_vault.ListBackupVaultsRequest() - - assert args[0] == request_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_backup_vault_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_backup_vault), - '__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.update_backup_vault(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_backup_vault.UpdateBackupVaultRequest() - - assert args[0] == request_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_backup_vault_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup_vault), - '__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_backup_vault(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup_vault.DeleteBackupVaultRequest() - - assert args[0] == request_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_backup_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_backup), - '__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_backup(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_backup.CreateBackupRequest() - - assert args[0] == request_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_backup_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_backup), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup.Backup( - name='name_value', - state=backup.Backup.State.CREATING, - description='description_value', - volume_usage_bytes=1938, - backup_type=backup.Backup.Type.MANUAL, - source_volume='source_volume_value', - source_snapshot='source_snapshot_value', - chain_storage_bytes=2013, - satisfies_pzs=True, - satisfies_pzi=True, - )) - await client.get_backup(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup.GetBackupRequest() - - assert args[0] == request_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_backups_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_backups), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup.ListBackupsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - await client.list_backups(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup.ListBackupsRequest() - - assert args[0] == request_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_backup_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup), - '__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_backup(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup.DeleteBackupRequest() - - assert args[0] == request_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_backup_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_backup), - '__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.update_backup(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_backup.UpdateBackupRequest() - - assert args[0] == request_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_backup_policy_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_backup_policy), - '__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_backup_policy(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_backup_policy.CreateBackupPolicyRequest() - - assert args[0] == request_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_backup_policy_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_backup_policy), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_policy.BackupPolicy( - name='name_value', - daily_backup_limit=1894, - weekly_backup_limit=2020, - monthly_backup_limit=2142, - description='description_value', - enabled=True, - assigned_volume_count=2253, - state=backup_policy.BackupPolicy.State.CREATING, - )) - await client.get_backup_policy(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup_policy.GetBackupPolicyRequest() - - assert args[0] == request_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_backup_policies_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_backup_policies), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(backup_policy.ListBackupPoliciesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - await client.list_backup_policies(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup_policy.ListBackupPoliciesRequest() - - assert args[0] == request_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_backup_policy_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_backup_policy), - '__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.update_backup_policy(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_backup_policy.UpdateBackupPolicyRequest() - - assert args[0] == request_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_backup_policy_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup_policy), - '__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_backup_policy(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup_policy.DeleteBackupPolicyRequest() - - assert args[0] == request_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_quota_rules_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_quota_rules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(quota_rule.ListQuotaRulesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - await client.list_quota_rules(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = quota_rule.ListQuotaRulesRequest() - - assert args[0] == request_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_quota_rule_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_quota_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(quota_rule.QuotaRule( - name='name_value', - target='target_value', - type_=quota_rule.QuotaRule.Type.INDIVIDUAL_USER_QUOTA, - disk_limit_mib=1472, - state=quota_rule.QuotaRule.State.CREATING, - state_details='state_details_value', - description='description_value', - )) - await client.get_quota_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = quota_rule.GetQuotaRuleRequest() - - assert args[0] == request_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_quota_rule_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_quota_rule), - '__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_quota_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_quota_rule.CreateQuotaRuleRequest() - - assert args[0] == request_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_quota_rule_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_quota_rule), - '__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.update_quota_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_quota_rule.UpdateQuotaRuleRequest() - - assert args[0] == request_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_quota_rule_empty_call_grpc_asyncio(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_quota_rule), - '__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_quota_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = quota_rule.DeleteQuotaRuleRequest() - - assert args[0] == request_msg - - -def test_transport_kind_rest(): - transport = NetAppClient.get_transport_class("rest")( - credentials=ga_credentials.AnonymousCredentials() - ) - assert transport.kind == "rest" - - -def test_list_storage_pools_rest_bad_request(request_type=storage_pool.ListStoragePoolsRequest): - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_storage_pools(request) - - -@pytest.mark.parametrize("request_type", [ - storage_pool.ListStoragePoolsRequest, - dict, -]) -def test_list_storage_pools_rest_call_success(request_type): - client = NetAppClient( - 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 = storage_pool.ListStoragePoolsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_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 = storage_pool.ListStoragePoolsResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_storage_pools(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListStoragePoolsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_storage_pools_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_list_storage_pools") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_list_storage_pools_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_list_storage_pools") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = storage_pool.ListStoragePoolsRequest.pb(storage_pool.ListStoragePoolsRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = storage_pool.ListStoragePoolsResponse.to_json(storage_pool.ListStoragePoolsResponse()) - req.return_value.content = return_value - - request = storage_pool.ListStoragePoolsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = storage_pool.ListStoragePoolsResponse() - post_with_metadata.return_value = storage_pool.ListStoragePoolsResponse(), metadata - - client.list_storage_pools(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_create_storage_pool_rest_bad_request(request_type=gcn_storage_pool.CreateStoragePoolRequest): - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_storage_pool(request) - - -@pytest.mark.parametrize("request_type", [ - gcn_storage_pool.CreateStoragePoolRequest, - dict, -]) -def test_create_storage_pool_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["storage_pool"] = {'name': 'name_value', 'service_level': 1, 'capacity_gib': 1247, 'volume_capacity_gib': 2006, 'volume_count': 1312, 'state': 1, 'state_details': 'state_details_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'description': 'description_value', 'labels': {}, 'network': 'network_value', 'active_directory': 'active_directory_value', 'kms_config': 'kms_config_value', 'ldap_enabled': True, 'psa_range': 'psa_range_value', 'encryption_type': 1, 'global_access_allowed': True, 'allow_auto_tiering': True, 'replica_zone': 'replica_zone_value', 'zone': 'zone_value', 'satisfies_pzs': 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 = gcn_storage_pool.CreateStoragePoolRequest.meta.fields["storage_pool"] - - 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["storage_pool"].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["storage_pool"][field])): - del request_init["storage_pool"][field][i][subfield] - else: - del request_init["storage_pool"][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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_storage_pool(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_storage_pool_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_create_storage_pool") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_create_storage_pool_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_create_storage_pool") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = gcn_storage_pool.CreateStoragePoolRequest.pb(gcn_storage_pool.CreateStoragePoolRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = gcn_storage_pool.CreateStoragePoolRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.create_storage_pool(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_get_storage_pool_rest_bad_request(request_type=storage_pool.GetStoragePoolRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/storagePools/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_storage_pool(request) - - -@pytest.mark.parametrize("request_type", [ - storage_pool.GetStoragePoolRequest, - dict, -]) -def test_get_storage_pool_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/storagePools/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 = storage_pool.StoragePool( - name='name_value', - service_level=common.ServiceLevel.PREMIUM, - capacity_gib=1247, - volume_capacity_gib=2006, - volume_count=1312, - state=storage_pool.StoragePool.State.READY, - state_details='state_details_value', - description='description_value', - network='network_value', - active_directory='active_directory_value', - kms_config='kms_config_value', - ldap_enabled=True, - psa_range='psa_range_value', - encryption_type=common.EncryptionType.SERVICE_MANAGED, - global_access_allowed=True, - allow_auto_tiering=True, - replica_zone='replica_zone_value', - zone='zone_value', - satisfies_pzs=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 = storage_pool.StoragePool.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_storage_pool(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, storage_pool.StoragePool) - assert response.name == 'name_value' - assert response.service_level == common.ServiceLevel.PREMIUM - assert response.capacity_gib == 1247 - assert response.volume_capacity_gib == 2006 - assert response.volume_count == 1312 - assert response.state == storage_pool.StoragePool.State.READY - assert response.state_details == 'state_details_value' - assert response.description == 'description_value' - assert response.network == 'network_value' - assert response.active_directory == 'active_directory_value' - assert response.kms_config == 'kms_config_value' - assert response.ldap_enabled is True - assert response.psa_range == 'psa_range_value' - assert response.encryption_type == common.EncryptionType.SERVICE_MANAGED - assert response.global_access_allowed is True - assert response.allow_auto_tiering is True - assert response.replica_zone == 'replica_zone_value' - assert response.zone == 'zone_value' - assert response.satisfies_pzs is True - assert response.satisfies_pzi is True - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_storage_pool_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_get_storage_pool") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_get_storage_pool_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_get_storage_pool") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = storage_pool.GetStoragePoolRequest.pb(storage_pool.GetStoragePoolRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = storage_pool.StoragePool.to_json(storage_pool.StoragePool()) - req.return_value.content = return_value - - request = storage_pool.GetStoragePoolRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = storage_pool.StoragePool() - post_with_metadata.return_value = storage_pool.StoragePool(), metadata - - client.get_storage_pool(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_update_storage_pool_rest_bad_request(request_type=gcn_storage_pool.UpdateStoragePoolRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'storage_pool': {'name': 'projects/sample1/locations/sample2/storagePools/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.update_storage_pool(request) - - -@pytest.mark.parametrize("request_type", [ - gcn_storage_pool.UpdateStoragePoolRequest, - dict, -]) -def test_update_storage_pool_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'storage_pool': {'name': 'projects/sample1/locations/sample2/storagePools/sample3'}} - request_init["storage_pool"] = {'name': 'projects/sample1/locations/sample2/storagePools/sample3', 'service_level': 1, 'capacity_gib': 1247, 'volume_capacity_gib': 2006, 'volume_count': 1312, 'state': 1, 'state_details': 'state_details_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'description': 'description_value', 'labels': {}, 'network': 'network_value', 'active_directory': 'active_directory_value', 'kms_config': 'kms_config_value', 'ldap_enabled': True, 'psa_range': 'psa_range_value', 'encryption_type': 1, 'global_access_allowed': True, 'allow_auto_tiering': True, 'replica_zone': 'replica_zone_value', 'zone': 'zone_value', 'satisfies_pzs': 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 = gcn_storage_pool.UpdateStoragePoolRequest.meta.fields["storage_pool"] - - 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["storage_pool"].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["storage_pool"][field])): - del request_init["storage_pool"][field][i][subfield] - else: - del request_init["storage_pool"][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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.update_storage_pool(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_update_storage_pool_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_update_storage_pool") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_update_storage_pool_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_update_storage_pool") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = gcn_storage_pool.UpdateStoragePoolRequest.pb(gcn_storage_pool.UpdateStoragePoolRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = gcn_storage_pool.UpdateStoragePoolRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.update_storage_pool(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_delete_storage_pool_rest_bad_request(request_type=storage_pool.DeleteStoragePoolRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/storagePools/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_storage_pool(request) - - -@pytest.mark.parametrize("request_type", [ - storage_pool.DeleteStoragePoolRequest, - dict, -]) -def test_delete_storage_pool_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/storagePools/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_storage_pool(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_storage_pool_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_delete_storage_pool") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_delete_storage_pool_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_delete_storage_pool") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = storage_pool.DeleteStoragePoolRequest.pb(storage_pool.DeleteStoragePoolRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = storage_pool.DeleteStoragePoolRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.delete_storage_pool(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_validate_directory_service_rest_bad_request(request_type=storage_pool.ValidateDirectoryServiceRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/storagePools/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.validate_directory_service(request) - - -@pytest.mark.parametrize("request_type", [ - storage_pool.ValidateDirectoryServiceRequest, - dict, -]) -def test_validate_directory_service_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/storagePools/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.validate_directory_service(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_validate_directory_service_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_validate_directory_service") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_validate_directory_service_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_validate_directory_service") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = storage_pool.ValidateDirectoryServiceRequest.pb(storage_pool.ValidateDirectoryServiceRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = storage_pool.ValidateDirectoryServiceRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.validate_directory_service(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_switch_active_replica_zone_rest_bad_request(request_type=storage_pool.SwitchActiveReplicaZoneRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/storagePools/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.switch_active_replica_zone(request) - - -@pytest.mark.parametrize("request_type", [ - storage_pool.SwitchActiveReplicaZoneRequest, - dict, -]) -def test_switch_active_replica_zone_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/storagePools/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.switch_active_replica_zone(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_switch_active_replica_zone_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_switch_active_replica_zone") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_switch_active_replica_zone_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_switch_active_replica_zone") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = storage_pool.SwitchActiveReplicaZoneRequest.pb(storage_pool.SwitchActiveReplicaZoneRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = storage_pool.SwitchActiveReplicaZoneRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.switch_active_replica_zone(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_list_volumes_rest_bad_request(request_type=volume.ListVolumesRequest): - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_volumes(request) - - -@pytest.mark.parametrize("request_type", [ - volume.ListVolumesRequest, - dict, -]) -def test_list_volumes_rest_call_success(request_type): - client = NetAppClient( - 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 = volume.ListVolumesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_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 = volume.ListVolumesResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_volumes(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListVolumesPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_volumes_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_list_volumes") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_list_volumes_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_list_volumes") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = volume.ListVolumesRequest.pb(volume.ListVolumesRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = volume.ListVolumesResponse.to_json(volume.ListVolumesResponse()) - req.return_value.content = return_value - - request = volume.ListVolumesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = volume.ListVolumesResponse() - post_with_metadata.return_value = volume.ListVolumesResponse(), metadata - - client.list_volumes(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_get_volume_rest_bad_request(request_type=volume.GetVolumeRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_volume(request) - - -@pytest.mark.parametrize("request_type", [ - volume.GetVolumeRequest, - dict, -]) -def test_get_volume_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/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 = volume.Volume( - name='name_value', - state=volume.Volume.State.READY, - state_details='state_details_value', - share_name='share_name_value', - psa_range='psa_range_value', - storage_pool='storage_pool_value', - network='network_value', - service_level=common.ServiceLevel.PREMIUM, - capacity_gib=1247, - protocols=[volume.Protocols.NFSV3], - smb_settings=[volume.SMBSettings.ENCRYPT_DATA], - unix_permissions='unix_permissions_value', - description='description_value', - snap_reserve=0.1293, - snapshot_directory=True, - used_gib=834, - security_style=volume.SecurityStyle.NTFS, - kerberos_enabled=True, - ldap_enabled=True, - active_directory='active_directory_value', - kms_config='kms_config_value', - encryption_type=common.EncryptionType.SERVICE_MANAGED, - has_replication=True, - restricted_actions=[volume.RestrictedAction.DELETE], - large_capacity=True, - multiple_endpoints=True, - replica_zone='replica_zone_value', - zone='zone_value', - cold_tier_size_gib=1888, - ) - - # 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 = volume.Volume.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_volume(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, volume.Volume) - assert response.name == 'name_value' - assert response.state == volume.Volume.State.READY - assert response.state_details == 'state_details_value' - assert response.share_name == 'share_name_value' - assert response.psa_range == 'psa_range_value' - assert response.storage_pool == 'storage_pool_value' - assert response.network == 'network_value' - assert response.service_level == common.ServiceLevel.PREMIUM - assert response.capacity_gib == 1247 - assert response.protocols == [volume.Protocols.NFSV3] - assert response.smb_settings == [volume.SMBSettings.ENCRYPT_DATA] - assert response.unix_permissions == 'unix_permissions_value' - assert response.description == 'description_value' - assert math.isclose(response.snap_reserve, 0.1293, rel_tol=1e-6) - assert response.snapshot_directory is True - assert response.used_gib == 834 - assert response.security_style == volume.SecurityStyle.NTFS - assert response.kerberos_enabled is True - assert response.ldap_enabled is True - assert response.active_directory == 'active_directory_value' - assert response.kms_config == 'kms_config_value' - assert response.encryption_type == common.EncryptionType.SERVICE_MANAGED - assert response.has_replication is True - assert response.restricted_actions == [volume.RestrictedAction.DELETE] - assert response.large_capacity is True - assert response.multiple_endpoints is True - assert response.replica_zone == 'replica_zone_value' - assert response.zone == 'zone_value' - assert response.cold_tier_size_gib == 1888 - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_volume_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_get_volume") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_get_volume_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_get_volume") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = volume.GetVolumeRequest.pb(volume.GetVolumeRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = volume.Volume.to_json(volume.Volume()) - req.return_value.content = return_value - - request = volume.GetVolumeRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = volume.Volume() - post_with_metadata.return_value = volume.Volume(), metadata - - client.get_volume(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_create_volume_rest_bad_request(request_type=gcn_volume.CreateVolumeRequest): - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_volume(request) - - -@pytest.mark.parametrize("request_type", [ - gcn_volume.CreateVolumeRequest, - dict, -]) -def test_create_volume_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["volume"] = {'name': 'name_value', 'state': 1, 'state_details': 'state_details_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'share_name': 'share_name_value', 'psa_range': 'psa_range_value', 'storage_pool': 'storage_pool_value', 'network': 'network_value', 'service_level': 1, 'capacity_gib': 1247, 'export_policy': {'rules': [{'allowed_clients': 'allowed_clients_value', 'has_root_access': 'has_root_access_value', 'access_type': 1, 'nfsv3': True, 'nfsv4': True, 'kerberos_5_read_only': True, 'kerberos_5_read_write': True, 'kerberos_5i_read_only': True, 'kerberos_5i_read_write': True, 'kerberos_5p_read_only': True, 'kerberos_5p_read_write': True}]}, 'protocols': [1], 'smb_settings': [1], 'mount_options': [{'export': 'export_value', 'export_full': 'export_full_value', 'protocol': 1, 'instructions': 'instructions_value', 'ip_address': 'ip_address_value'}], 'unix_permissions': 'unix_permissions_value', 'labels': {}, 'description': 'description_value', 'snapshot_policy': {'enabled': True, 'hourly_schedule': {'snapshots_to_keep': 0.18330000000000002, 'minute': 0.658}, 'daily_schedule': {'snapshots_to_keep': 0.18330000000000002, 'minute': 0.658, 'hour': 0.446}, 'weekly_schedule': {'snapshots_to_keep': 0.18330000000000002, 'minute': 0.658, 'hour': 0.446, 'day': 'day_value'}, 'monthly_schedule': {'snapshots_to_keep': 0.18330000000000002, 'minute': 0.658, 'hour': 0.446, 'days_of_month': 'days_of_month_value'}}, 'snap_reserve': 0.1293, 'snapshot_directory': True, 'used_gib': 834, 'security_style': 1, 'kerberos_enabled': True, 'ldap_enabled': True, 'active_directory': 'active_directory_value', 'restore_parameters': {'source_snapshot': 'source_snapshot_value', 'source_backup': 'source_backup_value'}, 'kms_config': 'kms_config_value', 'encryption_type': 1, 'has_replication': True, 'backup_config': {'backup_policies': ['backup_policies_value1', 'backup_policies_value2'], 'backup_vault': 'backup_vault_value', 'scheduled_backup_enabled': True, 'backup_chain_bytes': 1886}, 'restricted_actions': [1], 'large_capacity': True, 'multiple_endpoints': True, 'tiering_policy': {'tier_action': 1, 'cooling_threshold_days': 2343}, 'replica_zone': 'replica_zone_value', 'zone': 'zone_value', 'cold_tier_size_gib': 1888, 'hybrid_replication_parameters': {'replication': 'replication_value', 'peer_volume_name': 'peer_volume_name_value', 'peer_cluster_name': 'peer_cluster_name_value', 'peer_svm_name': 'peer_svm_name_value', 'peer_ip_addresses': ['peer_ip_addresses_value1', 'peer_ip_addresses_value2'], 'cluster_location': 'cluster_location_value', 'description': 'description_value', 'labels': {}}} - # 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 = gcn_volume.CreateVolumeRequest.meta.fields["volume"] - - 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["volume"].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["volume"][field])): - del request_init["volume"][field][i][subfield] - else: - del request_init["volume"][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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_volume(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_volume_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_create_volume") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_create_volume_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_create_volume") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = gcn_volume.CreateVolumeRequest.pb(gcn_volume.CreateVolumeRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = gcn_volume.CreateVolumeRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.create_volume(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_update_volume_rest_bad_request(request_type=gcn_volume.UpdateVolumeRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'volume': {'name': 'projects/sample1/locations/sample2/volumes/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.update_volume(request) - - -@pytest.mark.parametrize("request_type", [ - gcn_volume.UpdateVolumeRequest, - dict, -]) -def test_update_volume_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'volume': {'name': 'projects/sample1/locations/sample2/volumes/sample3'}} - request_init["volume"] = {'name': 'projects/sample1/locations/sample2/volumes/sample3', 'state': 1, 'state_details': 'state_details_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'share_name': 'share_name_value', 'psa_range': 'psa_range_value', 'storage_pool': 'storage_pool_value', 'network': 'network_value', 'service_level': 1, 'capacity_gib': 1247, 'export_policy': {'rules': [{'allowed_clients': 'allowed_clients_value', 'has_root_access': 'has_root_access_value', 'access_type': 1, 'nfsv3': True, 'nfsv4': True, 'kerberos_5_read_only': True, 'kerberos_5_read_write': True, 'kerberos_5i_read_only': True, 'kerberos_5i_read_write': True, 'kerberos_5p_read_only': True, 'kerberos_5p_read_write': True}]}, 'protocols': [1], 'smb_settings': [1], 'mount_options': [{'export': 'export_value', 'export_full': 'export_full_value', 'protocol': 1, 'instructions': 'instructions_value', 'ip_address': 'ip_address_value'}], 'unix_permissions': 'unix_permissions_value', 'labels': {}, 'description': 'description_value', 'snapshot_policy': {'enabled': True, 'hourly_schedule': {'snapshots_to_keep': 0.18330000000000002, 'minute': 0.658}, 'daily_schedule': {'snapshots_to_keep': 0.18330000000000002, 'minute': 0.658, 'hour': 0.446}, 'weekly_schedule': {'snapshots_to_keep': 0.18330000000000002, 'minute': 0.658, 'hour': 0.446, 'day': 'day_value'}, 'monthly_schedule': {'snapshots_to_keep': 0.18330000000000002, 'minute': 0.658, 'hour': 0.446, 'days_of_month': 'days_of_month_value'}}, 'snap_reserve': 0.1293, 'snapshot_directory': True, 'used_gib': 834, 'security_style': 1, 'kerberos_enabled': True, 'ldap_enabled': True, 'active_directory': 'active_directory_value', 'restore_parameters': {'source_snapshot': 'source_snapshot_value', 'source_backup': 'source_backup_value'}, 'kms_config': 'kms_config_value', 'encryption_type': 1, 'has_replication': True, 'backup_config': {'backup_policies': ['backup_policies_value1', 'backup_policies_value2'], 'backup_vault': 'backup_vault_value', 'scheduled_backup_enabled': True, 'backup_chain_bytes': 1886}, 'restricted_actions': [1], 'large_capacity': True, 'multiple_endpoints': True, 'tiering_policy': {'tier_action': 1, 'cooling_threshold_days': 2343}, 'replica_zone': 'replica_zone_value', 'zone': 'zone_value', 'cold_tier_size_gib': 1888, 'hybrid_replication_parameters': {'replication': 'replication_value', 'peer_volume_name': 'peer_volume_name_value', 'peer_cluster_name': 'peer_cluster_name_value', 'peer_svm_name': 'peer_svm_name_value', 'peer_ip_addresses': ['peer_ip_addresses_value1', 'peer_ip_addresses_value2'], 'cluster_location': 'cluster_location_value', 'description': 'description_value', 'labels': {}}} - # 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 = gcn_volume.UpdateVolumeRequest.meta.fields["volume"] - - 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["volume"].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["volume"][field])): - del request_init["volume"][field][i][subfield] - else: - del request_init["volume"][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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.update_volume(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_update_volume_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_update_volume") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_update_volume_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_update_volume") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = gcn_volume.UpdateVolumeRequest.pb(gcn_volume.UpdateVolumeRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = gcn_volume.UpdateVolumeRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.update_volume(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_delete_volume_rest_bad_request(request_type=volume.DeleteVolumeRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_volume(request) - - -@pytest.mark.parametrize("request_type", [ - volume.DeleteVolumeRequest, - dict, -]) -def test_delete_volume_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_volume(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_volume_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_delete_volume") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_delete_volume_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_delete_volume") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = volume.DeleteVolumeRequest.pb(volume.DeleteVolumeRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = volume.DeleteVolumeRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.delete_volume(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_revert_volume_rest_bad_request(request_type=volume.RevertVolumeRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.revert_volume(request) - - -@pytest.mark.parametrize("request_type", [ - volume.RevertVolumeRequest, - dict, -]) -def test_revert_volume_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.revert_volume(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_revert_volume_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_revert_volume") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_revert_volume_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_revert_volume") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = volume.RevertVolumeRequest.pb(volume.RevertVolumeRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = volume.RevertVolumeRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.revert_volume(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_list_snapshots_rest_bad_request(request_type=snapshot.ListSnapshotsRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/volumes/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_snapshots(request) - - -@pytest.mark.parametrize("request_type", [ - snapshot.ListSnapshotsRequest, - dict, -]) -def test_list_snapshots_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/volumes/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 = snapshot.ListSnapshotsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_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 = snapshot.ListSnapshotsResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_snapshots(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListSnapshotsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_snapshots_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_list_snapshots") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_list_snapshots_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_list_snapshots") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = snapshot.ListSnapshotsRequest.pb(snapshot.ListSnapshotsRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = snapshot.ListSnapshotsResponse.to_json(snapshot.ListSnapshotsResponse()) - req.return_value.content = return_value - - request = snapshot.ListSnapshotsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = snapshot.ListSnapshotsResponse() - post_with_metadata.return_value = snapshot.ListSnapshotsResponse(), metadata - - client.list_snapshots(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_get_snapshot_rest_bad_request(request_type=snapshot.GetSnapshotRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/snapshots/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_snapshot(request) - - -@pytest.mark.parametrize("request_type", [ - snapshot.GetSnapshotRequest, - dict, -]) -def test_get_snapshot_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/snapshots/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 = snapshot.Snapshot( - name='name_value', - state=snapshot.Snapshot.State.READY, - state_details='state_details_value', - description='description_value', - used_bytes=0.10790000000000001, - ) - - # 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 = snapshot.Snapshot.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_snapshot(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, snapshot.Snapshot) - assert response.name == 'name_value' - assert response.state == snapshot.Snapshot.State.READY - assert response.state_details == 'state_details_value' - assert response.description == 'description_value' - assert math.isclose(response.used_bytes, 0.10790000000000001, rel_tol=1e-6) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_snapshot_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_get_snapshot") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_get_snapshot_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_get_snapshot") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = snapshot.GetSnapshotRequest.pb(snapshot.GetSnapshotRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = snapshot.Snapshot.to_json(snapshot.Snapshot()) - req.return_value.content = return_value - - request = snapshot.GetSnapshotRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = snapshot.Snapshot() - post_with_metadata.return_value = snapshot.Snapshot(), metadata - - client.get_snapshot(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_create_snapshot_rest_bad_request(request_type=gcn_snapshot.CreateSnapshotRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/volumes/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_snapshot(request) - - -@pytest.mark.parametrize("request_type", [ - gcn_snapshot.CreateSnapshotRequest, - dict, -]) -def test_create_snapshot_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/volumes/sample3'} - request_init["snapshot"] = {'name': 'name_value', 'state': 1, 'state_details': 'state_details_value', 'description': 'description_value', 'used_bytes': 0.10790000000000001, 'create_time': {'seconds': 751, 'nanos': 543}, 'labels': {}} - # 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 = gcn_snapshot.CreateSnapshotRequest.meta.fields["snapshot"] - - 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["snapshot"].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["snapshot"][field])): - del request_init["snapshot"][field][i][subfield] - else: - del request_init["snapshot"][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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_snapshot(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_snapshot_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_create_snapshot") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_create_snapshot_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_create_snapshot") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = gcn_snapshot.CreateSnapshotRequest.pb(gcn_snapshot.CreateSnapshotRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = gcn_snapshot.CreateSnapshotRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.create_snapshot(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_delete_snapshot_rest_bad_request(request_type=snapshot.DeleteSnapshotRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/snapshots/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_snapshot(request) - - -@pytest.mark.parametrize("request_type", [ - snapshot.DeleteSnapshotRequest, - dict, -]) -def test_delete_snapshot_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/snapshots/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_snapshot(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_snapshot_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_delete_snapshot") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_delete_snapshot_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_delete_snapshot") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = snapshot.DeleteSnapshotRequest.pb(snapshot.DeleteSnapshotRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = snapshot.DeleteSnapshotRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.delete_snapshot(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_update_snapshot_rest_bad_request(request_type=gcn_snapshot.UpdateSnapshotRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'snapshot': {'name': 'projects/sample1/locations/sample2/volumes/sample3/snapshots/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.update_snapshot(request) - - -@pytest.mark.parametrize("request_type", [ - gcn_snapshot.UpdateSnapshotRequest, - dict, -]) -def test_update_snapshot_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'snapshot': {'name': 'projects/sample1/locations/sample2/volumes/sample3/snapshots/sample4'}} - request_init["snapshot"] = {'name': 'projects/sample1/locations/sample2/volumes/sample3/snapshots/sample4', 'state': 1, 'state_details': 'state_details_value', 'description': 'description_value', 'used_bytes': 0.10790000000000001, 'create_time': {'seconds': 751, 'nanos': 543}, 'labels': {}} - # 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 = gcn_snapshot.UpdateSnapshotRequest.meta.fields["snapshot"] - - 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["snapshot"].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["snapshot"][field])): - del request_init["snapshot"][field][i][subfield] - else: - del request_init["snapshot"][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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.update_snapshot(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_update_snapshot_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_update_snapshot") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_update_snapshot_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_update_snapshot") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = gcn_snapshot.UpdateSnapshotRequest.pb(gcn_snapshot.UpdateSnapshotRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = gcn_snapshot.UpdateSnapshotRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.update_snapshot(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_list_active_directories_rest_bad_request(request_type=active_directory.ListActiveDirectoriesRequest): - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_active_directories(request) - - -@pytest.mark.parametrize("request_type", [ - active_directory.ListActiveDirectoriesRequest, - dict, -]) -def test_list_active_directories_rest_call_success(request_type): - client = NetAppClient( - 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 = active_directory.ListActiveDirectoriesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_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 = active_directory.ListActiveDirectoriesResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_active_directories(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListActiveDirectoriesPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_active_directories_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_list_active_directories") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_list_active_directories_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_list_active_directories") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = active_directory.ListActiveDirectoriesRequest.pb(active_directory.ListActiveDirectoriesRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = active_directory.ListActiveDirectoriesResponse.to_json(active_directory.ListActiveDirectoriesResponse()) - req.return_value.content = return_value - - request = active_directory.ListActiveDirectoriesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = active_directory.ListActiveDirectoriesResponse() - post_with_metadata.return_value = active_directory.ListActiveDirectoriesResponse(), metadata - - client.list_active_directories(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_get_active_directory_rest_bad_request(request_type=active_directory.GetActiveDirectoryRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/activeDirectories/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_active_directory(request) - - -@pytest.mark.parametrize("request_type", [ - active_directory.GetActiveDirectoryRequest, - dict, -]) -def test_get_active_directory_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/activeDirectories/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 = active_directory.ActiveDirectory( - name='name_value', - state=active_directory.ActiveDirectory.State.CREATING, - domain='domain_value', - site='site_value', - dns='dns_value', - net_bios_prefix='net_bios_prefix_value', - organizational_unit='organizational_unit_value', - aes_encryption=True, - username='username_value', - password='password_value', - backup_operators=['backup_operators_value'], - administrators=['administrators_value'], - security_operators=['security_operators_value'], - kdc_hostname='kdc_hostname_value', - kdc_ip='kdc_ip_value', - nfs_users_with_ldap=True, - description='description_value', - ldap_signing=True, - encrypt_dc_connections=True, - state_details='state_details_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 = active_directory.ActiveDirectory.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_active_directory(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, active_directory.ActiveDirectory) - assert response.name == 'name_value' - assert response.state == active_directory.ActiveDirectory.State.CREATING - assert response.domain == 'domain_value' - assert response.site == 'site_value' - assert response.dns == 'dns_value' - assert response.net_bios_prefix == 'net_bios_prefix_value' - assert response.organizational_unit == 'organizational_unit_value' - assert response.aes_encryption is True - assert response.username == 'username_value' - assert response.password == 'password_value' - assert response.backup_operators == ['backup_operators_value'] - assert response.administrators == ['administrators_value'] - assert response.security_operators == ['security_operators_value'] - assert response.kdc_hostname == 'kdc_hostname_value' - assert response.kdc_ip == 'kdc_ip_value' - assert response.nfs_users_with_ldap is True - assert response.description == 'description_value' - assert response.ldap_signing is True - assert response.encrypt_dc_connections is True - assert response.state_details == 'state_details_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_active_directory_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_get_active_directory") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_get_active_directory_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_get_active_directory") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = active_directory.GetActiveDirectoryRequest.pb(active_directory.GetActiveDirectoryRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = active_directory.ActiveDirectory.to_json(active_directory.ActiveDirectory()) - req.return_value.content = return_value - - request = active_directory.GetActiveDirectoryRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = active_directory.ActiveDirectory() - post_with_metadata.return_value = active_directory.ActiveDirectory(), metadata - - client.get_active_directory(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_create_active_directory_rest_bad_request(request_type=gcn_active_directory.CreateActiveDirectoryRequest): - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_active_directory(request) - - -@pytest.mark.parametrize("request_type", [ - gcn_active_directory.CreateActiveDirectoryRequest, - dict, -]) -def test_create_active_directory_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["active_directory"] = {'name': 'name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'state': 1, 'domain': 'domain_value', 'site': 'site_value', 'dns': 'dns_value', 'net_bios_prefix': 'net_bios_prefix_value', 'organizational_unit': 'organizational_unit_value', 'aes_encryption': True, 'username': 'username_value', 'password': 'password_value', 'backup_operators': ['backup_operators_value1', 'backup_operators_value2'], 'administrators': ['administrators_value1', 'administrators_value2'], 'security_operators': ['security_operators_value1', 'security_operators_value2'], 'kdc_hostname': 'kdc_hostname_value', 'kdc_ip': 'kdc_ip_value', 'nfs_users_with_ldap': True, 'description': 'description_value', 'ldap_signing': True, 'encrypt_dc_connections': True, 'labels': {}, 'state_details': 'state_details_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 = gcn_active_directory.CreateActiveDirectoryRequest.meta.fields["active_directory"] - - 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["active_directory"].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["active_directory"][field])): - del request_init["active_directory"][field][i][subfield] - else: - del request_init["active_directory"][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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_active_directory(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_active_directory_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_create_active_directory") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_create_active_directory_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_create_active_directory") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = gcn_active_directory.CreateActiveDirectoryRequest.pb(gcn_active_directory.CreateActiveDirectoryRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = gcn_active_directory.CreateActiveDirectoryRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.create_active_directory(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_update_active_directory_rest_bad_request(request_type=gcn_active_directory.UpdateActiveDirectoryRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'active_directory': {'name': 'projects/sample1/locations/sample2/activeDirectories/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.update_active_directory(request) - - -@pytest.mark.parametrize("request_type", [ - gcn_active_directory.UpdateActiveDirectoryRequest, - dict, -]) -def test_update_active_directory_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'active_directory': {'name': 'projects/sample1/locations/sample2/activeDirectories/sample3'}} - request_init["active_directory"] = {'name': 'projects/sample1/locations/sample2/activeDirectories/sample3', 'create_time': {'seconds': 751, 'nanos': 543}, 'state': 1, 'domain': 'domain_value', 'site': 'site_value', 'dns': 'dns_value', 'net_bios_prefix': 'net_bios_prefix_value', 'organizational_unit': 'organizational_unit_value', 'aes_encryption': True, 'username': 'username_value', 'password': 'password_value', 'backup_operators': ['backup_operators_value1', 'backup_operators_value2'], 'administrators': ['administrators_value1', 'administrators_value2'], 'security_operators': ['security_operators_value1', 'security_operators_value2'], 'kdc_hostname': 'kdc_hostname_value', 'kdc_ip': 'kdc_ip_value', 'nfs_users_with_ldap': True, 'description': 'description_value', 'ldap_signing': True, 'encrypt_dc_connections': True, 'labels': {}, 'state_details': 'state_details_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 = gcn_active_directory.UpdateActiveDirectoryRequest.meta.fields["active_directory"] - - 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["active_directory"].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["active_directory"][field])): - del request_init["active_directory"][field][i][subfield] - else: - del request_init["active_directory"][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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.update_active_directory(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_update_active_directory_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_update_active_directory") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_update_active_directory_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_update_active_directory") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = gcn_active_directory.UpdateActiveDirectoryRequest.pb(gcn_active_directory.UpdateActiveDirectoryRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = gcn_active_directory.UpdateActiveDirectoryRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.update_active_directory(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_delete_active_directory_rest_bad_request(request_type=active_directory.DeleteActiveDirectoryRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/activeDirectories/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_active_directory(request) - - -@pytest.mark.parametrize("request_type", [ - active_directory.DeleteActiveDirectoryRequest, - dict, -]) -def test_delete_active_directory_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/activeDirectories/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_active_directory(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_active_directory_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_delete_active_directory") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_delete_active_directory_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_delete_active_directory") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = active_directory.DeleteActiveDirectoryRequest.pb(active_directory.DeleteActiveDirectoryRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = active_directory.DeleteActiveDirectoryRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.delete_active_directory(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_list_kms_configs_rest_bad_request(request_type=kms.ListKmsConfigsRequest): - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_kms_configs(request) - - -@pytest.mark.parametrize("request_type", [ - kms.ListKmsConfigsRequest, - dict, -]) -def test_list_kms_configs_rest_call_success(request_type): - client = NetAppClient( - 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 = kms.ListKmsConfigsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_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 = kms.ListKmsConfigsResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_kms_configs(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListKmsConfigsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_kms_configs_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_list_kms_configs") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_list_kms_configs_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_list_kms_configs") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = kms.ListKmsConfigsRequest.pb(kms.ListKmsConfigsRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = kms.ListKmsConfigsResponse.to_json(kms.ListKmsConfigsResponse()) - req.return_value.content = return_value - - request = kms.ListKmsConfigsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = kms.ListKmsConfigsResponse() - post_with_metadata.return_value = kms.ListKmsConfigsResponse(), metadata - - client.list_kms_configs(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_create_kms_config_rest_bad_request(request_type=kms.CreateKmsConfigRequest): - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_kms_config(request) - - -@pytest.mark.parametrize("request_type", [ - kms.CreateKmsConfigRequest, - dict, -]) -def test_create_kms_config_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["kms_config"] = {'name': 'name_value', 'crypto_key_name': 'crypto_key_name_value', 'state': 1, 'state_details': 'state_details_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'description': 'description_value', 'labels': {}, 'instructions': 'instructions_value', 'service_account': 'service_account_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 = kms.CreateKmsConfigRequest.meta.fields["kms_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["kms_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["kms_config"][field])): - del request_init["kms_config"][field][i][subfield] - else: - del request_init["kms_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 = 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_kms_config(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_kms_config_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_create_kms_config") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_create_kms_config_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_create_kms_config") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = kms.CreateKmsConfigRequest.pb(kms.CreateKmsConfigRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = kms.CreateKmsConfigRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.create_kms_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_get_kms_config_rest_bad_request(request_type=kms.GetKmsConfigRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/kmsConfigs/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_kms_config(request) - - -@pytest.mark.parametrize("request_type", [ - kms.GetKmsConfigRequest, - dict, -]) -def test_get_kms_config_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/kmsConfigs/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 = kms.KmsConfig( - name='name_value', - crypto_key_name='crypto_key_name_value', - state=kms.KmsConfig.State.READY, - state_details='state_details_value', - description='description_value', - instructions='instructions_value', - service_account='service_account_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 = kms.KmsConfig.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_kms_config(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, kms.KmsConfig) - assert response.name == 'name_value' - assert response.crypto_key_name == 'crypto_key_name_value' - assert response.state == kms.KmsConfig.State.READY - assert response.state_details == 'state_details_value' - assert response.description == 'description_value' - assert response.instructions == 'instructions_value' - assert response.service_account == 'service_account_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_kms_config_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_get_kms_config") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_get_kms_config_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_get_kms_config") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = kms.GetKmsConfigRequest.pb(kms.GetKmsConfigRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = kms.KmsConfig.to_json(kms.KmsConfig()) - req.return_value.content = return_value - - request = kms.GetKmsConfigRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = kms.KmsConfig() - post_with_metadata.return_value = kms.KmsConfig(), metadata - - client.get_kms_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_update_kms_config_rest_bad_request(request_type=kms.UpdateKmsConfigRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'kms_config': {'name': 'projects/sample1/locations/sample2/kmsConfigs/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.update_kms_config(request) - - -@pytest.mark.parametrize("request_type", [ - kms.UpdateKmsConfigRequest, - dict, -]) -def test_update_kms_config_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'kms_config': {'name': 'projects/sample1/locations/sample2/kmsConfigs/sample3'}} - request_init["kms_config"] = {'name': 'projects/sample1/locations/sample2/kmsConfigs/sample3', 'crypto_key_name': 'crypto_key_name_value', 'state': 1, 'state_details': 'state_details_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'description': 'description_value', 'labels': {}, 'instructions': 'instructions_value', 'service_account': 'service_account_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 = kms.UpdateKmsConfigRequest.meta.fields["kms_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["kms_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["kms_config"][field])): - del request_init["kms_config"][field][i][subfield] - else: - del request_init["kms_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 = 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.update_kms_config(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_update_kms_config_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_update_kms_config") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_update_kms_config_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_update_kms_config") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = kms.UpdateKmsConfigRequest.pb(kms.UpdateKmsConfigRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = kms.UpdateKmsConfigRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.update_kms_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_encrypt_volumes_rest_bad_request(request_type=kms.EncryptVolumesRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/kmsConfigs/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.encrypt_volumes(request) - - -@pytest.mark.parametrize("request_type", [ - kms.EncryptVolumesRequest, - dict, -]) -def test_encrypt_volumes_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/kmsConfigs/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.encrypt_volumes(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_encrypt_volumes_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_encrypt_volumes") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_encrypt_volumes_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_encrypt_volumes") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = kms.EncryptVolumesRequest.pb(kms.EncryptVolumesRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = kms.EncryptVolumesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.encrypt_volumes(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_verify_kms_config_rest_bad_request(request_type=kms.VerifyKmsConfigRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/kmsConfigs/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.verify_kms_config(request) - - -@pytest.mark.parametrize("request_type", [ - kms.VerifyKmsConfigRequest, - dict, -]) -def test_verify_kms_config_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/kmsConfigs/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 = kms.VerifyKmsConfigResponse( - healthy=True, - health_error='health_error_value', - instructions='instructions_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 = kms.VerifyKmsConfigResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.verify_kms_config(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, kms.VerifyKmsConfigResponse) - assert response.healthy is True - assert response.health_error == 'health_error_value' - assert response.instructions == 'instructions_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_verify_kms_config_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_verify_kms_config") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_verify_kms_config_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_verify_kms_config") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = kms.VerifyKmsConfigRequest.pb(kms.VerifyKmsConfigRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = kms.VerifyKmsConfigResponse.to_json(kms.VerifyKmsConfigResponse()) - req.return_value.content = return_value - - request = kms.VerifyKmsConfigRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = kms.VerifyKmsConfigResponse() - post_with_metadata.return_value = kms.VerifyKmsConfigResponse(), metadata - - client.verify_kms_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_delete_kms_config_rest_bad_request(request_type=kms.DeleteKmsConfigRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/kmsConfigs/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_kms_config(request) - - -@pytest.mark.parametrize("request_type", [ - kms.DeleteKmsConfigRequest, - dict, -]) -def test_delete_kms_config_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/kmsConfigs/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_kms_config(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_kms_config_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_delete_kms_config") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_delete_kms_config_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_delete_kms_config") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = kms.DeleteKmsConfigRequest.pb(kms.DeleteKmsConfigRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = kms.DeleteKmsConfigRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.delete_kms_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_list_replications_rest_bad_request(request_type=replication.ListReplicationsRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/volumes/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_replications(request) - - -@pytest.mark.parametrize("request_type", [ - replication.ListReplicationsRequest, - dict, -]) -def test_list_replications_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/volumes/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 = replication.ListReplicationsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_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 = replication.ListReplicationsResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_replications(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListReplicationsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_replications_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_list_replications") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_list_replications_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_list_replications") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = replication.ListReplicationsRequest.pb(replication.ListReplicationsRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = replication.ListReplicationsResponse.to_json(replication.ListReplicationsResponse()) - req.return_value.content = return_value - - request = replication.ListReplicationsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = replication.ListReplicationsResponse() - post_with_metadata.return_value = replication.ListReplicationsResponse(), metadata - - client.list_replications(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_get_replication_rest_bad_request(request_type=replication.GetReplicationRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_replication(request) - - -@pytest.mark.parametrize("request_type", [ - replication.GetReplicationRequest, - dict, -]) -def test_get_replication_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 = replication.Replication( - name='name_value', - state=replication.Replication.State.CREATING, - state_details='state_details_value', - role=replication.Replication.ReplicationRole.SOURCE, - replication_schedule=replication.Replication.ReplicationSchedule.EVERY_10_MINUTES, - mirror_state=replication.Replication.MirrorState.PREPARING, - healthy=True, - destination_volume='destination_volume_value', - description='description_value', - source_volume='source_volume_value', - cluster_location='cluster_location_value', - hybrid_replication_type=replication.Replication.HybridReplicationType.MIGRATION, - ) - - # 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 = replication.Replication.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_replication(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, replication.Replication) - assert response.name == 'name_value' - assert response.state == replication.Replication.State.CREATING - assert response.state_details == 'state_details_value' - assert response.role == replication.Replication.ReplicationRole.SOURCE - assert response.replication_schedule == replication.Replication.ReplicationSchedule.EVERY_10_MINUTES - assert response.mirror_state == replication.Replication.MirrorState.PREPARING - assert response.healthy is True - assert response.destination_volume == 'destination_volume_value' - assert response.description == 'description_value' - assert response.source_volume == 'source_volume_value' - assert response.cluster_location == 'cluster_location_value' - assert response.hybrid_replication_type == replication.Replication.HybridReplicationType.MIGRATION - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_replication_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_get_replication") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_get_replication_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_get_replication") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = replication.GetReplicationRequest.pb(replication.GetReplicationRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = replication.Replication.to_json(replication.Replication()) - req.return_value.content = return_value - - request = replication.GetReplicationRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = replication.Replication() - post_with_metadata.return_value = replication.Replication(), metadata - - client.get_replication(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_create_replication_rest_bad_request(request_type=gcn_replication.CreateReplicationRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/volumes/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_replication(request) - - -@pytest.mark.parametrize("request_type", [ - gcn_replication.CreateReplicationRequest, - dict, -]) -def test_create_replication_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/volumes/sample3'} - request_init["replication"] = {'name': 'name_value', 'state': 1, 'state_details': 'state_details_value', 'role': 1, 'replication_schedule': 1, 'mirror_state': 1, 'healthy': True, 'create_time': {'seconds': 751, 'nanos': 543}, 'destination_volume': 'destination_volume_value', 'transfer_stats': {'transfer_bytes': 1515, 'total_transfer_duration': {'seconds': 751, 'nanos': 543}, 'last_transfer_bytes': 2046, 'last_transfer_duration': {}, 'lag_duration': {}, 'update_time': {}, 'last_transfer_end_time': {}, 'last_transfer_error': 'last_transfer_error_value'}, 'labels': {}, 'description': 'description_value', 'destination_volume_parameters': {'storage_pool': 'storage_pool_value', 'volume_id': 'volume_id_value', 'share_name': 'share_name_value', 'description': 'description_value', 'tiering_policy': {'tier_action': 1, 'cooling_threshold_days': 2343}}, 'source_volume': 'source_volume_value', 'hybrid_peering_details': {'subnet_ip': 'subnet_ip_value', 'command': 'command_value', 'command_expiry_time': {}, 'passphrase': 'passphrase_value', 'peer_volume_name': 'peer_volume_name_value', 'peer_cluster_name': 'peer_cluster_name_value', 'peer_svm_name': 'peer_svm_name_value'}, 'cluster_location': 'cluster_location_value', 'hybrid_replication_type': 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 = gcn_replication.CreateReplicationRequest.meta.fields["replication"] - - 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["replication"].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["replication"][field])): - del request_init["replication"][field][i][subfield] - else: - del request_init["replication"][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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_replication(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_replication_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_create_replication") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_create_replication_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_create_replication") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = gcn_replication.CreateReplicationRequest.pb(gcn_replication.CreateReplicationRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = gcn_replication.CreateReplicationRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.create_replication(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_delete_replication_rest_bad_request(request_type=replication.DeleteReplicationRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_replication(request) - - -@pytest.mark.parametrize("request_type", [ - replication.DeleteReplicationRequest, - dict, -]) -def test_delete_replication_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_replication(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_replication_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_delete_replication") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_delete_replication_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_delete_replication") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = replication.DeleteReplicationRequest.pb(replication.DeleteReplicationRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = replication.DeleteReplicationRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.delete_replication(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_update_replication_rest_bad_request(request_type=gcn_replication.UpdateReplicationRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'replication': {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.update_replication(request) - - -@pytest.mark.parametrize("request_type", [ - gcn_replication.UpdateReplicationRequest, - dict, -]) -def test_update_replication_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'replication': {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/sample4'}} - request_init["replication"] = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/sample4', 'state': 1, 'state_details': 'state_details_value', 'role': 1, 'replication_schedule': 1, 'mirror_state': 1, 'healthy': True, 'create_time': {'seconds': 751, 'nanos': 543}, 'destination_volume': 'destination_volume_value', 'transfer_stats': {'transfer_bytes': 1515, 'total_transfer_duration': {'seconds': 751, 'nanos': 543}, 'last_transfer_bytes': 2046, 'last_transfer_duration': {}, 'lag_duration': {}, 'update_time': {}, 'last_transfer_end_time': {}, 'last_transfer_error': 'last_transfer_error_value'}, 'labels': {}, 'description': 'description_value', 'destination_volume_parameters': {'storage_pool': 'storage_pool_value', 'volume_id': 'volume_id_value', 'share_name': 'share_name_value', 'description': 'description_value', 'tiering_policy': {'tier_action': 1, 'cooling_threshold_days': 2343}}, 'source_volume': 'source_volume_value', 'hybrid_peering_details': {'subnet_ip': 'subnet_ip_value', 'command': 'command_value', 'command_expiry_time': {}, 'passphrase': 'passphrase_value', 'peer_volume_name': 'peer_volume_name_value', 'peer_cluster_name': 'peer_cluster_name_value', 'peer_svm_name': 'peer_svm_name_value'}, 'cluster_location': 'cluster_location_value', 'hybrid_replication_type': 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 = gcn_replication.UpdateReplicationRequest.meta.fields["replication"] - - 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["replication"].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["replication"][field])): - del request_init["replication"][field][i][subfield] - else: - del request_init["replication"][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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.update_replication(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_update_replication_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_update_replication") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_update_replication_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_update_replication") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = gcn_replication.UpdateReplicationRequest.pb(gcn_replication.UpdateReplicationRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = gcn_replication.UpdateReplicationRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.update_replication(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_stop_replication_rest_bad_request(request_type=replication.StopReplicationRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.stop_replication(request) - - -@pytest.mark.parametrize("request_type", [ - replication.StopReplicationRequest, - dict, -]) -def test_stop_replication_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.stop_replication(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_stop_replication_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_stop_replication") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_stop_replication_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_stop_replication") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = replication.StopReplicationRequest.pb(replication.StopReplicationRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = replication.StopReplicationRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.stop_replication(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_resume_replication_rest_bad_request(request_type=replication.ResumeReplicationRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.resume_replication(request) - - -@pytest.mark.parametrize("request_type", [ - replication.ResumeReplicationRequest, - dict, -]) -def test_resume_replication_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.resume_replication(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_resume_replication_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_resume_replication") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_resume_replication_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_resume_replication") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = replication.ResumeReplicationRequest.pb(replication.ResumeReplicationRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = replication.ResumeReplicationRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.resume_replication(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_reverse_replication_direction_rest_bad_request(request_type=replication.ReverseReplicationDirectionRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.reverse_replication_direction(request) - - -@pytest.mark.parametrize("request_type", [ - replication.ReverseReplicationDirectionRequest, - dict, -]) -def test_reverse_replication_direction_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.reverse_replication_direction(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_reverse_replication_direction_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_reverse_replication_direction") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_reverse_replication_direction_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_reverse_replication_direction") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = replication.ReverseReplicationDirectionRequest.pb(replication.ReverseReplicationDirectionRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = replication.ReverseReplicationDirectionRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.reverse_replication_direction(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_establish_peering_rest_bad_request(request_type=replication.EstablishPeeringRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.establish_peering(request) - - -@pytest.mark.parametrize("request_type", [ - replication.EstablishPeeringRequest, - dict, -]) -def test_establish_peering_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.establish_peering(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_establish_peering_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_establish_peering") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_establish_peering_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_establish_peering") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = replication.EstablishPeeringRequest.pb(replication.EstablishPeeringRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = replication.EstablishPeeringRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.establish_peering(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_sync_replication_rest_bad_request(request_type=replication.SyncReplicationRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.sync_replication(request) - - -@pytest.mark.parametrize("request_type", [ - replication.SyncReplicationRequest, - dict, -]) -def test_sync_replication_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/replications/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.sync_replication(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_sync_replication_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_sync_replication") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_sync_replication_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_sync_replication") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = replication.SyncReplicationRequest.pb(replication.SyncReplicationRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = replication.SyncReplicationRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.sync_replication(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_create_backup_vault_rest_bad_request(request_type=gcn_backup_vault.CreateBackupVaultRequest): - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_backup_vault(request) - - -@pytest.mark.parametrize("request_type", [ - gcn_backup_vault.CreateBackupVaultRequest, - dict, -]) -def test_create_backup_vault_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["backup_vault"] = {'name': 'name_value', 'state': 1, 'create_time': {'seconds': 751, 'nanos': 543}, 'description': 'description_value', 'labels': {}} - # 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 = gcn_backup_vault.CreateBackupVaultRequest.meta.fields["backup_vault"] - - 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["backup_vault"].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["backup_vault"][field])): - del request_init["backup_vault"][field][i][subfield] - else: - del request_init["backup_vault"][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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_backup_vault(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_backup_vault_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_create_backup_vault") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_create_backup_vault_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_create_backup_vault") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = gcn_backup_vault.CreateBackupVaultRequest.pb(gcn_backup_vault.CreateBackupVaultRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = gcn_backup_vault.CreateBackupVaultRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.create_backup_vault(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_get_backup_vault_rest_bad_request(request_type=backup_vault.GetBackupVaultRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/backupVaults/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_backup_vault(request) - - -@pytest.mark.parametrize("request_type", [ - backup_vault.GetBackupVaultRequest, - dict, -]) -def test_get_backup_vault_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/backupVaults/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 = backup_vault.BackupVault( - name='name_value', - state=backup_vault.BackupVault.State.CREATING, - 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 = backup_vault.BackupVault.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_backup_vault(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, backup_vault.BackupVault) - assert response.name == 'name_value' - assert response.state == backup_vault.BackupVault.State.CREATING - assert response.description == 'description_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_backup_vault_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_get_backup_vault") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_get_backup_vault_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_get_backup_vault") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = backup_vault.GetBackupVaultRequest.pb(backup_vault.GetBackupVaultRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = backup_vault.BackupVault.to_json(backup_vault.BackupVault()) - req.return_value.content = return_value - - request = backup_vault.GetBackupVaultRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = backup_vault.BackupVault() - post_with_metadata.return_value = backup_vault.BackupVault(), metadata - - client.get_backup_vault(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_list_backup_vaults_rest_bad_request(request_type=backup_vault.ListBackupVaultsRequest): - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_backup_vaults(request) - - -@pytest.mark.parametrize("request_type", [ - backup_vault.ListBackupVaultsRequest, - dict, -]) -def test_list_backup_vaults_rest_call_success(request_type): - client = NetAppClient( - 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 = backup_vault.ListBackupVaultsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_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 = backup_vault.ListBackupVaultsResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_backup_vaults(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListBackupVaultsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_backup_vaults_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_list_backup_vaults") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_list_backup_vaults_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_list_backup_vaults") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = backup_vault.ListBackupVaultsRequest.pb(backup_vault.ListBackupVaultsRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = backup_vault.ListBackupVaultsResponse.to_json(backup_vault.ListBackupVaultsResponse()) - req.return_value.content = return_value - - request = backup_vault.ListBackupVaultsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = backup_vault.ListBackupVaultsResponse() - post_with_metadata.return_value = backup_vault.ListBackupVaultsResponse(), metadata - - client.list_backup_vaults(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_update_backup_vault_rest_bad_request(request_type=gcn_backup_vault.UpdateBackupVaultRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'backup_vault': {'name': 'projects/sample1/locations/sample2/backupVaults/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.update_backup_vault(request) - - -@pytest.mark.parametrize("request_type", [ - gcn_backup_vault.UpdateBackupVaultRequest, - dict, -]) -def test_update_backup_vault_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'backup_vault': {'name': 'projects/sample1/locations/sample2/backupVaults/sample3'}} - request_init["backup_vault"] = {'name': 'projects/sample1/locations/sample2/backupVaults/sample3', 'state': 1, 'create_time': {'seconds': 751, 'nanos': 543}, 'description': 'description_value', 'labels': {}} - # 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 = gcn_backup_vault.UpdateBackupVaultRequest.meta.fields["backup_vault"] - - 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["backup_vault"].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["backup_vault"][field])): - del request_init["backup_vault"][field][i][subfield] - else: - del request_init["backup_vault"][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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.update_backup_vault(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_update_backup_vault_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_update_backup_vault") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_update_backup_vault_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_update_backup_vault") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = gcn_backup_vault.UpdateBackupVaultRequest.pb(gcn_backup_vault.UpdateBackupVaultRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = gcn_backup_vault.UpdateBackupVaultRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.update_backup_vault(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_delete_backup_vault_rest_bad_request(request_type=backup_vault.DeleteBackupVaultRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/backupVaults/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_backup_vault(request) - - -@pytest.mark.parametrize("request_type", [ - backup_vault.DeleteBackupVaultRequest, - dict, -]) -def test_delete_backup_vault_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/backupVaults/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_backup_vault(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_backup_vault_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_delete_backup_vault") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_delete_backup_vault_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_delete_backup_vault") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = backup_vault.DeleteBackupVaultRequest.pb(backup_vault.DeleteBackupVaultRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = backup_vault.DeleteBackupVaultRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.delete_backup_vault(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_create_backup_rest_bad_request(request_type=gcn_backup.CreateBackupRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/backupVaults/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_backup(request) - - -@pytest.mark.parametrize("request_type", [ - gcn_backup.CreateBackupRequest, - dict, -]) -def test_create_backup_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/backupVaults/sample3'} - request_init["backup"] = {'name': 'name_value', 'state': 1, 'description': 'description_value', 'volume_usage_bytes': 1938, 'backup_type': 1, 'source_volume': 'source_volume_value', 'source_snapshot': 'source_snapshot_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'labels': {}, 'chain_storage_bytes': 2013, 'satisfies_pzs': 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 = gcn_backup.CreateBackupRequest.meta.fields["backup"] - - 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["backup"].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["backup"][field])): - del request_init["backup"][field][i][subfield] - else: - del request_init["backup"][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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_backup(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_backup_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_create_backup") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_create_backup_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_create_backup") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = gcn_backup.CreateBackupRequest.pb(gcn_backup.CreateBackupRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = gcn_backup.CreateBackupRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.create_backup(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_get_backup_rest_bad_request(request_type=backup.GetBackupRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/backupVaults/sample3/backups/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_backup(request) - - -@pytest.mark.parametrize("request_type", [ - backup.GetBackupRequest, - dict, -]) -def test_get_backup_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/backupVaults/sample3/backups/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 = backup.Backup( - name='name_value', - state=backup.Backup.State.CREATING, - description='description_value', - volume_usage_bytes=1938, - backup_type=backup.Backup.Type.MANUAL, - source_volume='source_volume_value', - source_snapshot='source_snapshot_value', - chain_storage_bytes=2013, - satisfies_pzs=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 = backup.Backup.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_backup(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, backup.Backup) - assert response.name == 'name_value' - assert response.state == backup.Backup.State.CREATING - assert response.description == 'description_value' - assert response.volume_usage_bytes == 1938 - assert response.backup_type == backup.Backup.Type.MANUAL - assert response.source_volume == 'source_volume_value' - assert response.source_snapshot == 'source_snapshot_value' - assert response.chain_storage_bytes == 2013 - assert response.satisfies_pzs is True - assert response.satisfies_pzi is True - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_backup_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_get_backup") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_get_backup_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_get_backup") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = backup.GetBackupRequest.pb(backup.GetBackupRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = backup.Backup.to_json(backup.Backup()) - req.return_value.content = return_value - - request = backup.GetBackupRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = backup.Backup() - post_with_metadata.return_value = backup.Backup(), metadata - - client.get_backup(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_list_backups_rest_bad_request(request_type=backup.ListBackupsRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/backupVaults/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_backups(request) - - -@pytest.mark.parametrize("request_type", [ - backup.ListBackupsRequest, - dict, -]) -def test_list_backups_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/backupVaults/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 = backup.ListBackupsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_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 = backup.ListBackupsResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_backups(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListBackupsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_backups_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_list_backups") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_list_backups_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_list_backups") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = backup.ListBackupsRequest.pb(backup.ListBackupsRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = backup.ListBackupsResponse.to_json(backup.ListBackupsResponse()) - req.return_value.content = return_value - - request = backup.ListBackupsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = backup.ListBackupsResponse() - post_with_metadata.return_value = backup.ListBackupsResponse(), metadata - - client.list_backups(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_delete_backup_rest_bad_request(request_type=backup.DeleteBackupRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/backupVaults/sample3/backups/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_backup(request) - - -@pytest.mark.parametrize("request_type", [ - backup.DeleteBackupRequest, - dict, -]) -def test_delete_backup_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/backupVaults/sample3/backups/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_backup(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_backup_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_delete_backup") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_delete_backup_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_delete_backup") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = backup.DeleteBackupRequest.pb(backup.DeleteBackupRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = backup.DeleteBackupRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.delete_backup(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_update_backup_rest_bad_request(request_type=gcn_backup.UpdateBackupRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'backup': {'name': 'projects/sample1/locations/sample2/backupVaults/sample3/backups/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.update_backup(request) - - -@pytest.mark.parametrize("request_type", [ - gcn_backup.UpdateBackupRequest, - dict, -]) -def test_update_backup_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'backup': {'name': 'projects/sample1/locations/sample2/backupVaults/sample3/backups/sample4'}} - request_init["backup"] = {'name': 'projects/sample1/locations/sample2/backupVaults/sample3/backups/sample4', 'state': 1, 'description': 'description_value', 'volume_usage_bytes': 1938, 'backup_type': 1, 'source_volume': 'source_volume_value', 'source_snapshot': 'source_snapshot_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'labels': {}, 'chain_storage_bytes': 2013, 'satisfies_pzs': 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 = gcn_backup.UpdateBackupRequest.meta.fields["backup"] - - 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["backup"].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["backup"][field])): - del request_init["backup"][field][i][subfield] - else: - del request_init["backup"][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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.update_backup(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_update_backup_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_update_backup") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_update_backup_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_update_backup") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = gcn_backup.UpdateBackupRequest.pb(gcn_backup.UpdateBackupRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = gcn_backup.UpdateBackupRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.update_backup(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_create_backup_policy_rest_bad_request(request_type=gcn_backup_policy.CreateBackupPolicyRequest): - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_backup_policy(request) - - -@pytest.mark.parametrize("request_type", [ - gcn_backup_policy.CreateBackupPolicyRequest, - dict, -]) -def test_create_backup_policy_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["backup_policy"] = {'name': 'name_value', 'daily_backup_limit': 1894, 'weekly_backup_limit': 2020, 'monthly_backup_limit': 2142, 'description': 'description_value', 'enabled': True, 'assigned_volume_count': 2253, 'create_time': {'seconds': 751, 'nanos': 543}, 'labels': {}, '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 = gcn_backup_policy.CreateBackupPolicyRequest.meta.fields["backup_policy"] - - 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["backup_policy"].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["backup_policy"][field])): - del request_init["backup_policy"][field][i][subfield] - else: - del request_init["backup_policy"][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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_backup_policy(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_backup_policy_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_create_backup_policy") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_create_backup_policy_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_create_backup_policy") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = gcn_backup_policy.CreateBackupPolicyRequest.pb(gcn_backup_policy.CreateBackupPolicyRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = gcn_backup_policy.CreateBackupPolicyRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.create_backup_policy(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_get_backup_policy_rest_bad_request(request_type=backup_policy.GetBackupPolicyRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/backupPolicies/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_backup_policy(request) - - -@pytest.mark.parametrize("request_type", [ - backup_policy.GetBackupPolicyRequest, - dict, -]) -def test_get_backup_policy_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/backupPolicies/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 = backup_policy.BackupPolicy( - name='name_value', - daily_backup_limit=1894, - weekly_backup_limit=2020, - monthly_backup_limit=2142, - description='description_value', - enabled=True, - assigned_volume_count=2253, - state=backup_policy.BackupPolicy.State.CREATING, - ) - - # 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 = backup_policy.BackupPolicy.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_backup_policy(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, backup_policy.BackupPolicy) - assert response.name == 'name_value' - assert response.daily_backup_limit == 1894 - assert response.weekly_backup_limit == 2020 - assert response.monthly_backup_limit == 2142 - assert response.description == 'description_value' - assert response.enabled is True - assert response.assigned_volume_count == 2253 - assert response.state == backup_policy.BackupPolicy.State.CREATING - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_backup_policy_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_get_backup_policy") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_get_backup_policy_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_get_backup_policy") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = backup_policy.GetBackupPolicyRequest.pb(backup_policy.GetBackupPolicyRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = backup_policy.BackupPolicy.to_json(backup_policy.BackupPolicy()) - req.return_value.content = return_value - - request = backup_policy.GetBackupPolicyRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = backup_policy.BackupPolicy() - post_with_metadata.return_value = backup_policy.BackupPolicy(), metadata - - client.get_backup_policy(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_list_backup_policies_rest_bad_request(request_type=backup_policy.ListBackupPoliciesRequest): - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_backup_policies(request) - - -@pytest.mark.parametrize("request_type", [ - backup_policy.ListBackupPoliciesRequest, - dict, -]) -def test_list_backup_policies_rest_call_success(request_type): - client = NetAppClient( - 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 = backup_policy.ListBackupPoliciesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_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 = backup_policy.ListBackupPoliciesResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_backup_policies(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListBackupPoliciesPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_backup_policies_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_list_backup_policies") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_list_backup_policies_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_list_backup_policies") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = backup_policy.ListBackupPoliciesRequest.pb(backup_policy.ListBackupPoliciesRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = backup_policy.ListBackupPoliciesResponse.to_json(backup_policy.ListBackupPoliciesResponse()) - req.return_value.content = return_value - - request = backup_policy.ListBackupPoliciesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = backup_policy.ListBackupPoliciesResponse() - post_with_metadata.return_value = backup_policy.ListBackupPoliciesResponse(), metadata - - client.list_backup_policies(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_update_backup_policy_rest_bad_request(request_type=gcn_backup_policy.UpdateBackupPolicyRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'backup_policy': {'name': 'projects/sample1/locations/sample2/backupPolicies/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.update_backup_policy(request) - - -@pytest.mark.parametrize("request_type", [ - gcn_backup_policy.UpdateBackupPolicyRequest, - dict, -]) -def test_update_backup_policy_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'backup_policy': {'name': 'projects/sample1/locations/sample2/backupPolicies/sample3'}} - request_init["backup_policy"] = {'name': 'projects/sample1/locations/sample2/backupPolicies/sample3', 'daily_backup_limit': 1894, 'weekly_backup_limit': 2020, 'monthly_backup_limit': 2142, 'description': 'description_value', 'enabled': True, 'assigned_volume_count': 2253, 'create_time': {'seconds': 751, 'nanos': 543}, 'labels': {}, '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 = gcn_backup_policy.UpdateBackupPolicyRequest.meta.fields["backup_policy"] - - 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["backup_policy"].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["backup_policy"][field])): - del request_init["backup_policy"][field][i][subfield] - else: - del request_init["backup_policy"][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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.update_backup_policy(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_update_backup_policy_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_update_backup_policy") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_update_backup_policy_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_update_backup_policy") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = gcn_backup_policy.UpdateBackupPolicyRequest.pb(gcn_backup_policy.UpdateBackupPolicyRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = gcn_backup_policy.UpdateBackupPolicyRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.update_backup_policy(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_delete_backup_policy_rest_bad_request(request_type=backup_policy.DeleteBackupPolicyRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/backupPolicies/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_backup_policy(request) - - -@pytest.mark.parametrize("request_type", [ - backup_policy.DeleteBackupPolicyRequest, - dict, -]) -def test_delete_backup_policy_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/backupPolicies/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_backup_policy(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_backup_policy_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_delete_backup_policy") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_delete_backup_policy_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_delete_backup_policy") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = backup_policy.DeleteBackupPolicyRequest.pb(backup_policy.DeleteBackupPolicyRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = backup_policy.DeleteBackupPolicyRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.delete_backup_policy(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_list_quota_rules_rest_bad_request(request_type=quota_rule.ListQuotaRulesRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/volumes/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_quota_rules(request) - - -@pytest.mark.parametrize("request_type", [ - quota_rule.ListQuotaRulesRequest, - dict, -]) -def test_list_quota_rules_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/volumes/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 = quota_rule.ListQuotaRulesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_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 = quota_rule.ListQuotaRulesResponse.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_quota_rules(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListQuotaRulesPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_quota_rules_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_list_quota_rules") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_list_quota_rules_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_list_quota_rules") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = quota_rule.ListQuotaRulesRequest.pb(quota_rule.ListQuotaRulesRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = quota_rule.ListQuotaRulesResponse.to_json(quota_rule.ListQuotaRulesResponse()) - req.return_value.content = return_value - - request = quota_rule.ListQuotaRulesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = quota_rule.ListQuotaRulesResponse() - post_with_metadata.return_value = quota_rule.ListQuotaRulesResponse(), metadata - - client.list_quota_rules(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_get_quota_rule_rest_bad_request(request_type=quota_rule.GetQuotaRuleRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/quotaRules/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_quota_rule(request) - - -@pytest.mark.parametrize("request_type", [ - quota_rule.GetQuotaRuleRequest, - dict, -]) -def test_get_quota_rule_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/quotaRules/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 = quota_rule.QuotaRule( - name='name_value', - target='target_value', - type_=quota_rule.QuotaRule.Type.INDIVIDUAL_USER_QUOTA, - disk_limit_mib=1472, - state=quota_rule.QuotaRule.State.CREATING, - state_details='state_details_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 = quota_rule.QuotaRule.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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_quota_rule(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, quota_rule.QuotaRule) - assert response.name == 'name_value' - assert response.target == 'target_value' - assert response.type_ == quota_rule.QuotaRule.Type.INDIVIDUAL_USER_QUOTA - assert response.disk_limit_mib == 1472 - assert response.state == quota_rule.QuotaRule.State.CREATING - assert response.state_details == 'state_details_value' - assert response.description == 'description_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_quota_rule_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_get_quota_rule") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_get_quota_rule_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_get_quota_rule") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = quota_rule.GetQuotaRuleRequest.pb(quota_rule.GetQuotaRuleRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = quota_rule.QuotaRule.to_json(quota_rule.QuotaRule()) - req.return_value.content = return_value - - request = quota_rule.GetQuotaRuleRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = quota_rule.QuotaRule() - post_with_metadata.return_value = quota_rule.QuotaRule(), metadata - - client.get_quota_rule(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_create_quota_rule_rest_bad_request(request_type=gcn_quota_rule.CreateQuotaRuleRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/volumes/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_quota_rule(request) - - -@pytest.mark.parametrize("request_type", [ - gcn_quota_rule.CreateQuotaRuleRequest, - dict, -]) -def test_create_quota_rule_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/volumes/sample3'} - request_init["quota_rule"] = {'name': 'name_value', 'target': 'target_value', 'type_': 1, 'disk_limit_mib': 1472, 'state': 1, 'state_details': 'state_details_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'description': 'description_value', 'labels': {}} - # 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 = gcn_quota_rule.CreateQuotaRuleRequest.meta.fields["quota_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["quota_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["quota_rule"][field])): - del request_init["quota_rule"][field][i][subfield] - else: - del request_init["quota_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') - - # 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_quota_rule(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_quota_rule_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_create_quota_rule") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_create_quota_rule_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_create_quota_rule") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = gcn_quota_rule.CreateQuotaRuleRequest.pb(gcn_quota_rule.CreateQuotaRuleRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = gcn_quota_rule.CreateQuotaRuleRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.create_quota_rule(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_update_quota_rule_rest_bad_request(request_type=gcn_quota_rule.UpdateQuotaRuleRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'quota_rule': {'name': 'projects/sample1/locations/sample2/volumes/sample3/quotaRules/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.update_quota_rule(request) - - -@pytest.mark.parametrize("request_type", [ - gcn_quota_rule.UpdateQuotaRuleRequest, - dict, -]) -def test_update_quota_rule_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'quota_rule': {'name': 'projects/sample1/locations/sample2/volumes/sample3/quotaRules/sample4'}} - request_init["quota_rule"] = {'name': 'projects/sample1/locations/sample2/volumes/sample3/quotaRules/sample4', 'target': 'target_value', 'type_': 1, 'disk_limit_mib': 1472, 'state': 1, 'state_details': 'state_details_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'description': 'description_value', 'labels': {}} - # 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 = gcn_quota_rule.UpdateQuotaRuleRequest.meta.fields["quota_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["quota_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["quota_rule"][field])): - del request_init["quota_rule"][field][i][subfield] - else: - del request_init["quota_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') - - # 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.update_quota_rule(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_update_quota_rule_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_update_quota_rule") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_update_quota_rule_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_update_quota_rule") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = gcn_quota_rule.UpdateQuotaRuleRequest.pb(gcn_quota_rule.UpdateQuotaRuleRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = gcn_quota_rule.UpdateQuotaRuleRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.update_quota_rule(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_delete_quota_rule_rest_bad_request(request_type=quota_rule.DeleteQuotaRuleRequest): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/quotaRules/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_quota_rule(request) - - -@pytest.mark.parametrize("request_type", [ - quota_rule.DeleteQuotaRuleRequest, - dict, -]) -def test_delete_quota_rule_rest_call_success(request_type): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/volumes/sample3/quotaRules/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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_quota_rule(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_quota_rule_rest_interceptors(null_interceptor): - transport = transports.NetAppRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.NetAppRestInterceptor(), - ) - client = NetAppClient(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.NetAppRestInterceptor, "post_delete_quota_rule") as post, \ - mock.patch.object(transports.NetAppRestInterceptor, "post_delete_quota_rule_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.NetAppRestInterceptor, "pre_delete_quota_rule") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = quota_rule.DeleteQuotaRuleRequest.pb(quota_rule.DeleteQuotaRuleRequest()) - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = quota_rule.DeleteQuotaRuleRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.delete_quota_rule(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationRequest): - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_location(request) - - -@pytest.mark.parametrize("request_type", [ - locations_pb2.GetLocationRequest, - dict, -]) -def test_get_location_rest(request_type): - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - 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 = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_locations(request) - - -@pytest.mark.parametrize("request_type", [ - locations_pb2.ListLocationsRequest, - dict, -]) -def test_list_locations_rest(request_type): - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_locations(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, locations_pb2.ListLocationsResponse) - - -def test_cancel_operation_rest_bad_request(request_type=operations_pb2.CancelOperationRequest): - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.cancel_operation(request) - - -@pytest.mark.parametrize("request_type", [ - operations_pb2.CancelOperationRequest, - dict, -]) -def test_cancel_operation_rest(request_type): - client = NetAppClient( - 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 = 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.cancel_operation(request) - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_operation_rest_bad_request(request_type=operations_pb2.DeleteOperationRequest): - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_operation(request) - - -@pytest.mark.parametrize("request_type", [ - operations_pb2.DeleteOperationRequest, - dict, -]) -def test_delete_operation_rest(request_type): - client = NetAppClient( - 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 = 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.delete_operation(request) - - # Establish that the response is the type that we expect. - assert response is None - - -def test_get_operation_rest_bad_request(request_type=operations_pb2.GetOperationRequest): - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_operation(request) - - -@pytest.mark.parametrize("request_type", [ - operations_pb2.GetOperationRequest, - dict, -]) -def test_get_operation_rest(request_type): - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_operation(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, operations_pb2.Operation) - - -def test_list_operations_rest_bad_request(request_type=operations_pb2.ListOperationsRequest): - client = NetAppClient( - 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_operations(request) - - -@pytest.mark.parametrize("request_type", [ - operations_pb2.ListOperationsRequest, - dict, -]) -def test_list_operations_rest(request_type): - client = NetAppClient( - 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 = operations_pb2.ListOperationsResponse() - - # 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 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_operations(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, operations_pb2.ListOperationsResponse) - -def test_initialize_client_w_rest(): - client = NetAppClient( - 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_storage_pools_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_storage_pools), - '__call__') as call: - client.list_storage_pools(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = storage_pool.ListStoragePoolsRequest() - - assert args[0] == request_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_storage_pool_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_storage_pool), - '__call__') as call: - client.create_storage_pool(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_storage_pool.CreateStoragePoolRequest() - - assert args[0] == request_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_storage_pool_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_storage_pool), - '__call__') as call: - client.get_storage_pool(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = storage_pool.GetStoragePoolRequest() - - assert args[0] == request_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_storage_pool_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_storage_pool), - '__call__') as call: - client.update_storage_pool(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_storage_pool.UpdateStoragePoolRequest() - - assert args[0] == request_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_storage_pool_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_storage_pool), - '__call__') as call: - client.delete_storage_pool(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = storage_pool.DeleteStoragePoolRequest() - - assert args[0] == request_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_validate_directory_service_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.validate_directory_service), - '__call__') as call: - client.validate_directory_service(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = storage_pool.ValidateDirectoryServiceRequest() - - assert args[0] == request_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_switch_active_replica_zone_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.switch_active_replica_zone), - '__call__') as call: - client.switch_active_replica_zone(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = storage_pool.SwitchActiveReplicaZoneRequest() - - assert args[0] == request_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_volumes_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_volumes), - '__call__') as call: - client.list_volumes(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = volume.ListVolumesRequest() - - assert args[0] == request_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_volume_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_volume), - '__call__') as call: - client.get_volume(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = volume.GetVolumeRequest() - - assert args[0] == request_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_volume_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_volume), - '__call__') as call: - client.create_volume(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_volume.CreateVolumeRequest() - - assert args[0] == request_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_volume_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_volume), - '__call__') as call: - client.update_volume(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_volume.UpdateVolumeRequest() - - assert args[0] == request_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_volume_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_volume), - '__call__') as call: - client.delete_volume(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = volume.DeleteVolumeRequest() - - assert args[0] == request_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_revert_volume_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.revert_volume), - '__call__') as call: - client.revert_volume(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = volume.RevertVolumeRequest() - - assert args[0] == request_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_snapshots_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_snapshots), - '__call__') as call: - client.list_snapshots(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = snapshot.ListSnapshotsRequest() - - assert args[0] == request_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_snapshot_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_snapshot), - '__call__') as call: - client.get_snapshot(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = snapshot.GetSnapshotRequest() - - assert args[0] == request_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_snapshot_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_snapshot), - '__call__') as call: - client.create_snapshot(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_snapshot.CreateSnapshotRequest() - - assert args[0] == request_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_snapshot_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_snapshot), - '__call__') as call: - client.delete_snapshot(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = snapshot.DeleteSnapshotRequest() - - assert args[0] == request_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_snapshot_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_snapshot), - '__call__') as call: - client.update_snapshot(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_snapshot.UpdateSnapshotRequest() - - assert args[0] == request_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_active_directories_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_active_directories), - '__call__') as call: - client.list_active_directories(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = active_directory.ListActiveDirectoriesRequest() - - assert args[0] == request_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_active_directory_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_active_directory), - '__call__') as call: - client.get_active_directory(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = active_directory.GetActiveDirectoryRequest() - - assert args[0] == request_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_active_directory_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_active_directory), - '__call__') as call: - client.create_active_directory(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_active_directory.CreateActiveDirectoryRequest() - - assert args[0] == request_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_active_directory_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_active_directory), - '__call__') as call: - client.update_active_directory(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_active_directory.UpdateActiveDirectoryRequest() - - assert args[0] == request_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_active_directory_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_active_directory), - '__call__') as call: - client.delete_active_directory(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = active_directory.DeleteActiveDirectoryRequest() - - assert args[0] == request_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_kms_configs_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_kms_configs), - '__call__') as call: - client.list_kms_configs(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = kms.ListKmsConfigsRequest() - - assert args[0] == request_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_kms_config_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_kms_config), - '__call__') as call: - client.create_kms_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = kms.CreateKmsConfigRequest() - - assert args[0] == request_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_kms_config_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_kms_config), - '__call__') as call: - client.get_kms_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = kms.GetKmsConfigRequest() - - assert args[0] == request_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_kms_config_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_kms_config), - '__call__') as call: - client.update_kms_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = kms.UpdateKmsConfigRequest() - - assert args[0] == request_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_encrypt_volumes_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.encrypt_volumes), - '__call__') as call: - client.encrypt_volumes(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = kms.EncryptVolumesRequest() - - assert args[0] == request_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_verify_kms_config_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.verify_kms_config), - '__call__') as call: - client.verify_kms_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = kms.VerifyKmsConfigRequest() - - assert args[0] == request_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_kms_config_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_kms_config), - '__call__') as call: - client.delete_kms_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = kms.DeleteKmsConfigRequest() - - assert args[0] == request_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_replications_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_replications), - '__call__') as call: - client.list_replications(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.ListReplicationsRequest() - - assert args[0] == request_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_replication_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_replication), - '__call__') as call: - client.get_replication(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.GetReplicationRequest() - - assert args[0] == request_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_replication_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_replication), - '__call__') as call: - client.create_replication(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_replication.CreateReplicationRequest() - - assert args[0] == request_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_replication_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_replication), - '__call__') as call: - client.delete_replication(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.DeleteReplicationRequest() - - assert args[0] == request_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_replication_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_replication), - '__call__') as call: - client.update_replication(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_replication.UpdateReplicationRequest() - - assert args[0] == request_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_stop_replication_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.stop_replication), - '__call__') as call: - client.stop_replication(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.StopReplicationRequest() - - assert args[0] == request_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_resume_replication_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.resume_replication), - '__call__') as call: - client.resume_replication(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.ResumeReplicationRequest() - - assert args[0] == request_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_reverse_replication_direction_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.reverse_replication_direction), - '__call__') as call: - client.reverse_replication_direction(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.ReverseReplicationDirectionRequest() - - assert args[0] == request_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_establish_peering_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.establish_peering), - '__call__') as call: - client.establish_peering(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.EstablishPeeringRequest() - - assert args[0] == request_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_sync_replication_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.sync_replication), - '__call__') as call: - client.sync_replication(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = replication.SyncReplicationRequest() - - assert args[0] == request_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_backup_vault_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_backup_vault), - '__call__') as call: - client.create_backup_vault(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_backup_vault.CreateBackupVaultRequest() - - assert args[0] == request_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_backup_vault_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_backup_vault), - '__call__') as call: - client.get_backup_vault(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup_vault.GetBackupVaultRequest() - - assert args[0] == request_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_backup_vaults_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_backup_vaults), - '__call__') as call: - client.list_backup_vaults(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup_vault.ListBackupVaultsRequest() - - assert args[0] == request_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_backup_vault_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_backup_vault), - '__call__') as call: - client.update_backup_vault(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_backup_vault.UpdateBackupVaultRequest() - - assert args[0] == request_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_backup_vault_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup_vault), - '__call__') as call: - client.delete_backup_vault(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup_vault.DeleteBackupVaultRequest() - - assert args[0] == request_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_backup_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_backup), - '__call__') as call: - client.create_backup(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_backup.CreateBackupRequest() - - assert args[0] == request_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_backup_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_backup), - '__call__') as call: - client.get_backup(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup.GetBackupRequest() - - assert args[0] == request_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_backups_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_backups), - '__call__') as call: - client.list_backups(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup.ListBackupsRequest() - - assert args[0] == request_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_backup_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup), - '__call__') as call: - client.delete_backup(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup.DeleteBackupRequest() - - assert args[0] == request_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_backup_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_backup), - '__call__') as call: - client.update_backup(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_backup.UpdateBackupRequest() - - assert args[0] == request_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_backup_policy_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_backup_policy), - '__call__') as call: - client.create_backup_policy(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_backup_policy.CreateBackupPolicyRequest() - - assert args[0] == request_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_backup_policy_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_backup_policy), - '__call__') as call: - client.get_backup_policy(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup_policy.GetBackupPolicyRequest() - - assert args[0] == request_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_backup_policies_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_backup_policies), - '__call__') as call: - client.list_backup_policies(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup_policy.ListBackupPoliciesRequest() - - assert args[0] == request_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_backup_policy_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_backup_policy), - '__call__') as call: - client.update_backup_policy(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_backup_policy.UpdateBackupPolicyRequest() - - assert args[0] == request_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_backup_policy_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_backup_policy), - '__call__') as call: - client.delete_backup_policy(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = backup_policy.DeleteBackupPolicyRequest() - - assert args[0] == request_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_quota_rules_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_quota_rules), - '__call__') as call: - client.list_quota_rules(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = quota_rule.ListQuotaRulesRequest() - - assert args[0] == request_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_quota_rule_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_quota_rule), - '__call__') as call: - client.get_quota_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = quota_rule.GetQuotaRuleRequest() - - assert args[0] == request_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_quota_rule_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_quota_rule), - '__call__') as call: - client.create_quota_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_quota_rule.CreateQuotaRuleRequest() - - assert args[0] == request_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_quota_rule_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_quota_rule), - '__call__') as call: - client.update_quota_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gcn_quota_rule.UpdateQuotaRuleRequest() - - assert args[0] == request_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_quota_rule_empty_call_rest(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_quota_rule), - '__call__') as call: - client.delete_quota_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = quota_rule.DeleteQuotaRuleRequest() - - assert args[0] == request_msg - - -def test_net_app_rest_lro_client(): - client = NetAppClient( - 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 = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.NetAppGrpcTransport, - ) - -def test_net_app_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.NetAppTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_net_app_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.netapp_v1.services.net_app.transports.NetAppTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.NetAppTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'list_storage_pools', - 'create_storage_pool', - 'get_storage_pool', - 'update_storage_pool', - 'delete_storage_pool', - 'validate_directory_service', - 'switch_active_replica_zone', - 'list_volumes', - 'get_volume', - 'create_volume', - 'update_volume', - 'delete_volume', - 'revert_volume', - 'list_snapshots', - 'get_snapshot', - 'create_snapshot', - 'delete_snapshot', - 'update_snapshot', - 'list_active_directories', - 'get_active_directory', - 'create_active_directory', - 'update_active_directory', - 'delete_active_directory', - 'list_kms_configs', - 'create_kms_config', - 'get_kms_config', - 'update_kms_config', - 'encrypt_volumes', - 'verify_kms_config', - 'delete_kms_config', - 'list_replications', - 'get_replication', - 'create_replication', - 'delete_replication', - 'update_replication', - 'stop_replication', - 'resume_replication', - 'reverse_replication_direction', - 'establish_peering', - 'sync_replication', - 'create_backup_vault', - 'get_backup_vault', - 'list_backup_vaults', - 'update_backup_vault', - 'delete_backup_vault', - 'create_backup', - 'get_backup', - 'list_backups', - 'delete_backup', - 'update_backup', - 'create_backup_policy', - 'get_backup_policy', - 'list_backup_policies', - 'update_backup_policy', - 'delete_backup_policy', - 'list_quota_rules', - 'get_quota_rule', - 'create_quota_rule', - 'update_quota_rule', - 'delete_quota_rule', - 'get_location', - 'list_locations', - 'get_operation', - 'cancel_operation', - 'delete_operation', - 'list_operations', - ) - 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_net_app_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.netapp_v1.services.net_app.transports.NetAppTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.NetAppTransport( - 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', -), - quota_project_id="octopus", - ) - - -def test_net_app_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.netapp_v1.services.net_app.transports.NetAppTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.NetAppTransport() - adc.assert_called_once() - - -def test_net_app_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) - NetAppClient() - adc.assert_called_once_with( - scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - quota_project_id=None, - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.NetAppGrpcTransport, - transports.NetAppGrpcAsyncIOTransport, - ], -) -def test_net_app_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',), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.NetAppGrpcTransport, - transports.NetAppGrpcAsyncIOTransport, - transports.NetAppRestTransport, - ], -) -def test_net_app_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.NetAppGrpcTransport, grpc_helpers), - (transports.NetAppGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -def test_net_app_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( - "netapp.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - scopes=["1", "2"], - default_host="netapp.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize("transport_class", [transports.NetAppGrpcTransport, transports.NetAppGrpcAsyncIOTransport]) -def test_net_app_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_net_app_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.NetAppRestTransport ( - 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_net_app_host_no_port(transport_name): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='netapp.googleapis.com'), - transport=transport_name, - ) - assert client.transport._host == ( - 'netapp.googleapis.com:443' - if transport_name in ['grpc', 'grpc_asyncio'] - else 'https://netapp.googleapis.com' - ) - -@pytest.mark.parametrize("transport_name", [ - "grpc", - "grpc_asyncio", - "rest", -]) -def test_net_app_host_with_port(transport_name): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='netapp.googleapis.com:8000'), - transport=transport_name, - ) - assert client.transport._host == ( - 'netapp.googleapis.com:8000' - if transport_name in ['grpc', 'grpc_asyncio'] - else 'https://netapp.googleapis.com:8000' - ) - -@pytest.mark.parametrize("transport_name", [ - "rest", -]) -def test_net_app_client_transport_session_collision(transport_name): - creds1 = ga_credentials.AnonymousCredentials() - creds2 = ga_credentials.AnonymousCredentials() - client1 = NetAppClient( - credentials=creds1, - transport=transport_name, - ) - client2 = NetAppClient( - credentials=creds2, - transport=transport_name, - ) - session1 = client1.transport.list_storage_pools._session - session2 = client2.transport.list_storage_pools._session - assert session1 != session2 - session1 = client1.transport.create_storage_pool._session - session2 = client2.transport.create_storage_pool._session - assert session1 != session2 - session1 = client1.transport.get_storage_pool._session - session2 = client2.transport.get_storage_pool._session - assert session1 != session2 - session1 = client1.transport.update_storage_pool._session - session2 = client2.transport.update_storage_pool._session - assert session1 != session2 - session1 = client1.transport.delete_storage_pool._session - session2 = client2.transport.delete_storage_pool._session - assert session1 != session2 - session1 = client1.transport.validate_directory_service._session - session2 = client2.transport.validate_directory_service._session - assert session1 != session2 - session1 = client1.transport.switch_active_replica_zone._session - session2 = client2.transport.switch_active_replica_zone._session - assert session1 != session2 - session1 = client1.transport.list_volumes._session - session2 = client2.transport.list_volumes._session - assert session1 != session2 - session1 = client1.transport.get_volume._session - session2 = client2.transport.get_volume._session - assert session1 != session2 - session1 = client1.transport.create_volume._session - session2 = client2.transport.create_volume._session - assert session1 != session2 - session1 = client1.transport.update_volume._session - session2 = client2.transport.update_volume._session - assert session1 != session2 - session1 = client1.transport.delete_volume._session - session2 = client2.transport.delete_volume._session - assert session1 != session2 - session1 = client1.transport.revert_volume._session - session2 = client2.transport.revert_volume._session - assert session1 != session2 - session1 = client1.transport.list_snapshots._session - session2 = client2.transport.list_snapshots._session - assert session1 != session2 - session1 = client1.transport.get_snapshot._session - session2 = client2.transport.get_snapshot._session - assert session1 != session2 - session1 = client1.transport.create_snapshot._session - session2 = client2.transport.create_snapshot._session - assert session1 != session2 - session1 = client1.transport.delete_snapshot._session - session2 = client2.transport.delete_snapshot._session - assert session1 != session2 - session1 = client1.transport.update_snapshot._session - session2 = client2.transport.update_snapshot._session - assert session1 != session2 - session1 = client1.transport.list_active_directories._session - session2 = client2.transport.list_active_directories._session - assert session1 != session2 - session1 = client1.transport.get_active_directory._session - session2 = client2.transport.get_active_directory._session - assert session1 != session2 - session1 = client1.transport.create_active_directory._session - session2 = client2.transport.create_active_directory._session - assert session1 != session2 - session1 = client1.transport.update_active_directory._session - session2 = client2.transport.update_active_directory._session - assert session1 != session2 - session1 = client1.transport.delete_active_directory._session - session2 = client2.transport.delete_active_directory._session - assert session1 != session2 - session1 = client1.transport.list_kms_configs._session - session2 = client2.transport.list_kms_configs._session - assert session1 != session2 - session1 = client1.transport.create_kms_config._session - session2 = client2.transport.create_kms_config._session - assert session1 != session2 - session1 = client1.transport.get_kms_config._session - session2 = client2.transport.get_kms_config._session - assert session1 != session2 - session1 = client1.transport.update_kms_config._session - session2 = client2.transport.update_kms_config._session - assert session1 != session2 - session1 = client1.transport.encrypt_volumes._session - session2 = client2.transport.encrypt_volumes._session - assert session1 != session2 - session1 = client1.transport.verify_kms_config._session - session2 = client2.transport.verify_kms_config._session - assert session1 != session2 - session1 = client1.transport.delete_kms_config._session - session2 = client2.transport.delete_kms_config._session - assert session1 != session2 - session1 = client1.transport.list_replications._session - session2 = client2.transport.list_replications._session - assert session1 != session2 - session1 = client1.transport.get_replication._session - session2 = client2.transport.get_replication._session - assert session1 != session2 - session1 = client1.transport.create_replication._session - session2 = client2.transport.create_replication._session - assert session1 != session2 - session1 = client1.transport.delete_replication._session - session2 = client2.transport.delete_replication._session - assert session1 != session2 - session1 = client1.transport.update_replication._session - session2 = client2.transport.update_replication._session - assert session1 != session2 - session1 = client1.transport.stop_replication._session - session2 = client2.transport.stop_replication._session - assert session1 != session2 - session1 = client1.transport.resume_replication._session - session2 = client2.transport.resume_replication._session - assert session1 != session2 - session1 = client1.transport.reverse_replication_direction._session - session2 = client2.transport.reverse_replication_direction._session - assert session1 != session2 - session1 = client1.transport.establish_peering._session - session2 = client2.transport.establish_peering._session - assert session1 != session2 - session1 = client1.transport.sync_replication._session - session2 = client2.transport.sync_replication._session - assert session1 != session2 - session1 = client1.transport.create_backup_vault._session - session2 = client2.transport.create_backup_vault._session - assert session1 != session2 - session1 = client1.transport.get_backup_vault._session - session2 = client2.transport.get_backup_vault._session - assert session1 != session2 - session1 = client1.transport.list_backup_vaults._session - session2 = client2.transport.list_backup_vaults._session - assert session1 != session2 - session1 = client1.transport.update_backup_vault._session - session2 = client2.transport.update_backup_vault._session - assert session1 != session2 - session1 = client1.transport.delete_backup_vault._session - session2 = client2.transport.delete_backup_vault._session - assert session1 != session2 - session1 = client1.transport.create_backup._session - session2 = client2.transport.create_backup._session - assert session1 != session2 - session1 = client1.transport.get_backup._session - session2 = client2.transport.get_backup._session - assert session1 != session2 - session1 = client1.transport.list_backups._session - session2 = client2.transport.list_backups._session - assert session1 != session2 - session1 = client1.transport.delete_backup._session - session2 = client2.transport.delete_backup._session - assert session1 != session2 - session1 = client1.transport.update_backup._session - session2 = client2.transport.update_backup._session - assert session1 != session2 - session1 = client1.transport.create_backup_policy._session - session2 = client2.transport.create_backup_policy._session - assert session1 != session2 - session1 = client1.transport.get_backup_policy._session - session2 = client2.transport.get_backup_policy._session - assert session1 != session2 - session1 = client1.transport.list_backup_policies._session - session2 = client2.transport.list_backup_policies._session - assert session1 != session2 - session1 = client1.transport.update_backup_policy._session - session2 = client2.transport.update_backup_policy._session - assert session1 != session2 - session1 = client1.transport.delete_backup_policy._session - session2 = client2.transport.delete_backup_policy._session - assert session1 != session2 - session1 = client1.transport.list_quota_rules._session - session2 = client2.transport.list_quota_rules._session - assert session1 != session2 - session1 = client1.transport.get_quota_rule._session - session2 = client2.transport.get_quota_rule._session - assert session1 != session2 - session1 = client1.transport.create_quota_rule._session - session2 = client2.transport.create_quota_rule._session - assert session1 != session2 - session1 = client1.transport.update_quota_rule._session - session2 = client2.transport.update_quota_rule._session - assert session1 != session2 - session1 = client1.transport.delete_quota_rule._session - session2 = client2.transport.delete_quota_rule._session - assert session1 != session2 -def test_net_app_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.NetAppGrpcTransport( - 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_net_app_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.NetAppGrpcAsyncIOTransport( - 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.NetAppGrpcTransport, transports.NetAppGrpcAsyncIOTransport]) -def test_net_app_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.NetAppGrpcTransport, transports.NetAppGrpcAsyncIOTransport]) -def test_net_app_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_net_app_grpc_lro_client(): - client = NetAppClient( - 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_net_app_grpc_lro_async_client(): - client = NetAppAsyncClient( - 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_active_directory_path(): - project = "squid" - location = "clam" - active_directory = "whelk" - expected = "projects/{project}/locations/{location}/activeDirectories/{active_directory}".format(project=project, location=location, active_directory=active_directory, ) - actual = NetAppClient.active_directory_path(project, location, active_directory) - assert expected == actual - - -def test_parse_active_directory_path(): - expected = { - "project": "octopus", - "location": "oyster", - "active_directory": "nudibranch", - } - path = NetAppClient.active_directory_path(**expected) - - # Check that the path construction is reversible. - actual = NetAppClient.parse_active_directory_path(path) - assert expected == actual - -def test_backup_path(): - project = "cuttlefish" - location = "mussel" - backup_vault = "winkle" - backup = "nautilus" - expected = "projects/{project}/locations/{location}/backupVaults/{backup_vault}/backups/{backup}".format(project=project, location=location, backup_vault=backup_vault, backup=backup, ) - actual = NetAppClient.backup_path(project, location, backup_vault, backup) - assert expected == actual - - -def test_parse_backup_path(): - expected = { - "project": "scallop", - "location": "abalone", - "backup_vault": "squid", - "backup": "clam", - } - path = NetAppClient.backup_path(**expected) - - # Check that the path construction is reversible. - actual = NetAppClient.parse_backup_path(path) - assert expected == actual - -def test_backup_policy_path(): - project = "whelk" - location = "octopus" - backup_policy = "oyster" - expected = "projects/{project}/locations/{location}/backupPolicies/{backup_policy}".format(project=project, location=location, backup_policy=backup_policy, ) - actual = NetAppClient.backup_policy_path(project, location, backup_policy) - assert expected == actual - - -def test_parse_backup_policy_path(): - expected = { - "project": "nudibranch", - "location": "cuttlefish", - "backup_policy": "mussel", - } - path = NetAppClient.backup_policy_path(**expected) - - # Check that the path construction is reversible. - actual = NetAppClient.parse_backup_policy_path(path) - assert expected == actual - -def test_backup_vault_path(): - project = "winkle" - location = "nautilus" - backup_vault = "scallop" - expected = "projects/{project}/locations/{location}/backupVaults/{backup_vault}".format(project=project, location=location, backup_vault=backup_vault, ) - actual = NetAppClient.backup_vault_path(project, location, backup_vault) - assert expected == actual - - -def test_parse_backup_vault_path(): - expected = { - "project": "abalone", - "location": "squid", - "backup_vault": "clam", - } - path = NetAppClient.backup_vault_path(**expected) - - # Check that the path construction is reversible. - actual = NetAppClient.parse_backup_vault_path(path) - assert expected == actual - -def test_kms_config_path(): - project = "whelk" - location = "octopus" - kms_config = "oyster" - expected = "projects/{project}/locations/{location}/kmsConfigs/{kms_config}".format(project=project, location=location, kms_config=kms_config, ) - actual = NetAppClient.kms_config_path(project, location, kms_config) - assert expected == actual - - -def test_parse_kms_config_path(): - expected = { - "project": "nudibranch", - "location": "cuttlefish", - "kms_config": "mussel", - } - path = NetAppClient.kms_config_path(**expected) - - # Check that the path construction is reversible. - actual = NetAppClient.parse_kms_config_path(path) - assert expected == actual - -def test_network_path(): - project = "winkle" - network = "nautilus" - expected = "projects/{project}/global/networks/{network}".format(project=project, network=network, ) - actual = NetAppClient.network_path(project, network) - assert expected == actual - - -def test_parse_network_path(): - expected = { - "project": "scallop", - "network": "abalone", - } - path = NetAppClient.network_path(**expected) - - # Check that the path construction is reversible. - actual = NetAppClient.parse_network_path(path) - assert expected == actual - -def test_quota_rule_path(): - project = "squid" - location = "clam" - volume = "whelk" - quota_rule = "octopus" - expected = "projects/{project}/locations/{location}/volumes/{volume}/quotaRules/{quota_rule}".format(project=project, location=location, volume=volume, quota_rule=quota_rule, ) - actual = NetAppClient.quota_rule_path(project, location, volume, quota_rule) - assert expected == actual - - -def test_parse_quota_rule_path(): - expected = { - "project": "oyster", - "location": "nudibranch", - "volume": "cuttlefish", - "quota_rule": "mussel", - } - path = NetAppClient.quota_rule_path(**expected) - - # Check that the path construction is reversible. - actual = NetAppClient.parse_quota_rule_path(path) - assert expected == actual - -def test_replication_path(): - project = "winkle" - location = "nautilus" - volume = "scallop" - replication = "abalone" - expected = "projects/{project}/locations/{location}/volumes/{volume}/replications/{replication}".format(project=project, location=location, volume=volume, replication=replication, ) - actual = NetAppClient.replication_path(project, location, volume, replication) - assert expected == actual - - -def test_parse_replication_path(): - expected = { - "project": "squid", - "location": "clam", - "volume": "whelk", - "replication": "octopus", - } - path = NetAppClient.replication_path(**expected) - - # Check that the path construction is reversible. - actual = NetAppClient.parse_replication_path(path) - assert expected == actual - -def test_snapshot_path(): - project = "oyster" - location = "nudibranch" - volume = "cuttlefish" - snapshot = "mussel" - expected = "projects/{project}/locations/{location}/volumes/{volume}/snapshots/{snapshot}".format(project=project, location=location, volume=volume, snapshot=snapshot, ) - actual = NetAppClient.snapshot_path(project, location, volume, snapshot) - assert expected == actual - - -def test_parse_snapshot_path(): - expected = { - "project": "winkle", - "location": "nautilus", - "volume": "scallop", - "snapshot": "abalone", - } - path = NetAppClient.snapshot_path(**expected) - - # Check that the path construction is reversible. - actual = NetAppClient.parse_snapshot_path(path) - assert expected == actual - -def test_storage_pool_path(): - project = "squid" - location = "clam" - storage_pool = "whelk" - expected = "projects/{project}/locations/{location}/storagePools/{storage_pool}".format(project=project, location=location, storage_pool=storage_pool, ) - actual = NetAppClient.storage_pool_path(project, location, storage_pool) - assert expected == actual - - -def test_parse_storage_pool_path(): - expected = { - "project": "octopus", - "location": "oyster", - "storage_pool": "nudibranch", - } - path = NetAppClient.storage_pool_path(**expected) - - # Check that the path construction is reversible. - actual = NetAppClient.parse_storage_pool_path(path) - assert expected == actual - -def test_volume_path(): - project = "cuttlefish" - location = "mussel" - volume = "winkle" - expected = "projects/{project}/locations/{location}/volumes/{volume}".format(project=project, location=location, volume=volume, ) - actual = NetAppClient.volume_path(project, location, volume) - assert expected == actual - - -def test_parse_volume_path(): - expected = { - "project": "nautilus", - "location": "scallop", - "volume": "abalone", - } - path = NetAppClient.volume_path(**expected) - - # Check that the path construction is reversible. - actual = NetAppClient.parse_volume_path(path) - assert expected == actual - -def test_common_billing_account_path(): - billing_account = "squid" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - actual = NetAppClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "clam", - } - path = NetAppClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = NetAppClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "whelk" - expected = "folders/{folder}".format(folder=folder, ) - actual = NetAppClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "octopus", - } - path = NetAppClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = NetAppClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "oyster" - expected = "organizations/{organization}".format(organization=organization, ) - actual = NetAppClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "nudibranch", - } - path = NetAppClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = NetAppClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "cuttlefish" - expected = "projects/{project}".format(project=project, ) - actual = NetAppClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "mussel", - } - path = NetAppClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = NetAppClient.parse_common_project_path(path) - assert expected == actual - -def test_common_location_path(): - project = "winkle" - location = "nautilus" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) - actual = NetAppClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "scallop", - "location": "abalone", - } - path = NetAppClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = NetAppClient.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.NetAppTransport, '_prep_wrapped_messages') as prep: - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.NetAppTransport, '_prep_wrapped_messages') as prep: - transport_class = NetAppClient.get_transport_class() - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - -def test_delete_operation(transport: str = "grpc"): - client = NetAppClient( - 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.DeleteOperationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_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 response is None -@pytest.mark.asyncio -async def test_delete_operation_async(transport: str = "grpc_asyncio"): - client = NetAppAsyncClient( - 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.DeleteOperationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - None - ) - response = await client.delete_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 response is None - -def test_delete_operation_field_headers(): - client = NetAppClient( - 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.DeleteOperationRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: - call.return_value = None - - client.delete_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_delete_operation_field_headers_async(): - client = NetAppAsyncClient( - 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.DeleteOperationRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - None - ) - await client.delete_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_delete_operation_from_dict(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = None - - response = client.delete_operation( - request={ - "name": "locations", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_delete_operation_from_dict_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - None - ) - response = await client.delete_operation( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_cancel_operation(transport: str = "grpc"): - client = NetAppClient( - 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.CancelOperationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.cancel_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 response is None -@pytest.mark.asyncio -async def test_cancel_operation_async(transport: str = "grpc_asyncio"): - client = NetAppAsyncClient( - 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.CancelOperationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - None - ) - response = await client.cancel_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 response is None - -def test_cancel_operation_field_headers(): - client = NetAppClient( - 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.CancelOperationRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - call.return_value = None - - client.cancel_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_cancel_operation_field_headers_async(): - client = NetAppAsyncClient( - 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.CancelOperationRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - None - ) - await client.cancel_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_cancel_operation_from_dict(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = None - - response = client.cancel_operation( - request={ - "name": "locations", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_cancel_operation_from_dict_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - None - ) - response = await client.cancel_operation( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_get_operation(transport: str = "grpc"): - client = NetAppClient( - 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 = NetAppAsyncClient( - 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 = NetAppClient( - 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 = NetAppAsyncClient( - 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 = NetAppClient( - 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 = NetAppAsyncClient( - 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_operations(transport: str = "grpc"): - client = NetAppClient( - 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.ListOperationsRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.ListOperationsResponse() - response = client.list_operations(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.ListOperationsResponse) -@pytest.mark.asyncio -async def test_list_operations_async(transport: str = "grpc_asyncio"): - client = NetAppAsyncClient( - 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.ListOperationsRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.ListOperationsResponse() - ) - response = await client.list_operations(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.ListOperationsResponse) - -def test_list_operations_field_headers(): - client = NetAppClient( - 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.ListOperationsRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - call.return_value = operations_pb2.ListOperationsResponse() - - client.list_operations(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_operations_field_headers_async(): - client = NetAppAsyncClient( - 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.ListOperationsRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.ListOperationsResponse() - ) - await client.list_operations(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_operations_from_dict(): - client = NetAppClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.ListOperationsResponse() - - response = client.list_operations( - request={ - "name": "locations", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_list_operations_from_dict_async(): - client = NetAppAsyncClient( - credentials=async_anonymous_credentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.ListOperationsResponse() - ) - response = await client.list_operations( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_list_locations(transport: str = "grpc"): - client = NetAppClient( - 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 = NetAppAsyncClient( - 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 = NetAppClient( - 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 = NetAppAsyncClient( - 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 = NetAppClient( - 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 = NetAppAsyncClient( - 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 = NetAppClient( - 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 = NetAppAsyncClient( - 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 = NetAppClient( - 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 = NetAppAsyncClient( - 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 = NetAppClient( - 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 = NetAppAsyncClient( - 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 = NetAppClient( - 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 = NetAppAsyncClient( - 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 = NetAppClient( - 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 = NetAppClient( - 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", [ - (NetAppClient, transports.NetAppGrpcTransport), - (NetAppAsyncClient, transports.NetAppGrpcAsyncIOTransport), -]) -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-netapp/google/cloud/netapp_v1/types/volume.py b/packages/google-cloud-netapp/google/cloud/netapp_v1/types/volume.py index c57d0fead97a..4e8824f1512f 100644 --- a/packages/google-cloud-netapp/google/cloud/netapp_v1/types/volume.py +++ b/packages/google-cloud-netapp/google/cloud/netapp_v1/types/volume.py @@ -1217,7 +1217,7 @@ class TieringPolicy(proto.Message): cooling_threshold_days (int): Optional. Time in days to mark the volume's data block as cold and make it eligible for - tiering, can be range from 7-183. Default is 31. + tiering, can be range from 2-183. Default is 31. This field is a member of `oneof`_ ``_cooling_threshold_days``. """