From 837490f1bb72c2d6db8a0c8e3337cc29a90713f5 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 8 Feb 2022 22:55:13 +0100 Subject: [PATCH 01/16] chore(deps): update all dependencies (#678) --- samples/samples/requirements-test.txt | 2 +- samples/samples/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/samples/requirements-test.txt b/samples/samples/requirements-test.txt index e18a125cd8..e5759c8bc9 100644 --- a/samples/samples/requirements-test.txt +++ b/samples/samples/requirements-test.txt @@ -1,4 +1,4 @@ -pytest==6.2.5 +pytest==7.0.0 pytest-dependency==0.5.1 mock==4.0.3 google-cloud-testutils==1.3.1 diff --git a/samples/samples/requirements.txt b/samples/samples/requirements.txt index c5b7ca5fc5..c2b585853e 100644 --- a/samples/samples/requirements.txt +++ b/samples/samples/requirements.txt @@ -1,2 +1,2 @@ -google-cloud-spanner==3.12.1 +google-cloud-spanner==3.13.0 futures==3.3.0; python_version < "3" From 41015715c9465b8b7753b71350a4be3aaeb26704 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 14 Feb 2022 16:51:48 +0100 Subject: [PATCH 02/16] chore(deps): update dependency pytest to v7.0.1 (#681) --- samples/samples/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/samples/requirements-test.txt b/samples/samples/requirements-test.txt index e5759c8bc9..b8e7474e10 100644 --- a/samples/samples/requirements-test.txt +++ b/samples/samples/requirements-test.txt @@ -1,4 +1,4 @@ -pytest==7.0.0 +pytest==7.0.1 pytest-dependency==0.5.1 mock==4.0.3 google-cloud-testutils==1.3.1 From f21dac4c47cb6a6a85fd282b8e5de966b467b1b6 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sat, 26 Feb 2022 06:38:17 -0500 Subject: [PATCH 03/16] docs: add generated snippets (#680) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: use gapic-generator-python 0.63.2 docs: add generated snippets PiperOrigin-RevId: 427792504 Source-Link: https://github.com/googleapis/googleapis/commit/55b9e1e0b3106c850d13958352bc0751147b6b15 Source-Link: https://github.com/googleapis/googleapis-gen/commit/bf4e86b753f42cb0edb1fd51fbe840d7da0a1cde Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYmY0ZTg2Yjc1M2Y0MmNiMGVkYjFmZDUxZmJlODQwZDdkYTBhMWNkZSJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix!: annotating some fields as REQUIRED These fields were actually always required by the backend, so annotation just documents status quo. I believe this change will not require major version bump for any language. PiperOrigin-RevId: 429093810 Source-Link: https://github.com/googleapis/googleapis/commit/dc04c1c48ac4940abc36f430705c35d3c85bb6e2 Source-Link: https://github.com/googleapis/googleapis-gen/commit/0e23469bea2f397f2b783c5a25e64452f86be6bc Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMGUyMzQ2OWJlYTJmMzk3ZjJiNzgzYzVhMjVlNjQ0NTJmODZiZTZiYyJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: use gapic-generator-python 0.63.4 chore: fix snippet region tag format chore: fix docstring code block formatting PiperOrigin-RevId: 430730865 Source-Link: https://github.com/googleapis/googleapis/commit/ea5800229f73f94fd7204915a86ed09dcddf429a Source-Link: https://github.com/googleapis/googleapis-gen/commit/ca893ff8af25fc7fe001de1405a517d80446ecca Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiY2E4OTNmZjhhZjI1ZmM3ZmUwMDFkZTE0MDVhNTE3ZDgwNDQ2ZWNjYSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: delete duplicates * chore: update copyright year to 2022 PiperOrigin-RevId: 431037888 Source-Link: https://github.com/googleapis/googleapis/commit/b3397f5febbf21dfc69b875ddabaf76bee765058 Source-Link: https://github.com/googleapis/googleapis-gen/commit/510b54e1cdefd53173984df16645081308fe897e Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNTEwYjU0ZTFjZGVmZDUzMTczOTg0ZGYxNjY0NTA4MTMwOGZlODk3ZSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> --- .../spanner_admin_database_v1/__init__.py | 2 +- .../services/__init__.py | 2 +- .../services/database_admin/__init__.py | 2 +- .../services/database_admin/async_client.py | 359 +++- .../services/database_admin/client.py | 359 +++- .../services/database_admin/pagers.py | 2 +- .../database_admin/transports/__init__.py | 2 +- .../database_admin/transports/base.py | 2 +- .../database_admin/transports/grpc.py | 2 +- .../database_admin/transports/grpc_asyncio.py | 2 +- .../types/__init__.py | 2 +- .../spanner_admin_database_v1/types/backup.py | 2 +- .../spanner_admin_database_v1/types/common.py | 2 +- .../types/spanner_database_admin.py | 2 +- .../spanner_admin_instance_v1/__init__.py | 2 +- .../services/__init__.py | 2 +- .../services/instance_admin/__init__.py | 2 +- .../services/instance_admin/async_client.py | 220 ++- .../services/instance_admin/client.py | 220 ++- .../services/instance_admin/pagers.py | 2 +- .../instance_admin/transports/__init__.py | 2 +- .../instance_admin/transports/base.py | 2 +- .../instance_admin/transports/grpc.py | 2 +- .../instance_admin/transports/grpc_asyncio.py | 2 +- .../types/__init__.py | 2 +- .../types/spanner_instance_admin.py | 2 +- google/cloud/spanner_v1/services/__init__.py | 2 +- .../spanner_v1/services/spanner/__init__.py | 2 +- .../services/spanner/async_client.py | 314 +++- .../spanner_v1/services/spanner/client.py | 314 +++- .../spanner_v1/services/spanner/pagers.py | 2 +- .../services/spanner/transports/__init__.py | 2 +- .../services/spanner/transports/base.py | 2 +- .../services/spanner/transports/grpc.py | 2 +- .../spanner/transports/grpc_asyncio.py | 2 +- google/cloud/spanner_v1/types/__init__.py | 2 +- .../cloud/spanner_v1/types/commit_response.py | 2 +- google/cloud/spanner_v1/types/keys.py | 2 +- google/cloud/spanner_v1/types/mutation.py | 2 +- google/cloud/spanner_v1/types/query_plan.py | 2 +- google/cloud/spanner_v1/types/result_set.py | 2 +- google/cloud/spanner_v1/types/spanner.py | 4 +- google/cloud/spanner_v1/types/transaction.py | 2 +- google/cloud/spanner_v1/types/type.py | 2 +- ...et_metadata_spanner admin database_v1.json | 1509 +++++++++++++++++ ...et_metadata_spanner admin instance_v1.json | 890 ++++++++++ .../snippet_metadata_spanner_v1.json | 1331 +++++++++++++++ ...ated_database_admin_create_backup_async.py | 50 + ...rated_database_admin_create_backup_sync.py | 50 + ...ed_database_admin_create_database_async.py | 50 + ...ted_database_admin_create_database_sync.py | 50 + ...ated_database_admin_delete_backup_async.py | 43 + ...rated_database_admin_delete_backup_sync.py | 43 + ...ated_database_admin_drop_database_async.py | 43 + ...rated_database_admin_drop_database_sync.py | 43 + ...nerated_database_admin_get_backup_async.py | 45 + ...enerated_database_admin_get_backup_sync.py | 45 + ...rated_database_admin_get_database_async.py | 45 + ...d_database_admin_get_database_ddl_async.py | 45 + ...ed_database_admin_get_database_ddl_sync.py | 45 + ...erated_database_admin_get_database_sync.py | 45 + ...ted_database_admin_get_iam_policy_async.py | 45 + ...ated_database_admin_get_iam_policy_sync.py | 45 + ...base_admin_list_backup_operations_async.py | 46 + ...abase_admin_list_backup_operations_sync.py | 46 + ...rated_database_admin_list_backups_async.py | 46 + ...erated_database_admin_list_backups_sync.py | 46 + ...se_admin_list_database_operations_async.py | 46 + ...ase_admin_list_database_operations_sync.py | 46 + ...ted_database_admin_list_databases_async.py | 46 + ...ated_database_admin_list_databases_sync.py | 46 + ...d_database_admin_restore_database_async.py | 51 + ...ed_database_admin_restore_database_sync.py | 51 + ...ted_database_admin_set_iam_policy_async.py | 45 + ...ated_database_admin_set_iam_policy_sync.py | 45 + ...tabase_admin_test_iam_permissions_async.py | 46 + ...atabase_admin_test_iam_permissions_sync.py | 46 + ...ated_database_admin_update_backup_async.py | 44 + ...rated_database_admin_update_backup_sync.py | 44 + ...atabase_admin_update_database_ddl_async.py | 50 + ...database_admin_update_database_ddl_sync.py | 50 + ...ed_instance_admin_create_instance_async.py | 56 + ...ted_instance_admin_create_instance_sync.py | 56 + ...ed_instance_admin_delete_instance_async.py | 43 + ...ted_instance_admin_delete_instance_sync.py | 43 + ...ted_instance_admin_get_iam_policy_async.py | 45 + ...ated_instance_admin_get_iam_policy_sync.py | 45 + ...rated_instance_admin_get_instance_async.py | 45 + ...nstance_admin_get_instance_config_async.py | 45 + ...instance_admin_get_instance_config_sync.py | 45 + ...erated_instance_admin_get_instance_sync.py | 45 + ...tance_admin_list_instance_configs_async.py | 46 + ...stance_admin_list_instance_configs_sync.py | 46 + ...ted_instance_admin_list_instances_async.py | 46 + ...ated_instance_admin_list_instances_sync.py | 46 + ...ted_instance_admin_set_iam_policy_async.py | 45 + ...ated_instance_admin_set_iam_policy_sync.py | 45 + ...stance_admin_test_iam_permissions_async.py | 46 + ...nstance_admin_test_iam_permissions_sync.py | 46 + ...ed_instance_admin_update_instance_async.py | 54 + ...ted_instance_admin_update_instance_sync.py | 54 + ...ted_spanner_batch_create_sessions_async.py | 46 + ...ated_spanner_batch_create_sessions_sync.py | 46 + ...nerated_spanner_begin_transaction_async.py | 45 + ...enerated_spanner_begin_transaction_sync.py | 45 + ...anner_v1_generated_spanner_commit_async.py | 46 + ...panner_v1_generated_spanner_commit_sync.py | 46 + ..._generated_spanner_create_session_async.py | 45 + ...1_generated_spanner_create_session_sync.py | 45 + ..._generated_spanner_delete_session_async.py | 43 + ...1_generated_spanner_delete_session_sync.py | 43 + ...nerated_spanner_execute_batch_dml_async.py | 50 + ...enerated_spanner_execute_batch_dml_sync.py | 50 + ..._v1_generated_spanner_execute_sql_async.py | 46 + ...r_v1_generated_spanner_execute_sql_sync.py | 46 + ...ted_spanner_execute_streaming_sql_async.py | 47 + ...ated_spanner_execute_streaming_sql_sync.py | 47 + ..._v1_generated_spanner_get_session_async.py | 45 + ...r_v1_generated_spanner_get_session_sync.py | 45 + ...1_generated_spanner_list_sessions_async.py | 46 + ...v1_generated_spanner_list_sessions_sync.py | 46 + ...generated_spanner_partition_query_async.py | 46 + ..._generated_spanner_partition_query_sync.py | 46 + ..._generated_spanner_partition_read_async.py | 46 + ...1_generated_spanner_partition_read_sync.py | 46 + ...spanner_v1_generated_spanner_read_async.py | 47 + .../spanner_v1_generated_spanner_read_sync.py | 47 + ...ner_v1_generated_spanner_rollback_async.py | 44 + ...nner_v1_generated_spanner_rollback_sync.py | 44 + ..._generated_spanner_streaming_read_async.py | 48 + ...1_generated_spanner_streaming_read_sync.py | 48 + ...ixup_spanner_admin_database_v1_keywords.py | 2 +- ...ixup_spanner_admin_instance_v1_keywords.py | 2 +- scripts/fixup_spanner_v1_keywords.py | 2 +- tests/__init__.py | 2 +- tests/unit/__init__.py | 2 +- tests/unit/gapic/__init__.py | 2 +- .../spanner_admin_database_v1/__init__.py | 2 +- .../test_database_admin.py | 2 +- .../spanner_admin_instance_v1/__init__.py | 2 +- .../test_instance_admin.py | 2 +- tests/unit/gapic/spanner_v1/__init__.py | 2 +- tests/unit/gapic/spanner_v1/test_spanner.py | 2 +- 143 files changed, 9455 insertions(+), 57 deletions(-) create mode 100644 samples/generated_samples/snippet_metadata_spanner admin database_v1.json create mode 100644 samples/generated_samples/snippet_metadata_spanner admin instance_v1.json create mode 100644 samples/generated_samples/snippet_metadata_spanner_v1.json create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_create_backup_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_create_backup_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_create_database_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_create_database_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_delete_backup_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_delete_backup_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_drop_database_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_drop_database_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_get_backup_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_get_backup_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_get_database_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_get_database_ddl_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_get_database_ddl_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_get_database_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_get_iam_policy_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_get_iam_policy_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_list_backup_operations_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_list_backup_operations_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_list_backups_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_list_backups_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_list_database_operations_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_list_database_operations_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_list_databases_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_list_databases_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_restore_database_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_restore_database_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_set_iam_policy_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_set_iam_policy_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_test_iam_permissions_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_test_iam_permissions_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_update_backup_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_update_backup_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_update_database_ddl_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_update_database_ddl_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_instance_admin_create_instance_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_instance_admin_create_instance_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_instance_admin_delete_instance_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_instance_admin_delete_instance_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_instance_admin_get_iam_policy_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_instance_admin_get_iam_policy_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_instance_admin_get_instance_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_instance_admin_get_instance_config_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_instance_admin_get_instance_config_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_instance_admin_get_instance_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_instance_admin_list_instance_configs_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_instance_admin_list_instance_configs_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_instance_admin_list_instances_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_instance_admin_list_instances_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_instance_admin_set_iam_policy_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_instance_admin_set_iam_policy_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_instance_admin_test_iam_permissions_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_instance_admin_test_iam_permissions_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_instance_admin_update_instance_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_instance_admin_update_instance_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_batch_create_sessions_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_batch_create_sessions_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_begin_transaction_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_begin_transaction_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_commit_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_commit_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_create_session_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_create_session_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_delete_session_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_delete_session_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_execute_batch_dml_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_execute_batch_dml_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_execute_sql_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_execute_sql_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_execute_streaming_sql_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_execute_streaming_sql_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_get_session_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_get_session_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_list_sessions_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_list_sessions_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_partition_query_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_partition_query_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_partition_read_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_partition_read_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_read_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_read_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_rollback_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_rollback_sync.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_streaming_read_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_spanner_streaming_read_sync.py diff --git a/google/cloud/spanner_admin_database_v1/__init__.py b/google/cloud/spanner_admin_database_v1/__init__.py index f7d3a4f557..e587590c9a 100644 --- a/google/cloud/spanner_admin_database_v1/__init__.py +++ b/google/cloud/spanner_admin_database_v1/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_admin_database_v1/services/__init__.py b/google/cloud/spanner_admin_database_v1/services/__init__.py index 4de65971c2..e8e1c3845d 100644 --- a/google/cloud/spanner_admin_database_v1/services/__init__.py +++ b/google/cloud/spanner_admin_database_v1/services/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/__init__.py b/google/cloud/spanner_admin_database_v1/services/database_admin/__init__.py index abe449ebfa..6fcf1b82e7 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/__init__.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py b/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py index e4316c170b..add0829bc8 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -242,6 +242,26 @@ async def list_databases( ) -> pagers.ListDatabasesAsyncPager: r"""Lists Cloud Spanner databases. + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_list_databases(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.ListDatabasesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_databases(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.ListDatabasesRequest, dict]): The request object. The request for @@ -343,6 +363,31 @@ async def create_database( is [Database][google.spanner.admin.database.v1.Database], if successful. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_create_database(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.CreateDatabaseRequest( + parent="parent_value", + create_statement="create_statement_value", + ) + + # Make the request + operation = client.create_database(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.CreateDatabaseRequest, dict]): The request object. The request for @@ -440,6 +485,25 @@ async def get_database( ) -> spanner_database_admin.Database: r"""Gets the state of a Cloud Spanner database. + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_get_database(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.GetDatabaseRequest( + name="name_value", + ) + + # Make the request + response = client.get_database(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.GetDatabaseRequest, dict]): The request object. The request for @@ -529,6 +593,31 @@ async def update_database_ddl( [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. The operation has no response. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_update_database_ddl(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.UpdateDatabaseDdlRequest( + database="database_value", + statements=['statements_value_1', 'statements_value_2'], + ) + + # Make the request + operation = client.update_database_ddl(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.UpdateDatabaseDdlRequest, dict]): The request object. Enqueues the given DDL statements to @@ -658,6 +747,23 @@ async def drop_database( ``expire_time``. Note: Cloud Spanner might continue to accept requests for a few seconds after the database has been deleted. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_drop_database(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.DropDatabaseRequest( + database="database_value", + ) + + # Make the request + client.drop_database(request=request) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.DropDatabaseRequest, dict]): The request object. The request for @@ -733,6 +839,26 @@ async def get_database_ddl( schema updates, those may be queried using the [Operations][google.longrunning.Operations] API. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_get_database_ddl(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.GetDatabaseDdlRequest( + database="database_value", + ) + + # Make the request + response = client.get_database_ddl(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.GetDatabaseDdlRequest, dict]): The request object. The request for @@ -823,6 +949,26 @@ async def set_iam_policy( permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_set_iam_policy(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): The request object. Request message for `SetIamPolicy` @@ -958,6 +1104,26 @@ async def get_iam_policy( permission on [resource][google.iam.v1.GetIamPolicyRequest.resource]. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_get_iam_policy(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): The request object. Request message for `GetIamPolicy` @@ -1104,6 +1270,27 @@ async def test_iam_permissions( in a NOT_FOUND error if the user has ``spanner.backups.list`` permission on the containing instance. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_test_iam_permissions(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): The request object. Request message for @@ -1200,6 +1387,31 @@ async def create_backup( backup creation per database. Backup creation of different databases can run concurrently. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_create_backup(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_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.spanner_admin_database_v1.types.CreateBackupRequest, dict]): The request object. The request for @@ -1306,6 +1518,26 @@ async def get_backup( r"""Gets metadata on a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_get_backup(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.GetBackupRequest( + name="name_value", + ) + + # Make the request + response = client.get_backup(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.GetBackupRequest, dict]): The request object. The request for @@ -1387,6 +1619,25 @@ async def update_backup( r"""Updates a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_update_backup(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.UpdateBackupRequest( + ) + + # Make the request + response = client.update_backup(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.UpdateBackupRequest, dict]): The request object. The request for @@ -1487,6 +1738,23 @@ async def delete_backup( r"""Deletes a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_delete_backup(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.DeleteBackupRequest( + name="name_value", + ) + + # Make the request + client.delete_backup(request=request) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.DeleteBackupRequest, dict]): The request object. The request for @@ -1564,6 +1832,27 @@ async def list_backups( ordered by ``create_time`` in descending order, starting from the most recent ``create_time``. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_list_backups(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_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.spanner_admin_database_v1.types.ListBackupsRequest, dict]): The request object. The request for @@ -1674,6 +1963,32 @@ async def restore_database( without waiting for the optimize operation associated with the first restore to complete. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_restore_database(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.RestoreDatabaseRequest( + backup="backup_value", + parent="parent_value", + database_id="database_id_value", + ) + + # Make the request + operation = client.restore_database(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.RestoreDatabaseRequest, dict]): The request object. The request for @@ -1792,6 +2107,27 @@ async def list_database_operations( completed/failed/canceled within the last 7 days, and pending operations. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_list_database_operations(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.ListDatabaseOperationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_database_operations(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.ListDatabaseOperationsRequest, dict]): The request object. The request for @@ -1894,6 +2230,27 @@ async def list_backup_operations( ``operation.metadata.value.progress.start_time`` in descending order starting from the most recently started operation. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_list_backup_operations(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.ListBackupOperationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_backup_operations(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.ListBackupOperationsRequest, dict]): The request object. The request for diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/client.py b/google/cloud/spanner_admin_database_v1/services/database_admin/client.py index aca0ee8a43..120dec124a 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/client.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -503,6 +503,26 @@ def list_databases( ) -> pagers.ListDatabasesPager: r"""Lists Cloud Spanner databases. + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_list_databases(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.ListDatabasesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_databases(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.ListDatabasesRequest, dict]): The request object. The request for @@ -594,6 +614,31 @@ def create_database( is [Database][google.spanner.admin.database.v1.Database], if successful. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_create_database(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.CreateDatabaseRequest( + parent="parent_value", + create_statement="create_statement_value", + ) + + # Make the request + operation = client.create_database(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.CreateDatabaseRequest, dict]): The request object. The request for @@ -691,6 +736,25 @@ def get_database( ) -> spanner_database_admin.Database: r"""Gets the state of a Cloud Spanner database. + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_get_database(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.GetDatabaseRequest( + name="name_value", + ) + + # Make the request + response = client.get_database(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.GetDatabaseRequest, dict]): The request object. The request for @@ -770,6 +834,31 @@ def update_database_ddl( [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. The operation has no response. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_update_database_ddl(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.UpdateDatabaseDdlRequest( + database="database_value", + statements=['statements_value_1', 'statements_value_2'], + ) + + # Make the request + operation = client.update_database_ddl(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.UpdateDatabaseDdlRequest, dict]): The request object. Enqueues the given DDL statements to @@ -889,6 +978,23 @@ def drop_database( ``expire_time``. Note: Cloud Spanner might continue to accept requests for a few seconds after the database has been deleted. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_drop_database(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.DropDatabaseRequest( + database="database_value", + ) + + # Make the request + client.drop_database(request=request) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.DropDatabaseRequest, dict]): The request object. The request for @@ -954,6 +1060,26 @@ def get_database_ddl( schema updates, those may be queried using the [Operations][google.longrunning.Operations] API. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_get_database_ddl(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.GetDatabaseDdlRequest( + database="database_value", + ) + + # Make the request + response = client.get_database_ddl(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.GetDatabaseDdlRequest, dict]): The request object. The request for @@ -1034,6 +1160,26 @@ def set_iam_policy( permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_set_iam_policy(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): The request object. Request message for `SetIamPolicy` @@ -1168,6 +1314,26 @@ def get_iam_policy( permission on [resource][google.iam.v1.GetIamPolicyRequest.resource]. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_get_iam_policy(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): The request object. Request message for `GetIamPolicy` @@ -1303,6 +1469,27 @@ def test_iam_permissions( in a NOT_FOUND error if the user has ``spanner.backups.list`` permission on the containing instance. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_test_iam_permissions(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): The request object. Request message for @@ -1398,6 +1585,31 @@ def create_backup( backup creation per database. Backup creation of different databases can run concurrently. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_create_backup(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_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.spanner_admin_database_v1.types.CreateBackupRequest, dict]): The request object. The request for @@ -1504,6 +1716,26 @@ def get_backup( r"""Gets metadata on a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_get_backup(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.GetBackupRequest( + name="name_value", + ) + + # Make the request + response = client.get_backup(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.GetBackupRequest, dict]): The request object. The request for @@ -1575,6 +1807,25 @@ def update_backup( r"""Updates a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_update_backup(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.UpdateBackupRequest( + ) + + # Make the request + response = client.update_backup(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.UpdateBackupRequest, dict]): The request object. The request for @@ -1665,6 +1916,23 @@ def delete_backup( r"""Deletes a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_delete_backup(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.DeleteBackupRequest( + name="name_value", + ) + + # Make the request + client.delete_backup(request=request) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.DeleteBackupRequest, dict]): The request object. The request for @@ -1732,6 +2000,27 @@ def list_backups( ordered by ``create_time`` in descending order, starting from the most recent ``create_time``. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_list_backups(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_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.spanner_admin_database_v1.types.ListBackupsRequest, dict]): The request object. The request for @@ -1832,6 +2121,32 @@ def restore_database( without waiting for the optimize operation associated with the first restore to complete. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_restore_database(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.RestoreDatabaseRequest( + backup="backup_value", + parent="parent_value", + database_id="database_id_value", + ) + + # Make the request + operation = client.restore_database(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.RestoreDatabaseRequest, dict]): The request object. The request for @@ -1950,6 +2265,27 @@ def list_database_operations( completed/failed/canceled within the last 7 days, and pending operations. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_list_database_operations(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.ListDatabaseOperationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_database_operations(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.ListDatabaseOperationsRequest, dict]): The request object. The request for @@ -2044,6 +2380,27 @@ def list_backup_operations( ``operation.metadata.value.progress.start_time`` in descending order starting from the most recently started operation. + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_list_backup_operations(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.ListBackupOperationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_backup_operations(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.spanner_admin_database_v1.types.ListBackupOperationsRequest, dict]): The request object. The request for diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/pagers.py b/google/cloud/spanner_admin_database_v1/services/database_admin/pagers.py index a14ed07855..ed4bd6ba5d 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/pagers.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/__init__.py b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/__init__.py index 743a749bfa..8b203ec615 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/__init__.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py index 4869fd03d5..090e2a954e 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py index b96319cfdf..9c0d1ea4d0 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py index 62c804a2e7..fd35a3eaf5 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_admin_database_v1/types/__init__.py b/google/cloud/spanner_admin_database_v1/types/__init__.py index f671adc0cf..8a7e38d1ab 100644 --- a/google/cloud/spanner_admin_database_v1/types/__init__.py +++ b/google/cloud/spanner_admin_database_v1/types/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_admin_database_v1/types/backup.py b/google/cloud/spanner_admin_database_v1/types/backup.py index c27a5a5f31..da5f4d4b2e 100644 --- a/google/cloud/spanner_admin_database_v1/types/backup.py +++ b/google/cloud/spanner_admin_database_v1/types/backup.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_admin_database_v1/types/common.py b/google/cloud/spanner_admin_database_v1/types/common.py index 81e3433617..8e5e4aa9f4 100644 --- a/google/cloud/spanner_admin_database_v1/types/common.py +++ b/google/cloud/spanner_admin_database_v1/types/common.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py b/google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py index 7b598b09d9..42cf4f484f 100644 --- a/google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py +++ b/google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_admin_instance_v1/__init__.py b/google/cloud/spanner_admin_instance_v1/__init__.py index cdc373bcff..c641cd061c 100644 --- a/google/cloud/spanner_admin_instance_v1/__init__.py +++ b/google/cloud/spanner_admin_instance_v1/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_admin_instance_v1/services/__init__.py b/google/cloud/spanner_admin_instance_v1/services/__init__.py index 4de65971c2..e8e1c3845d 100644 --- a/google/cloud/spanner_admin_instance_v1/services/__init__.py +++ b/google/cloud/spanner_admin_instance_v1/services/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/__init__.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/__init__.py index 2ba47af654..15f143a119 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/__init__.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py index 35bbe7c817..2d8a01afb7 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -244,6 +244,27 @@ async def list_instance_configs( r"""Lists the supported instance configurations for a given project. + + .. code-block:: python + + from google.cloud import spanner_admin_instance_v1 + + def sample_list_instance_configs(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.ListInstanceConfigsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_instance_configs(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.spanner_admin_instance_v1.types.ListInstanceConfigsRequest, dict]): The request object. The request for @@ -336,6 +357,26 @@ async def get_instance_config( r"""Gets information about a particular instance configuration. + + .. code-block:: python + + from google.cloud import spanner_admin_instance_v1 + + def sample_get_instance_config(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.GetInstanceConfigRequest( + name="name_value", + ) + + # Make the request + response = client.get_instance_config(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_instance_v1.types.GetInstanceConfigRequest, dict]): The request object. The request for @@ -420,6 +461,26 @@ async def list_instances( ) -> pagers.ListInstancesAsyncPager: r"""Lists all instances in the given project. + .. code-block:: python + + from google.cloud import spanner_admin_instance_v1 + + def sample_list_instances(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.ListInstancesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_instances(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.spanner_admin_instance_v1.types.ListInstancesRequest, dict]): The request object. The request for @@ -511,6 +572,25 @@ async def get_instance( ) -> spanner_instance_admin.Instance: r"""Gets information about a particular instance. + .. code-block:: python + + from google.cloud import spanner_admin_instance_v1 + + def sample_get_instance(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.GetInstanceRequest( + name="name_value", + ) + + # Make the request + response = client.get_instance(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_instance_v1.types.GetInstanceRequest, dict]): The request object. The request for @@ -632,6 +712,37 @@ async def create_instance( is [Instance][google.spanner.admin.instance.v1.Instance], if successful. + + .. code-block:: python + + from google.cloud import spanner_admin_instance_v1 + + def sample_create_instance(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + instance = spanner_admin_instance_v1.Instance() + instance.name = "name_value" + instance.config = "config_value" + instance.display_name = "display_name_value" + + request = spanner_admin_instance_v1.CreateInstanceRequest( + parent="parent_value", + instance_id="instance_id_value", + instance=instance, + ) + + # Make the request + operation = client.create_instance(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_instance_v1.types.CreateInstanceRequest, dict]): The request object. The request for @@ -780,6 +891,35 @@ async def update_instance( on resource [name][google.spanner.admin.instance.v1.Instance.name]. + + .. code-block:: python + + from google.cloud import spanner_admin_instance_v1 + + def sample_update_instance(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + instance = spanner_admin_instance_v1.Instance() + instance.name = "name_value" + instance.config = "config_value" + instance.display_name = "display_name_value" + + request = spanner_admin_instance_v1.UpdateInstanceRequest( + instance=instance, + ) + + # Make the request + operation = client.update_instance(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_instance_v1.types.UpdateInstanceRequest, dict]): The request object. The request for @@ -892,6 +1032,23 @@ async def delete_instance( irrevocably disappear from the API. All data in the databases is permanently deleted. + + .. code-block:: python + + from google.cloud import spanner_admin_instance_v1 + + def sample_delete_instance(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.DeleteInstanceRequest( + name="name_value", + ) + + # Make the request + client.delete_instance(request=request) + Args: request (Union[google.cloud.spanner_admin_instance_v1.types.DeleteInstanceRequest, dict]): The request object. The request for @@ -971,6 +1128,26 @@ async def set_iam_policy( Authorization requires ``spanner.instances.setIamPolicy`` on [resource][google.iam.v1.SetIamPolicyRequest.resource]. + + .. code-block:: python + + from google.cloud import spanner_admin_instance_v1 + + def sample_set_iam_policy(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): The request object. Request message for `SetIamPolicy` @@ -1102,6 +1279,26 @@ async def get_iam_policy( Authorization requires ``spanner.instances.getIamPolicy`` on [resource][google.iam.v1.GetIamPolicyRequest.resource]. + + .. code-block:: python + + from google.cloud import spanner_admin_instance_v1 + + def sample_get_iam_policy(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): The request object. Request message for `GetIamPolicy` @@ -1245,6 +1442,27 @@ async def test_iam_permissions( ``spanner.instances.list`` permission on the containing Google Cloud Project. Otherwise returns an empty set of permissions. + + .. code-block:: python + + from google.cloud import spanner_admin_instance_v1 + + def sample_test_iam_permissions(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): The request object. Request message for diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py index 66e1ebe8c2..89eb1c5e68 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -448,6 +448,27 @@ def list_instance_configs( r"""Lists the supported instance configurations for a given project. + + .. code-block:: python + + from google.cloud import spanner_admin_instance_v1 + + def sample_list_instance_configs(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.ListInstanceConfigsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_instance_configs(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.spanner_admin_instance_v1.types.ListInstanceConfigsRequest, dict]): The request object. The request for @@ -530,6 +551,26 @@ def get_instance_config( r"""Gets information about a particular instance configuration. + + .. code-block:: python + + from google.cloud import spanner_admin_instance_v1 + + def sample_get_instance_config(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.GetInstanceConfigRequest( + name="name_value", + ) + + # Make the request + response = client.get_instance_config(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_instance_v1.types.GetInstanceConfigRequest, dict]): The request object. The request for @@ -604,6 +645,26 @@ def list_instances( ) -> pagers.ListInstancesPager: r"""Lists all instances in the given project. + .. code-block:: python + + from google.cloud import spanner_admin_instance_v1 + + def sample_list_instances(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.ListInstancesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_instances(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.spanner_admin_instance_v1.types.ListInstancesRequest, dict]): The request object. The request for @@ -685,6 +746,25 @@ def get_instance( ) -> spanner_instance_admin.Instance: r"""Gets information about a particular instance. + .. code-block:: python + + from google.cloud import spanner_admin_instance_v1 + + def sample_get_instance(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.GetInstanceRequest( + name="name_value", + ) + + # Make the request + response = client.get_instance(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_instance_v1.types.GetInstanceRequest, dict]): The request object. The request for @@ -796,6 +876,37 @@ def create_instance( is [Instance][google.spanner.admin.instance.v1.Instance], if successful. + + .. code-block:: python + + from google.cloud import spanner_admin_instance_v1 + + def sample_create_instance(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + instance = spanner_admin_instance_v1.Instance() + instance.name = "name_value" + instance.config = "config_value" + instance.display_name = "display_name_value" + + request = spanner_admin_instance_v1.CreateInstanceRequest( + parent="parent_value", + instance_id="instance_id_value", + instance=instance, + ) + + # Make the request + operation = client.create_instance(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_instance_v1.types.CreateInstanceRequest, dict]): The request object. The request for @@ -944,6 +1055,35 @@ def update_instance( on resource [name][google.spanner.admin.instance.v1.Instance.name]. + + .. code-block:: python + + from google.cloud import spanner_admin_instance_v1 + + def sample_update_instance(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + instance = spanner_admin_instance_v1.Instance() + instance.name = "name_value" + instance.config = "config_value" + instance.display_name = "display_name_value" + + request = spanner_admin_instance_v1.UpdateInstanceRequest( + instance=instance, + ) + + # Make the request + operation = client.update_instance(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_admin_instance_v1.types.UpdateInstanceRequest, dict]): The request object. The request for @@ -1056,6 +1196,23 @@ def delete_instance( irrevocably disappear from the API. All data in the databases is permanently deleted. + + .. code-block:: python + + from google.cloud import spanner_admin_instance_v1 + + def sample_delete_instance(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.DeleteInstanceRequest( + name="name_value", + ) + + # Make the request + client.delete_instance(request=request) + Args: request (Union[google.cloud.spanner_admin_instance_v1.types.DeleteInstanceRequest, dict]): The request object. The request for @@ -1125,6 +1282,26 @@ def set_iam_policy( Authorization requires ``spanner.instances.setIamPolicy`` on [resource][google.iam.v1.SetIamPolicyRequest.resource]. + + .. code-block:: python + + from google.cloud import spanner_admin_instance_v1 + + def sample_set_iam_policy(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): The request object. Request message for `SetIamPolicy` @@ -1255,6 +1432,26 @@ def get_iam_policy( Authorization requires ``spanner.instances.getIamPolicy`` on [resource][google.iam.v1.GetIamPolicyRequest.resource]. + + .. code-block:: python + + from google.cloud import spanner_admin_instance_v1 + + def sample_get_iam_policy(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): The request object. Request message for `GetIamPolicy` @@ -1387,6 +1584,27 @@ def test_iam_permissions( ``spanner.instances.list`` permission on the containing Google Cloud Project. Otherwise returns an empty set of permissions. + + .. code-block:: python + + from google.cloud import spanner_admin_instance_v1 + + def sample_test_iam_permissions(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): The request object. Request message for diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/pagers.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/pagers.py index 670978ab27..aec3583c56 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/pagers.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/__init__.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/__init__.py index cdcf8eb941..30872fa32a 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/__init__.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py index f059f8eb67..a6375d12b9 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py index 366d6b9a88..d6b043af68 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc_asyncio.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc_asyncio.py index 6ae38bdb42..830b947a8f 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc_asyncio.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_admin_instance_v1/types/__init__.py b/google/cloud/spanner_admin_instance_v1/types/__init__.py index 4833678c88..e403b6f3b6 100644 --- a/google/cloud/spanner_admin_instance_v1/types/__init__.py +++ b/google/cloud/spanner_admin_instance_v1/types/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py b/google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py index 51d4fbcc25..56bf55a560 100644 --- a/google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py +++ b/google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_v1/services/__init__.py b/google/cloud/spanner_v1/services/__init__.py index 4de65971c2..e8e1c3845d 100644 --- a/google/cloud/spanner_v1/services/__init__.py +++ b/google/cloud/spanner_v1/services/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_v1/services/spanner/__init__.py b/google/cloud/spanner_v1/services/spanner/__init__.py index 53f14ea629..106bb31c15 100644 --- a/google/cloud/spanner_v1/services/spanner/__init__.py +++ b/google/cloud/spanner_v1/services/spanner/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_v1/services/spanner/async_client.py b/google/cloud/spanner_v1/services/spanner/async_client.py index cc01d8d659..9fd1c6a75b 100644 --- a/google/cloud/spanner_v1/services/spanner/async_client.py +++ b/google/cloud/spanner_v1/services/spanner/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -244,6 +244,26 @@ async def create_session( Idle sessions can be kept alive by sending a trivial SQL query periodically, e.g., ``"SELECT 1"``. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_create_session(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.CreateSessionRequest( + database="database_value", + ) + + # Make the request + response = client.create_session(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_v1.types.CreateSessionRequest, dict]): The request object. The request for @@ -326,6 +346,27 @@ async def batch_create_sessions( the clients. See https://goo.gl/TgSFN2 for best practices on session cache management. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_batch_create_sessions(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.BatchCreateSessionsRequest( + database="database_value", + session_count=1420, + ) + + # Make the request + response = client.batch_create_sessions(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_v1.types.BatchCreateSessionsRequest, dict]): The request object. The request for @@ -422,6 +463,26 @@ async def get_session( exist. This is mainly useful for determining whether a session is still alive. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_get_session(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.GetSessionRequest( + name="name_value", + ) + + # Make the request + response = client.get_session(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_v1.types.GetSessionRequest, dict]): The request object. The request for @@ -500,6 +561,26 @@ async def list_sessions( ) -> pagers.ListSessionsAsyncPager: r"""Lists all sessions in a given database. + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_list_sessions(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.ListSessionsRequest( + database="database_value", + ) + + # Make the request + page_result = client.list_sessions(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.spanner_v1.types.ListSessionsRequest, dict]): The request object. The request for @@ -591,6 +672,23 @@ async def delete_session( with it. This will asynchronously trigger cancellation of any operations that are running with this session. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_delete_session(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.DeleteSessionRequest( + name="name_value", + ) + + # Make the request + client.delete_session(request=request) + Args: request (Union[google.cloud.spanner_v1.types.DeleteSessionRequest, dict]): The request object. The request for @@ -676,6 +774,27 @@ async def execute_sql( [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] instead. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_execute_sql(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.ExecuteSqlRequest( + session="session_value", + sql="sql_value", + ) + + # Make the request + response = client.execute_sql(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_v1.types.ExecuteSqlRequest, dict]): The request object. The request for @@ -740,6 +859,28 @@ def execute_streaming_sql( individual row in the result set can exceed 100 MiB, and no column value can exceed 10 MiB. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_execute_streaming_sql(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.ExecuteSqlRequest( + session="session_value", + sql="sql_value", + ) + + # Make the request + stream = client.execute_streaming_sql(request=request) + + # Handle the response + for response in stream: + print(response) + Args: request (Union[google.cloud.spanner_v1.types.ExecuteSqlRequest, dict]): The request object. The request for @@ -806,6 +947,31 @@ async def execute_batch_dml( Execution stops after the first failed statement; the remaining statements are not executed. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_execute_batch_dml(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + statements = spanner_v1.Statement() + statements.sql = "sql_value" + + request = spanner_v1.ExecuteBatchDmlRequest( + session="session_value", + statements=statements, + seqno=550, + ) + + # Make the request + response = client.execute_batch_dml(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_v1.types.ExecuteBatchDmlRequest, dict]): The request object. The request for @@ -915,6 +1081,28 @@ async def read( calling [StreamingRead][google.spanner.v1.Spanner.StreamingRead] instead. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_read(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.ReadRequest( + session="session_value", + table="table_value", + columns=['columns_value_1', 'columns_value_2'], + ) + + # Make the request + response = client.read(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_v1.types.ReadRequest, dict]): The request object. The request for @@ -979,6 +1167,29 @@ def streaming_read( the result set can exceed 100 MiB, and no column value can exceed 10 MiB. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_streaming_read(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.ReadRequest( + session="session_value", + table="table_value", + columns=['columns_value_1', 'columns_value_2'], + ) + + # Make the request + stream = client.streaming_read(request=request) + + # Handle the response + for response in stream: + print(response) + Args: request (Union[google.cloud.spanner_v1.types.ReadRequest, dict]): The request object. The request for @@ -1038,6 +1249,26 @@ async def begin_transaction( [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a side-effect. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_begin_transaction(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.BeginTransactionRequest( + session="session_value", + ) + + # Make the request + response = client.begin_transaction(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_v1.types.BeginTransactionRequest, dict]): The request object. The request for @@ -1143,6 +1374,27 @@ async def commit( perform another read from the database to see the state of things as they are now. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_commit(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.CommitRequest( + transaction_id=b'transaction_id_blob', + session="session_value", + ) + + # Make the request + response = client.commit(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_v1.types.CommitRequest, dict]): The request object. The request for @@ -1272,6 +1524,24 @@ async def rollback( transaction is not found. ``Rollback`` never returns ``ABORTED``. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_rollback(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.RollbackRequest( + session="session_value", + transaction_id=b'transaction_id_blob', + ) + + # Make the request + client.rollback(request=request) + Args: request (Union[google.cloud.spanner_v1.types.RollbackRequest, dict]): The request object. The request for @@ -1366,6 +1636,27 @@ async def partition_query( to resume the query, and the whole operation must be restarted from the beginning. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_partition_query(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.PartitionQueryRequest( + session="session_value", + sql="sql_value", + ) + + # Make the request + response = client.partition_query(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_v1.types.PartitionQueryRequest, dict]): The request object. The request for @@ -1441,6 +1732,27 @@ async def partition_read( to resume the read, and the whole operation must be restarted from the beginning. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_partition_read(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.PartitionReadRequest( + session="session_value", + table="table_value", + ) + + # Make the request + response = client.partition_read(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_v1.types.PartitionReadRequest, dict]): The request object. The request for diff --git a/google/cloud/spanner_v1/services/spanner/client.py b/google/cloud/spanner_v1/services/spanner/client.py index b701d16d29..31f274b0db 100644 --- a/google/cloud/spanner_v1/services/spanner/client.py +++ b/google/cloud/spanner_v1/services/spanner/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -452,6 +452,26 @@ def create_session( Idle sessions can be kept alive by sending a trivial SQL query periodically, e.g., ``"SELECT 1"``. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_create_session(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.CreateSessionRequest( + database="database_value", + ) + + # Make the request + response = client.create_session(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_v1.types.CreateSessionRequest, dict]): The request object. The request for @@ -525,6 +545,27 @@ def batch_create_sessions( the clients. See https://goo.gl/TgSFN2 for best practices on session cache management. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_batch_create_sessions(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.BatchCreateSessionsRequest( + database="database_value", + session_count=1420, + ) + + # Make the request + response = client.batch_create_sessions(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_v1.types.BatchCreateSessionsRequest, dict]): The request object. The request for @@ -612,6 +653,26 @@ def get_session( exist. This is mainly useful for determining whether a session is still alive. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_get_session(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.GetSessionRequest( + name="name_value", + ) + + # Make the request + response = client.get_session(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_v1.types.GetSessionRequest, dict]): The request object. The request for @@ -681,6 +742,26 @@ def list_sessions( ) -> pagers.ListSessionsPager: r"""Lists all sessions in a given database. + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_list_sessions(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.ListSessionsRequest( + database="database_value", + ) + + # Make the request + page_result = client.list_sessions(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.spanner_v1.types.ListSessionsRequest, dict]): The request object. The request for @@ -763,6 +844,23 @@ def delete_session( with it. This will asynchronously trigger cancellation of any operations that are running with this session. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_delete_session(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.DeleteSessionRequest( + name="name_value", + ) + + # Make the request + client.delete_session(request=request) + Args: request (Union[google.cloud.spanner_v1.types.DeleteSessionRequest, dict]): The request object. The request for @@ -839,6 +937,27 @@ def execute_sql( [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] instead. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_execute_sql(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.ExecuteSqlRequest( + session="session_value", + sql="sql_value", + ) + + # Make the request + response = client.execute_sql(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_v1.types.ExecuteSqlRequest, dict]): The request object. The request for @@ -895,6 +1014,28 @@ def execute_streaming_sql( individual row in the result set can exceed 100 MiB, and no column value can exceed 10 MiB. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_execute_streaming_sql(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.ExecuteSqlRequest( + session="session_value", + sql="sql_value", + ) + + # Make the request + stream = client.execute_streaming_sql(request=request) + + # Handle the response + for response in stream: + print(response) + Args: request (Union[google.cloud.spanner_v1.types.ExecuteSqlRequest, dict]): The request object. The request for @@ -962,6 +1103,31 @@ def execute_batch_dml( Execution stops after the first failed statement; the remaining statements are not executed. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_execute_batch_dml(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + statements = spanner_v1.Statement() + statements.sql = "sql_value" + + request = spanner_v1.ExecuteBatchDmlRequest( + session="session_value", + statements=statements, + seqno=550, + ) + + # Make the request + response = client.execute_batch_dml(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_v1.types.ExecuteBatchDmlRequest, dict]): The request object. The request for @@ -1063,6 +1229,28 @@ def read( calling [StreamingRead][google.spanner.v1.Spanner.StreamingRead] instead. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_read(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.ReadRequest( + session="session_value", + table="table_value", + columns=['columns_value_1', 'columns_value_2'], + ) + + # Make the request + response = client.read(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_v1.types.ReadRequest, dict]): The request object. The request for @@ -1119,6 +1307,29 @@ def streaming_read( the result set can exceed 100 MiB, and no column value can exceed 10 MiB. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_streaming_read(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.ReadRequest( + session="session_value", + table="table_value", + columns=['columns_value_1', 'columns_value_2'], + ) + + # Make the request + stream = client.streaming_read(request=request) + + # Handle the response + for response in stream: + print(response) + Args: request (Union[google.cloud.spanner_v1.types.ReadRequest, dict]): The request object. The request for @@ -1179,6 +1390,26 @@ def begin_transaction( [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a side-effect. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_begin_transaction(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.BeginTransactionRequest( + session="session_value", + ) + + # Make the request + response = client.begin_transaction(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_v1.types.BeginTransactionRequest, dict]): The request object. The request for @@ -1275,6 +1506,27 @@ def commit( perform another read from the database to see the state of things as they are now. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_commit(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.CommitRequest( + transaction_id=b'transaction_id_blob', + session="session_value", + ) + + # Make the request + response = client.commit(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_v1.types.CommitRequest, dict]): The request object. The request for @@ -1395,6 +1647,24 @@ def rollback( transaction is not found. ``Rollback`` never returns ``ABORTED``. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_rollback(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.RollbackRequest( + session="session_value", + transaction_id=b'transaction_id_blob', + ) + + # Make the request + client.rollback(request=request) + Args: request (Union[google.cloud.spanner_v1.types.RollbackRequest, dict]): The request object. The request for @@ -1480,6 +1750,27 @@ def partition_query( to resume the query, and the whole operation must be restarted from the beginning. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_partition_query(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.PartitionQueryRequest( + session="session_value", + sql="sql_value", + ) + + # Make the request + response = client.partition_query(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_v1.types.PartitionQueryRequest, dict]): The request object. The request for @@ -1547,6 +1838,27 @@ def partition_read( to resume the read, and the whole operation must be restarted from the beginning. + + .. code-block:: python + + from google.cloud import spanner_v1 + + def sample_partition_read(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.PartitionReadRequest( + session="session_value", + table="table_value", + ) + + # Make the request + response = client.partition_read(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.spanner_v1.types.PartitionReadRequest, dict]): The request object. The request for diff --git a/google/cloud/spanner_v1/services/spanner/pagers.py b/google/cloud/spanner_v1/services/spanner/pagers.py index 8b73b00fda..ff83dc50d5 100644 --- a/google/cloud/spanner_v1/services/spanner/pagers.py +++ b/google/cloud/spanner_v1/services/spanner/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_v1/services/spanner/transports/__init__.py b/google/cloud/spanner_v1/services/spanner/transports/__init__.py index 189d62b427..ac786d2f15 100644 --- a/google/cloud/spanner_v1/services/spanner/transports/__init__.py +++ b/google/cloud/spanner_v1/services/spanner/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_v1/services/spanner/transports/base.py b/google/cloud/spanner_v1/services/spanner/transports/base.py index f3d946b51d..40ef03a812 100644 --- a/google/cloud/spanner_v1/services/spanner/transports/base.py +++ b/google/cloud/spanner_v1/services/spanner/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_v1/services/spanner/transports/grpc.py b/google/cloud/spanner_v1/services/spanner/transports/grpc.py index f5cdfc3fec..d33a89b694 100644 --- a/google/cloud/spanner_v1/services/spanner/transports/grpc.py +++ b/google/cloud/spanner_v1/services/spanner/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_v1/services/spanner/transports/grpc_asyncio.py b/google/cloud/spanner_v1/services/spanner/transports/grpc_asyncio.py index 14e086d313..95d58bc06a 100644 --- a/google/cloud/spanner_v1/services/spanner/transports/grpc_asyncio.py +++ b/google/cloud/spanner_v1/services/spanner/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_v1/types/__init__.py b/google/cloud/spanner_v1/types/__init__.py index 01dde4208a..1ad35d70ed 100644 --- a/google/cloud/spanner_v1/types/__init__.py +++ b/google/cloud/spanner_v1/types/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_v1/types/commit_response.py b/google/cloud/spanner_v1/types/commit_response.py index e9a289f0ce..2d03f35ba5 100644 --- a/google/cloud/spanner_v1/types/commit_response.py +++ b/google/cloud/spanner_v1/types/commit_response.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_v1/types/keys.py b/google/cloud/spanner_v1/types/keys.py index d0ec1e92b7..6486b7ce6d 100644 --- a/google/cloud/spanner_v1/types/keys.py +++ b/google/cloud/spanner_v1/types/keys.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_v1/types/mutation.py b/google/cloud/spanner_v1/types/mutation.py index 5cbd660c0f..700efb15cc 100644 --- a/google/cloud/spanner_v1/types/mutation.py +++ b/google/cloud/spanner_v1/types/mutation.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_v1/types/query_plan.py b/google/cloud/spanner_v1/types/query_plan.py index 27df7bc908..c003aaadd0 100644 --- a/google/cloud/spanner_v1/types/query_plan.py +++ b/google/cloud/spanner_v1/types/query_plan.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_v1/types/result_set.py b/google/cloud/spanner_v1/types/result_set.py index bd5d5ebfbb..30862d1bd0 100644 --- a/google/cloud/spanner_v1/types/result_set.py +++ b/google/cloud/spanner_v1/types/result_set.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_v1/types/spanner.py b/google/cloud/spanner_v1/types/spanner.py index 2bdde094eb..cea8be56a9 100644 --- a/google/cloud/spanner_v1/types/spanner.py +++ b/google/cloud/spanner_v1/types/spanner.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -62,7 +62,7 @@ class CreateSessionRequest(proto.Message): Required. The database in which the new session is created. session (google.cloud.spanner_v1.types.Session): - The session to create. + Required. The session to create. """ database = proto.Field(proto.STRING, number=1,) diff --git a/google/cloud/spanner_v1/types/transaction.py b/google/cloud/spanner_v1/types/transaction.py index 04b8552a48..d8b9c31bc4 100644 --- a/google/cloud/spanner_v1/types/transaction.py +++ b/google/cloud/spanner_v1/types/transaction.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/spanner_v1/types/type.py b/google/cloud/spanner_v1/types/type.py index 5673fcb77d..0bba5fe7e6 100644 --- a/google/cloud/spanner_v1/types/type.py +++ b/google/cloud/spanner_v1/types/type.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/samples/generated_samples/snippet_metadata_spanner admin database_v1.json b/samples/generated_samples/snippet_metadata_spanner admin database_v1.json new file mode 100644 index 0000000000..10a85bf3f2 --- /dev/null +++ b/samples/generated_samples/snippet_metadata_spanner admin database_v1.json @@ -0,0 +1,1509 @@ +{ + "snippets": [ + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "CreateBackup" + } + }, + "file": "spanner_v1_generated_database_admin_create_backup_async.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_CreateBackup_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "CreateBackup" + } + }, + "file": "spanner_v1_generated_database_admin_create_backup_sync.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_CreateBackup_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "CreateDatabase" + } + }, + "file": "spanner_v1_generated_database_admin_create_database_async.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_CreateDatabase_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "CreateDatabase" + } + }, + "file": "spanner_v1_generated_database_admin_create_database_sync.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_CreateDatabase_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "DeleteBackup" + } + }, + "file": "spanner_v1_generated_database_admin_delete_backup_async.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_DeleteBackup_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "DeleteBackup" + } + }, + "file": "spanner_v1_generated_database_admin_delete_backup_sync.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_DeleteBackup_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "DropDatabase" + } + }, + "file": "spanner_v1_generated_database_admin_drop_database_async.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_DropDatabase_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "DropDatabase" + } + }, + "file": "spanner_v1_generated_database_admin_drop_database_sync.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_DropDatabase_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "GetBackup" + } + }, + "file": "spanner_v1_generated_database_admin_get_backup_async.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_GetBackup_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "GetBackup" + } + }, + "file": "spanner_v1_generated_database_admin_get_backup_sync.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_GetBackup_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "GetDatabaseDdl" + } + }, + "file": "spanner_v1_generated_database_admin_get_database_ddl_async.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_GetDatabaseDdl_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "GetDatabaseDdl" + } + }, + "file": "spanner_v1_generated_database_admin_get_database_ddl_sync.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_GetDatabaseDdl_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "GetDatabase" + } + }, + "file": "spanner_v1_generated_database_admin_get_database_async.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_GetDatabase_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "GetDatabase" + } + }, + "file": "spanner_v1_generated_database_admin_get_database_sync.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_GetDatabase_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "GetIamPolicy" + } + }, + "file": "spanner_v1_generated_database_admin_get_iam_policy_async.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_GetIamPolicy_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "GetIamPolicy" + } + }, + "file": "spanner_v1_generated_database_admin_get_iam_policy_sync.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_GetIamPolicy_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "ListBackupOperations" + } + }, + "file": "spanner_v1_generated_database_admin_list_backup_operations_async.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_ListBackupOperations_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "ListBackupOperations" + } + }, + "file": "spanner_v1_generated_database_admin_list_backup_operations_sync.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_ListBackupOperations_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "ListBackups" + } + }, + "file": "spanner_v1_generated_database_admin_list_backups_async.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_ListBackups_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "ListBackups" + } + }, + "file": "spanner_v1_generated_database_admin_list_backups_sync.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_ListBackups_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "ListDatabaseOperations" + } + }, + "file": "spanner_v1_generated_database_admin_list_database_operations_async.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_ListDatabaseOperations_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "ListDatabaseOperations" + } + }, + "file": "spanner_v1_generated_database_admin_list_database_operations_sync.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_ListDatabaseOperations_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "ListDatabases" + } + }, + "file": "spanner_v1_generated_database_admin_list_databases_async.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_ListDatabases_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "ListDatabases" + } + }, + "file": "spanner_v1_generated_database_admin_list_databases_sync.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_ListDatabases_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "RestoreDatabase" + } + }, + "file": "spanner_v1_generated_database_admin_restore_database_async.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_RestoreDatabase_async", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 40, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "RestoreDatabase" + } + }, + "file": "spanner_v1_generated_database_admin_restore_database_sync.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_RestoreDatabase_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 40, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "SetIamPolicy" + } + }, + "file": "spanner_v1_generated_database_admin_set_iam_policy_async.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_SetIamPolicy_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "SetIamPolicy" + } + }, + "file": "spanner_v1_generated_database_admin_set_iam_policy_sync.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_SetIamPolicy_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "TestIamPermissions" + } + }, + "file": "spanner_v1_generated_database_admin_test_iam_permissions_async.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_TestIamPermissions_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "TestIamPermissions" + } + }, + "file": "spanner_v1_generated_database_admin_test_iam_permissions_sync.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_TestIamPermissions_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "UpdateBackup" + } + }, + "file": "spanner_v1_generated_database_admin_update_backup_async.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_UpdateBackup_async", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "UpdateBackup" + } + }, + "file": "spanner_v1_generated_database_admin_update_backup_sync.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_UpdateBackup_sync", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "UpdateDatabaseDdl" + } + }, + "file": "spanner_v1_generated_database_admin_update_database_ddl_async.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_UpdateDatabaseDdl_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "UpdateDatabaseDdl" + } + }, + "file": "spanner_v1_generated_database_admin_update_database_ddl_sync.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_UpdateDatabaseDdl_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + } + ] +} diff --git a/samples/generated_samples/snippet_metadata_spanner admin instance_v1.json b/samples/generated_samples/snippet_metadata_spanner admin instance_v1.json new file mode 100644 index 0000000000..07c69a762e --- /dev/null +++ b/samples/generated_samples/snippet_metadata_spanner admin instance_v1.json @@ -0,0 +1,890 @@ +{ + "snippets": [ + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "InstanceAdmin" + }, + "shortName": "CreateInstance" + } + }, + "file": "spanner_v1_generated_instance_admin_create_instance_async.py", + "regionTag": "spanner_v1_generated_InstanceAdmin_CreateInstance_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "InstanceAdmin" + }, + "shortName": "CreateInstance" + } + }, + "file": "spanner_v1_generated_instance_admin_create_instance_sync.py", + "regionTag": "spanner_v1_generated_InstanceAdmin_CreateInstance_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "InstanceAdmin" + }, + "shortName": "DeleteInstance" + } + }, + "file": "spanner_v1_generated_instance_admin_delete_instance_async.py", + "regionTag": "spanner_v1_generated_InstanceAdmin_DeleteInstance_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "InstanceAdmin" + }, + "shortName": "DeleteInstance" + } + }, + "file": "spanner_v1_generated_instance_admin_delete_instance_sync.py", + "regionTag": "spanner_v1_generated_InstanceAdmin_DeleteInstance_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "InstanceAdmin" + }, + "shortName": "GetIamPolicy" + } + }, + "file": "spanner_v1_generated_instance_admin_get_iam_policy_async.py", + "regionTag": "spanner_v1_generated_InstanceAdmin_GetIamPolicy_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "InstanceAdmin" + }, + "shortName": "GetIamPolicy" + } + }, + "file": "spanner_v1_generated_instance_admin_get_iam_policy_sync.py", + "regionTag": "spanner_v1_generated_InstanceAdmin_GetIamPolicy_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "InstanceAdmin" + }, + "shortName": "GetInstanceConfig" + } + }, + "file": "spanner_v1_generated_instance_admin_get_instance_config_async.py", + "regionTag": "spanner_v1_generated_InstanceAdmin_GetInstanceConfig_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "InstanceAdmin" + }, + "shortName": "GetInstanceConfig" + } + }, + "file": "spanner_v1_generated_instance_admin_get_instance_config_sync.py", + "regionTag": "spanner_v1_generated_InstanceAdmin_GetInstanceConfig_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "InstanceAdmin" + }, + "shortName": "GetInstance" + } + }, + "file": "spanner_v1_generated_instance_admin_get_instance_async.py", + "regionTag": "spanner_v1_generated_InstanceAdmin_GetInstance_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "InstanceAdmin" + }, + "shortName": "GetInstance" + } + }, + "file": "spanner_v1_generated_instance_admin_get_instance_sync.py", + "regionTag": "spanner_v1_generated_InstanceAdmin_GetInstance_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "InstanceAdmin" + }, + "shortName": "ListInstanceConfigs" + } + }, + "file": "spanner_v1_generated_instance_admin_list_instance_configs_async.py", + "regionTag": "spanner_v1_generated_InstanceAdmin_ListInstanceConfigs_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "InstanceAdmin" + }, + "shortName": "ListInstanceConfigs" + } + }, + "file": "spanner_v1_generated_instance_admin_list_instance_configs_sync.py", + "regionTag": "spanner_v1_generated_InstanceAdmin_ListInstanceConfigs_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "InstanceAdmin" + }, + "shortName": "ListInstances" + } + }, + "file": "spanner_v1_generated_instance_admin_list_instances_async.py", + "regionTag": "spanner_v1_generated_InstanceAdmin_ListInstances_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "InstanceAdmin" + }, + "shortName": "ListInstances" + } + }, + "file": "spanner_v1_generated_instance_admin_list_instances_sync.py", + "regionTag": "spanner_v1_generated_InstanceAdmin_ListInstances_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "InstanceAdmin" + }, + "shortName": "SetIamPolicy" + } + }, + "file": "spanner_v1_generated_instance_admin_set_iam_policy_async.py", + "regionTag": "spanner_v1_generated_InstanceAdmin_SetIamPolicy_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "InstanceAdmin" + }, + "shortName": "SetIamPolicy" + } + }, + "file": "spanner_v1_generated_instance_admin_set_iam_policy_sync.py", + "regionTag": "spanner_v1_generated_InstanceAdmin_SetIamPolicy_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "InstanceAdmin" + }, + "shortName": "TestIamPermissions" + } + }, + "file": "spanner_v1_generated_instance_admin_test_iam_permissions_async.py", + "regionTag": "spanner_v1_generated_InstanceAdmin_TestIamPermissions_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "InstanceAdmin" + }, + "shortName": "TestIamPermissions" + } + }, + "file": "spanner_v1_generated_instance_admin_test_iam_permissions_sync.py", + "regionTag": "spanner_v1_generated_InstanceAdmin_TestIamPermissions_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "InstanceAdmin" + }, + "shortName": "UpdateInstance" + } + }, + "file": "spanner_v1_generated_instance_admin_update_instance_async.py", + "regionTag": "spanner_v1_generated_InstanceAdmin_UpdateInstance_async", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "InstanceAdmin" + }, + "shortName": "UpdateInstance" + } + }, + "file": "spanner_v1_generated_instance_admin_update_instance_sync.py", + "regionTag": "spanner_v1_generated_InstanceAdmin_UpdateInstance_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ] + } + ] +} diff --git a/samples/generated_samples/snippet_metadata_spanner_v1.json b/samples/generated_samples/snippet_metadata_spanner_v1.json new file mode 100644 index 0000000000..3303488e27 --- /dev/null +++ b/samples/generated_samples/snippet_metadata_spanner_v1.json @@ -0,0 +1,1331 @@ +{ + "snippets": [ + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "BatchCreateSessions" + } + }, + "file": "spanner_v1_generated_spanner_batch_create_sessions_async.py", + "regionTag": "spanner_v1_generated_Spanner_BatchCreateSessions_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "BatchCreateSessions" + } + }, + "file": "spanner_v1_generated_spanner_batch_create_sessions_sync.py", + "regionTag": "spanner_v1_generated_Spanner_BatchCreateSessions_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "BeginTransaction" + } + }, + "file": "spanner_v1_generated_spanner_begin_transaction_async.py", + "regionTag": "spanner_v1_generated_Spanner_BeginTransaction_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "BeginTransaction" + } + }, + "file": "spanner_v1_generated_spanner_begin_transaction_sync.py", + "regionTag": "spanner_v1_generated_Spanner_BeginTransaction_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "Commit" + } + }, + "file": "spanner_v1_generated_spanner_commit_async.py", + "regionTag": "spanner_v1_generated_Spanner_Commit_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "Commit" + } + }, + "file": "spanner_v1_generated_spanner_commit_sync.py", + "regionTag": "spanner_v1_generated_Spanner_Commit_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "CreateSession" + } + }, + "file": "spanner_v1_generated_spanner_create_session_async.py", + "regionTag": "spanner_v1_generated_Spanner_CreateSession_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "CreateSession" + } + }, + "file": "spanner_v1_generated_spanner_create_session_sync.py", + "regionTag": "spanner_v1_generated_Spanner_CreateSession_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "DeleteSession" + } + }, + "file": "spanner_v1_generated_spanner_delete_session_async.py", + "regionTag": "spanner_v1_generated_Spanner_DeleteSession_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "DeleteSession" + } + }, + "file": "spanner_v1_generated_spanner_delete_session_sync.py", + "regionTag": "spanner_v1_generated_Spanner_DeleteSession_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "ExecuteBatchDml" + } + }, + "file": "spanner_v1_generated_spanner_execute_batch_dml_async.py", + "regionTag": "spanner_v1_generated_Spanner_ExecuteBatchDml_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "ExecuteBatchDml" + } + }, + "file": "spanner_v1_generated_spanner_execute_batch_dml_sync.py", + "regionTag": "spanner_v1_generated_Spanner_ExecuteBatchDml_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "ExecuteSql" + } + }, + "file": "spanner_v1_generated_spanner_execute_sql_async.py", + "regionTag": "spanner_v1_generated_Spanner_ExecuteSql_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "ExecuteSql" + } + }, + "file": "spanner_v1_generated_spanner_execute_sql_sync.py", + "regionTag": "spanner_v1_generated_Spanner_ExecuteSql_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "ExecuteStreamingSql" + } + }, + "file": "spanner_v1_generated_spanner_execute_streaming_sql_async.py", + "regionTag": "spanner_v1_generated_Spanner_ExecuteStreamingSql_async", + "segments": [ + { + "end": 46, + "start": 27, + "type": "FULL" + }, + { + "end": 46, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 47, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "ExecuteStreamingSql" + } + }, + "file": "spanner_v1_generated_spanner_execute_streaming_sql_sync.py", + "regionTag": "spanner_v1_generated_Spanner_ExecuteStreamingSql_sync", + "segments": [ + { + "end": 46, + "start": 27, + "type": "FULL" + }, + { + "end": 46, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 47, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "GetSession" + } + }, + "file": "spanner_v1_generated_spanner_get_session_async.py", + "regionTag": "spanner_v1_generated_Spanner_GetSession_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "GetSession" + } + }, + "file": "spanner_v1_generated_spanner_get_session_sync.py", + "regionTag": "spanner_v1_generated_Spanner_GetSession_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "ListSessions" + } + }, + "file": "spanner_v1_generated_spanner_list_sessions_async.py", + "regionTag": "spanner_v1_generated_Spanner_ListSessions_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "ListSessions" + } + }, + "file": "spanner_v1_generated_spanner_list_sessions_sync.py", + "regionTag": "spanner_v1_generated_Spanner_ListSessions_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "PartitionQuery" + } + }, + "file": "spanner_v1_generated_spanner_partition_query_async.py", + "regionTag": "spanner_v1_generated_Spanner_PartitionQuery_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "PartitionQuery" + } + }, + "file": "spanner_v1_generated_spanner_partition_query_sync.py", + "regionTag": "spanner_v1_generated_Spanner_PartitionQuery_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "PartitionRead" + } + }, + "file": "spanner_v1_generated_spanner_partition_read_async.py", + "regionTag": "spanner_v1_generated_Spanner_PartitionRead_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "PartitionRead" + } + }, + "file": "spanner_v1_generated_spanner_partition_read_sync.py", + "regionTag": "spanner_v1_generated_Spanner_PartitionRead_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "Read" + } + }, + "file": "spanner_v1_generated_spanner_read_async.py", + "regionTag": "spanner_v1_generated_Spanner_Read_async", + "segments": [ + { + "end": 46, + "start": 27, + "type": "FULL" + }, + { + "end": 46, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 40, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 43, + "start": 41, + "type": "REQUEST_EXECUTION" + }, + { + "end": 47, + "start": 44, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "Read" + } + }, + "file": "spanner_v1_generated_spanner_read_sync.py", + "regionTag": "spanner_v1_generated_Spanner_Read_sync", + "segments": [ + { + "end": 46, + "start": 27, + "type": "FULL" + }, + { + "end": 46, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 40, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 43, + "start": 41, + "type": "REQUEST_EXECUTION" + }, + { + "end": 47, + "start": 44, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "Rollback" + } + }, + "file": "spanner_v1_generated_spanner_rollback_async.py", + "regionTag": "spanner_v1_generated_Spanner_Rollback_async", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "Rollback" + } + }, + "file": "spanner_v1_generated_spanner_rollback_sync.py", + "regionTag": "spanner_v1_generated_Spanner_Rollback_sync", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "StreamingRead" + } + }, + "file": "spanner_v1_generated_spanner_streaming_read_async.py", + "regionTag": "spanner_v1_generated_Spanner_StreamingRead_async", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 40, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 43, + "start": 41, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 44, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Spanner" + }, + "shortName": "StreamingRead" + } + }, + "file": "spanner_v1_generated_spanner_streaming_read_sync.py", + "regionTag": "spanner_v1_generated_Spanner_StreamingRead_sync", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 40, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 43, + "start": 41, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 44, + "type": "RESPONSE_HANDLING" + } + ] + } + ] +} diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_create_backup_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_create_backup_async.py new file mode 100644 index 0000000000..a1be785e1c --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_create_backup_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for 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-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_CreateBackup_async] +from google.cloud import spanner_admin_database_v1 + + +async def sample_create_backup(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_database_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 spanner_v1_generated_DatabaseAdmin_CreateBackup_async] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_create_backup_sync.py b/samples/generated_samples/spanner_v1_generated_database_admin_create_backup_sync.py new file mode 100644 index 0000000000..1a7ce9f8ca --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_create_backup_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for 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-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_CreateBackup_sync] +from google.cloud import spanner_admin_database_v1 + + +def sample_create_backup(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_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 spanner_v1_generated_DatabaseAdmin_CreateBackup_sync] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_create_database_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_create_database_async.py new file mode 100644 index 0000000000..fced822103 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_create_database_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateDatabase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_CreateDatabase_async] +from google.cloud import spanner_admin_database_v1 + + +async def sample_create_database(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.CreateDatabaseRequest( + parent="parent_value", + create_statement="create_statement_value", + ) + + # Make the request + operation = client.create_database(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_CreateDatabase_async] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_create_database_sync.py b/samples/generated_samples/spanner_v1_generated_database_admin_create_database_sync.py new file mode 100644 index 0000000000..27675447f5 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_create_database_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateDatabase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_CreateDatabase_sync] +from google.cloud import spanner_admin_database_v1 + + +def sample_create_database(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.CreateDatabaseRequest( + parent="parent_value", + create_statement="create_statement_value", + ) + + # Make the request + operation = client.create_database(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_CreateDatabase_sync] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_delete_backup_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_delete_backup_async.py new file mode 100644 index 0000000000..4d59be06df --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_delete_backup_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for 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-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_DeleteBackup_async] +from google.cloud import spanner_admin_database_v1 + + +async def sample_delete_backup(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.DeleteBackupRequest( + name="name_value", + ) + + # Make the request + await client.delete_backup(request=request) + + +# [END spanner_v1_generated_DatabaseAdmin_DeleteBackup_async] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_delete_backup_sync.py b/samples/generated_samples/spanner_v1_generated_database_admin_delete_backup_sync.py new file mode 100644 index 0000000000..7f4ed7f95a --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_delete_backup_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for 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-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_DeleteBackup_sync] +from google.cloud import spanner_admin_database_v1 + + +def sample_delete_backup(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.DeleteBackupRequest( + name="name_value", + ) + + # Make the request + client.delete_backup(request=request) + + +# [END spanner_v1_generated_DatabaseAdmin_DeleteBackup_sync] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_drop_database_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_drop_database_async.py new file mode 100644 index 0000000000..245fbacffb --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_drop_database_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DropDatabase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_DropDatabase_async] +from google.cloud import spanner_admin_database_v1 + + +async def sample_drop_database(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.DropDatabaseRequest( + database="database_value", + ) + + # Make the request + await client.drop_database(request=request) + + +# [END spanner_v1_generated_DatabaseAdmin_DropDatabase_async] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_drop_database_sync.py b/samples/generated_samples/spanner_v1_generated_database_admin_drop_database_sync.py new file mode 100644 index 0000000000..d710e77dbb --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_drop_database_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DropDatabase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_DropDatabase_sync] +from google.cloud import spanner_admin_database_v1 + + +def sample_drop_database(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.DropDatabaseRequest( + database="database_value", + ) + + # Make the request + client.drop_database(request=request) + + +# [END spanner_v1_generated_DatabaseAdmin_DropDatabase_sync] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_get_backup_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_get_backup_async.py new file mode 100644 index 0000000000..a0fa4faa37 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_get_backup_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for 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-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_GetBackup_async] +from google.cloud import spanner_admin_database_v1 + + +async def sample_get_backup(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.GetBackupRequest( + name="name_value", + ) + + # Make the request + response = await client.get_backup(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_GetBackup_async] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_get_backup_sync.py b/samples/generated_samples/spanner_v1_generated_database_admin_get_backup_sync.py new file mode 100644 index 0000000000..fa1b735014 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_get_backup_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for 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-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_GetBackup_sync] +from google.cloud import spanner_admin_database_v1 + + +def sample_get_backup(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.GetBackupRequest( + name="name_value", + ) + + # Make the request + response = client.get_backup(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_GetBackup_sync] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_get_database_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_get_database_async.py new file mode 100644 index 0000000000..37056a3efc --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_get_database_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDatabase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_GetDatabase_async] +from google.cloud import spanner_admin_database_v1 + + +async def sample_get_database(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.GetDatabaseRequest( + name="name_value", + ) + + # Make the request + response = await client.get_database(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_GetDatabase_async] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_get_database_ddl_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_get_database_ddl_async.py new file mode 100644 index 0000000000..ece964619b --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_get_database_ddl_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDatabaseDdl +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_GetDatabaseDdl_async] +from google.cloud import spanner_admin_database_v1 + + +async def sample_get_database_ddl(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.GetDatabaseDdlRequest( + database="database_value", + ) + + # Make the request + response = await client.get_database_ddl(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_GetDatabaseDdl_async] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_get_database_ddl_sync.py b/samples/generated_samples/spanner_v1_generated_database_admin_get_database_ddl_sync.py new file mode 100644 index 0000000000..4272b0eb3d --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_get_database_ddl_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDatabaseDdl +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_GetDatabaseDdl_sync] +from google.cloud import spanner_admin_database_v1 + + +def sample_get_database_ddl(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.GetDatabaseDdlRequest( + database="database_value", + ) + + # Make the request + response = client.get_database_ddl(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_GetDatabaseDdl_sync] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_get_database_sync.py b/samples/generated_samples/spanner_v1_generated_database_admin_get_database_sync.py new file mode 100644 index 0000000000..a1800f30bc --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_get_database_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDatabase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_GetDatabase_sync] +from google.cloud import spanner_admin_database_v1 + + +def sample_get_database(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.GetDatabaseRequest( + name="name_value", + ) + + # Make the request + response = client.get_database(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_GetDatabase_sync] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_get_iam_policy_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_get_iam_policy_async.py new file mode 100644 index 0000000000..b9ef3174d4 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_get_iam_policy_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_GetIamPolicy_async] +from google.cloud import spanner_admin_database_v1 + + +async def sample_get_iam_policy(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.get_iam_policy(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_GetIamPolicy_async] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_get_iam_policy_sync.py b/samples/generated_samples/spanner_v1_generated_database_admin_get_iam_policy_sync.py new file mode 100644 index 0000000000..41c61972c6 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_get_iam_policy_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_GetIamPolicy_sync] +from google.cloud import spanner_admin_database_v1 + + +def sample_get_iam_policy(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_GetIamPolicy_sync] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_list_backup_operations_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_list_backup_operations_async.py new file mode 100644 index 0000000000..bf5ec734d2 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_list_backup_operations_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListBackupOperations +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_ListBackupOperations_async] +from google.cloud import spanner_admin_database_v1 + + +async def sample_list_backup_operations(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.ListBackupOperationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_backup_operations(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_ListBackupOperations_async] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_list_backup_operations_sync.py b/samples/generated_samples/spanner_v1_generated_database_admin_list_backup_operations_sync.py new file mode 100644 index 0000000000..5bc5aeaa12 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_list_backup_operations_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListBackupOperations +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_ListBackupOperations_sync] +from google.cloud import spanner_admin_database_v1 + + +def sample_list_backup_operations(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.ListBackupOperationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_backup_operations(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_ListBackupOperations_sync] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_list_backups_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_list_backups_async.py new file mode 100644 index 0000000000..26cfe9ec7d --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_list_backups_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for 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-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_ListBackups_async] +from google.cloud import spanner_admin_database_v1 + + +async def sample_list_backups(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_database_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 spanner_v1_generated_DatabaseAdmin_ListBackups_async] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_list_backups_sync.py b/samples/generated_samples/spanner_v1_generated_database_admin_list_backups_sync.py new file mode 100644 index 0000000000..6857e7d320 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_list_backups_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for 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-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_ListBackups_sync] +from google.cloud import spanner_admin_database_v1 + + +def sample_list_backups(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_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 spanner_v1_generated_DatabaseAdmin_ListBackups_sync] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_list_database_operations_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_list_database_operations_async.py new file mode 100644 index 0000000000..261110f5bd --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_list_database_operations_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDatabaseOperations +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_ListDatabaseOperations_async] +from google.cloud import spanner_admin_database_v1 + + +async def sample_list_database_operations(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.ListDatabaseOperationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_database_operations(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_ListDatabaseOperations_async] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_list_database_operations_sync.py b/samples/generated_samples/spanner_v1_generated_database_admin_list_database_operations_sync.py new file mode 100644 index 0000000000..b9b8b55b02 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_list_database_operations_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDatabaseOperations +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_ListDatabaseOperations_sync] +from google.cloud import spanner_admin_database_v1 + + +def sample_list_database_operations(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.ListDatabaseOperationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_database_operations(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_ListDatabaseOperations_sync] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_list_databases_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_list_databases_async.py new file mode 100644 index 0000000000..5e718ee39f --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_list_databases_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDatabases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_ListDatabases_async] +from google.cloud import spanner_admin_database_v1 + + +async def sample_list_databases(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.ListDatabasesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_databases(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_ListDatabases_async] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_list_databases_sync.py b/samples/generated_samples/spanner_v1_generated_database_admin_list_databases_sync.py new file mode 100644 index 0000000000..ddab069f91 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_list_databases_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDatabases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_ListDatabases_sync] +from google.cloud import spanner_admin_database_v1 + + +def sample_list_databases(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.ListDatabasesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_databases(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_ListDatabases_sync] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_restore_database_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_restore_database_async.py new file mode 100644 index 0000000000..4aaec9b90c --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_restore_database_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RestoreDatabase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_RestoreDatabase_async] +from google.cloud import spanner_admin_database_v1 + + +async def sample_restore_database(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.RestoreDatabaseRequest( + backup="backup_value", + parent="parent_value", + database_id="database_id_value", + ) + + # Make the request + operation = client.restore_database(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_RestoreDatabase_async] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_restore_database_sync.py b/samples/generated_samples/spanner_v1_generated_database_admin_restore_database_sync.py new file mode 100644 index 0000000000..4cba97cec2 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_restore_database_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RestoreDatabase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_RestoreDatabase_sync] +from google.cloud import spanner_admin_database_v1 + + +def sample_restore_database(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.RestoreDatabaseRequest( + backup="backup_value", + parent="parent_value", + database_id="database_id_value", + ) + + # Make the request + operation = client.restore_database(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_RestoreDatabase_sync] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_set_iam_policy_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_set_iam_policy_async.py new file mode 100644 index 0000000000..598b532ec5 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_set_iam_policy_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_SetIamPolicy_async] +from google.cloud import spanner_admin_database_v1 + + +async def sample_set_iam_policy(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.set_iam_policy(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_SetIamPolicy_async] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_set_iam_policy_sync.py b/samples/generated_samples/spanner_v1_generated_database_admin_set_iam_policy_sync.py new file mode 100644 index 0000000000..64099fc14d --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_set_iam_policy_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_SetIamPolicy_sync] +from google.cloud import spanner_admin_database_v1 + + +def sample_set_iam_policy(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_SetIamPolicy_sync] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_test_iam_permissions_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_test_iam_permissions_async.py new file mode 100644 index 0000000000..2c1bcf70c9 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_test_iam_permissions_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for TestIamPermissions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_TestIamPermissions_async] +from google.cloud import spanner_admin_database_v1 + + +async def sample_test_iam_permissions(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = await client.test_iam_permissions(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_TestIamPermissions_async] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_test_iam_permissions_sync.py b/samples/generated_samples/spanner_v1_generated_database_admin_test_iam_permissions_sync.py new file mode 100644 index 0000000000..1ebc5140e9 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_test_iam_permissions_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for TestIamPermissions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_TestIamPermissions_sync] +from google.cloud import spanner_admin_database_v1 + + +def sample_test_iam_permissions(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_TestIamPermissions_sync] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_update_backup_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_update_backup_async.py new file mode 100644 index 0000000000..569e68395f --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_update_backup_async.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for 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-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_UpdateBackup_async] +from google.cloud import spanner_admin_database_v1 + + +async def sample_update_backup(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.UpdateBackupRequest( + ) + + # Make the request + response = await client.update_backup(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_UpdateBackup_async] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_update_backup_sync.py b/samples/generated_samples/spanner_v1_generated_database_admin_update_backup_sync.py new file mode 100644 index 0000000000..40613c1f0b --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_update_backup_sync.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for 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-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_UpdateBackup_sync] +from google.cloud import spanner_admin_database_v1 + + +def sample_update_backup(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.UpdateBackupRequest( + ) + + # Make the request + response = client.update_backup(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_UpdateBackup_sync] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_update_database_ddl_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_update_database_ddl_async.py new file mode 100644 index 0000000000..2d16052746 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_update_database_ddl_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateDatabaseDdl +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_UpdateDatabaseDdl_async] +from google.cloud import spanner_admin_database_v1 + + +async def sample_update_database_ddl(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.UpdateDatabaseDdlRequest( + database="database_value", + statements=['statements_value_1', 'statements_value_2'], + ) + + # Make the request + operation = client.update_database_ddl(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_UpdateDatabaseDdl_async] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_update_database_ddl_sync.py b/samples/generated_samples/spanner_v1_generated_database_admin_update_database_ddl_sync.py new file mode 100644 index 0000000000..019b739cff --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_update_database_ddl_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateDatabaseDdl +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_UpdateDatabaseDdl_sync] +from google.cloud import spanner_admin_database_v1 + + +def sample_update_database_ddl(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.UpdateDatabaseDdlRequest( + database="database_value", + statements=['statements_value_1', 'statements_value_2'], + ) + + # Make the request + operation = client.update_database_ddl(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_UpdateDatabaseDdl_sync] diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_create_instance_async.py b/samples/generated_samples/spanner_v1_generated_instance_admin_create_instance_async.py new file mode 100644 index 0000000000..f9cc40553b --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_create_instance_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateInstance +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-instance + + +# [START spanner_v1_generated_InstanceAdmin_CreateInstance_async] +from google.cloud import spanner_admin_instance_v1 + + +async def sample_create_instance(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminAsyncClient() + + # Initialize request argument(s) + instance = spanner_admin_instance_v1.Instance() + instance.name = "name_value" + instance.config = "config_value" + instance.display_name = "display_name_value" + + request = spanner_admin_instance_v1.CreateInstanceRequest( + parent="parent_value", + instance_id="instance_id_value", + instance=instance, + ) + + # Make the request + operation = client.create_instance(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END spanner_v1_generated_InstanceAdmin_CreateInstance_async] diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_create_instance_sync.py b/samples/generated_samples/spanner_v1_generated_instance_admin_create_instance_sync.py new file mode 100644 index 0000000000..298a6fb34d --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_create_instance_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateInstance +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-instance + + +# [START spanner_v1_generated_InstanceAdmin_CreateInstance_sync] +from google.cloud import spanner_admin_instance_v1 + + +def sample_create_instance(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + instance = spanner_admin_instance_v1.Instance() + instance.name = "name_value" + instance.config = "config_value" + instance.display_name = "display_name_value" + + request = spanner_admin_instance_v1.CreateInstanceRequest( + parent="parent_value", + instance_id="instance_id_value", + instance=instance, + ) + + # Make the request + operation = client.create_instance(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END spanner_v1_generated_InstanceAdmin_CreateInstance_sync] diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_delete_instance_async.py b/samples/generated_samples/spanner_v1_generated_instance_admin_delete_instance_async.py new file mode 100644 index 0000000000..84054f0e00 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_delete_instance_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteInstance +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-instance + + +# [START spanner_v1_generated_InstanceAdmin_DeleteInstance_async] +from google.cloud import spanner_admin_instance_v1 + + +async def sample_delete_instance(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.DeleteInstanceRequest( + name="name_value", + ) + + # Make the request + await client.delete_instance(request=request) + + +# [END spanner_v1_generated_InstanceAdmin_DeleteInstance_async] diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_delete_instance_sync.py b/samples/generated_samples/spanner_v1_generated_instance_admin_delete_instance_sync.py new file mode 100644 index 0000000000..7cf64b0a36 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_delete_instance_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteInstance +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-instance + + +# [START spanner_v1_generated_InstanceAdmin_DeleteInstance_sync] +from google.cloud import spanner_admin_instance_v1 + + +def sample_delete_instance(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.DeleteInstanceRequest( + name="name_value", + ) + + # Make the request + client.delete_instance(request=request) + + +# [END spanner_v1_generated_InstanceAdmin_DeleteInstance_sync] diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_get_iam_policy_async.py b/samples/generated_samples/spanner_v1_generated_instance_admin_get_iam_policy_async.py new file mode 100644 index 0000000000..01f1b4e3d2 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_get_iam_policy_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-instance + + +# [START spanner_v1_generated_InstanceAdmin_GetIamPolicy_async] +from google.cloud import spanner_admin_instance_v1 + + +async def sample_get_iam_policy(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.get_iam_policy(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_InstanceAdmin_GetIamPolicy_async] diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_get_iam_policy_sync.py b/samples/generated_samples/spanner_v1_generated_instance_admin_get_iam_policy_sync.py new file mode 100644 index 0000000000..8de214c9bb --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_get_iam_policy_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-instance + + +# [START spanner_v1_generated_InstanceAdmin_GetIamPolicy_sync] +from google.cloud import spanner_admin_instance_v1 + + +def sample_get_iam_policy(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_InstanceAdmin_GetIamPolicy_sync] diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_get_instance_async.py b/samples/generated_samples/spanner_v1_generated_instance_admin_get_instance_async.py new file mode 100644 index 0000000000..50093013d4 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_get_instance_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetInstance +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-instance + + +# [START spanner_v1_generated_InstanceAdmin_GetInstance_async] +from google.cloud import spanner_admin_instance_v1 + + +async def sample_get_instance(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.GetInstanceRequest( + name="name_value", + ) + + # Make the request + response = await client.get_instance(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_InstanceAdmin_GetInstance_async] diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_get_instance_config_async.py b/samples/generated_samples/spanner_v1_generated_instance_admin_get_instance_config_async.py new file mode 100644 index 0000000000..7b620f61e1 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_get_instance_config_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetInstanceConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-instance + + +# [START spanner_v1_generated_InstanceAdmin_GetInstanceConfig_async] +from google.cloud import spanner_admin_instance_v1 + + +async def sample_get_instance_config(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.GetInstanceConfigRequest( + name="name_value", + ) + + # Make the request + response = await client.get_instance_config(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_InstanceAdmin_GetInstanceConfig_async] diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_get_instance_config_sync.py b/samples/generated_samples/spanner_v1_generated_instance_admin_get_instance_config_sync.py new file mode 100644 index 0000000000..50691dbcdb --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_get_instance_config_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetInstanceConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-instance + + +# [START spanner_v1_generated_InstanceAdmin_GetInstanceConfig_sync] +from google.cloud import spanner_admin_instance_v1 + + +def sample_get_instance_config(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.GetInstanceConfigRequest( + name="name_value", + ) + + # Make the request + response = client.get_instance_config(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_InstanceAdmin_GetInstanceConfig_sync] diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_get_instance_sync.py b/samples/generated_samples/spanner_v1_generated_instance_admin_get_instance_sync.py new file mode 100644 index 0000000000..f7a2ea1323 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_get_instance_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetInstance +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-instance + + +# [START spanner_v1_generated_InstanceAdmin_GetInstance_sync] +from google.cloud import spanner_admin_instance_v1 + + +def sample_get_instance(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.GetInstanceRequest( + name="name_value", + ) + + # Make the request + response = client.get_instance(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_InstanceAdmin_GetInstance_sync] diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_list_instance_configs_async.py b/samples/generated_samples/spanner_v1_generated_instance_admin_list_instance_configs_async.py new file mode 100644 index 0000000000..b330645135 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_list_instance_configs_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListInstanceConfigs +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-instance + + +# [START spanner_v1_generated_InstanceAdmin_ListInstanceConfigs_async] +from google.cloud import spanner_admin_instance_v1 + + +async def sample_list_instance_configs(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.ListInstanceConfigsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_instance_configs(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END spanner_v1_generated_InstanceAdmin_ListInstanceConfigs_async] diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_list_instance_configs_sync.py b/samples/generated_samples/spanner_v1_generated_instance_admin_list_instance_configs_sync.py new file mode 100644 index 0000000000..a2309f6d91 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_list_instance_configs_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListInstanceConfigs +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-instance + + +# [START spanner_v1_generated_InstanceAdmin_ListInstanceConfigs_sync] +from google.cloud import spanner_admin_instance_v1 + + +def sample_list_instance_configs(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.ListInstanceConfigsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_instance_configs(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END spanner_v1_generated_InstanceAdmin_ListInstanceConfigs_sync] diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_list_instances_async.py b/samples/generated_samples/spanner_v1_generated_instance_admin_list_instances_async.py new file mode 100644 index 0000000000..138993f116 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_list_instances_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListInstances +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-instance + + +# [START spanner_v1_generated_InstanceAdmin_ListInstances_async] +from google.cloud import spanner_admin_instance_v1 + + +async def sample_list_instances(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.ListInstancesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_instances(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END spanner_v1_generated_InstanceAdmin_ListInstances_async] diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_list_instances_sync.py b/samples/generated_samples/spanner_v1_generated_instance_admin_list_instances_sync.py new file mode 100644 index 0000000000..88dfd120e8 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_list_instances_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListInstances +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-instance + + +# [START spanner_v1_generated_InstanceAdmin_ListInstances_sync] +from google.cloud import spanner_admin_instance_v1 + + +def sample_list_instances(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.ListInstancesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_instances(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END spanner_v1_generated_InstanceAdmin_ListInstances_sync] diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_set_iam_policy_async.py b/samples/generated_samples/spanner_v1_generated_instance_admin_set_iam_policy_async.py new file mode 100644 index 0000000000..ee5d8280ab --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_set_iam_policy_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-instance + + +# [START spanner_v1_generated_InstanceAdmin_SetIamPolicy_async] +from google.cloud import spanner_admin_instance_v1 + + +async def sample_set_iam_policy(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.set_iam_policy(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_InstanceAdmin_SetIamPolicy_async] diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_set_iam_policy_sync.py b/samples/generated_samples/spanner_v1_generated_instance_admin_set_iam_policy_sync.py new file mode 100644 index 0000000000..ea140d4e43 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_set_iam_policy_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-instance + + +# [START spanner_v1_generated_InstanceAdmin_SetIamPolicy_sync] +from google.cloud import spanner_admin_instance_v1 + + +def sample_set_iam_policy(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_InstanceAdmin_SetIamPolicy_sync] diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_test_iam_permissions_async.py b/samples/generated_samples/spanner_v1_generated_instance_admin_test_iam_permissions_async.py new file mode 100644 index 0000000000..63a65aee57 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_test_iam_permissions_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for TestIamPermissions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-instance + + +# [START spanner_v1_generated_InstanceAdmin_TestIamPermissions_async] +from google.cloud import spanner_admin_instance_v1 + + +async def sample_test_iam_permissions(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = await client.test_iam_permissions(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_InstanceAdmin_TestIamPermissions_async] diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_test_iam_permissions_sync.py b/samples/generated_samples/spanner_v1_generated_instance_admin_test_iam_permissions_sync.py new file mode 100644 index 0000000000..55a400649f --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_test_iam_permissions_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for TestIamPermissions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-instance + + +# [START spanner_v1_generated_InstanceAdmin_TestIamPermissions_sync] +from google.cloud import spanner_admin_instance_v1 + + +def sample_test_iam_permissions(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + request = spanner_admin_instance_v1.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_InstanceAdmin_TestIamPermissions_sync] diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_update_instance_async.py b/samples/generated_samples/spanner_v1_generated_instance_admin_update_instance_async.py new file mode 100644 index 0000000000..a6a3c5e756 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_update_instance_async.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateInstance +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-instance + + +# [START spanner_v1_generated_InstanceAdmin_UpdateInstance_async] +from google.cloud import spanner_admin_instance_v1 + + +async def sample_update_instance(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminAsyncClient() + + # Initialize request argument(s) + instance = spanner_admin_instance_v1.Instance() + instance.name = "name_value" + instance.config = "config_value" + instance.display_name = "display_name_value" + + request = spanner_admin_instance_v1.UpdateInstanceRequest( + instance=instance, + ) + + # Make the request + operation = client.update_instance(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END spanner_v1_generated_InstanceAdmin_UpdateInstance_async] diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_update_instance_sync.py b/samples/generated_samples/spanner_v1_generated_instance_admin_update_instance_sync.py new file mode 100644 index 0000000000..90160a2cc1 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_update_instance_sync.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateInstance +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-instance + + +# [START spanner_v1_generated_InstanceAdmin_UpdateInstance_sync] +from google.cloud import spanner_admin_instance_v1 + + +def sample_update_instance(): + # Create a client + client = spanner_admin_instance_v1.InstanceAdminClient() + + # Initialize request argument(s) + instance = spanner_admin_instance_v1.Instance() + instance.name = "name_value" + instance.config = "config_value" + instance.display_name = "display_name_value" + + request = spanner_admin_instance_v1.UpdateInstanceRequest( + instance=instance, + ) + + # Make the request + operation = client.update_instance(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END spanner_v1_generated_InstanceAdmin_UpdateInstance_sync] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_batch_create_sessions_async.py b/samples/generated_samples/spanner_v1_generated_spanner_batch_create_sessions_async.py new file mode 100644 index 0000000000..78f195c393 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_batch_create_sessions_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchCreateSessions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_BatchCreateSessions_async] +from google.cloud import spanner_v1 + + +async def sample_batch_create_sessions(): + # Create a client + client = spanner_v1.SpannerAsyncClient() + + # Initialize request argument(s) + request = spanner_v1.BatchCreateSessionsRequest( + database="database_value", + session_count=1420, + ) + + # Make the request + response = await client.batch_create_sessions(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_Spanner_BatchCreateSessions_async] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_batch_create_sessions_sync.py b/samples/generated_samples/spanner_v1_generated_spanner_batch_create_sessions_sync.py new file mode 100644 index 0000000000..2842953afd --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_batch_create_sessions_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchCreateSessions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_BatchCreateSessions_sync] +from google.cloud import spanner_v1 + + +def sample_batch_create_sessions(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.BatchCreateSessionsRequest( + database="database_value", + session_count=1420, + ) + + # Make the request + response = client.batch_create_sessions(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_Spanner_BatchCreateSessions_sync] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_begin_transaction_async.py b/samples/generated_samples/spanner_v1_generated_spanner_begin_transaction_async.py new file mode 100644 index 0000000000..90a1fd1e00 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_begin_transaction_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BeginTransaction +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_BeginTransaction_async] +from google.cloud import spanner_v1 + + +async def sample_begin_transaction(): + # Create a client + client = spanner_v1.SpannerAsyncClient() + + # Initialize request argument(s) + request = spanner_v1.BeginTransactionRequest( + session="session_value", + ) + + # Make the request + response = await client.begin_transaction(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_Spanner_BeginTransaction_async] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_begin_transaction_sync.py b/samples/generated_samples/spanner_v1_generated_spanner_begin_transaction_sync.py new file mode 100644 index 0000000000..43d5ff0dc1 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_begin_transaction_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BeginTransaction +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_BeginTransaction_sync] +from google.cloud import spanner_v1 + + +def sample_begin_transaction(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.BeginTransactionRequest( + session="session_value", + ) + + # Make the request + response = client.begin_transaction(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_Spanner_BeginTransaction_sync] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_commit_async.py b/samples/generated_samples/spanner_v1_generated_spanner_commit_async.py new file mode 100644 index 0000000000..354d44fc0f --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_commit_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for Commit +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_Commit_async] +from google.cloud import spanner_v1 + + +async def sample_commit(): + # Create a client + client = spanner_v1.SpannerAsyncClient() + + # Initialize request argument(s) + request = spanner_v1.CommitRequest( + transaction_id=b'transaction_id_blob', + session="session_value", + ) + + # Make the request + response = await client.commit(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_Spanner_Commit_async] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_commit_sync.py b/samples/generated_samples/spanner_v1_generated_spanner_commit_sync.py new file mode 100644 index 0000000000..ae1969c464 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_commit_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for Commit +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_Commit_sync] +from google.cloud import spanner_v1 + + +def sample_commit(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.CommitRequest( + transaction_id=b'transaction_id_blob', + session="session_value", + ) + + # Make the request + response = client.commit(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_Spanner_Commit_sync] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_create_session_async.py b/samples/generated_samples/spanner_v1_generated_spanner_create_session_async.py new file mode 100644 index 0000000000..2536506397 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_create_session_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateSession +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_CreateSession_async] +from google.cloud import spanner_v1 + + +async def sample_create_session(): + # Create a client + client = spanner_v1.SpannerAsyncClient() + + # Initialize request argument(s) + request = spanner_v1.CreateSessionRequest( + database="database_value", + ) + + # Make the request + response = await client.create_session(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_Spanner_CreateSession_async] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_create_session_sync.py b/samples/generated_samples/spanner_v1_generated_spanner_create_session_sync.py new file mode 100644 index 0000000000..5d457e4f9c --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_create_session_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateSession +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_CreateSession_sync] +from google.cloud import spanner_v1 + + +def sample_create_session(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.CreateSessionRequest( + database="database_value", + ) + + # Make the request + response = client.create_session(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_Spanner_CreateSession_sync] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_delete_session_async.py b/samples/generated_samples/spanner_v1_generated_spanner_delete_session_async.py new file mode 100644 index 0000000000..1493a78beb --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_delete_session_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteSession +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_DeleteSession_async] +from google.cloud import spanner_v1 + + +async def sample_delete_session(): + # Create a client + client = spanner_v1.SpannerAsyncClient() + + # Initialize request argument(s) + request = spanner_v1.DeleteSessionRequest( + name="name_value", + ) + + # Make the request + await client.delete_session(request=request) + + +# [END spanner_v1_generated_Spanner_DeleteSession_async] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_delete_session_sync.py b/samples/generated_samples/spanner_v1_generated_spanner_delete_session_sync.py new file mode 100644 index 0000000000..f83f686fd7 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_delete_session_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteSession +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_DeleteSession_sync] +from google.cloud import spanner_v1 + + +def sample_delete_session(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.DeleteSessionRequest( + name="name_value", + ) + + # Make the request + client.delete_session(request=request) + + +# [END spanner_v1_generated_Spanner_DeleteSession_sync] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_execute_batch_dml_async.py b/samples/generated_samples/spanner_v1_generated_spanner_execute_batch_dml_async.py new file mode 100644 index 0000000000..285f70d8d6 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_execute_batch_dml_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExecuteBatchDml +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_ExecuteBatchDml_async] +from google.cloud import spanner_v1 + + +async def sample_execute_batch_dml(): + # Create a client + client = spanner_v1.SpannerAsyncClient() + + # Initialize request argument(s) + statements = spanner_v1.Statement() + statements.sql = "sql_value" + + request = spanner_v1.ExecuteBatchDmlRequest( + session="session_value", + statements=statements, + seqno=550, + ) + + # Make the request + response = await client.execute_batch_dml(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_Spanner_ExecuteBatchDml_async] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_execute_batch_dml_sync.py b/samples/generated_samples/spanner_v1_generated_spanner_execute_batch_dml_sync.py new file mode 100644 index 0000000000..1e4a448567 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_execute_batch_dml_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExecuteBatchDml +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_ExecuteBatchDml_sync] +from google.cloud import spanner_v1 + + +def sample_execute_batch_dml(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + statements = spanner_v1.Statement() + statements.sql = "sql_value" + + request = spanner_v1.ExecuteBatchDmlRequest( + session="session_value", + statements=statements, + seqno=550, + ) + + # Make the request + response = client.execute_batch_dml(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_Spanner_ExecuteBatchDml_sync] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_execute_sql_async.py b/samples/generated_samples/spanner_v1_generated_spanner_execute_sql_async.py new file mode 100644 index 0000000000..1d884903fb --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_execute_sql_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExecuteSql +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_ExecuteSql_async] +from google.cloud import spanner_v1 + + +async def sample_execute_sql(): + # Create a client + client = spanner_v1.SpannerAsyncClient() + + # Initialize request argument(s) + request = spanner_v1.ExecuteSqlRequest( + session="session_value", + sql="sql_value", + ) + + # Make the request + response = await client.execute_sql(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_Spanner_ExecuteSql_async] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_execute_sql_sync.py b/samples/generated_samples/spanner_v1_generated_spanner_execute_sql_sync.py new file mode 100644 index 0000000000..361c30ed0d --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_execute_sql_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExecuteSql +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_ExecuteSql_sync] +from google.cloud import spanner_v1 + + +def sample_execute_sql(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.ExecuteSqlRequest( + session="session_value", + sql="sql_value", + ) + + # Make the request + response = client.execute_sql(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_Spanner_ExecuteSql_sync] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_execute_streaming_sql_async.py b/samples/generated_samples/spanner_v1_generated_spanner_execute_streaming_sql_async.py new file mode 100644 index 0000000000..d47b3d55fc --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_execute_streaming_sql_async.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExecuteStreamingSql +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_ExecuteStreamingSql_async] +from google.cloud import spanner_v1 + + +async def sample_execute_streaming_sql(): + # Create a client + client = spanner_v1.SpannerAsyncClient() + + # Initialize request argument(s) + request = spanner_v1.ExecuteSqlRequest( + session="session_value", + sql="sql_value", + ) + + # Make the request + stream = await client.execute_streaming_sql(request=request) + + # Handle the response + async for response in stream: + print(response) + +# [END spanner_v1_generated_Spanner_ExecuteStreamingSql_async] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_execute_streaming_sql_sync.py b/samples/generated_samples/spanner_v1_generated_spanner_execute_streaming_sql_sync.py new file mode 100644 index 0000000000..9265963da4 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_execute_streaming_sql_sync.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExecuteStreamingSql +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_ExecuteStreamingSql_sync] +from google.cloud import spanner_v1 + + +def sample_execute_streaming_sql(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.ExecuteSqlRequest( + session="session_value", + sql="sql_value", + ) + + # Make the request + stream = client.execute_streaming_sql(request=request) + + # Handle the response + for response in stream: + print(response) + +# [END spanner_v1_generated_Spanner_ExecuteStreamingSql_sync] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_get_session_async.py b/samples/generated_samples/spanner_v1_generated_spanner_get_session_async.py new file mode 100644 index 0000000000..b274f4e949 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_get_session_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetSession +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_GetSession_async] +from google.cloud import spanner_v1 + + +async def sample_get_session(): + # Create a client + client = spanner_v1.SpannerAsyncClient() + + # Initialize request argument(s) + request = spanner_v1.GetSessionRequest( + name="name_value", + ) + + # Make the request + response = await client.get_session(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_Spanner_GetSession_async] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_get_session_sync.py b/samples/generated_samples/spanner_v1_generated_spanner_get_session_sync.py new file mode 100644 index 0000000000..d613f8b293 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_get_session_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetSession +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_GetSession_sync] +from google.cloud import spanner_v1 + + +def sample_get_session(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.GetSessionRequest( + name="name_value", + ) + + # Make the request + response = client.get_session(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_Spanner_GetSession_sync] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_list_sessions_async.py b/samples/generated_samples/spanner_v1_generated_spanner_list_sessions_async.py new file mode 100644 index 0000000000..e3ba126ce6 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_list_sessions_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListSessions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_ListSessions_async] +from google.cloud import spanner_v1 + + +async def sample_list_sessions(): + # Create a client + client = spanner_v1.SpannerAsyncClient() + + # Initialize request argument(s) + request = spanner_v1.ListSessionsRequest( + database="database_value", + ) + + # Make the request + page_result = client.list_sessions(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END spanner_v1_generated_Spanner_ListSessions_async] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_list_sessions_sync.py b/samples/generated_samples/spanner_v1_generated_spanner_list_sessions_sync.py new file mode 100644 index 0000000000..0bc0bac7d2 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_list_sessions_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListSessions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_ListSessions_sync] +from google.cloud import spanner_v1 + + +def sample_list_sessions(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.ListSessionsRequest( + database="database_value", + ) + + # Make the request + page_result = client.list_sessions(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END spanner_v1_generated_Spanner_ListSessions_sync] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_partition_query_async.py b/samples/generated_samples/spanner_v1_generated_spanner_partition_query_async.py new file mode 100644 index 0000000000..4e0a22d7fc --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_partition_query_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for PartitionQuery +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_PartitionQuery_async] +from google.cloud import spanner_v1 + + +async def sample_partition_query(): + # Create a client + client = spanner_v1.SpannerAsyncClient() + + # Initialize request argument(s) + request = spanner_v1.PartitionQueryRequest( + session="session_value", + sql="sql_value", + ) + + # Make the request + response = await client.partition_query(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_Spanner_PartitionQuery_async] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_partition_query_sync.py b/samples/generated_samples/spanner_v1_generated_spanner_partition_query_sync.py new file mode 100644 index 0000000000..04af535cf3 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_partition_query_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for PartitionQuery +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_PartitionQuery_sync] +from google.cloud import spanner_v1 + + +def sample_partition_query(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.PartitionQueryRequest( + session="session_value", + sql="sql_value", + ) + + # Make the request + response = client.partition_query(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_Spanner_PartitionQuery_sync] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_partition_read_async.py b/samples/generated_samples/spanner_v1_generated_spanner_partition_read_async.py new file mode 100644 index 0000000000..ab35787e21 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_partition_read_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for PartitionRead +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_PartitionRead_async] +from google.cloud import spanner_v1 + + +async def sample_partition_read(): + # Create a client + client = spanner_v1.SpannerAsyncClient() + + # Initialize request argument(s) + request = spanner_v1.PartitionReadRequest( + session="session_value", + table="table_value", + ) + + # Make the request + response = await client.partition_read(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_Spanner_PartitionRead_async] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_partition_read_sync.py b/samples/generated_samples/spanner_v1_generated_spanner_partition_read_sync.py new file mode 100644 index 0000000000..f5ccab3958 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_partition_read_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for PartitionRead +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_PartitionRead_sync] +from google.cloud import spanner_v1 + + +def sample_partition_read(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.PartitionReadRequest( + session="session_value", + table="table_value", + ) + + # Make the request + response = client.partition_read(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_Spanner_PartitionRead_sync] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_read_async.py b/samples/generated_samples/spanner_v1_generated_spanner_read_async.py new file mode 100644 index 0000000000..315cb067df --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_read_async.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for Read +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_Read_async] +from google.cloud import spanner_v1 + + +async def sample_read(): + # Create a client + client = spanner_v1.SpannerAsyncClient() + + # Initialize request argument(s) + request = spanner_v1.ReadRequest( + session="session_value", + table="table_value", + columns=['columns_value_1', 'columns_value_2'], + ) + + # Make the request + response = await client.read(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_Spanner_Read_async] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_read_sync.py b/samples/generated_samples/spanner_v1_generated_spanner_read_sync.py new file mode 100644 index 0000000000..7fd4758d17 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_read_sync.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for Read +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_Read_sync] +from google.cloud import spanner_v1 + + +def sample_read(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.ReadRequest( + session="session_value", + table="table_value", + columns=['columns_value_1', 'columns_value_2'], + ) + + # Make the request + response = client.read(request=request) + + # Handle the response + print(response) + +# [END spanner_v1_generated_Spanner_Read_sync] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_rollback_async.py b/samples/generated_samples/spanner_v1_generated_spanner_rollback_async.py new file mode 100644 index 0000000000..926171e5fd --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_rollback_async.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for Rollback +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_Rollback_async] +from google.cloud import spanner_v1 + + +async def sample_rollback(): + # Create a client + client = spanner_v1.SpannerAsyncClient() + + # Initialize request argument(s) + request = spanner_v1.RollbackRequest( + session="session_value", + transaction_id=b'transaction_id_blob', + ) + + # Make the request + await client.rollback(request=request) + + +# [END spanner_v1_generated_Spanner_Rollback_async] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_rollback_sync.py b/samples/generated_samples/spanner_v1_generated_spanner_rollback_sync.py new file mode 100644 index 0000000000..3047b54984 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_rollback_sync.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for Rollback +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_Rollback_sync] +from google.cloud import spanner_v1 + + +def sample_rollback(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.RollbackRequest( + session="session_value", + transaction_id=b'transaction_id_blob', + ) + + # Make the request + client.rollback(request=request) + + +# [END spanner_v1_generated_Spanner_Rollback_sync] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_streaming_read_async.py b/samples/generated_samples/spanner_v1_generated_spanner_streaming_read_async.py new file mode 100644 index 0000000000..7f0139e3b7 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_streaming_read_async.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for StreamingRead +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_StreamingRead_async] +from google.cloud import spanner_v1 + + +async def sample_streaming_read(): + # Create a client + client = spanner_v1.SpannerAsyncClient() + + # Initialize request argument(s) + request = spanner_v1.ReadRequest( + session="session_value", + table="table_value", + columns=['columns_value_1', 'columns_value_2'], + ) + + # Make the request + stream = await client.streaming_read(request=request) + + # Handle the response + async for response in stream: + print(response) + +# [END spanner_v1_generated_Spanner_StreamingRead_async] diff --git a/samples/generated_samples/spanner_v1_generated_spanner_streaming_read_sync.py b/samples/generated_samples/spanner_v1_generated_spanner_streaming_read_sync.py new file mode 100644 index 0000000000..1484239348 --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_spanner_streaming_read_sync.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for StreamingRead +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner + + +# [START spanner_v1_generated_Spanner_StreamingRead_sync] +from google.cloud import spanner_v1 + + +def sample_streaming_read(): + # Create a client + client = spanner_v1.SpannerClient() + + # Initialize request argument(s) + request = spanner_v1.ReadRequest( + session="session_value", + table="table_value", + columns=['columns_value_1', 'columns_value_2'], + ) + + # Make the request + stream = client.streaming_read(request=request) + + # Handle the response + for response in stream: + print(response) + +# [END spanner_v1_generated_Spanner_StreamingRead_sync] diff --git a/scripts/fixup_spanner_admin_database_v1_keywords.py b/scripts/fixup_spanner_admin_database_v1_keywords.py index 9ac9f80702..5a0630802f 100644 --- a/scripts/fixup_spanner_admin_database_v1_keywords.py +++ b/scripts/fixup_spanner_admin_database_v1_keywords.py @@ -1,6 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/scripts/fixup_spanner_admin_instance_v1_keywords.py b/scripts/fixup_spanner_admin_instance_v1_keywords.py index afbc7517bc..4142cf7000 100644 --- a/scripts/fixup_spanner_admin_instance_v1_keywords.py +++ b/scripts/fixup_spanner_admin_instance_v1_keywords.py @@ -1,6 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/scripts/fixup_spanner_v1_keywords.py b/scripts/fixup_spanner_v1_keywords.py index fec728843e..ed532c0d8f 100644 --- a/scripts/fixup_spanner_v1_keywords.py +++ b/scripts/fixup_spanner_v1_keywords.py @@ -1,6 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/__init__.py b/tests/__init__.py index 4de65971c2..e8e1c3845d 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py index 4de65971c2..e8e1c3845d 100644 --- a/tests/unit/__init__.py +++ b/tests/unit/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/unit/gapic/__init__.py b/tests/unit/gapic/__init__.py index 4de65971c2..e8e1c3845d 100644 --- a/tests/unit/gapic/__init__.py +++ b/tests/unit/gapic/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/unit/gapic/spanner_admin_database_v1/__init__.py b/tests/unit/gapic/spanner_admin_database_v1/__init__.py index 4de65971c2..e8e1c3845d 100644 --- a/tests/unit/gapic/spanner_admin_database_v1/__init__.py +++ b/tests/unit/gapic/spanner_admin_database_v1/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py b/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py index bf80690516..de918f8c79 100644 --- a/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py +++ b/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/unit/gapic/spanner_admin_instance_v1/__init__.py b/tests/unit/gapic/spanner_admin_instance_v1/__init__.py index 4de65971c2..e8e1c3845d 100644 --- a/tests/unit/gapic/spanner_admin_instance_v1/__init__.py +++ b/tests/unit/gapic/spanner_admin_instance_v1/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/unit/gapic/spanner_admin_instance_v1/test_instance_admin.py b/tests/unit/gapic/spanner_admin_instance_v1/test_instance_admin.py index 64fed509dd..caef9d05d9 100644 --- a/tests/unit/gapic/spanner_admin_instance_v1/test_instance_admin.py +++ b/tests/unit/gapic/spanner_admin_instance_v1/test_instance_admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/unit/gapic/spanner_v1/__init__.py b/tests/unit/gapic/spanner_v1/__init__.py index 4de65971c2..e8e1c3845d 100644 --- a/tests/unit/gapic/spanner_v1/__init__.py +++ b/tests/unit/gapic/spanner_v1/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/unit/gapic/spanner_v1/test_spanner.py b/tests/unit/gapic/spanner_v1/test_spanner.py index c9fe4fadb1..c207dc5fbc 100644 --- a/tests/unit/gapic/spanner_v1/test_spanner.py +++ b/tests/unit/gapic/spanner_v1/test_spanner.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From 7a46a27bacbdcb1e72888bd93dfce93c439ceae2 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Fri, 4 Mar 2022 11:39:26 -0500 Subject: [PATCH 04/16] fix(deps): require google-api-core>=1.31.5, >=2.3.2 (#685) fix(deps): require proto-plus>=1.15.0 --- setup.py | 4 ++-- testing/constraints-3.6.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 39649d6e28..3da9372306 100644 --- a/setup.py +++ b/setup.py @@ -32,13 +32,13 @@ # NOTE: Maintainers, please do not require google-api-core>=2.x.x # Until this issue is closed # https://github.com/googleapis/google-cloud-python/issues/10566 - "google-api-core[grpc] >= 1.26.0, <3.0.0dev", + "google-api-core[grpc] >= 1.31.5, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0", # NOTE: Maintainers, please do not require google-cloud-core>=2.x.x # Until this issue is closed # https://github.com/googleapis/google-cloud-python/issues/10566 "google-cloud-core >= 1.4.1, < 3.0dev", "grpc-google-iam-v1 >= 0.12.3, < 0.13dev", - "proto-plus >= 1.11.0, != 1.19.6", + "proto-plus >= 1.15.0, != 1.19.6", "sqlparse >= 0.3.0", "packaging >= 14.3", ] diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index 2eac9c8653..7ceb82cd99 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -5,11 +5,11 @@ # # e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", # Then this file should have foo==1.14.0 -google-api-core==1.26.0 +google-api-core==1.31.5 google-cloud-core==1.4.1 grpc-google-iam-v1==0.12.3 libcst==0.2.5 -proto-plus==1.13.0 +proto-plus==1.15.0 sqlparse==0.3.0 opentelemetry-api==1.1.0 opentelemetry-sdk==1.1.0 From 09c514488433e635b050bc307fad5e81deb918eb Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 4 Mar 2022 16:48:53 -0500 Subject: [PATCH 05/16] chore: Adding support for pytest-xdist and pytest-parallel (#686) Source-Link: https://github.com/googleapis/synthtool/commit/82f5cb283efffe96e1b6cd634738e0e7de2cd90a Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:5d8da01438ece4021d135433f2cf3227aa39ef0eaccc941d62aa35e6902832ae Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- .github/.OwlBot.lock.yaml | 2 +- samples/samples/noxfile.py | 80 ++++++++++++++++++++++---------------- 2 files changed, 47 insertions(+), 35 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 8cb43804d9..7e08e05a38 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:ed1f9983d5a935a89fe8085e8bb97d94e41015252c5b6c9771257cf8624367e6 + digest: sha256:5d8da01438ece4021d135433f2cf3227aa39ef0eaccc941d62aa35e6902832ae diff --git a/samples/samples/noxfile.py b/samples/samples/noxfile.py index 20cdfc6201..4c808af73e 100644 --- a/samples/samples/noxfile.py +++ b/samples/samples/noxfile.py @@ -188,42 +188,54 @@ def _session_tests( # check for presence of tests test_list = glob.glob("*_test.py") + glob.glob("test_*.py") test_list.extend(glob.glob("tests")) + if len(test_list) == 0: print("No tests found, skipping directory.") - else: - if TEST_CONFIG["pip_version_override"]: - pip_version = TEST_CONFIG["pip_version_override"] - session.install(f"pip=={pip_version}") - """Runs py.test for a particular project.""" - if os.path.exists("requirements.txt"): - if os.path.exists("constraints.txt"): - session.install("-r", "requirements.txt", "-c", "constraints.txt") - else: - session.install("-r", "requirements.txt") - - if os.path.exists("requirements-test.txt"): - if os.path.exists("constraints-test.txt"): - session.install( - "-r", "requirements-test.txt", "-c", "constraints-test.txt" - ) - else: - session.install("-r", "requirements-test.txt") - - if INSTALL_LIBRARY_FROM_SOURCE: - session.install("-e", _get_repo_root()) - - if post_install: - post_install(session) - - session.run( - "pytest", - *(PYTEST_COMMON_ARGS + session.posargs), - # Pytest will return 5 when no tests are collected. This can happen - # on travis where slow and flaky tests are excluded. - # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html - success_codes=[0, 5], - env=get_pytest_env_vars(), - ) + return + + if TEST_CONFIG["pip_version_override"]: + pip_version = TEST_CONFIG["pip_version_override"] + session.install(f"pip=={pip_version}") + """Runs py.test for a particular project.""" + concurrent_args = [] + if os.path.exists("requirements.txt"): + if os.path.exists("constraints.txt"): + session.install("-r", "requirements.txt", "-c", "constraints.txt") + else: + session.install("-r", "requirements.txt") + with open("requirements.txt") as rfile: + packages = rfile.read() + + if os.path.exists("requirements-test.txt"): + if os.path.exists("constraints-test.txt"): + session.install( + "-r", "requirements-test.txt", "-c", "constraints-test.txt" + ) + else: + session.install("-r", "requirements-test.txt") + with open("requirements-test.txt") as rtfile: + packages += rtfile.read() + + if INSTALL_LIBRARY_FROM_SOURCE: + session.install("-e", _get_repo_root()) + + if post_install: + post_install(session) + + if "pytest-parallel" in packages: + concurrent_args.extend(['--workers', 'auto', '--tests-per-worker', 'auto']) + elif "pytest-xdist" in packages: + concurrent_args.extend(['-n', 'auto']) + + session.run( + "pytest", + *(PYTEST_COMMON_ARGS + session.posargs + concurrent_args), + # Pytest will return 5 when no tests are collected. This can happen + # on travis where slow and flaky tests are excluded. + # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html + success_codes=[0, 5], + env=get_pytest_env_vars(), + ) @nox.session(python=ALL_VERSIONS) From b79c9957eb101ed2afcfc7565bb08e79499a28f3 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sun, 13 Mar 2022 20:53:27 +0100 Subject: [PATCH 06/16] chore(deps): update all dependencies (#689) --- .github/workflows/integration-tests-against-emulator.yaml | 4 ++-- samples/samples/requirements-test.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration-tests-against-emulator.yaml b/.github/workflows/integration-tests-against-emulator.yaml index 7438f8f0a9..3c8b1c5080 100644 --- a/.github/workflows/integration-tests-against-emulator.yaml +++ b/.github/workflows/integration-tests-against-emulator.yaml @@ -17,9 +17,9 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: 3.8 - name: Install nox diff --git a/samples/samples/requirements-test.txt b/samples/samples/requirements-test.txt index b8e7474e10..47ad2792b2 100644 --- a/samples/samples/requirements-test.txt +++ b/samples/samples/requirements-test.txt @@ -1,4 +1,4 @@ -pytest==7.0.1 +pytest==7.1.0 pytest-dependency==0.5.1 mock==4.0.3 google-cloud-testutils==1.3.1 From 8c3f25f1910884d3f625f401f27eab210d44109d Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sat, 19 Mar 2022 11:34:15 +0100 Subject: [PATCH 07/16] chore(deps): update dependency pytest to v7.1.1 (#690) --- samples/samples/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/samples/requirements-test.txt b/samples/samples/requirements-test.txt index 47ad2792b2..3d42f3a24a 100644 --- a/samples/samples/requirements-test.txt +++ b/samples/samples/requirements-test.txt @@ -1,4 +1,4 @@ -pytest==7.1.0 +pytest==7.1.1 pytest-dependency==0.5.1 mock==4.0.3 google-cloud-testutils==1.3.1 From 8ac62cb83ee5525d6233dcc34919dcbf9471461b Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 21 Mar 2022 17:03:18 -0400 Subject: [PATCH 08/16] feat: add support for Cross region backup proto changes (#691) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Synchronize new proto/yaml changes. PiperOrigin-RevId: 436114471 Source-Link: https://github.com/googleapis/googleapis/commit/6379d5fe706781af6682447f77f20d18b4db05b2 Source-Link: https://github.com/googleapis/googleapis-gen/commit/a59984b4cb711eeb186bca4f5b35adbfe60825df Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYTU5OTg0YjRjYjcxMWVlYjE4NmJjYTRmNWIzNWFkYmZlNjA4MjVkZiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- .../spanner_admin_database_v1/__init__.py | 6 + .../gapic_metadata.json | 10 + .../services/database_admin/async_client.py | 162 ++++++++++++ .../services/database_admin/client.py | 162 ++++++++++++ .../database_admin/transports/base.py | 12 + .../database_admin/transports/grpc.py | 38 +++ .../database_admin/transports/grpc_asyncio.py | 38 +++ .../types/__init__.py | 6 + .../spanner_admin_database_v1/types/backup.py | 185 ++++++++++++- .../types/spanner_database_admin.py | 2 + ...et_metadata_spanner admin database_v1.json | 89 +++++++ ...erated_database_admin_copy_backup_async.py | 51 ++++ ...nerated_database_admin_copy_backup_sync.py | 51 ++++ ...ixup_spanner_admin_database_v1_keywords.py | 1 + .../test_database_admin.py | 244 ++++++++++++++++++ 15 files changed, 1050 insertions(+), 7 deletions(-) create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_copy_backup_async.py create mode 100644 samples/generated_samples/spanner_v1_generated_database_admin_copy_backup_sync.py diff --git a/google/cloud/spanner_admin_database_v1/__init__.py b/google/cloud/spanner_admin_database_v1/__init__.py index e587590c9a..ee52bda123 100644 --- a/google/cloud/spanner_admin_database_v1/__init__.py +++ b/google/cloud/spanner_admin_database_v1/__init__.py @@ -19,6 +19,9 @@ from .types.backup import Backup from .types.backup import BackupInfo +from .types.backup import CopyBackupEncryptionConfig +from .types.backup import CopyBackupMetadata +from .types.backup import CopyBackupRequest from .types.backup import CreateBackupEncryptionConfig from .types.backup import CreateBackupMetadata from .types.backup import CreateBackupRequest @@ -57,6 +60,9 @@ "DatabaseAdminAsyncClient", "Backup", "BackupInfo", + "CopyBackupEncryptionConfig", + "CopyBackupMetadata", + "CopyBackupRequest", "CreateBackupEncryptionConfig", "CreateBackupMetadata", "CreateBackupRequest", diff --git a/google/cloud/spanner_admin_database_v1/gapic_metadata.json b/google/cloud/spanner_admin_database_v1/gapic_metadata.json index 1460097dc3..f7272318ef 100644 --- a/google/cloud/spanner_admin_database_v1/gapic_metadata.json +++ b/google/cloud/spanner_admin_database_v1/gapic_metadata.json @@ -10,6 +10,11 @@ "grpc": { "libraryClient": "DatabaseAdminClient", "rpcs": { + "CopyBackup": { + "methods": [ + "copy_backup" + ] + }, "CreateBackup": { "methods": [ "create_backup" @@ -100,6 +105,11 @@ "grpc-async": { "libraryClient": "DatabaseAdminAsyncClient", "rpcs": { + "CopyBackup": { + "methods": [ + "copy_backup" + ] + }, "CreateBackup": { "methods": [ "create_backup" diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py b/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py index add0829bc8..e4793ae26b 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py @@ -1506,6 +1506,168 @@ def sample_create_backup(): # Done; return the response. return response + async def copy_backup( + self, + request: Union[backup.CopyBackupRequest, dict] = None, + *, + parent: str = None, + backup_id: str = None, + source_backup: str = None, + expire_time: timestamp_pb2.Timestamp = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Starts copying a Cloud Spanner Backup. The returned backup + [long-running operation][google.longrunning.Operation] will have + a name of the format + ``projects//instances//backups//operations/`` + and can be used to track copying of the backup. The operation is + associated with the destination backup. The + [metadata][google.longrunning.Operation.metadata] field type is + [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. + The [response][google.longrunning.Operation.response] field type + is [Backup][google.spanner.admin.database.v1.Backup], if + successful. Cancelling the returned operation will stop the + copying and delete the backup. Concurrent CopyBackup requests + can run on the same source backup. + + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_copy_backup(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.CopyBackupRequest( + parent="parent_value", + backup_id="backup_id_value", + source_backup="source_backup_value", + ) + + # Make the request + operation = client.copy_backup(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.spanner_admin_database_v1.types.CopyBackupRequest, dict]): + The request object. The request for + [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup]. + parent (:class:`str`): + Required. The name of the destination instance that will + contain the backup copy. Values are of the form: + ``projects//instances/``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + backup_id (:class:`str`): + Required. The id of the backup copy. The ``backup_id`` + appended to ``parent`` forms the full backup_uri of the + form + ``projects//instances//backups/``. + + This corresponds to the ``backup_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + source_backup (:class:`str`): + Required. The source backup to be copied. The source + backup needs to be in READY state for it to be copied. + Once CopyBackup is in progress, the source backup cannot + be deleted or cleaned up on expiration until CopyBackup + is finished. Values are of the form: + ``projects//instances//backups/``. + + This corresponds to the ``source_backup`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + expire_time (:class:`google.protobuf.timestamp_pb2.Timestamp`): + Required. The expiration time of the backup in + microsecond granularity. The expiration time must be at + least 6 hours and at most 366 days from the + ``create_time`` of the source backup. Once the + ``expire_time`` has passed, the backup is eligible to be + automatically deleted by Cloud Spanner to free the + resources used by the backup. + + This corresponds to the ``expire_time`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.spanner_admin_database_v1.types.Backup` + A backup of a Cloud Spanner database. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, backup_id, source_backup, expire_time]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = backup.CopyBackupRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if backup_id is not None: + request.backup_id = backup_id + if source_backup is not None: + request.source_backup = source_backup + if expire_time is not None: + request.expire_time = expire_time + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.copy_backup, + default_timeout=3600.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + backup.Backup, + metadata_type=backup.CopyBackupMetadata, + ) + + # Done; return the response. + return response + async def get_backup( self, request: Union[backup.GetBackupRequest, dict] = None, diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/client.py b/google/cloud/spanner_admin_database_v1/services/database_admin/client.py index 120dec124a..a7106d7aa7 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/client.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/client.py @@ -1704,6 +1704,168 @@ def sample_create_backup(): # Done; return the response. return response + def copy_backup( + self, + request: Union[backup.CopyBackupRequest, dict] = None, + *, + parent: str = None, + backup_id: str = None, + source_backup: str = None, + expire_time: timestamp_pb2.Timestamp = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Starts copying a Cloud Spanner Backup. The returned backup + [long-running operation][google.longrunning.Operation] will have + a name of the format + ``projects//instances//backups//operations/`` + and can be used to track copying of the backup. The operation is + associated with the destination backup. The + [metadata][google.longrunning.Operation.metadata] field type is + [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. + The [response][google.longrunning.Operation.response] field type + is [Backup][google.spanner.admin.database.v1.Backup], if + successful. Cancelling the returned operation will stop the + copying and delete the backup. Concurrent CopyBackup requests + can run on the same source backup. + + + .. code-block:: python + + from google.cloud import spanner_admin_database_v1 + + def sample_copy_backup(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.CopyBackupRequest( + parent="parent_value", + backup_id="backup_id_value", + source_backup="source_backup_value", + ) + + # Make the request + operation = client.copy_backup(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.spanner_admin_database_v1.types.CopyBackupRequest, dict]): + The request object. The request for + [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup]. + parent (str): + Required. The name of the destination instance that will + contain the backup copy. Values are of the form: + ``projects//instances/``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + backup_id (str): + Required. The id of the backup copy. The ``backup_id`` + appended to ``parent`` forms the full backup_uri of the + form + ``projects//instances//backups/``. + + This corresponds to the ``backup_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + source_backup (str): + Required. The source backup to be copied. The source + backup needs to be in READY state for it to be copied. + Once CopyBackup is in progress, the source backup cannot + be deleted or cleaned up on expiration until CopyBackup + is finished. Values are of the form: + ``projects//instances//backups/``. + + This corresponds to the ``source_backup`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + expire_time (google.protobuf.timestamp_pb2.Timestamp): + Required. The expiration time of the backup in + microsecond granularity. The expiration time must be at + least 6 hours and at most 366 days from the + ``create_time`` of the source backup. Once the + ``expire_time`` has passed, the backup is eligible to be + automatically deleted by Cloud Spanner to free the + resources used by the backup. + + This corresponds to the ``expire_time`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.spanner_admin_database_v1.types.Backup` + A backup of a Cloud Spanner database. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, backup_id, source_backup, expire_time]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a backup.CopyBackupRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, backup.CopyBackupRequest): + request = backup.CopyBackupRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if backup_id is not None: + request.backup_id = backup_id + if source_backup is not None: + request.source_backup = source_backup + if expire_time is not None: + request.expire_time = expire_time + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.copy_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),)), + ) + + # 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, + backup.Backup, + metadata_type=backup.CopyBackupMetadata, + ) + + # Done; return the response. + return response + def get_backup( self, request: Union[backup.GetBackupRequest, dict] = None, diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py index 090e2a954e..18dfc4074c 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py @@ -234,6 +234,9 @@ def _prep_wrapped_messages(self, client_info): self.create_backup: gapic_v1.method.wrap_method( self.create_backup, default_timeout=3600.0, client_info=client_info, ), + self.copy_backup: gapic_v1.method.wrap_method( + self.copy_backup, default_timeout=3600.0, client_info=client_info, + ), self.get_backup: gapic_v1.method.wrap_method( self.get_backup, default_retry=retries.Retry( @@ -444,6 +447,15 @@ def create_backup( ]: raise NotImplementedError() + @property + def copy_backup( + self, + ) -> Callable[ + [backup.CopyBackupRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + @property def get_backup( self, diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py index 9c0d1ea4d0..6f1d695122 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py @@ -593,6 +593,44 @@ def create_backup( ) return self._stubs["create_backup"] + @property + def copy_backup( + self, + ) -> Callable[[backup.CopyBackupRequest], operations_pb2.Operation]: + r"""Return a callable for the copy backup method over gRPC. + + Starts copying a Cloud Spanner Backup. The returned backup + [long-running operation][google.longrunning.Operation] will have + a name of the format + ``projects//instances//backups//operations/`` + and can be used to track copying of the backup. The operation is + associated with the destination backup. The + [metadata][google.longrunning.Operation.metadata] field type is + [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. + The [response][google.longrunning.Operation.response] field type + is [Backup][google.spanner.admin.database.v1.Backup], if + successful. Cancelling the returned operation will stop the + copying and delete the backup. Concurrent CopyBackup requests + can run on the same source backup. + + Returns: + Callable[[~.CopyBackupRequest], + ~.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 "copy_backup" not in self._stubs: + self._stubs["copy_backup"] = self.grpc_channel.unary_unary( + "/google.spanner.admin.database.v1.DatabaseAdmin/CopyBackup", + request_serializer=backup.CopyBackupRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["copy_backup"] + @property def get_backup(self) -> Callable[[backup.GetBackupRequest], backup.Backup]: r"""Return a callable for the get backup method over gRPC. diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py index fd35a3eaf5..2a3200a882 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py @@ -604,6 +604,44 @@ def create_backup( ) return self._stubs["create_backup"] + @property + def copy_backup( + self, + ) -> Callable[[backup.CopyBackupRequest], Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the copy backup method over gRPC. + + Starts copying a Cloud Spanner Backup. The returned backup + [long-running operation][google.longrunning.Operation] will have + a name of the format + ``projects//instances//backups//operations/`` + and can be used to track copying of the backup. The operation is + associated with the destination backup. The + [metadata][google.longrunning.Operation.metadata] field type is + [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. + The [response][google.longrunning.Operation.response] field type + is [Backup][google.spanner.admin.database.v1.Backup], if + successful. Cancelling the returned operation will stop the + copying and delete the backup. Concurrent CopyBackup requests + can run on the same source backup. + + Returns: + Callable[[~.CopyBackupRequest], + 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 "copy_backup" not in self._stubs: + self._stubs["copy_backup"] = self.grpc_channel.unary_unary( + "/google.spanner.admin.database.v1.DatabaseAdmin/CopyBackup", + request_serializer=backup.CopyBackupRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["copy_backup"] + @property def get_backup( self, diff --git a/google/cloud/spanner_admin_database_v1/types/__init__.py b/google/cloud/spanner_admin_database_v1/types/__init__.py index 8a7e38d1ab..8d4b5f4094 100644 --- a/google/cloud/spanner_admin_database_v1/types/__init__.py +++ b/google/cloud/spanner_admin_database_v1/types/__init__.py @@ -16,6 +16,9 @@ from .backup import ( Backup, BackupInfo, + CopyBackupEncryptionConfig, + CopyBackupMetadata, + CopyBackupRequest, CreateBackupEncryptionConfig, CreateBackupMetadata, CreateBackupRequest, @@ -58,6 +61,9 @@ __all__ = ( "Backup", "BackupInfo", + "CopyBackupEncryptionConfig", + "CopyBackupMetadata", + "CopyBackupRequest", "CreateBackupEncryptionConfig", "CreateBackupMetadata", "CreateBackupRequest", diff --git a/google/cloud/spanner_admin_database_v1/types/backup.py b/google/cloud/spanner_admin_database_v1/types/backup.py index da5f4d4b2e..b4cff201a2 100644 --- a/google/cloud/spanner_admin_database_v1/types/backup.py +++ b/google/cloud/spanner_admin_database_v1/types/backup.py @@ -27,6 +27,8 @@ "Backup", "CreateBackupRequest", "CreateBackupMetadata", + "CopyBackupRequest", + "CopyBackupMetadata", "UpdateBackupRequest", "GetBackupRequest", "DeleteBackupRequest", @@ -36,6 +38,7 @@ "ListBackupOperationsResponse", "BackupInfo", "CreateBackupEncryptionConfig", + "CopyBackupEncryptionConfig", }, ) @@ -107,6 +110,23 @@ class Backup(proto.Message): database_dialect (google.cloud.spanner_admin_database_v1.types.DatabaseDialect): Output only. The database dialect information for the backup. + referencing_backups (Sequence[str]): + Output only. The names of the destination backups being + created by copying this source backup. The backup names are + of the form + ``projects//instances//backups/``. + Referencing backups may exist in different instances. The + existence of any referencing backup prevents the backup from + being deleted. When the copy operation is done (either + successfully completed or cancelled or the destination + backup is deleted), the reference to the backup is removed. + max_expire_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The max allowed expiration time of the backup, + with microseconds granularity. A backup's expiration time + can be configured in multiple APIs: CreateBackup, + UpdateBackup, CopyBackup. When updating or copying an + existing backup, the expiration time specified must be less + than ``Backup.max_expire_time``. """ class State(proto.Enum): @@ -129,6 +149,10 @@ class State(proto.Enum): proto.MESSAGE, number=8, message=common.EncryptionInfo, ) database_dialect = proto.Field(proto.ENUM, number=10, enum=common.DatabaseDialect,) + referencing_backups = proto.RepeatedField(proto.STRING, number=11,) + max_expire_time = proto.Field( + proto.MESSAGE, number=12, message=timestamp_pb2.Timestamp, + ) class CreateBackupRequest(proto.Message): @@ -204,6 +228,91 @@ class CreateBackupMetadata(proto.Message): cancel_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) +class CopyBackupRequest(proto.Message): + r"""The request for + [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup]. + + Attributes: + parent (str): + Required. The name of the destination instance that will + contain the backup copy. Values are of the form: + ``projects//instances/``. + backup_id (str): + Required. The id of the backup copy. The ``backup_id`` + appended to ``parent`` forms the full backup_uri of the form + ``projects//instances//backups/``. + source_backup (str): + Required. The source backup to be copied. The source backup + needs to be in READY state for it to be copied. Once + CopyBackup is in progress, the source backup cannot be + deleted or cleaned up on expiration until CopyBackup is + finished. Values are of the form: + ``projects//instances//backups/``. + expire_time (google.protobuf.timestamp_pb2.Timestamp): + Required. The expiration time of the backup in microsecond + granularity. The expiration time must be at least 6 hours + and at most 366 days from the ``create_time`` of the source + backup. Once the ``expire_time`` has passed, the backup is + eligible to be automatically deleted by Cloud Spanner to + free the resources used by the backup. + encryption_config (google.cloud.spanner_admin_database_v1.types.CopyBackupEncryptionConfig): + Optional. The encryption configuration used to encrypt the + backup. If this field is not specified, the backup will use + the same encryption configuration as the source backup by + default, namely + [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] + = ``USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION``. + """ + + parent = proto.Field(proto.STRING, number=1,) + backup_id = proto.Field(proto.STRING, number=2,) + source_backup = proto.Field(proto.STRING, number=3,) + expire_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + encryption_config = proto.Field( + proto.MESSAGE, number=5, message="CopyBackupEncryptionConfig", + ) + + +class CopyBackupMetadata(proto.Message): + r"""Metadata type for the google.longrunning.Operation returned by + [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup]. + + Attributes: + name (str): + The name of the backup being created through the copy + operation. Values are of the form + ``projects//instances//backups/``. + source_backup (str): + The name of the source backup that is being copied. Values + are of the form + ``projects//instances//backups/``. + progress (google.cloud.spanner_admin_database_v1.types.OperationProgress): + The progress of the + [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup] + operation. + cancel_time (google.protobuf.timestamp_pb2.Timestamp): + The time at which cancellation of CopyBackup operation was + received. + [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] + starts asynchronous cancellation on a long-running + operation. The server makes a best effort to cancel the + operation, but success is not guaranteed. Clients can use + [Operations.GetOperation][google.longrunning.Operations.GetOperation] + or other methods to check whether the cancellation succeeded + or whether the operation completed despite cancellation. On + successful cancellation, the operation is not deleted; + instead, it becomes an operation with an + [Operation.error][google.longrunning.Operation.error] value + with a [google.rpc.Status.code][google.rpc.Status.code] of + 1, corresponding to ``Code.CANCELLED``. + """ + + name = proto.Field(proto.STRING, number=1,) + source_backup = proto.Field(proto.STRING, number=2,) + progress = proto.Field(proto.MESSAGE, number=3, message=common.OperationProgress,) + cancel_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + + class UpdateBackupRequest(proto.Message): r"""The request for [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup]. @@ -386,6 +495,8 @@ class ListBackupOperationsRequest(proto.Message): is ``type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata``. - ``metadata.`` - any field in metadata.value. + ``metadata.@type`` must be specified first if filtering + on metadata fields. - ``error`` - Error associated with the long-running operation. - ``response.@type`` - the type of response. @@ -399,8 +510,14 @@ class ListBackupOperationsRequest(proto.Message): Here are a few examples: - ``done:true`` - The operation is complete. - - ``metadata.database:prod`` - The database the backup was - taken from has a name containing the string "prod". + - ``(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND`` + ``metadata.database:prod`` - Returns operations where: + + - The operation's metadata type is + [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. + - The database the backup was taken from has a name + containing the string "prod". + - ``(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND`` ``(metadata.name:howl) AND`` ``(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND`` @@ -411,6 +528,37 @@ class ListBackupOperationsRequest(proto.Message): - The backup name contains the string "howl". - The operation started before 2018-03-28T14:50:00Z. - The operation resulted in an error. + + - ``(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) AND`` + ``(metadata.source_backup:test) AND`` + ``(metadata.progress.start_time < \"2022-01-18T14:50:00Z\") AND`` + ``(error:*)`` - Returns operations where: + + - The operation's metadata type is + [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. + - The source backup of the copied backup name contains + the string "test". + - The operation started before 2022-01-18T14:50:00Z. + - The operation resulted in an error. + + - ``((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND`` + ``(metadata.database:test_db)) OR`` + ``((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) AND`` + ``(metadata.source_backup:test_bkp)) AND`` + ``(error:*)`` - Returns operations where: + + - The operation's metadata matches either of criteria: + + - The operation's metadata type is + [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata] + AND the database the backup was taken from has name + containing string "test_db" + - The operation's metadata type is + [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata] + AND the backup the backup was copied from has name + containing string "test_bkp" + + - The operation resulted in an error. page_size (int): Number of operations to be returned in the response. If 0 or less, defaults to the server's @@ -437,11 +585,9 @@ class ListBackupOperationsResponse(proto.Message): operations (Sequence[google.longrunning.operations_pb2.Operation]): The list of matching backup [long-running operations][google.longrunning.Operation]. Each operation's - name will be prefixed by the backup's name and the - operation's - [metadata][google.longrunning.Operation.metadata] will be of - type - [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. + name will be prefixed by the backup's name. The operation's + [metadata][google.longrunning.Operation.metadata] field type + ``metadata.type_url`` describes the type of the metadata. Operations returned include those that are pending or have completed/failed/canceled within the last 7 days. Operations returned are ordered by @@ -520,4 +666,29 @@ class EncryptionType(proto.Enum): kms_key_name = proto.Field(proto.STRING, number=2,) +class CopyBackupEncryptionConfig(proto.Message): + r"""Encryption configuration for the copied backup. + + Attributes: + encryption_type (google.cloud.spanner_admin_database_v1.types.CopyBackupEncryptionConfig.EncryptionType): + Required. The encryption type of the backup. + kms_key_name (str): + Optional. The Cloud KMS key that will be used to protect the + backup. This field should be set only when + [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] + is ``CUSTOMER_MANAGED_ENCRYPTION``. Values are of the form + ``projects//locations//keyRings//cryptoKeys/``. + """ + + class EncryptionType(proto.Enum): + r"""Encryption types for the backup.""" + ENCRYPTION_TYPE_UNSPECIFIED = 0 + USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION = 1 + GOOGLE_DEFAULT_ENCRYPTION = 2 + CUSTOMER_MANAGED_ENCRYPTION = 3 + + encryption_type = proto.Field(proto.ENUM, number=1, enum=EncryptionType,) + kms_key_name = proto.Field(proto.STRING, number=2,) + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py b/google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py index 42cf4f484f..c9c519334b 100644 --- a/google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py +++ b/google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py @@ -447,6 +447,8 @@ class ListDatabaseOperationsRequest(proto.Message): is ``type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata``. - ``metadata.`` - any field in metadata.value. + ``metadata.@type`` must be specified first, if filtering + on metadata fields. - ``error`` - Error associated with the long-running operation. - ``response.@type`` - the type of response. diff --git a/samples/generated_samples/snippet_metadata_spanner admin database_v1.json b/samples/generated_samples/snippet_metadata_spanner admin database_v1.json index 10a85bf3f2..5564ff3d37 100644 --- a/samples/generated_samples/snippet_metadata_spanner admin database_v1.json +++ b/samples/generated_samples/snippet_metadata_spanner admin database_v1.json @@ -1,5 +1,94 @@ { "snippets": [ + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "CopyBackup" + } + }, + "file": "spanner_v1_generated_database_admin_copy_backup_async.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_CopyBackup_async", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 40, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DatabaseAdmin" + }, + "shortName": "CopyBackup" + } + }, + "file": "spanner_v1_generated_database_admin_copy_backup_sync.py", + "regionTag": "spanner_v1_generated_DatabaseAdmin_CopyBackup_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 40, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ] + }, { "clientMethod": { "async": true, diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_copy_backup_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_copy_backup_async.py new file mode 100644 index 0000000000..645e606faf --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_copy_backup_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CopyBackup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_CopyBackup_async] +from google.cloud import spanner_admin_database_v1 + + +async def sample_copy_backup(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminAsyncClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.CopyBackupRequest( + parent="parent_value", + backup_id="backup_id_value", + source_backup="source_backup_value", + ) + + # Make the request + operation = client.copy_backup(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_CopyBackup_async] diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_copy_backup_sync.py b/samples/generated_samples/spanner_v1_generated_database_admin_copy_backup_sync.py new file mode 100644 index 0000000000..f5babd289c --- /dev/null +++ b/samples/generated_samples/spanner_v1_generated_database_admin_copy_backup_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CopyBackup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-spanner-admin-database + + +# [START spanner_v1_generated_DatabaseAdmin_CopyBackup_sync] +from google.cloud import spanner_admin_database_v1 + + +def sample_copy_backup(): + # Create a client + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Initialize request argument(s) + request = spanner_admin_database_v1.CopyBackupRequest( + parent="parent_value", + backup_id="backup_id_value", + source_backup="source_backup_value", + ) + + # Make the request + operation = client.copy_backup(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END spanner_v1_generated_DatabaseAdmin_CopyBackup_sync] diff --git a/scripts/fixup_spanner_admin_database_v1_keywords.py b/scripts/fixup_spanner_admin_database_v1_keywords.py index 5a0630802f..5c11670473 100644 --- a/scripts/fixup_spanner_admin_database_v1_keywords.py +++ b/scripts/fixup_spanner_admin_database_v1_keywords.py @@ -39,6 +39,7 @@ def partition( class spanner_admin_databaseCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'copy_backup': ('parent', 'backup_id', 'source_backup', 'expire_time', 'encryption_config', ), 'create_backup': ('parent', 'backup_id', 'backup', 'encryption_config', ), 'create_database': ('parent', 'create_statement', 'extra_statements', 'encryption_config', 'database_dialect', ), 'delete_backup': ('name', ), diff --git a/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py b/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py index de918f8c79..71fb398101 100644 --- a/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py +++ b/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py @@ -3005,6 +3005,241 @@ async def test_create_backup_flattened_error_async(): ) +@pytest.mark.parametrize("request_type", [backup.CopyBackupRequest, dict,]) +def test_copy_backup(request_type, transport: str = "grpc"): + client = DatabaseAdminClient( + 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.copy_backup), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.copy_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] == backup.CopyBackupRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_copy_backup_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.copy_backup), "__call__") as call: + client.copy_backup() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == backup.CopyBackupRequest() + + +@pytest.mark.asyncio +async def test_copy_backup_async( + transport: str = "grpc_asyncio", request_type=backup.CopyBackupRequest +): + client = DatabaseAdminAsyncClient( + 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.copy_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.copy_backup(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == backup.CopyBackupRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_copy_backup_async_from_dict(): + await test_copy_backup_async(request_type=dict) + + +def test_copy_backup_field_headers(): + client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value 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.CopyBackupRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.copy_backup), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.copy_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_copy_backup_field_headers_async(): + client = DatabaseAdminAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value 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.CopyBackupRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.copy_backup), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.copy_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_copy_backup_flattened(): + client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.copy_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.copy_backup( + parent="parent_value", + backup_id="backup_id_value", + source_backup="source_backup_value", + expire_time=timestamp_pb2.Timestamp(seconds=751), + ) + + # 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_id + mock_val = "backup_id_value" + assert arg == mock_val + arg = args[0].source_backup + mock_val = "source_backup_value" + assert arg == mock_val + assert TimestampRule().to_proto(args[0].expire_time) == timestamp_pb2.Timestamp( + seconds=751 + ) + + +def test_copy_backup_flattened_error(): + client = DatabaseAdminClient(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.copy_backup( + backup.CopyBackupRequest(), + parent="parent_value", + backup_id="backup_id_value", + source_backup="source_backup_value", + expire_time=timestamp_pb2.Timestamp(seconds=751), + ) + + +@pytest.mark.asyncio +async def test_copy_backup_flattened_async(): + client = DatabaseAdminAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.copy_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.copy_backup( + parent="parent_value", + backup_id="backup_id_value", + source_backup="source_backup_value", + expire_time=timestamp_pb2.Timestamp(seconds=751), + ) + + # 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_id + mock_val = "backup_id_value" + assert arg == mock_val + arg = args[0].source_backup + mock_val = "source_backup_value" + assert arg == mock_val + assert TimestampRule().to_proto(args[0].expire_time) == timestamp_pb2.Timestamp( + seconds=751 + ) + + +@pytest.mark.asyncio +async def test_copy_backup_flattened_error_async(): + client = DatabaseAdminAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.copy_backup( + backup.CopyBackupRequest(), + parent="parent_value", + backup_id="backup_id_value", + source_backup="source_backup_value", + expire_time=timestamp_pb2.Timestamp(seconds=751), + ) + + @pytest.mark.parametrize("request_type", [backup.GetBackupRequest, dict,]) def test_get_backup(request_type, transport: str = "grpc"): client = DatabaseAdminClient( @@ -3025,6 +3260,7 @@ def test_get_backup(request_type, transport: str = "grpc"): state=backup.Backup.State.CREATING, referencing_databases=["referencing_databases_value"], database_dialect=common.DatabaseDialect.GOOGLE_STANDARD_SQL, + referencing_backups=["referencing_backups_value"], ) response = client.get_backup(request) @@ -3041,6 +3277,7 @@ def test_get_backup(request_type, transport: str = "grpc"): assert response.state == backup.Backup.State.CREATING assert response.referencing_databases == ["referencing_databases_value"] assert response.database_dialect == common.DatabaseDialect.GOOGLE_STANDARD_SQL + assert response.referencing_backups == ["referencing_backups_value"] def test_get_backup_empty_call(): @@ -3081,6 +3318,7 @@ async def test_get_backup_async( state=backup.Backup.State.CREATING, referencing_databases=["referencing_databases_value"], database_dialect=common.DatabaseDialect.GOOGLE_STANDARD_SQL, + referencing_backups=["referencing_backups_value"], ) ) response = await client.get_backup(request) @@ -3098,6 +3336,7 @@ async def test_get_backup_async( assert response.state == backup.Backup.State.CREATING assert response.referencing_databases == ["referencing_databases_value"] assert response.database_dialect == common.DatabaseDialect.GOOGLE_STANDARD_SQL + assert response.referencing_backups == ["referencing_backups_value"] @pytest.mark.asyncio @@ -3246,6 +3485,7 @@ def test_update_backup(request_type, transport: str = "grpc"): state=gsad_backup.Backup.State.CREATING, referencing_databases=["referencing_databases_value"], database_dialect=common.DatabaseDialect.GOOGLE_STANDARD_SQL, + referencing_backups=["referencing_backups_value"], ) response = client.update_backup(request) @@ -3262,6 +3502,7 @@ def test_update_backup(request_type, transport: str = "grpc"): assert response.state == gsad_backup.Backup.State.CREATING assert response.referencing_databases == ["referencing_databases_value"] assert response.database_dialect == common.DatabaseDialect.GOOGLE_STANDARD_SQL + assert response.referencing_backups == ["referencing_backups_value"] def test_update_backup_empty_call(): @@ -3302,6 +3543,7 @@ async def test_update_backup_async( state=gsad_backup.Backup.State.CREATING, referencing_databases=["referencing_databases_value"], database_dialect=common.DatabaseDialect.GOOGLE_STANDARD_SQL, + referencing_backups=["referencing_backups_value"], ) ) response = await client.update_backup(request) @@ -3319,6 +3561,7 @@ async def test_update_backup_async( assert response.state == gsad_backup.Backup.State.CREATING assert response.referencing_databases == ["referencing_databases_value"] assert response.database_dialect == common.DatabaseDialect.GOOGLE_STANDARD_SQL + assert response.referencing_backups == ["referencing_backups_value"] @pytest.mark.asyncio @@ -5076,6 +5319,7 @@ def test_database_admin_base_transport(): "get_iam_policy", "test_iam_permissions", "create_backup", + "copy_backup", "get_backup", "update_backup", "delete_backup", From 97faf6c11f985f128446bc7d9e99a22362bd1bc1 Mon Sep 17 00:00:00 2001 From: Astha Mohta <35952883+asthamohta@users.noreply.github.com> Date: Fri, 25 Mar 2022 14:42:36 +0530 Subject: [PATCH 09/16] feat: add support for spanner copy backup feature (#600) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * changes for copy backup feature * changes to test case * changes to documenttation * feat: changes as per review, adding shared_backup * changes for cross region backup * samples: changes to list backup operations * chore(deps): update all dependencies (#689) * chore(deps): update dependency pytest to v7.1.1 (#690) * feat: add support for Cross region backup proto changes (#691) * Synchronize new proto/yaml changes. PiperOrigin-RevId: 436114471 Source-Link: https://github.com/googleapis/googleapis/commit/6379d5fe706781af6682447f77f20d18b4db05b2 Source-Link: https://github.com/googleapis/googleapis-gen/commit/a59984b4cb711eeb186bca4f5b35adbfe60825df Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYTU5OTg0YjRjYjcxMWVlYjE4NmJjYTRmNWIzNWFkYmZlNjA4MjVkZiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot * feat: adding samples * linting Co-authored-by: WhiteSource Renovate Co-authored-by: gcf-owl-bot[bot] <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Owl Bot --- google/cloud/spanner_v1/backup.py | 67 +++++++++++++-- google/cloud/spanner_v1/instance.py | 33 ++++++++ samples/samples/autocommit.py | 7 +- samples/samples/autocommit_test.py | 2 +- samples/samples/backup_sample.py | 112 +++++++++++++++++++++----- samples/samples/backup_sample_test.py | 46 +++++++---- samples/samples/conftest.py | 6 +- samples/samples/noxfile.py | 8 +- samples/samples/snippets.py | 86 +++++++++++--------- samples/samples/snippets_test.py | 36 +++++++-- tests/system/_helpers.py | 3 + tests/system/conftest.py | 33 ++++++++ tests/system/test_backup_api.py | 56 +++++++++++++ 13 files changed, 395 insertions(+), 100 deletions(-) diff --git a/google/cloud/spanner_v1/backup.py b/google/cloud/spanner_v1/backup.py index dba7ba1fcb..d7a97809f1 100644 --- a/google/cloud/spanner_v1/backup.py +++ b/google/cloud/spanner_v1/backup.py @@ -21,6 +21,8 @@ from google.cloud.spanner_admin_database_v1 import Backup as BackupPB from google.cloud.spanner_admin_database_v1 import CreateBackupEncryptionConfig from google.cloud.spanner_admin_database_v1 import CreateBackupRequest +from google.cloud.spanner_admin_database_v1 import CopyBackupEncryptionConfig +from google.cloud.spanner_admin_database_v1 import CopyBackupRequest from google.cloud.spanner_v1._helpers import _metadata_with_prefix _BACKUP_NAME_RE = re.compile( @@ -77,10 +79,12 @@ def __init__( expire_time=None, version_time=None, encryption_config=None, + source_backup=None, ): self.backup_id = backup_id self._instance = instance self._database = database + self._source_backup = source_backup self._expire_time = expire_time self._create_time = None self._version_time = version_time @@ -88,8 +92,17 @@ def __init__( self._state = None self._referencing_databases = None self._encryption_info = None + self._max_expire_time = None + self._referencing_backups = None if type(encryption_config) == dict: - self._encryption_config = CreateBackupEncryptionConfig(**encryption_config) + if source_backup: + self._encryption_config = CopyBackupEncryptionConfig( + **encryption_config + ) + else: + self._encryption_config = CreateBackupEncryptionConfig( + **encryption_config + ) else: self._encryption_config = encryption_config @@ -185,6 +198,24 @@ def encryption_info(self): """ return self._encryption_info + @property + def max_expire_time(self): + """The max allowed expiration time of the backup. + :rtype: :class:`datetime.datetime` + :returns: a datetime object representing the max expire time of + this backup + """ + return self._max_expire_time + + @property + def referencing_backups(self): + """The names of the destination backups being created by copying this source backup. + :rtype: list of strings + :returns: a list of backup path strings which specify the backups that are + referencing this copy backup + """ + return self._referencing_backups + @classmethod def from_pb(cls, backup_pb, instance): """Create an instance of this class from a protobuf message. @@ -223,7 +254,7 @@ def from_pb(cls, backup_pb, instance): return cls(backup_id, instance) def create(self): - """Create this backup within its instance. + """Create this backup or backup copy within its instance. :rtype: :class:`~google.api_core.operation.Operation` :returns: a future used to poll the status of the create request @@ -234,17 +265,39 @@ def create(self): """ if not self._expire_time: raise ValueError("expire_time not set") - if not self._database: - raise ValueError("database not set") + + if not self._database and not self._source_backup: + raise ValueError("database and source backup both not set") + if ( - self._encryption_config + ( + self._encryption_config + and self._encryption_config.kms_key_name + and self._encryption_config.encryption_type + != CreateBackupEncryptionConfig.EncryptionType.CUSTOMER_MANAGED_ENCRYPTION + ) + and self._encryption_config and self._encryption_config.kms_key_name and self._encryption_config.encryption_type - != CreateBackupEncryptionConfig.EncryptionType.CUSTOMER_MANAGED_ENCRYPTION + != CopyBackupEncryptionConfig.EncryptionType.CUSTOMER_MANAGED_ENCRYPTION ): raise ValueError("kms_key_name only used with CUSTOMER_MANAGED_ENCRYPTION") + api = self._instance._client.database_admin_api metadata = _metadata_with_prefix(self.name) + + if self._source_backup: + request = CopyBackupRequest( + parent=self._instance.name, + backup_id=self.backup_id, + source_backup=self._source_backup, + expire_time=self._expire_time, + encryption_config=self._encryption_config, + ) + + future = api.copy_backup(request=request, metadata=metadata,) + return future + backup = BackupPB( database=self._database, expire_time=self.expire_time, @@ -294,6 +347,8 @@ def reload(self): self._state = BackupPB.State(pb.state) self._referencing_databases = pb.referencing_databases self._encryption_info = pb.encryption_info + self._max_expire_time = pb.max_expire_time + self._referencing_backups = pb.referencing_backups def update_expire_time(self, new_expire_time): """Update the expire time of this backup. diff --git a/google/cloud/spanner_v1/instance.py b/google/cloud/spanner_v1/instance.py index 75e70eaf17..d3514bd85d 100644 --- a/google/cloud/spanner_v1/instance.py +++ b/google/cloud/spanner_v1/instance.py @@ -44,6 +44,7 @@ _OPERATION_METADATA_MESSAGES = ( backup.Backup, backup.CreateBackupMetadata, + backup.CopyBackupMetadata, spanner_database_admin.CreateDatabaseMetadata, spanner_database_admin.Database, spanner_database_admin.OptimizeRestoredDatabaseMetadata, @@ -58,6 +59,7 @@ _OPERATION_RESPONSE_TYPES = { backup.CreateBackupMetadata: backup.Backup, + backup.CopyBackupMetadata: backup.Backup, spanner_database_admin.CreateDatabaseMetadata: spanner_database_admin.Database, spanner_database_admin.OptimizeRestoredDatabaseMetadata: spanner_database_admin.Database, spanner_database_admin.RestoreDatabaseMetadata: spanner_database_admin.Database, @@ -551,6 +553,37 @@ def backup( encryption_config=encryption_config, ) + def copy_backup( + self, backup_id, source_backup, expire_time=None, encryption_config=None, + ): + """Factory to create a copy backup within this instance. + + :type backup_id: str + :param backup_id: The ID of the backup copy. + :type source_backup: str + :param source_backup_id: The full path of the source backup to be copied. + :type expire_time: :class:`datetime.datetime` + :param expire_time: + Optional. The expire time that will be used when creating the copy backup. + Required if the create method needs to be called. + :type encryption_config: + :class:`~google.cloud.spanner_admin_database_v1.types.CopyBackupEncryptionConfig` + or :class:`dict` + :param encryption_config: + (Optional) Encryption configuration for the backup. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.spanner_admin_database_v1.types.CopyBackupEncryptionConfig` + :rtype: :class:`~google.cloud.spanner_v1.backup.Backup` + :returns: a copy backup owned by this instance. + """ + return Backup( + backup_id, + self, + source_backup=source_backup, + expire_time=expire_time, + encryption_config=encryption_config, + ) + def list_backups(self, filter_="", page_size=None): """List backups for the instance. diff --git a/samples/samples/autocommit.py b/samples/samples/autocommit.py index 873ed2b7bd..d5c44b0c53 100644 --- a/samples/samples/autocommit.py +++ b/samples/samples/autocommit.py @@ -46,14 +46,11 @@ def enable_autocommit_mode(instance_id, database_id): if __name__ == "__main__": parser = argparse.ArgumentParser( - description=__doc__, - formatter_class=argparse.RawDescriptionHelpFormatter, + description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter, ) parser.add_argument("instance_id", help="Your Cloud Spanner instance ID.") parser.add_argument( - "--database-id", - help="Your Cloud Spanner database ID.", - default="example_db", + "--database-id", help="Your Cloud Spanner database ID.", default="example_db", ) subparsers = parser.add_subparsers(dest="command") subparsers.add_parser("enable_autocommit_mode", help=enable_autocommit_mode.__doc__) diff --git a/samples/samples/autocommit_test.py b/samples/samples/autocommit_test.py index 9880460cac..6b102da8fe 100644 --- a/samples/samples/autocommit_test.py +++ b/samples/samples/autocommit_test.py @@ -19,7 +19,7 @@ def sample_name(): @RetryErrors(exception=Aborted, max_tries=2) def test_enable_autocommit_mode(capsys, instance_id, sample_database): # Delete table if it exists for retry attempts. - table = sample_database.table('Singers') + table = sample_database.table("Singers") if table.exists(): op = sample_database.update_ddl(["DROP TABLE Singers"]) op.result() diff --git a/samples/samples/backup_sample.py b/samples/samples/backup_sample.py index d22530c735..01d3e4bf60 100644 --- a/samples/samples/backup_sample.py +++ b/samples/samples/backup_sample.py @@ -34,7 +34,9 @@ def create_backup(instance_id, database_id, backup_id, version_time): # Create a backup expire_time = datetime.utcnow() + timedelta(days=14) - backup = instance.backup(backup_id, database=database, expire_time=expire_time, version_time=version_time) + backup = instance.backup( + backup_id, database=database, expire_time=expire_time, version_time=version_time + ) operation = backup.create() # Wait for backup operation to complete. @@ -56,7 +58,9 @@ def create_backup(instance_id, database_id, backup_id, version_time): # [END spanner_create_backup] # [START spanner_create_backup_with_encryption_key] -def create_backup_with_encryption_key(instance_id, database_id, backup_id, kms_key_name): +def create_backup_with_encryption_key( + instance_id, database_id, backup_id, kms_key_name +): """Creates a backup for a database using a Customer Managed Encryption Key (CMEK).""" from google.cloud.spanner_admin_database_v1 import CreateBackupEncryptionConfig @@ -67,10 +71,15 @@ def create_backup_with_encryption_key(instance_id, database_id, backup_id, kms_k # Create a backup expire_time = datetime.utcnow() + timedelta(days=14) encryption_config = { - 'encryption_type': CreateBackupEncryptionConfig.EncryptionType.CUSTOMER_MANAGED_ENCRYPTION, - 'kms_key_name': kms_key_name, + "encryption_type": CreateBackupEncryptionConfig.EncryptionType.CUSTOMER_MANAGED_ENCRYPTION, + "kms_key_name": kms_key_name, } - backup = instance.backup(backup_id, database=database, expire_time=expire_time, encryption_config=encryption_config) + backup = instance.backup( + backup_id, + database=database, + expire_time=expire_time, + encryption_config=encryption_config, + ) operation = backup.create() # Wait for backup operation to complete. @@ -115,7 +124,7 @@ def restore_database(instance_id, new_database_id, backup_id): restore_info.backup_info.source_database, new_database_id, restore_info.backup_info.backup, - restore_info.backup_info.version_time + restore_info.backup_info.version_time, ) ) @@ -124,7 +133,9 @@ def restore_database(instance_id, new_database_id, backup_id): # [START spanner_restore_backup_with_encryption_key] -def restore_database_with_encryption_key(instance_id, new_database_id, backup_id, kms_key_name): +def restore_database_with_encryption_key( + instance_id, new_database_id, backup_id, kms_key_name +): """Restores a database from a backup using a Customer Managed Encryption Key (CMEK).""" from google.cloud.spanner_admin_database_v1 import RestoreDatabaseEncryptionConfig @@ -134,10 +145,12 @@ def restore_database_with_encryption_key(instance_id, new_database_id, backup_id # Start restoring an existing backup to a new database. backup = instance.backup(backup_id) encryption_config = { - 'encryption_type': RestoreDatabaseEncryptionConfig.EncryptionType.CUSTOMER_MANAGED_ENCRYPTION, - 'kms_key_name': kms_key_name, + "encryption_type": RestoreDatabaseEncryptionConfig.EncryptionType.CUSTOMER_MANAGED_ENCRYPTION, + "kms_key_name": kms_key_name, } - new_database = instance.database(new_database_id, encryption_config=encryption_config) + new_database = instance.database( + new_database_id, encryption_config=encryption_config + ) operation = new_database.restore(backup) # Wait for restore operation to complete. @@ -192,7 +205,7 @@ def cancel_backup(instance_id, database_id, backup_id): # [START spanner_list_backup_operations] -def list_backup_operations(instance_id, database_id): +def list_backup_operations(instance_id, database_id, backup_id): spanner_client = spanner.Client() instance = spanner_client.instance(instance_id) @@ -211,6 +224,22 @@ def list_backup_operations(instance_id, database_id): ) ) + # List the CopyBackup operations. + filter_ = ( + "(metadata.@type:type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) " + "AND (metadata.source_backup:{})" + ).format(backup_id) + operations = instance.list_backup_operations(filter_=filter_) + for op in operations: + metadata = op.metadata + print( + "Backup {} on source backup {}: {}% complete.".format( + metadata.name, + metadata.source_backup, + metadata.progress.progress_percent, + ) + ) + # [END spanner_list_backup_operations] @@ -291,8 +320,11 @@ def list_backups(instance_id, database_id, backup_id): print("All backups with pagination") # If there are multiple pages, additional ``ListBackup`` # requests will be made as needed while iterating. + paged_backups = set() for backup in instance.list_backups(page_size=2): - print(backup.name) + paged_backups.add(backup.name) + for backup in paged_backups: + print(backup) # [END spanner_list_backups] @@ -330,7 +362,8 @@ def update_backup(instance_id, backup_id): # Expire time must be within 366 days of the create time of the backup. old_expire_time = backup.expire_time - new_expire_time = old_expire_time + timedelta(days=30) + # New expire time should be less than the max expire time + new_expire_time = min(backup.max_expire_time, old_expire_time + timedelta(days=30)) backup.update_expire_time(new_expire_time) print( "Backup {} expire time was updated from {} to {}.".format( @@ -343,7 +376,9 @@ def update_backup(instance_id, backup_id): # [START spanner_create_database_with_version_retention_period] -def create_database_with_version_retention_period(instance_id, database_id, retention_period): +def create_database_with_version_retention_period( + instance_id, database_id, retention_period +): """Creates a database with a version retention period.""" spanner_client = spanner.Client() instance = spanner_client.instance(instance_id) @@ -363,7 +398,7 @@ def create_database_with_version_retention_period(instance_id, database_id, rete "ALTER DATABASE `{}`" " SET OPTIONS (version_retention_period = '{}')".format( database_id, retention_period - ) + ), ] db = instance.database(database_id, ddl_statements) operation = db.create() @@ -372,15 +407,51 @@ def create_database_with_version_retention_period(instance_id, database_id, rete db.reload() - print("Database {} created with version retention period {} and earliest version time {}".format( - db.database_id, db.version_retention_period, db.earliest_version_time - )) + print( + "Database {} created with version retention period {} and earliest version time {}".format( + db.database_id, db.version_retention_period, db.earliest_version_time + ) + ) db.drop() + # [END spanner_create_database_with_version_retention_period] +# [START spanner_copy_backup] +def copy_backup(instance_id, backup_id, source_backup_path): + """Copies a backup.""" + spanner_client = spanner.Client() + instance = spanner_client.instance(instance_id) + + # Create a backup object and wait for copy backup operation to complete. + expire_time = datetime.utcnow() + timedelta(days=14) + copy_backup = instance.copy_backup( + backup_id=backup_id, source_backup=source_backup_path, expire_time=expire_time + ) + operation = copy_backup.create() + + # Wait for copy backup operation to complete. + operation.result(2100) + + # Verify that the copy backup is ready. + copy_backup.reload() + assert copy_backup.is_ready() is True + + print( + "Backup {} of size {} bytes was created at {} with version time {}".format( + copy_backup.name, + copy_backup.size_bytes, + copy_backup.create_time, + copy_backup.version_time, + ) + ) + + +# [END spanner_copy_backup] + + if __name__ == "__main__": # noqa: C901 parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter @@ -404,6 +475,7 @@ def create_database_with_version_retention_period(instance_id, database_id, rete "list_database_operations", help=list_database_operations.__doc__ ) subparsers.add_parser("delete_backup", help=delete_backup.__doc__) + subparsers.add_parser("copy_backup", help=copy_backup.__doc__) args = parser.parse_args() @@ -418,10 +490,12 @@ def create_database_with_version_retention_period(instance_id, database_id, rete elif args.command == "list_backups": list_backups(args.instance_id, args.database_id, args.backup_id) elif args.command == "list_backup_operations": - list_backup_operations(args.instance_id, args.database_id) + list_backup_operations(args.instance_id, args.database_id, args.backup_id) elif args.command == "list_database_operations": list_database_operations(args.instance_id) elif args.command == "delete_backup": delete_backup(args.instance_id, args.backup_id) + elif args.command == "copy_backup": + copy_backup(args.instance_id, args.backup_id, args.source_backup_id) else: print("Command {} did not match expected commands.".format(args.command)) diff --git a/samples/samples/backup_sample_test.py b/samples/samples/backup_sample_test.py index 6d89dcf440..da50fbba46 100644 --- a/samples/samples/backup_sample_test.py +++ b/samples/samples/backup_sample_test.py @@ -41,6 +41,7 @@ def unique_backup_id(): CMEK_BACKUP_ID = unique_backup_id() RETENTION_DATABASE_ID = unique_database_id() RETENTION_PERIOD = "7d" +COPY_BACKUP_ID = unique_backup_id() @pytest.mark.dependency(name="create_backup") @@ -51,24 +52,32 @@ def test_create_backup(capsys, instance_id, sample_database): version_time = list(results)[0][0] backup_sample.create_backup( - instance_id, - sample_database.database_id, - BACKUP_ID, - version_time, + instance_id, sample_database.database_id, BACKUP_ID, version_time, ) out, _ = capsys.readouterr() assert BACKUP_ID in out +@pytest.mark.dependency(name="copy_backup", depends=["create_backup"]) +def test_copy_backup(capsys, instance_id, spanner_client): + source_backp_path = ( + spanner_client.project_name + + "/instances/" + + instance_id + + "/backups/" + + BACKUP_ID + ) + backup_sample.copy_backup(instance_id, COPY_BACKUP_ID, source_backp_path) + out, _ = capsys.readouterr() + assert COPY_BACKUP_ID in out + + @pytest.mark.dependency(name="create_backup_with_encryption_key") def test_create_backup_with_encryption_key( capsys, instance_id, sample_database, kms_key_name, ): backup_sample.create_backup_with_encryption_key( - instance_id, - sample_database.database_id, - CMEK_BACKUP_ID, - kms_key_name, + instance_id, sample_database.database_id, CMEK_BACKUP_ID, kms_key_name, ) out, _ = capsys.readouterr() assert CMEK_BACKUP_ID in out @@ -91,7 +100,8 @@ def test_restore_database_with_encryption_key( capsys, instance_id, sample_database, kms_key_name, ): backup_sample.restore_database_with_encryption_key( - instance_id, CMEK_RESTORE_DB_ID, CMEK_BACKUP_ID, kms_key_name) + instance_id, CMEK_RESTORE_DB_ID, CMEK_BACKUP_ID, kms_key_name + ) out, _ = capsys.readouterr() assert (sample_database.database_id + " restored to ") in out assert (CMEK_RESTORE_DB_ID + " from backup ") in out @@ -99,17 +109,22 @@ def test_restore_database_with_encryption_key( assert kms_key_name in out -@pytest.mark.dependency(depends=["create_backup"]) +@pytest.mark.dependency(depends=["create_backup", "copy_backup"]) def test_list_backup_operations(capsys, instance_id, sample_database): backup_sample.list_backup_operations( - instance_id, sample_database.database_id) + instance_id, sample_database.database_id, BACKUP_ID + ) out, _ = capsys.readouterr() assert BACKUP_ID in out assert sample_database.database_id in out + assert COPY_BACKUP_ID in out + print(out) -@pytest.mark.dependency(depends=["create_backup"]) -def test_list_backups(capsys, instance_id, sample_database): +@pytest.mark.dependency(name="list_backup", depends=["create_backup", "copy_backup"]) +def test_list_backups( + capsys, instance_id, sample_database, +): backup_sample.list_backups( instance_id, sample_database.database_id, BACKUP_ID, ) @@ -125,11 +140,14 @@ def test_update_backup(capsys, instance_id): assert BACKUP_ID in out -@pytest.mark.dependency(depends=["create_backup"]) +@pytest.mark.dependency(depends=["create_backup", "copy_backup", "list_backup"]) def test_delete_backup(capsys, instance_id): backup_sample.delete_backup(instance_id, BACKUP_ID) out, _ = capsys.readouterr() assert BACKUP_ID in out + backup_sample.delete_backup(instance_id, COPY_BACKUP_ID) + out, _ = capsys.readouterr() + assert COPY_BACKUP_ID in out @pytest.mark.dependency(depends=["create_backup"]) diff --git a/samples/samples/conftest.py b/samples/samples/conftest.py index b3728a4db4..314c984920 100644 --- a/samples/samples/conftest.py +++ b/samples/samples/conftest.py @@ -93,9 +93,7 @@ def instance_config(spanner_client): @pytest.fixture(scope="module") def multi_region_instance_config(spanner_client): - return "{}/instanceConfigs/{}".format( - spanner_client.project_name, "nam3" - ) + return "{}/instanceConfigs/{}".format(spanner_client.project_name, "nam3") @pytest.fixture(scope="module") @@ -143,7 +141,7 @@ def multi_region_instance( labels={ "cloud_spanner_samples": "true", "sample_name": sample_name, - "created": str(int(time.time())) + "created": str(int(time.time())), }, ) op = retry_429(multi_region_instance.create)() diff --git a/samples/samples/noxfile.py b/samples/samples/noxfile.py index 4c808af73e..85f5836dba 100644 --- a/samples/samples/noxfile.py +++ b/samples/samples/noxfile.py @@ -208,9 +208,7 @@ def _session_tests( if os.path.exists("requirements-test.txt"): if os.path.exists("constraints-test.txt"): - session.install( - "-r", "requirements-test.txt", "-c", "constraints-test.txt" - ) + session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt") else: session.install("-r", "requirements-test.txt") with open("requirements-test.txt") as rtfile: @@ -223,9 +221,9 @@ def _session_tests( post_install(session) if "pytest-parallel" in packages: - concurrent_args.extend(['--workers', 'auto', '--tests-per-worker', 'auto']) + concurrent_args.extend(["--workers", "auto", "--tests-per-worker", "auto"]) elif "pytest-xdist" in packages: - concurrent_args.extend(['-n', 'auto']) + concurrent_args.extend(["-n", "auto"]) session.run( "pytest", diff --git a/samples/samples/snippets.py b/samples/samples/snippets.py index 5a3ac6df24..87721c021f 100644 --- a/samples/samples/snippets.py +++ b/samples/samples/snippets.py @@ -51,8 +51,8 @@ def create_instance(instance_id): labels={ "cloud_spanner_samples": "true", "sample_name": "snippets-create_instance-explicit", - "created": str(int(time.time())) - } + "created": str(int(time.time())), + }, ) operation = instance.create() @@ -83,8 +83,8 @@ def create_instance_with_processing_units(instance_id, processing_units): labels={ "cloud_spanner_samples": "true", "sample_name": "snippets-create_instance_with_processing_units", - "created": str(int(time.time())) - } + "created": str(int(time.time())), + }, ) operation = instance.create() @@ -92,8 +92,11 @@ def create_instance_with_processing_units(instance_id, processing_units): print("Waiting for operation to complete...") operation.result(OPERATION_TIMEOUT_SECONDS) - print("Created instance {} with {} processing units".format( - instance_id, instance.processing_units)) + print( + "Created instance {} with {} processing units".format( + instance_id, instance.processing_units + ) + ) # [END spanner_create_instance_with_processing_units] @@ -103,10 +106,15 @@ def create_instance_with_processing_units(instance_id, processing_units): def get_instance_config(instance_config): """Gets the leader options for the instance configuration.""" spanner_client = spanner.Client() - config_name = "{}/instanceConfigs/{}".format(spanner_client.project_name, instance_config) + config_name = "{}/instanceConfigs/{}".format( + spanner_client.project_name, instance_config + ) config = spanner_client.instance_admin_api.get_instance_config(name=config_name) - print("Available leader options for instance config {}: {}".format( - instance_config, config.leader_options)) + print( + "Available leader options for instance config {}: {}".format( + instance_config, config.leader_options + ) + ) # [END spanner_get_instance_config] @@ -203,7 +211,7 @@ def create_database_with_encryption_key(instance_id, database_id, kms_key_name): ) PRIMARY KEY (SingerId, AlbumId), INTERLEAVE IN PARENT Singers ON DELETE CASCADE""", ], - encryption_config={'kms_key_name': kms_key_name}, + encryption_config={"kms_key_name": kms_key_name}, ) operation = database.create() @@ -211,17 +219,18 @@ def create_database_with_encryption_key(instance_id, database_id, kms_key_name): print("Waiting for operation to complete...") operation.result(OPERATION_TIMEOUT_SECONDS) - print("Database {} created with encryption key {}".format( - database.name, database.encryption_config.kms_key_name)) + print( + "Database {} created with encryption key {}".format( + database.name, database.encryption_config.kms_key_name + ) + ) # [END spanner_create_database_with_encryption_key] # [START spanner_create_database_with_default_leader] -def create_database_with_default_leader( - instance_id, database_id, default_leader -): +def create_database_with_default_leader(instance_id, database_id, default_leader): """Creates a database with tables with a default leader.""" spanner_client = spanner.Client() instance = spanner_client.instance(instance_id) @@ -254,7 +263,7 @@ def create_database_with_default_leader( print( "Database {} created with default leader {}".format( - database.name, database.default_leader + database.name, database.default_leader ) ) @@ -263,17 +272,19 @@ def create_database_with_default_leader( # [START spanner_update_database_with_default_leader] -def update_database_with_default_leader( - instance_id, database_id, default_leader -): +def update_database_with_default_leader(instance_id, database_id, default_leader): """Updates a database with tables with a default leader.""" spanner_client = spanner.Client() instance = spanner_client.instance(instance_id) database = instance.database(database_id) - operation = database.update_ddl(["ALTER DATABASE {}" - " SET OPTIONS (default_leader = '{}')".format(database_id, default_leader)]) + operation = database.update_ddl( + [ + "ALTER DATABASE {}" + " SET OPTIONS (default_leader = '{}')".format(database_id, default_leader) + ] + ) operation.result(OPERATION_TIMEOUT_SECONDS) database.reload() @@ -316,9 +327,7 @@ def query_information_schema_database_options(instance_id, database_id): "WHERE SCHEMA_NAME = '' AND OPTION_NAME = 'default_leader'" ) for result in results: - print("Database {} has default leader {}".format( - database_id, result[0] - )) + print("Database {} has default leader {}".format(database_id, result[0])) # [END spanner_query_information_schema_database_options] @@ -1307,11 +1316,9 @@ def insert_singers(transaction): database.run_in_transaction(insert_singers) commit_stats = database.logger.last_commit_stats - print( - "{} mutation(s) in transaction.".format( - commit_stats.mutation_count - ) - ) + print("{} mutation(s) in transaction.".format(commit_stats.mutation_count)) + + # [END spanner_get_commit_stats] @@ -2011,7 +2018,7 @@ def query_data_with_query_options(instance_id, database_id): "SELECT VenueId, VenueName, LastUpdateTime FROM Venues", query_options={ "optimizer_version": "1", - "optimizer_statistics_package": "latest" + "optimizer_statistics_package": "latest", }, ) @@ -2028,8 +2035,9 @@ def create_client_with_query_options(instance_id, database_id): spanner_client = spanner.Client( query_options={ "optimizer_version": "1", - "optimizer_statistics_package": "auto_20191128_14_47_22UTC" - }) + "optimizer_statistics_package": "auto_20191128_14_47_22UTC", + } + ) instance = spanner_client.instance(instance_id) database = instance.database(database_id) @@ -2057,7 +2065,7 @@ def update_venues(transaction): # This request tag will only be set on this request. transaction.execute_update( "UPDATE Venues SET Capacity = CAST(Capacity/4 AS INT64) WHERE OutdoorVenue = false", - request_options={"request_tag": "app=concert,env=dev,action=update"} + request_options={"request_tag": "app=concert,env=dev,action=update"}, ) print("Venue capacities updated.") @@ -2070,21 +2078,19 @@ def update_venues(transaction): "venueId": 81, "venueName": "Venue 81", "capacity": 1440, - "outdoorVenue": True + "outdoorVenue": True, }, param_types={ "venueId": param_types.INT64, "venueName": param_types.STRING, "capacity": param_types.INT64, - "outdoorVenue": param_types.BOOL + "outdoorVenue": param_types.BOOL, }, - request_options={"request_tag": "app=concert,env=dev,action=insert"} + request_options={"request_tag": "app=concert,env=dev,action=insert"}, ) print("New venue inserted.") - database.run_in_transaction( - update_venues, transaction_tag="app=concert,env=dev" - ) + database.run_in_transaction(update_venues, transaction_tag="app=concert,env=dev") # [END spanner_set_transaction_tag] @@ -2101,7 +2107,7 @@ def set_request_tag(instance_id, database_id): with database.snapshot() as snapshot: results = snapshot.execute_sql( "SELECT SingerId, AlbumId, AlbumTitle FROM Albums", - request_options={"request_tag": "app=concert,env=dev,action=select"} + request_options={"request_tag": "app=concert,env=dev,action=select"}, ) for row in results: diff --git a/samples/samples/snippets_test.py b/samples/samples/snippets_test.py index d81032fa20..a5fa6a5caf 100644 --- a/samples/samples/snippets_test.py +++ b/samples/samples/snippets_test.py @@ -124,8 +124,12 @@ def test_create_instance_with_processing_units(capsys, lci_instance_id): retry_429(instance.delete)() -def test_create_database_with_encryption_config(capsys, instance_id, cmek_database_id, kms_key_name): - snippets.create_database_with_encryption_key(instance_id, cmek_database_id, kms_key_name) +def test_create_database_with_encryption_config( + capsys, instance_id, cmek_database_id, kms_key_name +): + snippets.create_database_with_encryption_key( + instance_id, cmek_database_id, kms_key_name + ) out, _ = capsys.readouterr() assert cmek_database_id in out assert kms_key_name in out @@ -150,7 +154,13 @@ def test_list_databases(capsys, instance_id): assert "has default leader" in out -def test_create_database_with_default_leader(capsys, multi_region_instance, multi_region_instance_id, default_leader_database_id, default_leader): +def test_create_database_with_default_leader( + capsys, + multi_region_instance, + multi_region_instance_id, + default_leader_database_id, + default_leader, +): retry_429 = RetryErrors(exceptions.ResourceExhausted, delay=15) retry_429(snippets.create_database_with_default_leader)( multi_region_instance_id, default_leader_database_id, default_leader @@ -160,7 +170,13 @@ def test_create_database_with_default_leader(capsys, multi_region_instance, mult assert default_leader in out -def test_update_database_with_default_leader(capsys, multi_region_instance, multi_region_instance_id, default_leader_database_id, default_leader): +def test_update_database_with_default_leader( + capsys, + multi_region_instance, + multi_region_instance_id, + default_leader_database_id, + default_leader, +): retry_429 = RetryErrors(exceptions.ResourceExhausted, delay=15) retry_429(snippets.update_database_with_default_leader)( multi_region_instance_id, default_leader_database_id, default_leader @@ -176,7 +192,13 @@ def test_get_database_ddl(capsys, instance_id, sample_database): assert sample_database.database_id in out -def test_query_information_schema_database_options(capsys, multi_region_instance, multi_region_instance_id, default_leader_database_id, default_leader): +def test_query_information_schema_database_options( + capsys, + multi_region_instance, + multi_region_instance_id, + default_leader_database_id, + default_leader, +): snippets.query_information_schema_database_options( multi_region_instance_id, default_leader_database_id ) @@ -587,7 +609,9 @@ def test_query_data_with_json_parameter(capsys, instance_id, sample_database): @pytest.mark.dependency(depends=["insert_datatypes_data"]) def test_query_data_with_timestamp_parameter(capsys, instance_id, sample_database): - snippets.query_data_with_timestamp_parameter(instance_id, sample_database.database_id) + snippets.query_data_with_timestamp_parameter( + instance_id, sample_database.database_id + ) out, _ = capsys.readouterr() assert "VenueId: 4, VenueName: Venue 4, LastUpdateTime:" in out assert "VenueId: 19, VenueName: Venue 19, LastUpdateTime:" in out diff --git a/tests/system/_helpers.py b/tests/system/_helpers.py index 2d0df01718..80eb9361cd 100644 --- a/tests/system/_helpers.py +++ b/tests/system/_helpers.py @@ -39,6 +39,9 @@ DATABASE_OPERATION_TIMEOUT_IN_SECONDS = int( os.getenv("SPANNER_DATABASE_OPERATION_TIMEOUT_IN_SECONDS", 120) ) +BACKUP_OPERATION_TIMEOUT_IN_SECONDS = int( + os.getenv("SPANNER_BACKUP_OPERATION_TIMEOUT_IN_SECONDS", 1200) +) USE_EMULATOR_ENVVAR = "SPANNER_EMULATOR_HOST" USE_EMULATOR = os.getenv(USE_EMULATOR_ENVVAR) is not None diff --git a/tests/system/conftest.py b/tests/system/conftest.py index 7e74725189..40b76208e8 100644 --- a/tests/system/conftest.py +++ b/tests/system/conftest.py @@ -12,12 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. +import datetime import time import pytest from google.cloud import spanner_v1 from . import _helpers +from google.cloud.spanner_admin_database_v1.types.backup import ( + CreateBackupEncryptionConfig, +) @pytest.fixture(scope="function") @@ -67,6 +71,11 @@ def database_operation_timeout(): return _helpers.DATABASE_OPERATION_TIMEOUT_IN_SECONDS +@pytest.fixture(scope="session") +def backup_operation_timeout(): + return _helpers.BACKUP_OPERATION_TIMEOUT_IN_SECONDS + + @pytest.fixture(scope="session") def shared_instance_id(): if _helpers.CREATE_INSTANCE: @@ -152,6 +161,30 @@ def shared_database(shared_instance, database_operation_timeout): database.drop() +@pytest.fixture(scope="session") +def shared_backup(shared_instance, shared_database, backup_operation_timeout): + backup_name = _helpers.unique_id("test_backup") + expire_time = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta( + days=3 + ) + source_encryption_enum = CreateBackupEncryptionConfig.EncryptionType + source_encryption_config = CreateBackupEncryptionConfig( + encryption_type=source_encryption_enum.GOOGLE_DEFAULT_ENCRYPTION, + ) + backup = shared_instance.backup( + backup_name, + database=shared_database, + expire_time=expire_time, + encryption_config=source_encryption_config, + ) + operation = backup.create() + operation.result(backup_operation_timeout) # raises on failure / timeout. + + yield backup + + backup.delete() + + @pytest.fixture(scope="function") def databases_to_delete(): to_delete = [] diff --git a/tests/system/test_backup_api.py b/tests/system/test_backup_api.py index 77ffca0f44..f7325dc356 100644 --- a/tests/system/test_backup_api.py +++ b/tests/system/test_backup_api.py @@ -199,6 +199,62 @@ def test_backup_workflow( assert not backup.exists() +def test_copy_backup_workflow( + shared_instance, shared_backup, backups_to_delete, +): + from google.cloud.spanner_admin_database_v1 import ( + CopyBackupEncryptionConfig, + EncryptionInfo, + ) + + backup_id = _helpers.unique_id("backup_id", separator="_") + expire_time = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta( + days=3 + ) + copy_encryption_enum = CopyBackupEncryptionConfig.EncryptionType + copy_encryption_config = CopyBackupEncryptionConfig( + encryption_type=copy_encryption_enum.GOOGLE_DEFAULT_ENCRYPTION, + ) + + # Create backup. + shared_backup.reload() + # Create a copy backup + copy_backup = shared_instance.copy_backup( + backup_id=backup_id, + source_backup=shared_backup.name, + expire_time=expire_time, + encryption_config=copy_encryption_config, + ) + operation = copy_backup.create() + backups_to_delete.append(copy_backup) + + # Check metadata. + metadata = operation.metadata + assert copy_backup.name == metadata.name + operation.result() # blocks indefinitely + + # Check backup object. + copy_backup.reload() + assert expire_time == copy_backup.expire_time + assert copy_backup.create_time is not None + assert copy_backup.size_bytes is not None + assert copy_backup.state is not None + assert ( + EncryptionInfo.Type.GOOGLE_DEFAULT_ENCRYPTION + == copy_backup.encryption_info.encryption_type + ) + + # Update with valid argument. + valid_expire_time = datetime.datetime.now( + datetime.timezone.utc + ) + datetime.timedelta(days=7) + copy_backup.update_expire_time(valid_expire_time) + assert valid_expire_time == copy_backup.expire_time + + copy_backup.delete() + assert not copy_backup.exists() + + def test_backup_create_w_version_time_dflt_to_create_time( shared_instance, shared_database, backups_to_delete, databases_to_delete, ): From 474b1b56cd11bc22d274a85664b09532a576e3d6 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 29 Mar 2022 01:48:12 +0000 Subject: [PATCH 10/16] chore(python): use black==22.3.0 (#695) Source-Link: https://github.com/googleapis/synthtool/commit/6fab84af09f2cf89a031fd8671d1def6b2931b11 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe --- .github/.OwlBot.lock.yaml | 2 +- docs/conf.py | 5 +- .../services/database_admin/async_client.py | 153 +- .../services/database_admin/client.py | 216 ++- .../database_admin/transports/base.py | 26 +- .../database_admin/transports/grpc.py | 3 +- .../spanner_admin_database_v1/types/backup.py | 274 +++- .../spanner_admin_database_v1/types/common.py | 39 +- .../types/spanner_database_admin.py | 280 +++- .../services/instance_admin/async_client.py | 89 +- .../services/instance_admin/client.py | 135 +- .../instance_admin/transports/base.py | 18 +- .../instance_admin/transports/grpc.py | 3 +- .../types/spanner_instance_admin.py | 231 ++- google/cloud/spanner_dbapi/connection.py | 7 +- google/cloud/spanner_dbapi/cursor.py | 7 +- google/cloud/spanner_v1/backup.py | 15 +- google/cloud/spanner_v1/batch.py | 5 +- google/cloud/spanner_v1/database.py | 24 +- google/cloud/spanner_v1/instance.py | 18 +- .../services/spanner/async_client.py | 110 +- .../spanner_v1/services/spanner/client.py | 173 ++- .../services/spanner/transports/base.py | 14 +- .../services/spanner/transports/grpc.py | 3 +- google/cloud/spanner_v1/session.py | 7 +- google/cloud/spanner_v1/snapshot.py | 10 +- google/cloud/spanner_v1/streamed.py | 6 +- google/cloud/spanner_v1/transaction.py | 5 +- .../cloud/spanner_v1/types/commit_response.py | 22 +- google/cloud/spanner_v1/types/keys.py | 43 +- google/cloud/spanner_v1/types/mutation.py | 65 +- google/cloud/spanner_v1/types/query_plan.py | 78 +- google/cloud/spanner_v1/types/result_set.py | 87 +- google/cloud/spanner_v1/types/spanner.py | 423 ++++-- google/cloud/spanner_v1/types/transaction.py | 64 +- google/cloud/spanner_v1/types/type.py | 50 +- noxfile.py | 9 +- samples/samples/noxfile.py | 10 +- tests/system/_sample_data.py | 6 +- tests/system/conftest.py | 3 +- tests/system/test_backup_api.py | 40 +- tests/system/test_database_api.py | 12 +- tests/system/test_dbapi.py | 7 +- tests/system/test_instance_api.py | 5 +- tests/system/test_session_api.py | 67 +- tests/system/utils/streaming_utils.py | 2 +- .../test_database_admin.py | 1297 +++++++++++++---- .../test_instance_admin.py | 701 ++++++--- tests/unit/gapic/spanner_v1/test_spanner.py | 943 +++++++++--- tests/unit/spanner_dbapi/test_connect.py | 11 +- tests/unit/spanner_dbapi/test_connection.py | 16 +- tests/unit/spanner_dbapi/test_cursor.py | 4 +- tests/unit/spanner_dbapi/test_parse_utils.py | 3 +- tests/unit/spanner_dbapi/test_parser.py | 4 +- tests/unit/test__helpers.py | 26 +- tests/unit/test_backup.py | 54 +- tests/unit/test_batch.py | 19 +- tests/unit/test_database.py | 27 +- tests/unit/test_keyset.py | 113 +- tests/unit/test_session.py | 55 +- tests/unit/test_snapshot.py | 26 +- tests/unit/test_streamed.py | 144 +- tests/unit/test_transaction.py | 37 +- 63 files changed, 4861 insertions(+), 1490 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 7e08e05a38..87dd006115 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:5d8da01438ece4021d135433f2cf3227aa39ef0eaccc941d62aa35e6902832ae + digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe diff --git a/docs/conf.py b/docs/conf.py index 6410a1a2ad..96337defe2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -361,7 +361,10 @@ intersphinx_mapping = { "python": ("https://python.readthedocs.org/en/latest/", None), "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), + "google.api_core": ( + "https://googleapis.dev/python/google-api-core/latest/", + None, + ), "grpc": ("https://grpc.github.io/grpc/python/", None), "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py b/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py index e4793ae26b..750c3dd5f5 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py @@ -331,12 +331,20 @@ def sample_list_databases(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + 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.ListDatabasesAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -461,7 +469,12 @@ def sample_create_database(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -568,7 +581,12 @@ def sample_get_database(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -720,7 +738,12 @@ def sample_update_database_ddl(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -822,7 +845,10 @@ def sample_drop_database(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def get_database_ddl( @@ -925,7 +951,12 @@ def sample_get_database_ddl(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1062,7 +1093,9 @@ def sample_set_iam_policy(): if isinstance(request, dict): request = iam_policy_pb2.SetIamPolicyRequest(**request) elif not request: - request = iam_policy_pb2.SetIamPolicyRequest(resource=resource,) + request = iam_policy_pb2.SetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1079,7 +1112,12 @@ def sample_set_iam_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1217,7 +1255,9 @@ def sample_get_iam_policy(): if isinstance(request, dict): request = iam_policy_pb2.GetIamPolicyRequest(**request) elif not request: - request = iam_policy_pb2.GetIamPolicyRequest(resource=resource,) + request = iam_policy_pb2.GetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1244,7 +1284,12 @@ def sample_get_iam_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1339,7 +1384,8 @@ def sample_test_iam_permissions(): request = iam_policy_pb2.TestIamPermissionsRequest(**request) elif not request: request = iam_policy_pb2.TestIamPermissionsRequest( - resource=resource, permissions=permissions, + resource=resource, + permissions=permissions, ) # Wrap the RPC method; this adds retry and timeout information, @@ -1357,7 +1403,12 @@ def sample_test_iam_permissions(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1493,7 +1544,12 @@ def sample_create_backup(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -1655,7 +1711,12 @@ def sample_copy_backup(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -1763,7 +1824,12 @@ def sample_get_backup(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1883,7 +1949,12 @@ def sample_update_backup(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1978,7 +2049,10 @@ def sample_delete_backup(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def list_backups( @@ -2083,12 +2157,20 @@ def sample_list_backups(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + 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, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -2234,7 +2316,12 @@ def sample_restore_database(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -2359,12 +2446,20 @@ def sample_list_database_operations(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + 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.ListDatabaseOperationsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -2482,12 +2577,20 @@ def sample_list_backup_operations(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + 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.ListBackupOperationsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/client.py b/google/cloud/spanner_admin_database_v1/services/database_admin/client.py index a7106d7aa7..3e300807c9 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/client.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/client.py @@ -64,7 +64,10 @@ class DatabaseAdminClientMeta(type): _transport_registry["grpc"] = DatabaseAdminGrpcTransport _transport_registry["grpc_asyncio"] = DatabaseAdminGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[DatabaseAdminTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[DatabaseAdminTransport]: """Returns an appropriate transport class. Args: @@ -177,10 +180,16 @@ def transport(self) -> DatabaseAdminTransport: return self._transport @staticmethod - def backup_path(project: str, instance: str, backup: str,) -> str: + def backup_path( + project: str, + instance: str, + backup: str, + ) -> str: """Returns a fully-qualified backup string.""" return "projects/{project}/instances/{instance}/backups/{backup}".format( - project=project, instance=instance, backup=backup, + project=project, + instance=instance, + backup=backup, ) @staticmethod @@ -194,7 +203,10 @@ def parse_backup_path(path: str) -> Dict[str, str]: @staticmethod def crypto_key_path( - project: str, location: str, key_ring: str, crypto_key: str, + project: str, + location: str, + key_ring: str, + crypto_key: str, ) -> str: """Returns a fully-qualified crypto_key string.""" return "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format( @@ -240,10 +252,16 @@ def parse_crypto_key_version_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def database_path(project: str, instance: str, database: str,) -> str: + def database_path( + project: str, + instance: str, + database: str, + ) -> str: """Returns a fully-qualified database string.""" return "projects/{project}/instances/{instance}/databases/{database}".format( - project=project, instance=instance, database=database, + project=project, + instance=instance, + database=database, ) @staticmethod @@ -256,10 +274,14 @@ def parse_database_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def instance_path(project: str, instance: str,) -> str: + def instance_path( + project: str, + instance: str, + ) -> str: """Returns a fully-qualified instance string.""" return "projects/{project}/instances/{instance}".format( - project=project, instance=instance, + project=project, + instance=instance, ) @staticmethod @@ -269,7 +291,9 @@ def parse_instance_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -282,9 +306,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -293,9 +321,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -304,9 +336,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -315,10 +351,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -582,12 +622,20 @@ def sample_list_databases(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + 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.ListDatabasesPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -712,7 +760,12 @@ def sample_create_database(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -809,7 +862,12 @@ def sample_get_database(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -951,7 +1009,12 @@ def sample_update_database_ddl(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -1043,7 +1106,10 @@ def sample_drop_database(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def get_database_ddl( @@ -1136,7 +1202,12 @@ def sample_get_database_ddl(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1289,7 +1360,12 @@ def sample_set_iam_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1443,7 +1519,12 @@ def sample_get_iam_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1555,7 +1636,12 @@ def sample_test_iam_permissions(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1691,7 +1777,12 @@ def sample_create_backup(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -1853,7 +1944,12 @@ def sample_copy_backup(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -1951,7 +2047,12 @@ def sample_get_backup(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2061,7 +2162,12 @@ def sample_update_backup(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2146,7 +2252,10 @@ def sample_delete_backup(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def list_backups( @@ -2241,12 +2350,20 @@ def sample_list_backups(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + 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, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -2392,7 +2509,12 @@ def sample_restore_database(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -2509,12 +2631,20 @@ def sample_list_database_operations(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + 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.ListDatabaseOperationsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -2622,12 +2752,20 @@ def sample_list_backup_operations(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + 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.ListBackupOperationsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py index 18dfc4074c..21f27aeaf6 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py @@ -146,7 +146,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.create_database: gapic_v1.method.wrap_method( - self.create_database, default_timeout=3600.0, client_info=client_info, + self.create_database, + default_timeout=3600.0, + client_info=client_info, ), self.get_database: gapic_v1.method.wrap_method( self.get_database, @@ -209,7 +211,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.set_iam_policy: gapic_v1.method.wrap_method( - self.set_iam_policy, default_timeout=30.0, client_info=client_info, + self.set_iam_policy, + default_timeout=30.0, + client_info=client_info, ), self.get_iam_policy: gapic_v1.method.wrap_method( self.get_iam_policy, @@ -232,10 +236,14 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.create_backup: gapic_v1.method.wrap_method( - self.create_backup, default_timeout=3600.0, client_info=client_info, + self.create_backup, + default_timeout=3600.0, + client_info=client_info, ), self.copy_backup: gapic_v1.method.wrap_method( - self.copy_backup, default_timeout=3600.0, client_info=client_info, + self.copy_backup, + default_timeout=3600.0, + client_info=client_info, ), self.get_backup: gapic_v1.method.wrap_method( self.get_backup, @@ -298,7 +306,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.restore_database: gapic_v1.method.wrap_method( - self.restore_database, default_timeout=3600.0, client_info=client_info, + self.restore_database, + default_timeout=3600.0, + client_info=client_info, ), self.list_database_operations: gapic_v1.method.wrap_method( self.list_database_operations, @@ -335,9 +345,9 @@ def _prep_wrapped_messages(self, client_info): def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py index 6f1d695122..70b1c8158a 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py @@ -239,8 +239,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property diff --git a/google/cloud/spanner_admin_database_v1/types/backup.py b/google/cloud/spanner_admin_database_v1/types/backup.py index b4cff201a2..dd42c409b9 100644 --- a/google/cloud/spanner_admin_database_v1/types/backup.py +++ b/google/cloud/spanner_admin_database_v1/types/backup.py @@ -135,23 +135,60 @@ class State(proto.Enum): CREATING = 1 READY = 2 - database = proto.Field(proto.STRING, number=2,) + database = proto.Field( + proto.STRING, + number=2, + ) version_time = proto.Field( - proto.MESSAGE, number=9, message=timestamp_pb2.Timestamp, - ) - expire_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) - name = proto.Field(proto.STRING, number=1,) - create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) - size_bytes = proto.Field(proto.INT64, number=5,) - state = proto.Field(proto.ENUM, number=6, enum=State,) - referencing_databases = proto.RepeatedField(proto.STRING, number=7,) + proto.MESSAGE, + number=9, + message=timestamp_pb2.Timestamp, + ) + expire_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + name = proto.Field( + proto.STRING, + number=1, + ) + create_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + size_bytes = proto.Field( + proto.INT64, + number=5, + ) + state = proto.Field( + proto.ENUM, + number=6, + enum=State, + ) + referencing_databases = proto.RepeatedField( + proto.STRING, + number=7, + ) encryption_info = proto.Field( - proto.MESSAGE, number=8, message=common.EncryptionInfo, + proto.MESSAGE, + number=8, + message=common.EncryptionInfo, + ) + database_dialect = proto.Field( + proto.ENUM, + number=10, + enum=common.DatabaseDialect, + ) + referencing_backups = proto.RepeatedField( + proto.STRING, + number=11, ) - database_dialect = proto.Field(proto.ENUM, number=10, enum=common.DatabaseDialect,) - referencing_backups = proto.RepeatedField(proto.STRING, number=11,) max_expire_time = proto.Field( - proto.MESSAGE, number=12, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=12, + message=timestamp_pb2.Timestamp, ) @@ -183,11 +220,23 @@ class CreateBackupRequest(proto.Message): = ``USE_DATABASE_ENCRYPTION``. """ - parent = proto.Field(proto.STRING, number=1,) - backup_id = proto.Field(proto.STRING, number=2,) - backup = proto.Field(proto.MESSAGE, number=3, message="Backup",) + parent = proto.Field( + proto.STRING, + number=1, + ) + backup_id = proto.Field( + proto.STRING, + number=2, + ) + backup = proto.Field( + proto.MESSAGE, + number=3, + message="Backup", + ) encryption_config = proto.Field( - proto.MESSAGE, number=4, message="CreateBackupEncryptionConfig", + proto.MESSAGE, + number=4, + message="CreateBackupEncryptionConfig", ) @@ -222,10 +271,24 @@ class CreateBackupMetadata(proto.Message): 1, corresponding to ``Code.CANCELLED``. """ - name = proto.Field(proto.STRING, number=1,) - database = proto.Field(proto.STRING, number=2,) - progress = proto.Field(proto.MESSAGE, number=3, message=common.OperationProgress,) - cancel_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + name = proto.Field( + proto.STRING, + number=1, + ) + database = proto.Field( + proto.STRING, + number=2, + ) + progress = proto.Field( + proto.MESSAGE, + number=3, + message=common.OperationProgress, + ) + cancel_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) class CopyBackupRequest(proto.Message): @@ -264,12 +327,27 @@ class CopyBackupRequest(proto.Message): = ``USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION``. """ - parent = proto.Field(proto.STRING, number=1,) - backup_id = proto.Field(proto.STRING, number=2,) - source_backup = proto.Field(proto.STRING, number=3,) - expire_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + parent = proto.Field( + proto.STRING, + number=1, + ) + backup_id = proto.Field( + proto.STRING, + number=2, + ) + source_backup = proto.Field( + proto.STRING, + number=3, + ) + expire_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) encryption_config = proto.Field( - proto.MESSAGE, number=5, message="CopyBackupEncryptionConfig", + proto.MESSAGE, + number=5, + message="CopyBackupEncryptionConfig", ) @@ -307,10 +385,24 @@ class CopyBackupMetadata(proto.Message): 1, corresponding to ``Code.CANCELLED``. """ - name = proto.Field(proto.STRING, number=1,) - source_backup = proto.Field(proto.STRING, number=2,) - progress = proto.Field(proto.MESSAGE, number=3, message=common.OperationProgress,) - cancel_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + name = proto.Field( + proto.STRING, + number=1, + ) + source_backup = proto.Field( + proto.STRING, + number=2, + ) + progress = proto.Field( + proto.MESSAGE, + number=3, + message=common.OperationProgress, + ) + cancel_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) class UpdateBackupRequest(proto.Message): @@ -334,9 +426,15 @@ class UpdateBackupRequest(proto.Message): accidentally by clients that do not know about them. """ - backup = proto.Field(proto.MESSAGE, number=1, message="Backup",) + backup = proto.Field( + proto.MESSAGE, + number=1, + message="Backup", + ) update_mask = proto.Field( - proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, ) @@ -350,7 +448,10 @@ class GetBackupRequest(proto.Message): ``projects//instances//backups/``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class DeleteBackupRequest(proto.Message): @@ -364,7 +465,10 @@ class DeleteBackupRequest(proto.Message): ``projects//instances//backups/``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class ListBackupsRequest(proto.Message): @@ -434,10 +538,22 @@ class ListBackupsRequest(proto.Message): to the same ``parent`` and with the same ``filter``. """ - parent = proto.Field(proto.STRING, number=1,) - filter = proto.Field(proto.STRING, number=2,) - page_size = proto.Field(proto.INT32, number=3,) - page_token = proto.Field(proto.STRING, number=4,) + parent = proto.Field( + proto.STRING, + number=1, + ) + filter = proto.Field( + proto.STRING, + number=2, + ) + page_size = proto.Field( + proto.INT32, + number=3, + ) + page_token = proto.Field( + proto.STRING, + number=4, + ) class ListBackupsResponse(proto.Message): @@ -459,8 +575,15 @@ class ListBackupsResponse(proto.Message): def raw_page(self): return self - backups = proto.RepeatedField(proto.MESSAGE, number=1, message="Backup",) - next_page_token = proto.Field(proto.STRING, number=2,) + backups = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Backup", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class ListBackupOperationsRequest(proto.Message): @@ -571,10 +694,22 @@ class ListBackupOperationsRequest(proto.Message): to the same ``parent`` and with the same ``filter``. """ - parent = proto.Field(proto.STRING, number=1,) - filter = proto.Field(proto.STRING, number=2,) - page_size = proto.Field(proto.INT32, number=3,) - page_token = proto.Field(proto.STRING, number=4,) + parent = proto.Field( + proto.STRING, + number=1, + ) + filter = proto.Field( + proto.STRING, + number=2, + ) + page_size = proto.Field( + proto.INT32, + number=3, + ) + page_token = proto.Field( + proto.STRING, + number=4, + ) class ListBackupOperationsResponse(proto.Message): @@ -605,9 +740,14 @@ def raw_page(self): return self operations = proto.RepeatedField( - proto.MESSAGE, number=1, message=operations_pb2.Operation, + proto.MESSAGE, + number=1, + message=operations_pb2.Operation, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, ) - next_page_token = proto.Field(proto.STRING, number=2,) class BackupInfo(proto.Message): @@ -633,12 +773,24 @@ class BackupInfo(proto.Message): from. """ - backup = proto.Field(proto.STRING, number=1,) + backup = proto.Field( + proto.STRING, + number=1, + ) version_time = proto.Field( - proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + create_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + source_database = proto.Field( + proto.STRING, + number=3, ) - create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) - source_database = proto.Field(proto.STRING, number=3,) class CreateBackupEncryptionConfig(proto.Message): @@ -662,8 +814,15 @@ class EncryptionType(proto.Enum): GOOGLE_DEFAULT_ENCRYPTION = 2 CUSTOMER_MANAGED_ENCRYPTION = 3 - encryption_type = proto.Field(proto.ENUM, number=1, enum=EncryptionType,) - kms_key_name = proto.Field(proto.STRING, number=2,) + encryption_type = proto.Field( + proto.ENUM, + number=1, + enum=EncryptionType, + ) + kms_key_name = proto.Field( + proto.STRING, + number=2, + ) class CopyBackupEncryptionConfig(proto.Message): @@ -687,8 +846,15 @@ class EncryptionType(proto.Enum): GOOGLE_DEFAULT_ENCRYPTION = 2 CUSTOMER_MANAGED_ENCRYPTION = 3 - encryption_type = proto.Field(proto.ENUM, number=1, enum=EncryptionType,) - kms_key_name = proto.Field(proto.STRING, number=2,) + encryption_type = proto.Field( + proto.ENUM, + number=1, + enum=EncryptionType, + ) + kms_key_name = proto.Field( + proto.STRING, + number=2, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/spanner_admin_database_v1/types/common.py b/google/cloud/spanner_admin_database_v1/types/common.py index 8e5e4aa9f4..6475e588bc 100644 --- a/google/cloud/spanner_admin_database_v1/types/common.py +++ b/google/cloud/spanner_admin_database_v1/types/common.py @@ -52,9 +52,20 @@ class OperationProgress(proto.Message): failed or was completed successfully. """ - progress_percent = proto.Field(proto.INT32, number=1,) - start_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) - end_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + progress_percent = proto.Field( + proto.INT32, + number=1, + ) + start_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) class EncryptionConfig(proto.Message): @@ -67,7 +78,10 @@ class EncryptionConfig(proto.Message): ``projects//locations//keyRings//cryptoKeys/``. """ - kms_key_name = proto.Field(proto.STRING, number=2,) + kms_key_name = proto.Field( + proto.STRING, + number=2, + ) class EncryptionInfo(proto.Message): @@ -93,9 +107,20 @@ class Type(proto.Enum): GOOGLE_DEFAULT_ENCRYPTION = 1 CUSTOMER_MANAGED_ENCRYPTION = 2 - encryption_type = proto.Field(proto.ENUM, number=3, enum=Type,) - encryption_status = proto.Field(proto.MESSAGE, number=4, message=status_pb2.Status,) - kms_key_version = proto.Field(proto.STRING, number=2,) + encryption_type = proto.Field( + proto.ENUM, + number=3, + enum=Type, + ) + encryption_status = proto.Field( + proto.MESSAGE, + number=4, + message=status_pb2.Status, + ) + kms_key_version = proto.Field( + proto.STRING, + number=2, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py b/google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py index c9c519334b..52521db98d 100644 --- a/google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py +++ b/google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py @@ -68,9 +68,16 @@ class RestoreInfo(proto.Message): This field is a member of `oneof`_ ``source_info``. """ - source_type = proto.Field(proto.ENUM, number=1, enum="RestoreSourceType",) + source_type = proto.Field( + proto.ENUM, + number=1, + enum="RestoreSourceType", + ) backup_info = proto.Field( - proto.MESSAGE, number=2, oneof="source_info", message=gsad_backup.BackupInfo, + proto.MESSAGE, + number=2, + oneof="source_info", + message=gsad_backup.BackupInfo, ) @@ -147,22 +154,53 @@ class State(proto.Enum): READY = 2 READY_OPTIMIZING = 3 - name = proto.Field(proto.STRING, number=1,) - state = proto.Field(proto.ENUM, number=2, enum=State,) - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) - restore_info = proto.Field(proto.MESSAGE, number=4, message="RestoreInfo",) + name = proto.Field( + proto.STRING, + number=1, + ) + state = proto.Field( + proto.ENUM, + number=2, + enum=State, + ) + create_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + restore_info = proto.Field( + proto.MESSAGE, + number=4, + message="RestoreInfo", + ) encryption_config = proto.Field( - proto.MESSAGE, number=5, message=common.EncryptionConfig, + proto.MESSAGE, + number=5, + message=common.EncryptionConfig, ) encryption_info = proto.RepeatedField( - proto.MESSAGE, number=8, message=common.EncryptionInfo, + proto.MESSAGE, + number=8, + message=common.EncryptionInfo, + ) + version_retention_period = proto.Field( + proto.STRING, + number=6, ) - version_retention_period = proto.Field(proto.STRING, number=6,) earliest_version_time = proto.Field( - proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + default_leader = proto.Field( + proto.STRING, + number=9, + ) + database_dialect = proto.Field( + proto.ENUM, + number=10, + enum=common.DatabaseDialect, ) - default_leader = proto.Field(proto.STRING, number=9,) - database_dialect = proto.Field(proto.ENUM, number=10, enum=common.DatabaseDialect,) class ListDatabasesRequest(proto.Message): @@ -185,9 +223,18 @@ class ListDatabasesRequest(proto.Message): [ListDatabasesResponse][google.spanner.admin.database.v1.ListDatabasesResponse]. """ - parent = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=3,) - page_token = proto.Field(proto.STRING, number=4,) + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=3, + ) + page_token = proto.Field( + proto.STRING, + number=4, + ) class ListDatabasesResponse(proto.Message): @@ -207,8 +254,15 @@ class ListDatabasesResponse(proto.Message): def raw_page(self): return self - databases = proto.RepeatedField(proto.MESSAGE, number=1, message="Database",) - next_page_token = proto.Field(proto.STRING, number=2,) + databases = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Database", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class CreateDatabaseRequest(proto.Message): @@ -244,13 +298,28 @@ class CreateDatabaseRequest(proto.Message): Database. """ - parent = proto.Field(proto.STRING, number=1,) - create_statement = proto.Field(proto.STRING, number=2,) - extra_statements = proto.RepeatedField(proto.STRING, number=3,) + parent = proto.Field( + proto.STRING, + number=1, + ) + create_statement = proto.Field( + proto.STRING, + number=2, + ) + extra_statements = proto.RepeatedField( + proto.STRING, + number=3, + ) encryption_config = proto.Field( - proto.MESSAGE, number=4, message=common.EncryptionConfig, + proto.MESSAGE, + number=4, + message=common.EncryptionConfig, + ) + database_dialect = proto.Field( + proto.ENUM, + number=5, + enum=common.DatabaseDialect, ) - database_dialect = proto.Field(proto.ENUM, number=5, enum=common.DatabaseDialect,) class CreateDatabaseMetadata(proto.Message): @@ -262,7 +331,10 @@ class CreateDatabaseMetadata(proto.Message): The database being created. """ - database = proto.Field(proto.STRING, number=1,) + database = proto.Field( + proto.STRING, + number=1, + ) class GetDatabaseRequest(proto.Message): @@ -276,7 +348,10 @@ class GetDatabaseRequest(proto.Message): ``projects//instances//databases/``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class UpdateDatabaseDdlRequest(proto.Message): @@ -327,9 +402,18 @@ class UpdateDatabaseDdlRequest(proto.Message): returns ``ALREADY_EXISTS``. """ - database = proto.Field(proto.STRING, number=1,) - statements = proto.RepeatedField(proto.STRING, number=2,) - operation_id = proto.Field(proto.STRING, number=3,) + database = proto.Field( + proto.STRING, + number=1, + ) + statements = proto.RepeatedField( + proto.STRING, + number=2, + ) + operation_id = proto.Field( + proto.STRING, + number=3, + ) class UpdateDatabaseDdlMetadata(proto.Message): @@ -365,14 +449,27 @@ class UpdateDatabaseDdlMetadata(proto.Message): ``statements[i]``. """ - database = proto.Field(proto.STRING, number=1,) - statements = proto.RepeatedField(proto.STRING, number=2,) + database = proto.Field( + proto.STRING, + number=1, + ) + statements = proto.RepeatedField( + proto.STRING, + number=2, + ) commit_timestamps = proto.RepeatedField( - proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + throttled = proto.Field( + proto.BOOL, + number=4, ) - throttled = proto.Field(proto.BOOL, number=4,) progress = proto.RepeatedField( - proto.MESSAGE, number=5, message=common.OperationProgress, + proto.MESSAGE, + number=5, + message=common.OperationProgress, ) @@ -385,7 +482,10 @@ class DropDatabaseRequest(proto.Message): Required. The database to be dropped. """ - database = proto.Field(proto.STRING, number=1,) + database = proto.Field( + proto.STRING, + number=1, + ) class GetDatabaseDdlRequest(proto.Message): @@ -399,7 +499,10 @@ class GetDatabaseDdlRequest(proto.Message): ``projects//instances//databases/`` """ - database = proto.Field(proto.STRING, number=1,) + database = proto.Field( + proto.STRING, + number=1, + ) class GetDatabaseDdlResponse(proto.Message): @@ -413,7 +516,10 @@ class GetDatabaseDdlResponse(proto.Message): request. """ - statements = proto.RepeatedField(proto.STRING, number=1,) + statements = proto.RepeatedField( + proto.STRING, + number=1, + ) class ListDatabaseOperationsRequest(proto.Message): @@ -488,10 +594,22 @@ class ListDatabaseOperationsRequest(proto.Message): to the same ``parent`` and with the same ``filter``. """ - parent = proto.Field(proto.STRING, number=1,) - filter = proto.Field(proto.STRING, number=2,) - page_size = proto.Field(proto.INT32, number=3,) - page_token = proto.Field(proto.STRING, number=4,) + parent = proto.Field( + proto.STRING, + number=1, + ) + filter = proto.Field( + proto.STRING, + number=2, + ) + page_size = proto.Field( + proto.INT32, + number=3, + ) + page_token = proto.Field( + proto.STRING, + number=4, + ) class ListDatabaseOperationsResponse(proto.Message): @@ -517,9 +635,14 @@ def raw_page(self): return self operations = proto.RepeatedField( - proto.MESSAGE, number=1, message=operations_pb2.Operation, + proto.MESSAGE, + number=1, + message=operations_pb2.Operation, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, ) - next_page_token = proto.Field(proto.STRING, number=2,) class RestoreDatabaseRequest(proto.Message): @@ -558,11 +681,23 @@ class RestoreDatabaseRequest(proto.Message): = ``USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION``. """ - parent = proto.Field(proto.STRING, number=1,) - database_id = proto.Field(proto.STRING, number=2,) - backup = proto.Field(proto.STRING, number=3, oneof="source",) + parent = proto.Field( + proto.STRING, + number=1, + ) + database_id = proto.Field( + proto.STRING, + number=2, + ) + backup = proto.Field( + proto.STRING, + number=3, + oneof="source", + ) encryption_config = proto.Field( - proto.MESSAGE, number=4, message="RestoreDatabaseEncryptionConfig", + proto.MESSAGE, + number=4, + message="RestoreDatabaseEncryptionConfig", ) @@ -589,8 +724,15 @@ class EncryptionType(proto.Enum): GOOGLE_DEFAULT_ENCRYPTION = 2 CUSTOMER_MANAGED_ENCRYPTION = 3 - encryption_type = proto.Field(proto.ENUM, number=1, enum=EncryptionType,) - kms_key_name = proto.Field(proto.STRING, number=2,) + encryption_type = proto.Field( + proto.ENUM, + number=1, + enum=EncryptionType, + ) + kms_key_name = proto.Field( + proto.STRING, + number=2, + ) class RestoreDatabaseMetadata(proto.Message): @@ -646,14 +788,35 @@ class RestoreDatabaseMetadata(proto.Message): if the restore was not successful. """ - name = proto.Field(proto.STRING, number=1,) - source_type = proto.Field(proto.ENUM, number=2, enum="RestoreSourceType",) + name = proto.Field( + proto.STRING, + number=1, + ) + source_type = proto.Field( + proto.ENUM, + number=2, + enum="RestoreSourceType", + ) backup_info = proto.Field( - proto.MESSAGE, number=3, oneof="source_info", message=gsad_backup.BackupInfo, + proto.MESSAGE, + number=3, + oneof="source_info", + message=gsad_backup.BackupInfo, + ) + progress = proto.Field( + proto.MESSAGE, + number=4, + message=common.OperationProgress, + ) + cancel_time = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, + ) + optimize_database_operation_name = proto.Field( + proto.STRING, + number=6, ) - progress = proto.Field(proto.MESSAGE, number=4, message=common.OperationProgress,) - cancel_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) - optimize_database_operation_name = proto.Field(proto.STRING, number=6,) class OptimizeRestoredDatabaseMetadata(proto.Message): @@ -672,8 +835,15 @@ class OptimizeRestoredDatabaseMetadata(proto.Message): optimizations. """ - name = proto.Field(proto.STRING, number=1,) - progress = proto.Field(proto.MESSAGE, number=2, message=common.OperationProgress,) + name = proto.Field( + proto.STRING, + number=1, + ) + progress = proto.Field( + proto.MESSAGE, + number=2, + message=common.OperationProgress, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py index 2d8a01afb7..1d79ac996e 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py @@ -334,12 +334,20 @@ def sample_list_instance_configs(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + 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.ListInstanceConfigsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -445,7 +453,12 @@ def sample_get_instance_config(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -550,12 +563,20 @@ def sample_list_instances(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + 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.ListInstancesAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -657,7 +678,12 @@ def sample_get_instance(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -822,7 +848,12 @@ def sample_create_instance(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -998,7 +1029,12 @@ def sample_update_instance(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -1110,7 +1146,10 @@ def sample_delete_instance(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def set_iam_policy( @@ -1241,7 +1280,9 @@ def sample_set_iam_policy(): if isinstance(request, dict): request = iam_policy_pb2.SetIamPolicyRequest(**request) elif not request: - request = iam_policy_pb2.SetIamPolicyRequest(resource=resource,) + request = iam_policy_pb2.SetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1258,7 +1299,12 @@ def sample_set_iam_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1392,7 +1438,9 @@ def sample_get_iam_policy(): if isinstance(request, dict): request = iam_policy_pb2.GetIamPolicyRequest(**request) elif not request: - request = iam_policy_pb2.GetIamPolicyRequest(resource=resource,) + request = iam_policy_pb2.GetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1419,7 +1467,12 @@ def sample_get_iam_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1511,7 +1564,8 @@ def sample_test_iam_permissions(): request = iam_policy_pb2.TestIamPermissionsRequest(**request) elif not request: request = iam_policy_pb2.TestIamPermissionsRequest( - resource=resource, permissions=permissions, + resource=resource, + permissions=permissions, ) # Wrap the RPC method; this adds retry and timeout information, @@ -1529,7 +1583,12 @@ def sample_test_iam_permissions(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py index 89eb1c5e68..1ebf127487 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py @@ -58,7 +58,10 @@ class InstanceAdminClientMeta(type): _transport_registry["grpc"] = InstanceAdminGrpcTransport _transport_registry["grpc_asyncio"] = InstanceAdminGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[InstanceAdminTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[InstanceAdminTransport]: """Returns an appropriate transport class. Args: @@ -184,10 +187,14 @@ def transport(self) -> InstanceAdminTransport: return self._transport @staticmethod - def instance_path(project: str, instance: str,) -> str: + def instance_path( + project: str, + instance: str, + ) -> str: """Returns a fully-qualified instance string.""" return "projects/{project}/instances/{instance}".format( - project=project, instance=instance, + project=project, + instance=instance, ) @staticmethod @@ -197,10 +204,14 @@ def parse_instance_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def instance_config_path(project: str, instance_config: str,) -> str: + def instance_config_path( + project: str, + instance_config: str, + ) -> str: """Returns a fully-qualified instance_config string.""" return "projects/{project}/instanceConfigs/{instance_config}".format( - project=project, instance_config=instance_config, + project=project, + instance_config=instance_config, ) @staticmethod @@ -213,7 +224,9 @@ def parse_instance_config_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -226,9 +239,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -237,9 +254,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -248,9 +269,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -259,10 +284,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -528,12 +557,20 @@ def sample_list_instance_configs(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + 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.ListInstanceConfigsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -629,7 +666,12 @@ def sample_get_instance_config(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -724,12 +766,20 @@ def sample_list_instances(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + 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.ListInstancesPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -821,7 +871,12 @@ def sample_get_instance(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -986,7 +1041,12 @@ def sample_create_instance(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -1162,7 +1222,12 @@ def sample_update_instance(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -1264,7 +1329,10 @@ def sample_delete_instance(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def set_iam_policy( @@ -1411,7 +1479,12 @@ def sample_set_iam_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1561,7 +1634,12 @@ def sample_get_iam_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1670,7 +1748,12 @@ def sample_test_iam_permissions(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py index a6375d12b9..3f9888c363 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py @@ -189,10 +189,14 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.create_instance: gapic_v1.method.wrap_method( - self.create_instance, default_timeout=3600.0, client_info=client_info, + self.create_instance, + default_timeout=3600.0, + client_info=client_info, ), self.update_instance: gapic_v1.method.wrap_method( - self.update_instance, default_timeout=3600.0, client_info=client_info, + self.update_instance, + default_timeout=3600.0, + client_info=client_info, ), self.delete_instance: gapic_v1.method.wrap_method( self.delete_instance, @@ -210,7 +214,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.set_iam_policy: gapic_v1.method.wrap_method( - self.set_iam_policy, default_timeout=30.0, client_info=client_info, + self.set_iam_policy, + default_timeout=30.0, + client_info=client_info, ), self.get_iam_policy: gapic_v1.method.wrap_method( self.get_iam_policy, @@ -237,9 +243,9 @@ def _prep_wrapped_messages(self, client_info): def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py index d6b043af68..012c2dce2e 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py @@ -250,8 +250,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property diff --git a/google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py b/google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py index 56bf55a560..5b964a7935 100644 --- a/google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py +++ b/google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py @@ -67,9 +67,19 @@ class ReplicaType(proto.Enum): READ_ONLY = 2 WITNESS = 3 - location = proto.Field(proto.STRING, number=1,) - type_ = proto.Field(proto.ENUM, number=2, enum=ReplicaType,) - default_leader_location = proto.Field(proto.BOOL, number=3,) + location = proto.Field( + proto.STRING, + number=1, + ) + type_ = proto.Field( + proto.ENUM, + number=2, + enum=ReplicaType, + ) + default_leader_location = proto.Field( + proto.BOOL, + number=3, + ) class InstanceConfig(proto.Message): @@ -94,10 +104,23 @@ class InstanceConfig(proto.Message): databases in instances that use this instance configuration. """ - name = proto.Field(proto.STRING, number=1,) - display_name = proto.Field(proto.STRING, number=2,) - replicas = proto.RepeatedField(proto.MESSAGE, number=3, message="ReplicaInfo",) - leader_options = proto.RepeatedField(proto.STRING, number=4,) + name = proto.Field( + proto.STRING, + number=1, + ) + display_name = proto.Field( + proto.STRING, + number=2, + ) + replicas = proto.RepeatedField( + proto.MESSAGE, + number=3, + message="ReplicaInfo", + ) + leader_options = proto.RepeatedField( + proto.STRING, + number=4, + ) class Instance(proto.Message): @@ -183,14 +206,40 @@ class State(proto.Enum): CREATING = 1 READY = 2 - name = proto.Field(proto.STRING, number=1,) - config = proto.Field(proto.STRING, number=2,) - display_name = proto.Field(proto.STRING, number=3,) - node_count = proto.Field(proto.INT32, number=5,) - processing_units = proto.Field(proto.INT32, number=9,) - state = proto.Field(proto.ENUM, number=6, enum=State,) - labels = proto.MapField(proto.STRING, proto.STRING, number=7,) - endpoint_uris = proto.RepeatedField(proto.STRING, number=8,) + name = proto.Field( + proto.STRING, + number=1, + ) + config = proto.Field( + proto.STRING, + number=2, + ) + display_name = proto.Field( + proto.STRING, + number=3, + ) + node_count = proto.Field( + proto.INT32, + number=5, + ) + processing_units = proto.Field( + proto.INT32, + number=9, + ) + state = proto.Field( + proto.ENUM, + number=6, + enum=State, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=7, + ) + endpoint_uris = proto.RepeatedField( + proto.STRING, + number=8, + ) class ListInstanceConfigsRequest(proto.Message): @@ -213,9 +262,18 @@ class ListInstanceConfigsRequest(proto.Message): [ListInstanceConfigsResponse][google.spanner.admin.instance.v1.ListInstanceConfigsResponse]. """ - parent = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) class ListInstanceConfigsResponse(proto.Message): @@ -237,9 +295,14 @@ def raw_page(self): return self instance_configs = proto.RepeatedField( - proto.MESSAGE, number=1, message="InstanceConfig", + proto.MESSAGE, + number=1, + message="InstanceConfig", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, ) - next_page_token = proto.Field(proto.STRING, number=2,) class GetInstanceConfigRequest(proto.Message): @@ -253,7 +316,10 @@ class GetInstanceConfigRequest(proto.Message): ``projects//instanceConfigs/``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class GetInstanceRequest(proto.Message): @@ -272,8 +338,15 @@ class GetInstanceRequest(proto.Message): are returned. """ - name = proto.Field(proto.STRING, number=1,) - field_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask,) + name = proto.Field( + proto.STRING, + number=1, + ) + field_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) class CreateInstanceRequest(proto.Message): @@ -294,9 +367,19 @@ class CreateInstanceRequest(proto.Message): ``/instances/``. """ - parent = proto.Field(proto.STRING, number=1,) - instance_id = proto.Field(proto.STRING, number=2,) - instance = proto.Field(proto.MESSAGE, number=3, message="Instance",) + parent = proto.Field( + proto.STRING, + number=1, + ) + instance_id = proto.Field( + proto.STRING, + number=2, + ) + instance = proto.Field( + proto.MESSAGE, + number=3, + message="Instance", + ) class ListInstancesRequest(proto.Message): @@ -341,10 +424,22 @@ class ListInstancesRequest(proto.Message): containing "dev". """ - parent = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) - filter = proto.Field(proto.STRING, number=4,) + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) class ListInstancesResponse(proto.Message): @@ -364,8 +459,15 @@ class ListInstancesResponse(proto.Message): def raw_page(self): return self - instances = proto.RepeatedField(proto.MESSAGE, number=1, message="Instance",) - next_page_token = proto.Field(proto.STRING, number=2,) + instances = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Instance", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class UpdateInstanceRequest(proto.Message): @@ -388,8 +490,16 @@ class UpdateInstanceRequest(proto.Message): them. """ - instance = proto.Field(proto.MESSAGE, number=1, message="Instance",) - field_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask,) + instance = proto.Field( + proto.MESSAGE, + number=1, + message="Instance", + ) + field_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) class DeleteInstanceRequest(proto.Message): @@ -402,7 +512,10 @@ class DeleteInstanceRequest(proto.Message): of the form ``projects//instances/`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class CreateInstanceMetadata(proto.Message): @@ -426,10 +539,26 @@ class CreateInstanceMetadata(proto.Message): was completed successfully. """ - instance = proto.Field(proto.MESSAGE, number=1, message="Instance",) - start_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) - cancel_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) - end_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + instance = proto.Field( + proto.MESSAGE, + number=1, + message="Instance", + ) + start_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + cancel_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) class UpdateInstanceMetadata(proto.Message): @@ -453,10 +582,26 @@ class UpdateInstanceMetadata(proto.Message): was completed successfully. """ - instance = proto.Field(proto.MESSAGE, number=1, message="Instance",) - start_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) - cancel_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) - end_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + instance = proto.Field( + proto.MESSAGE, + number=1, + message="Instance", + ) + start_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + cancel_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/spanner_dbapi/connection.py b/google/cloud/spanner_dbapi/connection.py index 0da0c15584..76f04338c4 100644 --- a/google/cloud/spanner_dbapi/connection.py +++ b/google/cloud/spanner_dbapi/connection.py @@ -446,7 +446,8 @@ def run_statement(self, statement, retried=False): ) else: _execute_insert_heterogenous( - transaction, parts.get("sql_params_list"), + transaction, + parts.get("sql_params_list"), ) return ( iter(()), @@ -455,7 +456,9 @@ def run_statement(self, statement, retried=False): return ( transaction.execute_sql( - statement.sql, statement.params, param_types=statement.param_types, + statement.sql, + statement.params, + param_types=statement.param_types, ), ResultsChecksum() if retried else statement.checksum, ) diff --git a/google/cloud/spanner_dbapi/cursor.py b/google/cloud/spanner_dbapi/cursor.py index 7c8c5bdbc5..0fc36a72a9 100644 --- a/google/cloud/spanner_dbapi/cursor.py +++ b/google/cloud/spanner_dbapi/cursor.py @@ -260,9 +260,10 @@ def execute(self, sql, args=None): class_ == parse_utils.STMT_INSERT, ) - (self._result_set, self._checksum,) = self.connection.run_statement( - statement - ) + ( + self._result_set, + self._checksum, + ) = self.connection.run_statement(statement) while True: try: self._itr = PeekIterator(self._result_set) diff --git a/google/cloud/spanner_v1/backup.py b/google/cloud/spanner_v1/backup.py index d7a97809f1..a7b7a972b6 100644 --- a/google/cloud/spanner_v1/backup.py +++ b/google/cloud/spanner_v1/backup.py @@ -295,7 +295,10 @@ def create(self): encryption_config=self._encryption_config, ) - future = api.copy_backup(request=request, metadata=metadata,) + future = api.copy_backup( + request=request, + metadata=metadata, + ) return future backup = BackupPB( @@ -311,7 +314,10 @@ def create(self): encryption_config=self._encryption_config, ) - future = api.create_backup(request=request, metadata=metadata,) + future = api.create_backup( + request=request, + metadata=metadata, + ) return future def exists(self): @@ -358,7 +364,10 @@ def update_expire_time(self, new_expire_time): """ api = self._instance._client.database_admin_api metadata = _metadata_with_prefix(self.name) - backup_update = BackupPB(name=self.name, expire_time=new_expire_time,) + backup_update = BackupPB( + name=self.name, + expire_time=new_expire_time, + ) update_mask = {"paths": ["expire_time"]} api.update_backup( backup=backup_update, update_mask=update_mask, metadata=metadata diff --git a/google/cloud/spanner_v1/batch.py b/google/cloud/spanner_v1/batch.py index 4d8364df1f..48c533d2cd 100644 --- a/google/cloud/spanner_v1/batch.py +++ b/google/cloud/spanner_v1/batch.py @@ -179,7 +179,10 @@ def commit(self, return_commit_stats=False, request_options=None): request_options=request_options, ) with trace_call("CloudSpanner.Commit", self._session, trace_attributes): - response = api.commit(request=request, metadata=metadata,) + response = api.commit( + request=request, + metadata=metadata, + ) self.committed = response.commit_timestamp self.commit_stats = response.commit_stats return self.committed diff --git a/google/cloud/spanner_v1/database.py b/google/cloud/spanner_v1/database.py index 7ccefc1228..5dc41e525e 100644 --- a/google/cloud/spanner_v1/database.py +++ b/google/cloud/spanner_v1/database.py @@ -441,7 +441,9 @@ def update_ddl(self, ddl_statements, operation_id=""): metadata = _metadata_with_prefix(self.name) request = UpdateDatabaseDdlRequest( - database=self.name, statements=ddl_statements, operation_id=operation_id, + database=self.name, + statements=ddl_statements, + operation_id=operation_id, ) future = api.update_database_ddl(request=request, metadata=metadata) @@ -544,7 +546,8 @@ def execute_pdml(): request_options=request_options, ) method = functools.partial( - api.execute_streaming_sql, metadata=metadata, + api.execute_streaming_sql, + metadata=metadata, ) iterator = _restart_on_unavailable(method, request) @@ -694,7 +697,10 @@ def restore(self, source): backup=source.name, encryption_config=self._encryption_config or None, ) - future = api.restore_database(request=request, metadata=metadata,) + future = api.restore_database( + request=request, + metadata=metadata, + ) return future def is_ready(self): @@ -1032,7 +1038,11 @@ def generate_read_batches( yield {"partition": partition, "read": read_info.copy()} def process_read_batch( - self, batch, *, retry=gapic_v1.method.DEFAULT, timeout=gapic_v1.method.DEFAULT, + self, + batch, + *, + retry=gapic_v1.method.DEFAULT, + timeout=gapic_v1.method.DEFAULT, ): """Process a single, partitioned read. @@ -1149,7 +1159,11 @@ def generate_query_batches( yield {"partition": partition, "query": query_info} def process_query_batch( - self, batch, *, retry=gapic_v1.method.DEFAULT, timeout=gapic_v1.method.DEFAULT, + self, + batch, + *, + retry=gapic_v1.method.DEFAULT, + timeout=gapic_v1.method.DEFAULT, ): """Process a single, partitioned query. diff --git a/google/cloud/spanner_v1/instance.py b/google/cloud/spanner_v1/instance.py index d3514bd85d..f8869d1f7b 100644 --- a/google/cloud/spanner_v1/instance.py +++ b/google/cloud/spanner_v1/instance.py @@ -554,7 +554,11 @@ def backup( ) def copy_backup( - self, backup_id, source_backup, expire_time=None, encryption_config=None, + self, + backup_id, + source_backup, + expire_time=None, + encryption_config=None, ): """Factory to create a copy backup within this instance. @@ -604,7 +608,9 @@ def list_backups(self, filter_="", page_size=None): """ metadata = _metadata_with_prefix(self.name) request = ListBackupsRequest( - parent=self.name, filter=filter_, page_size=page_size, + parent=self.name, + filter=filter_, + page_size=page_size, ) page_iter = self._client.database_admin_api.list_backups( request=request, metadata=metadata @@ -632,7 +638,9 @@ def list_backup_operations(self, filter_="", page_size=None): """ metadata = _metadata_with_prefix(self.name) request = ListBackupOperationsRequest( - parent=self.name, filter=filter_, page_size=page_size, + parent=self.name, + filter=filter_, + page_size=page_size, ) page_iter = self._client.database_admin_api.list_backup_operations( request=request, metadata=metadata @@ -660,7 +668,9 @@ def list_database_operations(self, filter_="", page_size=None): """ metadata = _metadata_with_prefix(self.name) request = ListDatabaseOperationsRequest( - parent=self.name, filter=filter_, page_size=page_size, + parent=self.name, + filter=filter_, + page_size=page_size, ) page_iter = self._client.database_admin_api.list_database_operations( request=request, metadata=metadata diff --git a/google/cloud/spanner_v1/services/spanner/async_client.py b/google/cloud/spanner_v1/services/spanner/async_client.py index 9fd1c6a75b..a9dc85cb22 100644 --- a/google/cloud/spanner_v1/services/spanner/async_client.py +++ b/google/cloud/spanner_v1/services/spanner/async_client.py @@ -326,7 +326,12 @@ def sample_create_session(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -445,7 +450,12 @@ def sample_batch_create_sessions(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -545,7 +555,12 @@ def sample_get_session(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -648,12 +663,20 @@ def sample_list_sessions(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + 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.ListSessionsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -748,7 +771,10 @@ def sample_delete_session(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def execute_sql( @@ -839,7 +865,12 @@ def sample_execute_sql(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -919,7 +950,12 @@ def sample_execute_streaming_sql(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1052,7 +1088,12 @@ def sample_execute_batch_dml(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1147,7 +1188,12 @@ def sample_read(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1228,7 +1274,12 @@ def sample_streaming_read(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1340,7 +1391,12 @@ def sample_begin_transaction(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1498,7 +1554,12 @@ def sample_commit(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1610,7 +1671,10 @@ def sample_rollback(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def partition_query( @@ -1701,7 +1765,12 @@ def sample_partition_query(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1797,7 +1866,12 @@ def sample_partition_read(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1811,7 +1885,9 @@ async def __aexit__(self, exc_type, exc, tb): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-spanner",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-spanner", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/spanner_v1/services/spanner/client.py b/google/cloud/spanner_v1/services/spanner/client.py index 31f274b0db..42fb0a9a9c 100644 --- a/google/cloud/spanner_v1/services/spanner/client.py +++ b/google/cloud/spanner_v1/services/spanner/client.py @@ -60,7 +60,10 @@ class SpannerClientMeta(type): _transport_registry["grpc"] = SpannerGrpcTransport _transport_registry["grpc_asyncio"] = SpannerGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[SpannerTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[SpannerTransport]: """Returns an appropriate transport class. Args: @@ -168,10 +171,16 @@ def transport(self) -> SpannerTransport: return self._transport @staticmethod - def database_path(project: str, instance: str, database: str,) -> str: + def database_path( + project: str, + instance: str, + database: str, + ) -> str: """Returns a fully-qualified database string.""" return "projects/{project}/instances/{instance}/databases/{database}".format( - project=project, instance=instance, database=database, + project=project, + instance=instance, + database=database, ) @staticmethod @@ -184,10 +193,18 @@ def parse_database_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def session_path(project: str, instance: str, database: str, session: str,) -> str: + def session_path( + project: str, + instance: str, + database: str, + session: str, + ) -> str: """Returns a fully-qualified session string.""" return "projects/{project}/instances/{instance}/databases/{database}/sessions/{session}".format( - project=project, instance=instance, database=database, session=session, + project=project, + instance=instance, + database=database, + session=session, ) @staticmethod @@ -200,7 +217,9 @@ def parse_session_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -213,9 +232,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -224,9 +247,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -235,9 +262,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -246,10 +277,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -525,7 +560,12 @@ def sample_create_session(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -635,7 +675,12 @@ def sample_batch_create_sessions(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -726,7 +771,12 @@ def sample_get_session(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -820,12 +870,20 @@ def sample_list_sessions(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + 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.ListSessionsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -911,7 +969,10 @@ def sample_delete_session(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def execute_sql( @@ -994,7 +1055,12 @@ def sample_execute_sql(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1075,7 +1141,12 @@ def sample_execute_streaming_sql(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1200,7 +1271,12 @@ def sample_execute_batch_dml(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1287,7 +1363,12 @@ def sample_read(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1369,7 +1450,12 @@ def sample_streaming_read(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1472,7 +1558,12 @@ def sample_begin_transaction(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1621,7 +1712,12 @@ def sample_commit(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1724,7 +1820,10 @@ def sample_rollback(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def partition_query( @@ -1807,7 +1906,12 @@ def sample_partition_query(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1895,7 +1999,12 @@ def sample_partition_read(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1916,7 +2025,9 @@ def __exit__(self, type, value, traceback): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-spanner",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-spanner", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/spanner_v1/services/spanner/transports/base.py b/google/cloud/spanner_v1/services/spanner/transports/base.py index 40ef03a812..0066447c79 100644 --- a/google/cloud/spanner_v1/services/spanner/transports/base.py +++ b/google/cloud/spanner_v1/services/spanner/transports/base.py @@ -33,7 +33,9 @@ try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-spanner",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-spanner", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -243,7 +245,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.streaming_read: gapic_v1.method.wrap_method( - self.streaming_read, default_timeout=3600.0, client_info=client_info, + self.streaming_read, + default_timeout=3600.0, + client_info=client_info, ), self.begin_transaction: gapic_v1.method.wrap_method( self.begin_transaction, @@ -320,9 +324,9 @@ def _prep_wrapped_messages(self, client_info): def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() diff --git a/google/cloud/spanner_v1/services/spanner/transports/grpc.py b/google/cloud/spanner_v1/services/spanner/transports/grpc.py index d33a89b694..ba84345989 100644 --- a/google/cloud/spanner_v1/services/spanner/transports/grpc.py +++ b/google/cloud/spanner_v1/services/spanner/transports/grpc.py @@ -230,8 +230,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property diff --git a/google/cloud/spanner_v1/session.py b/google/cloud/spanner_v1/session.py index 5eca0a8d2f..1ab6a93626 100644 --- a/google/cloud/spanner_v1/session.py +++ b/google/cloud/spanner_v1/session.py @@ -120,7 +120,10 @@ def create(self): request.session.labels = self._labels with trace_call("CloudSpanner.CreateSession", self, self._labels): - session_pb = api.create_session(request=request, metadata=metadata,) + session_pb = api.create_session( + request=request, + metadata=metadata, + ) self._session_id = session_pb.name.split("/")[-1] def exists(self): @@ -438,4 +441,4 @@ def _get_retry_delay(cause, attempts): nanos = retry_info.retry_delay.nanos return retry_info.retry_delay.seconds + nanos / 1.0e9 - return 2 ** attempts + random.random() + return 2**attempts + random.random() diff --git a/google/cloud/spanner_v1/snapshot.py b/google/cloud/spanner_v1/snapshot.py index aaf9caa2fc..75aed33e33 100644 --- a/google/cloud/spanner_v1/snapshot.py +++ b/google/cloud/spanner_v1/snapshot.py @@ -449,7 +449,10 @@ def partition_read( "CloudSpanner.PartitionReadOnlyTransaction", self._session, trace_attributes ): response = api.partition_read( - request=request, metadata=metadata, retry=retry, timeout=timeout, + request=request, + metadata=metadata, + retry=retry, + timeout=timeout, ) return [partition.partition_token for partition in response.partitions] @@ -541,7 +544,10 @@ def partition_query( trace_attributes, ): response = api.partition_query( - request=request, metadata=metadata, retry=retry, timeout=timeout, + request=request, + metadata=metadata, + retry=retry, + timeout=timeout, ) return [partition.partition_token for partition in response.partitions] diff --git a/google/cloud/spanner_v1/streamed.py b/google/cloud/spanner_v1/streamed.py index 3b7eb7c89a..80a452d558 100644 --- a/google/cloud/spanner_v1/streamed.py +++ b/google/cloud/spanner_v1/streamed.py @@ -205,7 +205,11 @@ class Unmergeable(ValueError): """ def __init__(self, lhs, rhs, type_): - message = "Cannot merge %s values: %s %s" % (TypeCode(type_.code), lhs, rhs,) + message = "Cannot merge %s values: %s %s" % ( + TypeCode(type_.code), + lhs, + rhs, + ) super(Unmergeable, self).__init__(message) diff --git a/google/cloud/spanner_v1/transaction.py b/google/cloud/spanner_v1/transaction.py index b960761147..d776b12469 100644 --- a/google/cloud/spanner_v1/transaction.py +++ b/google/cloud/spanner_v1/transaction.py @@ -166,7 +166,10 @@ def commit(self, return_commit_stats=False, request_options=None): request_options=request_options, ) with trace_call("CloudSpanner.Commit", self._session, trace_attributes): - response = api.commit(request=request, metadata=metadata,) + response = api.commit( + request=request, + metadata=metadata, + ) self.committed = response.commit_timestamp if return_commit_stats: self.commit_stats = response.commit_stats diff --git a/google/cloud/spanner_v1/types/commit_response.py b/google/cloud/spanner_v1/types/commit_response.py index 2d03f35ba5..837cbbf4f4 100644 --- a/google/cloud/spanner_v1/types/commit_response.py +++ b/google/cloud/spanner_v1/types/commit_response.py @@ -18,7 +18,12 @@ from google.protobuf import timestamp_pb2 # type: ignore -__protobuf__ = proto.module(package="google.spanner.v1", manifest={"CommitResponse",},) +__protobuf__ = proto.module( + package="google.spanner.v1", + manifest={ + "CommitResponse", + }, +) class CommitResponse(proto.Message): @@ -50,12 +55,21 @@ class CommitStats(proto.Message): `INVALID_ARGUMENT `__. """ - mutation_count = proto.Field(proto.INT64, number=1,) + mutation_count = proto.Field( + proto.INT64, + number=1, + ) commit_timestamp = proto.Field( - proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + commit_stats = proto.Field( + proto.MESSAGE, + number=2, + message=CommitStats, ) - commit_stats = proto.Field(proto.MESSAGE, number=2, message=CommitStats,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/spanner_v1/types/keys.py b/google/cloud/spanner_v1/types/keys.py index 6486b7ce6d..81e6e1360c 100644 --- a/google/cloud/spanner_v1/types/keys.py +++ b/google/cloud/spanner_v1/types/keys.py @@ -19,7 +19,11 @@ __protobuf__ = proto.module( - package="google.spanner.v1", manifest={"KeyRange", "KeySet",}, + package="google.spanner.v1", + manifest={ + "KeyRange", + "KeySet", + }, ) @@ -169,16 +173,28 @@ class KeyRange(proto.Message): """ start_closed = proto.Field( - proto.MESSAGE, number=1, oneof="start_key_type", message=struct_pb2.ListValue, + proto.MESSAGE, + number=1, + oneof="start_key_type", + message=struct_pb2.ListValue, ) start_open = proto.Field( - proto.MESSAGE, number=2, oneof="start_key_type", message=struct_pb2.ListValue, + proto.MESSAGE, + number=2, + oneof="start_key_type", + message=struct_pb2.ListValue, ) end_closed = proto.Field( - proto.MESSAGE, number=3, oneof="end_key_type", message=struct_pb2.ListValue, + proto.MESSAGE, + number=3, + oneof="end_key_type", + message=struct_pb2.ListValue, ) end_open = proto.Field( - proto.MESSAGE, number=4, oneof="end_key_type", message=struct_pb2.ListValue, + proto.MESSAGE, + number=4, + oneof="end_key_type", + message=struct_pb2.ListValue, ) @@ -209,9 +225,20 @@ class KeySet(proto.Message): only yielded once. """ - keys = proto.RepeatedField(proto.MESSAGE, number=1, message=struct_pb2.ListValue,) - ranges = proto.RepeatedField(proto.MESSAGE, number=2, message="KeyRange",) - all_ = proto.Field(proto.BOOL, number=3,) + keys = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=struct_pb2.ListValue, + ) + ranges = proto.RepeatedField( + proto.MESSAGE, + number=2, + message="KeyRange", + ) + all_ = proto.Field( + proto.BOOL, + number=3, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/spanner_v1/types/mutation.py b/google/cloud/spanner_v1/types/mutation.py index 700efb15cc..2ad2db30ac 100644 --- a/google/cloud/spanner_v1/types/mutation.py +++ b/google/cloud/spanner_v1/types/mutation.py @@ -19,7 +19,12 @@ from google.protobuf import struct_pb2 # type: ignore -__protobuf__ = proto.module(package="google.spanner.v1", manifest={"Mutation",},) +__protobuf__ = proto.module( + package="google.spanner.v1", + manifest={ + "Mutation", + }, +) class Mutation(proto.Message): @@ -116,10 +121,18 @@ class Write(proto.Message): [here][google.spanner.v1.TypeCode]. """ - table = proto.Field(proto.STRING, number=1,) - columns = proto.RepeatedField(proto.STRING, number=2,) + table = proto.Field( + proto.STRING, + number=1, + ) + columns = proto.RepeatedField( + proto.STRING, + number=2, + ) values = proto.RepeatedField( - proto.MESSAGE, number=3, message=struct_pb2.ListValue, + proto.MESSAGE, + number=3, + message=struct_pb2.ListValue, ) class Delete(proto.Message): @@ -139,16 +152,46 @@ class Delete(proto.Message): succeed even if some or all rows do not exist. """ - table = proto.Field(proto.STRING, number=1,) - key_set = proto.Field(proto.MESSAGE, number=2, message=keys.KeySet,) + table = proto.Field( + proto.STRING, + number=1, + ) + key_set = proto.Field( + proto.MESSAGE, + number=2, + message=keys.KeySet, + ) - insert = proto.Field(proto.MESSAGE, number=1, oneof="operation", message=Write,) - update = proto.Field(proto.MESSAGE, number=2, oneof="operation", message=Write,) + insert = proto.Field( + proto.MESSAGE, + number=1, + oneof="operation", + message=Write, + ) + update = proto.Field( + proto.MESSAGE, + number=2, + oneof="operation", + message=Write, + ) insert_or_update = proto.Field( - proto.MESSAGE, number=3, oneof="operation", message=Write, + proto.MESSAGE, + number=3, + oneof="operation", + message=Write, + ) + replace = proto.Field( + proto.MESSAGE, + number=4, + oneof="operation", + message=Write, + ) + delete = proto.Field( + proto.MESSAGE, + number=5, + oneof="operation", + message=Delete, ) - replace = proto.Field(proto.MESSAGE, number=4, oneof="operation", message=Write,) - delete = proto.Field(proto.MESSAGE, number=5, oneof="operation", message=Delete,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/spanner_v1/types/query_plan.py b/google/cloud/spanner_v1/types/query_plan.py index c003aaadd0..76467cf6ab 100644 --- a/google/cloud/spanner_v1/types/query_plan.py +++ b/google/cloud/spanner_v1/types/query_plan.py @@ -19,7 +19,11 @@ __protobuf__ = proto.module( - package="google.spanner.v1", manifest={"PlanNode", "QueryPlan",}, + package="google.spanner.v1", + manifest={ + "PlanNode", + "QueryPlan", + }, ) @@ -101,9 +105,18 @@ class ChildLink(proto.Message): to the variable names assigned to the columns. """ - child_index = proto.Field(proto.INT32, number=1,) - type_ = proto.Field(proto.STRING, number=2,) - variable = proto.Field(proto.STRING, number=3,) + child_index = proto.Field( + proto.INT32, + number=1, + ) + type_ = proto.Field( + proto.STRING, + number=2, + ) + variable = proto.Field( + proto.STRING, + number=3, + ) class ShortRepresentation(proto.Message): r"""Condensed representation of a node and its subtree. Only present for @@ -121,18 +134,49 @@ class ShortRepresentation(proto.Message): subquery may not necessarily be a direct child of this node. """ - description = proto.Field(proto.STRING, number=1,) - subqueries = proto.MapField(proto.STRING, proto.INT32, number=2,) - - index = proto.Field(proto.INT32, number=1,) - kind = proto.Field(proto.ENUM, number=2, enum=Kind,) - display_name = proto.Field(proto.STRING, number=3,) - child_links = proto.RepeatedField(proto.MESSAGE, number=4, message=ChildLink,) + description = proto.Field( + proto.STRING, + number=1, + ) + subqueries = proto.MapField( + proto.STRING, + proto.INT32, + number=2, + ) + + index = proto.Field( + proto.INT32, + number=1, + ) + kind = proto.Field( + proto.ENUM, + number=2, + enum=Kind, + ) + display_name = proto.Field( + proto.STRING, + number=3, + ) + child_links = proto.RepeatedField( + proto.MESSAGE, + number=4, + message=ChildLink, + ) short_representation = proto.Field( - proto.MESSAGE, number=5, message=ShortRepresentation, + proto.MESSAGE, + number=5, + message=ShortRepresentation, + ) + metadata = proto.Field( + proto.MESSAGE, + number=6, + message=struct_pb2.Struct, + ) + execution_stats = proto.Field( + proto.MESSAGE, + number=7, + message=struct_pb2.Struct, ) - metadata = proto.Field(proto.MESSAGE, number=6, message=struct_pb2.Struct,) - execution_stats = proto.Field(proto.MESSAGE, number=7, message=struct_pb2.Struct,) class QueryPlan(proto.Message): @@ -147,7 +191,11 @@ class QueryPlan(proto.Message): to its index in ``plan_nodes``. """ - plan_nodes = proto.RepeatedField(proto.MESSAGE, number=1, message="PlanNode",) + plan_nodes = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="PlanNode", + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/spanner_v1/types/result_set.py b/google/cloud/spanner_v1/types/result_set.py index 30862d1bd0..68ff3700c5 100644 --- a/google/cloud/spanner_v1/types/result_set.py +++ b/google/cloud/spanner_v1/types/result_set.py @@ -23,7 +23,12 @@ __protobuf__ = proto.module( package="google.spanner.v1", - manifest={"ResultSet", "PartialResultSet", "ResultSetMetadata", "ResultSetStats",}, + manifest={ + "ResultSet", + "PartialResultSet", + "ResultSetMetadata", + "ResultSetStats", + }, ) @@ -55,9 +60,21 @@ class ResultSet(proto.Message): [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]. """ - metadata = proto.Field(proto.MESSAGE, number=1, message="ResultSetMetadata",) - rows = proto.RepeatedField(proto.MESSAGE, number=2, message=struct_pb2.ListValue,) - stats = proto.Field(proto.MESSAGE, number=3, message="ResultSetStats",) + metadata = proto.Field( + proto.MESSAGE, + number=1, + message="ResultSetMetadata", + ) + rows = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=struct_pb2.ListValue, + ) + stats = proto.Field( + proto.MESSAGE, + number=3, + message="ResultSetStats", + ) class PartialResultSet(proto.Message): @@ -175,11 +192,29 @@ class PartialResultSet(proto.Message): statements. """ - metadata = proto.Field(proto.MESSAGE, number=1, message="ResultSetMetadata",) - values = proto.RepeatedField(proto.MESSAGE, number=2, message=struct_pb2.Value,) - chunked_value = proto.Field(proto.BOOL, number=3,) - resume_token = proto.Field(proto.BYTES, number=4,) - stats = proto.Field(proto.MESSAGE, number=5, message="ResultSetStats",) + metadata = proto.Field( + proto.MESSAGE, + number=1, + message="ResultSetMetadata", + ) + values = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=struct_pb2.Value, + ) + chunked_value = proto.Field( + proto.BOOL, + number=3, + ) + resume_token = proto.Field( + proto.BYTES, + number=4, + ) + stats = proto.Field( + proto.MESSAGE, + number=5, + message="ResultSetStats", + ) class ResultSetMetadata(proto.Message): @@ -205,9 +240,15 @@ class ResultSetMetadata(proto.Message): transaction is yielded here. """ - row_type = proto.Field(proto.MESSAGE, number=1, message=gs_type.StructType,) + row_type = proto.Field( + proto.MESSAGE, + number=1, + message=gs_type.StructType, + ) transaction = proto.Field( - proto.MESSAGE, number=2, message=gs_transaction.Transaction, + proto.MESSAGE, + number=2, + message=gs_transaction.Transaction, ) @@ -252,10 +293,26 @@ class ResultSetStats(proto.Message): This field is a member of `oneof`_ ``row_count``. """ - query_plan = proto.Field(proto.MESSAGE, number=1, message=gs_query_plan.QueryPlan,) - query_stats = proto.Field(proto.MESSAGE, number=2, message=struct_pb2.Struct,) - row_count_exact = proto.Field(proto.INT64, number=3, oneof="row_count",) - row_count_lower_bound = proto.Field(proto.INT64, number=4, oneof="row_count",) + query_plan = proto.Field( + proto.MESSAGE, + number=1, + message=gs_query_plan.QueryPlan, + ) + query_stats = proto.Field( + proto.MESSAGE, + number=2, + message=struct_pb2.Struct, + ) + row_count_exact = proto.Field( + proto.INT64, + number=3, + oneof="row_count", + ) + row_count_lower_bound = proto.Field( + proto.INT64, + number=4, + oneof="row_count", + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/spanner_v1/types/spanner.py b/google/cloud/spanner_v1/types/spanner.py index cea8be56a9..2a94ded3fe 100644 --- a/google/cloud/spanner_v1/types/spanner.py +++ b/google/cloud/spanner_v1/types/spanner.py @@ -65,8 +65,15 @@ class CreateSessionRequest(proto.Message): Required. The session to create. """ - database = proto.Field(proto.STRING, number=1,) - session = proto.Field(proto.MESSAGE, number=2, message="Session",) + database = proto.Field( + proto.STRING, + number=1, + ) + session = proto.Field( + proto.MESSAGE, + number=2, + message="Session", + ) class BatchCreateSessionsRequest(proto.Message): @@ -90,9 +97,19 @@ class BatchCreateSessionsRequest(proto.Message): as necessary). """ - database = proto.Field(proto.STRING, number=1,) - session_template = proto.Field(proto.MESSAGE, number=2, message="Session",) - session_count = proto.Field(proto.INT32, number=3,) + database = proto.Field( + proto.STRING, + number=1, + ) + session_template = proto.Field( + proto.MESSAGE, + number=2, + message="Session", + ) + session_count = proto.Field( + proto.INT32, + number=3, + ) class BatchCreateSessionsResponse(proto.Message): @@ -104,7 +121,11 @@ class BatchCreateSessionsResponse(proto.Message): The freshly created sessions. """ - session = proto.RepeatedField(proto.MESSAGE, number=1, message="Session",) + session = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Session", + ) class Session(proto.Message): @@ -137,11 +158,24 @@ class Session(proto.Message): earlier than the actual last use time. """ - name = proto.Field(proto.STRING, number=1,) - labels = proto.MapField(proto.STRING, proto.STRING, number=2,) - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + name = proto.Field( + proto.STRING, + number=1, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=2, + ) + create_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) approximate_last_use_time = proto.Field( - proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, ) @@ -154,7 +188,10 @@ class GetSessionRequest(proto.Message): retrieve. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class ListSessionsRequest(proto.Message): @@ -188,10 +225,22 @@ class ListSessionsRequest(proto.Message): and the value of the label contains the string "dev". """ - database = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) - filter = proto.Field(proto.STRING, number=4,) + database = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) class ListSessionsResponse(proto.Message): @@ -211,8 +260,15 @@ class ListSessionsResponse(proto.Message): def raw_page(self): return self - sessions = proto.RepeatedField(proto.MESSAGE, number=1, message="Session",) - next_page_token = proto.Field(proto.STRING, number=2,) + sessions = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Session", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class DeleteSessionRequest(proto.Message): @@ -224,7 +280,10 @@ class DeleteSessionRequest(proto.Message): Required. The name of the session to delete. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class RequestOptions(proto.Message): @@ -282,9 +341,19 @@ class Priority(proto.Enum): PRIORITY_MEDIUM = 2 PRIORITY_HIGH = 3 - priority = proto.Field(proto.ENUM, number=1, enum=Priority,) - request_tag = proto.Field(proto.STRING, number=2,) - transaction_tag = proto.Field(proto.STRING, number=3,) + priority = proto.Field( + proto.ENUM, + number=1, + enum=Priority, + ) + request_tag = proto.Field( + proto.STRING, + number=2, + ) + transaction_tag = proto.Field( + proto.STRING, + number=3, + ) class ExecuteSqlRequest(proto.Message): @@ -450,24 +519,66 @@ class QueryOptions(proto.Message): garbage collection fails with an ``INVALID_ARGUMENT`` error. """ - optimizer_version = proto.Field(proto.STRING, number=1,) - optimizer_statistics_package = proto.Field(proto.STRING, number=2,) + optimizer_version = proto.Field( + proto.STRING, + number=1, + ) + optimizer_statistics_package = proto.Field( + proto.STRING, + number=2, + ) - session = proto.Field(proto.STRING, number=1,) + session = proto.Field( + proto.STRING, + number=1, + ) transaction = proto.Field( - proto.MESSAGE, number=2, message=gs_transaction.TransactionSelector, + proto.MESSAGE, + number=2, + message=gs_transaction.TransactionSelector, + ) + sql = proto.Field( + proto.STRING, + number=3, + ) + params = proto.Field( + proto.MESSAGE, + number=4, + message=struct_pb2.Struct, ) - sql = proto.Field(proto.STRING, number=3,) - params = proto.Field(proto.MESSAGE, number=4, message=struct_pb2.Struct,) param_types = proto.MapField( - proto.STRING, proto.MESSAGE, number=5, message=gs_type.Type, + proto.STRING, + proto.MESSAGE, + number=5, + message=gs_type.Type, + ) + resume_token = proto.Field( + proto.BYTES, + number=6, + ) + query_mode = proto.Field( + proto.ENUM, + number=7, + enum=QueryMode, + ) + partition_token = proto.Field( + proto.BYTES, + number=8, + ) + seqno = proto.Field( + proto.INT64, + number=9, + ) + query_options = proto.Field( + proto.MESSAGE, + number=10, + message=QueryOptions, + ) + request_options = proto.Field( + proto.MESSAGE, + number=11, + message="RequestOptions", ) - resume_token = proto.Field(proto.BYTES, number=6,) - query_mode = proto.Field(proto.ENUM, number=7, enum=QueryMode,) - partition_token = proto.Field(proto.BYTES, number=8,) - seqno = proto.Field(proto.INT64, number=9,) - query_options = proto.Field(proto.MESSAGE, number=10, message=QueryOptions,) - request_options = proto.Field(proto.MESSAGE, number=11, message="RequestOptions",) class ExecuteBatchDmlRequest(proto.Message): @@ -548,19 +659,45 @@ class Statement(proto.Message): SQL types. """ - sql = proto.Field(proto.STRING, number=1,) - params = proto.Field(proto.MESSAGE, number=2, message=struct_pb2.Struct,) + sql = proto.Field( + proto.STRING, + number=1, + ) + params = proto.Field( + proto.MESSAGE, + number=2, + message=struct_pb2.Struct, + ) param_types = proto.MapField( - proto.STRING, proto.MESSAGE, number=3, message=gs_type.Type, + proto.STRING, + proto.MESSAGE, + number=3, + message=gs_type.Type, ) - session = proto.Field(proto.STRING, number=1,) + session = proto.Field( + proto.STRING, + number=1, + ) transaction = proto.Field( - proto.MESSAGE, number=2, message=gs_transaction.TransactionSelector, + proto.MESSAGE, + number=2, + message=gs_transaction.TransactionSelector, + ) + statements = proto.RepeatedField( + proto.MESSAGE, + number=3, + message=Statement, + ) + seqno = proto.Field( + proto.INT64, + number=4, + ) + request_options = proto.Field( + proto.MESSAGE, + number=5, + message="RequestOptions", ) - statements = proto.RepeatedField(proto.MESSAGE, number=3, message=Statement,) - seqno = proto.Field(proto.INT64, number=4,) - request_options = proto.Field(proto.MESSAGE, number=5, message="RequestOptions",) class ExecuteBatchDmlResponse(proto.Message): @@ -619,9 +756,15 @@ class ExecuteBatchDmlResponse(proto.Message): """ result_sets = proto.RepeatedField( - proto.MESSAGE, number=1, message=result_set.ResultSet, + proto.MESSAGE, + number=1, + message=result_set.ResultSet, + ) + status = proto.Field( + proto.MESSAGE, + number=2, + message=status_pb2.Status, ) - status = proto.Field(proto.MESSAGE, number=2, message=status_pb2.Status,) class PartitionOptions(proto.Message): @@ -649,8 +792,14 @@ class PartitionOptions(proto.Message): this maximum count request. """ - partition_size_bytes = proto.Field(proto.INT64, number=1,) - max_partitions = proto.Field(proto.INT64, number=2,) + partition_size_bytes = proto.Field( + proto.INT64, + number=1, + ) + max_partitions = proto.Field( + proto.INT64, + number=2, + ) class PartitionQueryRequest(proto.Message): @@ -712,17 +861,34 @@ class PartitionQueryRequest(proto.Message): partitions are created. """ - session = proto.Field(proto.STRING, number=1,) + session = proto.Field( + proto.STRING, + number=1, + ) transaction = proto.Field( - proto.MESSAGE, number=2, message=gs_transaction.TransactionSelector, + proto.MESSAGE, + number=2, + message=gs_transaction.TransactionSelector, + ) + sql = proto.Field( + proto.STRING, + number=3, + ) + params = proto.Field( + proto.MESSAGE, + number=4, + message=struct_pb2.Struct, ) - sql = proto.Field(proto.STRING, number=3,) - params = proto.Field(proto.MESSAGE, number=4, message=struct_pb2.Struct,) param_types = proto.MapField( - proto.STRING, proto.MESSAGE, number=5, message=gs_type.Type, + proto.STRING, + proto.MESSAGE, + number=5, + message=gs_type.Type, ) partition_options = proto.Field( - proto.MESSAGE, number=6, message="PartitionOptions", + proto.MESSAGE, + number=6, + message="PartitionOptions", ) @@ -775,16 +941,36 @@ class PartitionReadRequest(proto.Message): partitions are created. """ - session = proto.Field(proto.STRING, number=1,) + session = proto.Field( + proto.STRING, + number=1, + ) transaction = proto.Field( - proto.MESSAGE, number=2, message=gs_transaction.TransactionSelector, + proto.MESSAGE, + number=2, + message=gs_transaction.TransactionSelector, + ) + table = proto.Field( + proto.STRING, + number=3, + ) + index = proto.Field( + proto.STRING, + number=4, + ) + columns = proto.RepeatedField( + proto.STRING, + number=5, + ) + key_set = proto.Field( + proto.MESSAGE, + number=6, + message=keys.KeySet, ) - table = proto.Field(proto.STRING, number=3,) - index = proto.Field(proto.STRING, number=4,) - columns = proto.RepeatedField(proto.STRING, number=5,) - key_set = proto.Field(proto.MESSAGE, number=6, message=keys.KeySet,) partition_options = proto.Field( - proto.MESSAGE, number=9, message="PartitionOptions", + proto.MESSAGE, + number=9, + message="PartitionOptions", ) @@ -801,7 +987,10 @@ class Partition(proto.Message): token. """ - partition_token = proto.Field(proto.BYTES, number=1,) + partition_token = proto.Field( + proto.BYTES, + number=1, + ) class PartitionResponse(proto.Message): @@ -816,9 +1005,15 @@ class PartitionResponse(proto.Message): Transaction created by this request. """ - partitions = proto.RepeatedField(proto.MESSAGE, number=1, message="Partition",) + partitions = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Partition", + ) transaction = proto.Field( - proto.MESSAGE, number=2, message=gs_transaction.Transaction, + proto.MESSAGE, + number=2, + message=gs_transaction.Transaction, ) @@ -896,18 +1091,49 @@ class ReadRequest(proto.Message): Common options for this request. """ - session = proto.Field(proto.STRING, number=1,) + session = proto.Field( + proto.STRING, + number=1, + ) transaction = proto.Field( - proto.MESSAGE, number=2, message=gs_transaction.TransactionSelector, + proto.MESSAGE, + number=2, + message=gs_transaction.TransactionSelector, + ) + table = proto.Field( + proto.STRING, + number=3, + ) + index = proto.Field( + proto.STRING, + number=4, + ) + columns = proto.RepeatedField( + proto.STRING, + number=5, + ) + key_set = proto.Field( + proto.MESSAGE, + number=6, + message=keys.KeySet, + ) + limit = proto.Field( + proto.INT64, + number=8, + ) + resume_token = proto.Field( + proto.BYTES, + number=9, + ) + partition_token = proto.Field( + proto.BYTES, + number=10, + ) + request_options = proto.Field( + proto.MESSAGE, + number=11, + message="RequestOptions", ) - table = proto.Field(proto.STRING, number=3,) - index = proto.Field(proto.STRING, number=4,) - columns = proto.RepeatedField(proto.STRING, number=5,) - key_set = proto.Field(proto.MESSAGE, number=6, message=keys.KeySet,) - limit = proto.Field(proto.INT64, number=8,) - resume_token = proto.Field(proto.BYTES, number=9,) - partition_token = proto.Field(proto.BYTES, number=10,) - request_options = proto.Field(proto.MESSAGE, number=11, message="RequestOptions",) class BeginTransactionRequest(proto.Message): @@ -928,11 +1154,20 @@ class BeginTransactionRequest(proto.Message): this transaction instead. """ - session = proto.Field(proto.STRING, number=1,) + session = proto.Field( + proto.STRING, + number=1, + ) options = proto.Field( - proto.MESSAGE, number=2, message=gs_transaction.TransactionOptions, + proto.MESSAGE, + number=2, + message=gs_transaction.TransactionOptions, + ) + request_options = proto.Field( + proto.MESSAGE, + number=3, + message="RequestOptions", ) - request_options = proto.Field(proto.MESSAGE, number=3, message="RequestOptions",) class CommitRequest(proto.Message): @@ -979,17 +1214,35 @@ class CommitRequest(proto.Message): Common options for this request. """ - session = proto.Field(proto.STRING, number=1,) - transaction_id = proto.Field(proto.BYTES, number=2, oneof="transaction",) + session = proto.Field( + proto.STRING, + number=1, + ) + transaction_id = proto.Field( + proto.BYTES, + number=2, + oneof="transaction", + ) single_use_transaction = proto.Field( proto.MESSAGE, number=3, oneof="transaction", message=gs_transaction.TransactionOptions, ) - mutations = proto.RepeatedField(proto.MESSAGE, number=4, message=mutation.Mutation,) - return_commit_stats = proto.Field(proto.BOOL, number=5,) - request_options = proto.Field(proto.MESSAGE, number=6, message="RequestOptions",) + mutations = proto.RepeatedField( + proto.MESSAGE, + number=4, + message=mutation.Mutation, + ) + return_commit_stats = proto.Field( + proto.BOOL, + number=5, + ) + request_options = proto.Field( + proto.MESSAGE, + number=6, + message="RequestOptions", + ) class RollbackRequest(proto.Message): @@ -1003,8 +1256,14 @@ class RollbackRequest(proto.Message): Required. The transaction to roll back. """ - session = proto.Field(proto.STRING, number=1,) - transaction_id = proto.Field(proto.BYTES, number=2,) + session = proto.Field( + proto.STRING, + number=1, + ) + transaction_id = proto.Field( + proto.BYTES, + number=2, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/spanner_v1/types/transaction.py b/google/cloud/spanner_v1/types/transaction.py index d8b9c31bc4..7c0a766c58 100644 --- a/google/cloud/spanner_v1/types/transaction.py +++ b/google/cloud/spanner_v1/types/transaction.py @@ -21,7 +21,11 @@ __protobuf__ = proto.module( package="google.spanner.v1", - manifest={"TransactionOptions", "Transaction", "TransactionSelector",}, + manifest={ + "TransactionOptions", + "Transaction", + "TransactionSelector", + }, ) @@ -340,8 +344,7 @@ class ReadWrite(proto.Message): """ class PartitionedDml(proto.Message): - r"""Message type to initiate a Partitioned DML transaction. - """ + r"""Message type to initiate a Partitioned DML transaction.""" class ReadOnly(proto.Message): r"""Message type to initiate a read-only transaction. @@ -427,7 +430,11 @@ class ReadOnly(proto.Message): message that describes the transaction. """ - strong = proto.Field(proto.BOOL, number=1, oneof="timestamp_bound",) + strong = proto.Field( + proto.BOOL, + number=1, + oneof="timestamp_bound", + ) min_read_timestamp = proto.Field( proto.MESSAGE, number=2, @@ -452,13 +459,29 @@ class ReadOnly(proto.Message): oneof="timestamp_bound", message=duration_pb2.Duration, ) - return_read_timestamp = proto.Field(proto.BOOL, number=6,) + return_read_timestamp = proto.Field( + proto.BOOL, + number=6, + ) - read_write = proto.Field(proto.MESSAGE, number=1, oneof="mode", message=ReadWrite,) + read_write = proto.Field( + proto.MESSAGE, + number=1, + oneof="mode", + message=ReadWrite, + ) partitioned_dml = proto.Field( - proto.MESSAGE, number=3, oneof="mode", message=PartitionedDml, + proto.MESSAGE, + number=3, + oneof="mode", + message=PartitionedDml, + ) + read_only = proto.Field( + proto.MESSAGE, + number=2, + oneof="mode", + message=ReadOnly, ) - read_only = proto.Field(proto.MESSAGE, number=2, oneof="mode", message=ReadOnly,) class Transaction(proto.Message): @@ -483,9 +506,14 @@ class Transaction(proto.Message): nanoseconds. Example: ``"2014-10-02T15:01:23.045123456Z"``. """ - id = proto.Field(proto.BYTES, number=1,) + id = proto.Field( + proto.BYTES, + number=1, + ) read_timestamp = proto.Field( - proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, ) @@ -528,11 +556,21 @@ class TransactionSelector(proto.Message): """ single_use = proto.Field( - proto.MESSAGE, number=1, oneof="selector", message="TransactionOptions", + proto.MESSAGE, + number=1, + oneof="selector", + message="TransactionOptions", + ) + id = proto.Field( + proto.BYTES, + number=2, + oneof="selector", ) - id = proto.Field(proto.BYTES, number=2, oneof="selector",) begin = proto.Field( - proto.MESSAGE, number=3, oneof="selector", message="TransactionOptions", + proto.MESSAGE, + number=3, + oneof="selector", + message="TransactionOptions", ) diff --git a/google/cloud/spanner_v1/types/type.py b/google/cloud/spanner_v1/types/type.py index 0bba5fe7e6..12b06fc737 100644 --- a/google/cloud/spanner_v1/types/type.py +++ b/google/cloud/spanner_v1/types/type.py @@ -18,7 +18,12 @@ __protobuf__ = proto.module( package="google.spanner.v1", - manifest={"TypeCode", "TypeAnnotationCode", "Type", "StructType",}, + manifest={ + "TypeCode", + "TypeAnnotationCode", + "Type", + "StructType", + }, ) @@ -88,10 +93,26 @@ class Type(proto.Message): on the read path. """ - code = proto.Field(proto.ENUM, number=1, enum="TypeCode",) - array_element_type = proto.Field(proto.MESSAGE, number=2, message="Type",) - struct_type = proto.Field(proto.MESSAGE, number=3, message="StructType",) - type_annotation = proto.Field(proto.ENUM, number=4, enum="TypeAnnotationCode",) + code = proto.Field( + proto.ENUM, + number=1, + enum="TypeCode", + ) + array_element_type = proto.Field( + proto.MESSAGE, + number=2, + message="Type", + ) + struct_type = proto.Field( + proto.MESSAGE, + number=3, + message="StructType", + ) + type_annotation = proto.Field( + proto.ENUM, + number=4, + enum="TypeAnnotationCode", + ) class StructType(proto.Message): @@ -126,10 +147,21 @@ class Field(proto.Message): The type of the field. """ - name = proto.Field(proto.STRING, number=1,) - type_ = proto.Field(proto.MESSAGE, number=2, message="Type",) - - fields = proto.RepeatedField(proto.MESSAGE, number=1, message=Field,) + name = proto.Field( + proto.STRING, + number=1, + ) + type_ = proto.Field( + proto.MESSAGE, + number=2, + message="Type", + ) + + fields = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=Field, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/noxfile.py b/noxfile.py index 7759904126..b00d81b102 100644 --- a/noxfile.py +++ b/noxfile.py @@ -24,7 +24,7 @@ import nox -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" @@ -57,7 +57,9 @@ def lint(session): """ session.install("flake8", BLACK_VERSION) session.run( - "black", "--check", *BLACK_PATHS, + "black", + "--check", + *BLACK_PATHS, ) session.run("flake8", "google", "tests") @@ -67,7 +69,8 @@ def blacken(session): """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) session.run( - "black", *BLACK_PATHS, + "black", + *BLACK_PATHS, ) diff --git a/samples/samples/noxfile.py b/samples/samples/noxfile.py index 85f5836dba..949e0fde9a 100644 --- a/samples/samples/noxfile.py +++ b/samples/samples/noxfile.py @@ -29,7 +29,7 @@ # WARNING - WARNING - WARNING - WARNING - WARNING # WARNING - WARNING - WARNING - WARNING - WARNING -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" # Copy `noxfile_config.py` to your directory and modify it instead. @@ -208,7 +208,9 @@ def _session_tests( if os.path.exists("requirements-test.txt"): if os.path.exists("constraints-test.txt"): - session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt") + session.install( + "-r", "requirements-test.txt", "-c", "constraints-test.txt" + ) else: session.install("-r", "requirements-test.txt") with open("requirements-test.txt") as rtfile: @@ -221,9 +223,9 @@ def _session_tests( post_install(session) if "pytest-parallel" in packages: - concurrent_args.extend(["--workers", "auto", "--tests-per-worker", "auto"]) + concurrent_args.extend(['--workers', 'auto', '--tests-per-worker', 'auto']) elif "pytest-xdist" in packages: - concurrent_args.extend(["-n", "auto"]) + concurrent_args.extend(['-n', 'auto']) session.run( "pytest", diff --git a/tests/system/_sample_data.py b/tests/system/_sample_data.py index 65f6e23ad3..a7f3b80a86 100644 --- a/tests/system/_sample_data.py +++ b/tests/system/_sample_data.py @@ -23,9 +23,9 @@ TABLE = "contacts" COLUMNS = ("contact_id", "first_name", "last_name", "email") ROW_DATA = ( - (1, u"Phred", u"Phlyntstone", u"phred@example.com"), - (2, u"Bharney", u"Rhubble", u"bharney@example.com"), - (3, u"Wylma", u"Phlyntstone", u"wylma@example.com"), + (1, "Phred", "Phlyntstone", "phred@example.com"), + (2, "Bharney", "Rhubble", "bharney@example.com"), + (3, "Wylma", "Phlyntstone", "wylma@example.com"), ) ALL = spanner_v1.KeySet(all_=True) SQL = "SELECT * FROM contacts ORDER BY contact_id" diff --git a/tests/system/conftest.py b/tests/system/conftest.py index 40b76208e8..0568b3bf3f 100644 --- a/tests/system/conftest.py +++ b/tests/system/conftest.py @@ -55,7 +55,8 @@ def spanner_client(): credentials = AnonymousCredentials() return spanner_v1.Client( - project=_helpers.EMULATOR_PROJECT, credentials=credentials, + project=_helpers.EMULATOR_PROJECT, + credentials=credentials, ) else: return spanner_v1.Client() # use google.auth.default credentials diff --git a/tests/system/test_backup_api.py b/tests/system/test_backup_api.py index f7325dc356..c09c06a5f2 100644 --- a/tests/system/test_backup_api.py +++ b/tests/system/test_backup_api.py @@ -60,7 +60,10 @@ def diff_config(shared_instance, instance_configs): @pytest.fixture(scope="session") def diff_config_instance( - spanner_client, shared_instance, instance_operation_timeout, diff_config, + spanner_client, + shared_instance, + instance_operation_timeout, + diff_config, ): if diff_config is None: return None @@ -180,7 +183,8 @@ def test_backup_workflow( encryption_type=RestoreDatabaseEncryptionConfig.EncryptionType.GOOGLE_DEFAULT_ENCRYPTION, ) database = shared_instance.database( - restored_id, encryption_config=encryption_config, + restored_id, + encryption_config=encryption_config, ) databases_to_delete.append(database) operation = database.restore(source=backup) @@ -200,7 +204,9 @@ def test_backup_workflow( def test_copy_backup_workflow( - shared_instance, shared_backup, backups_to_delete, + shared_instance, + shared_backup, + backups_to_delete, ): from google.cloud.spanner_admin_database_v1 import ( CopyBackupEncryptionConfig, @@ -256,7 +262,10 @@ def test_copy_backup_workflow( def test_backup_create_w_version_time_dflt_to_create_time( - shared_instance, shared_database, backups_to_delete, databases_to_delete, + shared_instance, + shared_database, + backups_to_delete, + databases_to_delete, ): backup_id = _helpers.unique_id("backup_id", separator="_") expire_time = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta( @@ -265,7 +274,9 @@ def test_backup_create_w_version_time_dflt_to_create_time( # Create backup. backup = shared_instance.backup( - backup_id, database=shared_database, expire_time=expire_time, + backup_id, + database=shared_database, + expire_time=expire_time, ) operation = backup.create() backups_to_delete.append(backup) @@ -300,7 +311,8 @@ def test_backup_create_w_invalid_expire_time(shared_instance, shared_database): def test_backup_create_w_invalid_version_time_past( - shared_instance, shared_database, + shared_instance, + shared_database, ): backup_id = _helpers.unique_id("backup_id", separator="_") expire_time = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta( @@ -323,7 +335,8 @@ def test_backup_create_w_invalid_version_time_past( def test_backup_create_w_invalid_version_time_future( - shared_instance, shared_database, + shared_instance, + shared_database, ): backup_id = _helpers.unique_id("backup_id", separator="_") expire_time = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta( @@ -359,7 +372,9 @@ def test_database_restore_to_diff_instance( # Create backup. backup = shared_instance.backup( - backup_id, database=shared_database, expire_time=expire_time, + backup_id, + database=shared_database, + expire_time=expire_time, ) op = backup.create() backups_to_delete.append(backup) @@ -439,7 +454,10 @@ def test_multi_create_cancel_update_error_restore_errors( def test_instance_list_backups( - shared_instance, shared_database, second_database, backups_to_delete, + shared_instance, + shared_database, + second_database, + backups_to_delete, ): # Remove un-scrubbed backups FBO count below. _helpers.scrub_instance_backups(shared_instance) @@ -453,7 +471,9 @@ def test_instance_list_backups( expire_time_1_stamp = expire_time_1.strftime("%Y-%m-%dT%H:%M:%S.%fZ") backup1 = shared_instance.backup( - backup_id_1, database=shared_database, expire_time=expire_time_1, + backup_id_1, + database=shared_database, + expire_time=expire_time_1, ) expire_time_2 = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta( diff --git a/tests/system/test_database_api.py b/tests/system/test_database_api.py index d702748a53..09f6d0e038 100644 --- a/tests/system/test_database_api.py +++ b/tests/system/test_database_api.py @@ -207,7 +207,9 @@ def test_update_ddl_w_operation_id(shared_instance, databases_to_delete): def test_update_ddl_w_pitr_invalid( - not_emulator, shared_instance, databases_to_delete, + not_emulator, + shared_instance, + databases_to_delete, ): pool = spanner_v1.BurstyPool(labels={"testcase": "update_database_ddl_pitr"}) temp_db_id = _helpers.unique_id("pitr_upd_ddl_inv", separator="_") @@ -229,7 +231,9 @@ def test_update_ddl_w_pitr_invalid( def test_update_ddl_w_pitr_success( - not_emulator, shared_instance, databases_to_delete, + not_emulator, + shared_instance, + databases_to_delete, ): pool = spanner_v1.BurstyPool(labels={"testcase": "update_database_ddl_pitr"}) temp_db_id = _helpers.unique_id("pitr_upd_ddl_inv", separator="_") @@ -255,7 +259,9 @@ def test_update_ddl_w_pitr_success( def test_update_ddl_w_default_leader_success( - not_emulator, multiregion_instance, databases_to_delete, + not_emulator, + multiregion_instance, + databases_to_delete, ): pool = spanner_v1.BurstyPool( labels={"testcase": "update_database_ddl_default_leader"}, diff --git a/tests/system/test_dbapi.py b/tests/system/test_dbapi.py index 49efc7e3f4..9557a46b37 100644 --- a/tests/system/test_dbapi.py +++ b/tests/system/test_dbapi.py @@ -45,7 +45,9 @@ def raw_database(shared_instance, database_operation_timeout): databse_id = _helpers.unique_id("dbapi-txn") pool = spanner_v1.BurstyPool(labels={"testcase": "database_api"}) database = shared_instance.database( - databse_id, ddl_statements=DDL_STATEMENTS, pool=pool, + databse_id, + ddl_statements=DDL_STATEMENTS, + pool=pool, ) op = database.create() op.result(database_operation_timeout) # raises on failure / timeout. @@ -285,7 +287,8 @@ def test_execute_many(shared_instance, dbapi_database): conn.commit() cursor.executemany( - """SELECT * FROM contacts WHERE contact_id = %s""", ((1,), (2,)), + """SELECT * FROM contacts WHERE contact_id = %s""", + ((1,), (2,)), ) res = cursor.fetchall() conn.commit() diff --git a/tests/system/test_instance_api.py b/tests/system/test_instance_api.py index 8992174871..6825e50721 100644 --- a/tests/system/test_instance_api.py +++ b/tests/system/test_instance_api.py @@ -30,7 +30,10 @@ def instances_to_delete(): def test_list_instances( - no_create_instance, spanner_client, existing_instances, shared_instance, + no_create_instance, + spanner_client, + existing_instances, + shared_instance, ): instances = list(spanner_client.list_instances()) diff --git a/tests/system/test_session_api.py b/tests/system/test_session_api.py index 3fc523e46b..09c65970f3 100644 --- a/tests/system/test_session_api.py +++ b/tests/system/test_session_api.py @@ -53,7 +53,9 @@ "sample_array": [23, 76, 19], } ) -JSON_2 = JsonObject({"sample_object": {"name": "Anamika", "id": 2635}},) +JSON_2 = JsonObject( + {"sample_object": {"name": "Anamika", "id": 2635}}, +) COUNTERS_TABLE = "counters" COUNTERS_COLUMNS = ("name", "value") @@ -167,7 +169,9 @@ def sessions_database(shared_instance, database_operation_timeout): database_name = _helpers.unique_id("test_sessions", separator="_") pool = spanner_v1.BurstyPool(labels={"testcase": "session_api"}) sessions_database = shared_instance.database( - database_name, ddl_statements=_helpers.DDL_STATEMENTS, pool=pool, + database_name, + ddl_statements=_helpers.DDL_STATEMENTS, + pool=pool, ) operation = sessions_database.create() operation.result(database_operation_timeout) # raises on failure / timeout. @@ -426,7 +430,9 @@ def test_batch_insert_w_commit_timestamp(sessions_database): @_helpers.retry_mabye_aborted_txn def test_transaction_read_and_insert_then_rollback( - sessions_database, ot_exporter, sessions_to_delete, + sessions_database, + ot_exporter, + sessions_to_delete, ): sd = _sample_data db_name = sessions_database.name @@ -486,7 +492,9 @@ def test_transaction_read_and_insert_then_rollback( ot_exporter, "CloudSpanner.ReadOnlyTransaction", attributes=_make_attributes( - db_name, table_id=sd.TABLE, columns=sd.COLUMNS, + db_name, + table_id=sd.TABLE, + columns=sd.COLUMNS, ), span=span_list[4], ) @@ -494,7 +502,9 @@ def test_transaction_read_and_insert_then_rollback( ot_exporter, "CloudSpanner.ReadOnlyTransaction", attributes=_make_attributes( - db_name, table_id=sd.TABLE, columns=sd.COLUMNS, + db_name, + table_id=sd.TABLE, + columns=sd.COLUMNS, ), span=span_list[5], ) @@ -508,7 +518,9 @@ def test_transaction_read_and_insert_then_rollback( ot_exporter, "CloudSpanner.ReadOnlyTransaction", attributes=_make_attributes( - db_name, table_id=sd.TABLE, columns=sd.COLUMNS, + db_name, + table_id=sd.TABLE, + columns=sd.COLUMNS, ), span=span_list[7], ) @@ -543,7 +555,8 @@ def _transaction_read_then_raise(transaction): @_helpers.retry_mabye_conflict def test_transaction_read_and_insert_or_update_then_commit( - sessions_database, sessions_to_delete, + sessions_database, + sessions_to_delete, ): # [START spanner_test_dml_read_your_writes] sd = _sample_data @@ -581,7 +594,8 @@ def _generate_insert_statements(): @_helpers.retry_mabye_conflict def test_transaction_execute_sql_w_dml_read_rollback( - sessions_database, sessions_to_delete, + sessions_database, + sessions_to_delete, ): # [START spanner_test_dml_rollback_txn_not_committed] sd = _sample_data @@ -723,7 +737,8 @@ def unit_of_work(transaction): def test_transaction_batch_update_and_execute_dml( - sessions_database, sessions_to_delete, + sessions_database, + sessions_to_delete, ): sd = _sample_data param_types = spanner_v1.param_types @@ -819,10 +834,13 @@ def test_transaction_batch_update_wo_statements(sessions_database, sessions_to_d @pytest.mark.skipif( - not ot_helpers.HAS_OPENTELEMETRY_INSTALLED, reason="trace requires OpenTelemetry", + not ot_helpers.HAS_OPENTELEMETRY_INSTALLED, + reason="trace requires OpenTelemetry", ) def test_transaction_batch_update_w_parent_span( - sessions_database, sessions_to_delete, ot_exporter, + sessions_database, + sessions_to_delete, + ot_exporter, ): from opentelemetry import trace @@ -1093,7 +1111,10 @@ def test_read_with_multiple_keys_index(sessions_database): with sessions_database.snapshot() as snapshot: rows = list( snapshot.read( - sd.TABLE, columns, spanner_v1.KeySet(keys=expected), index="name", + sd.TABLE, + columns, + spanner_v1.KeySet(keys=expected), + index="name", ) ) assert rows == expected @@ -1291,7 +1312,8 @@ def test_read_w_ranges(sessions_database): end = 2000 committed = _set_up_table(sessions_database, row_count) with sessions_database.snapshot( - read_timestamp=committed, multi_use=True, + read_timestamp=committed, + multi_use=True, ) as snapshot: all_data_rows = list(_row_data(row_count)) @@ -1332,7 +1354,8 @@ def test_read_partial_range_until_end(sessions_database): start = 1000 committed = _set_up_table(sessions_database, row_count) with sessions_database.snapshot( - read_timestamp=committed, multi_use=True, + read_timestamp=committed, + multi_use=True, ) as snapshot: all_data_rows = list(_row_data(row_count)) @@ -1376,7 +1399,8 @@ def test_read_partial_range_from_beginning(sessions_database): keyset = spanner_v1.KeySet(ranges=(spanner_v1.KeyRange(**range_kwargs),)) with sessions_database.snapshot( - read_timestamp=committed, multi_use=True, + read_timestamp=committed, + multi_use=True, ) as snapshot: rows = list(snapshot.read(sd.TABLE, sd.COLUMNS, keyset)) expected = expected_map[(start_arg, end_arg)] @@ -1623,7 +1647,13 @@ def test_execute_sql_w_manual_consume(sessions_database): def _check_sql_results( - database, sql, params, param_types, expected, order=True, recurse_into_lists=True, + database, + sql, + params, + param_types, + expected, + order=True, + recurse_into_lists=True, ): if order and "ORDER" not in sql: sql += " ORDER BY pkey" @@ -1886,7 +1916,10 @@ def test_execute_sql_w_numeric_bindings(not_emulator, sessions_database): def test_execute_sql_w_json_bindings(not_emulator, sessions_database): _bind_test_helper( - sessions_database, spanner_v1.TypeCode.JSON, JSON_1, [JSON_1, JSON_2], + sessions_database, + spanner_v1.TypeCode.JSON, + JSON_1, + [JSON_1, JSON_2], ) diff --git a/tests/system/utils/streaming_utils.py b/tests/system/utils/streaming_utils.py index a39637bf0f..174ddae557 100644 --- a/tests/system/utils/streaming_utils.py +++ b/tests/system/utils/streaming_utils.py @@ -26,7 +26,7 @@ class _TableDesc( ) ): def value(self): - return u"X" * self.value_size + return "X" * self.value_size FOUR_KAY = _TableDesc("four_kay", 1000, 4096, 1) diff --git a/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py b/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py index 71fb398101..4052f1a787 100644 --- a/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py +++ b/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py @@ -106,7 +106,11 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", [DatabaseAdminClient, DatabaseAdminAsyncClient,] + "client_class", + [ + DatabaseAdminClient, + DatabaseAdminAsyncClient, + ], ) def test_database_admin_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() @@ -148,7 +152,11 @@ def test_database_admin_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", [DatabaseAdminClient, DatabaseAdminAsyncClient,] + "client_class", + [ + DatabaseAdminClient, + DatabaseAdminAsyncClient, + ], ) def test_database_admin_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() @@ -512,7 +520,9 @@ def test_database_admin_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -656,11 +666,16 @@ def test_database_admin_client_create_channel_credentials_file( @pytest.mark.parametrize( - "request_type", [spanner_database_admin.ListDatabasesRequest, dict,] + "request_type", + [ + spanner_database_admin.ListDatabasesRequest, + dict, + ], ) def test_list_databases(request_type, transport: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -689,7 +704,8 @@ def test_list_databases_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -706,7 +722,8 @@ async def test_list_databases_async( request_type=spanner_database_admin.ListDatabasesRequest, ): client = DatabaseAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -739,7 +756,9 @@ async def test_list_databases_async_from_dict(): def test_list_databases_field_headers(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -759,7 +778,10 @@ def test_list_databases_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -788,11 +810,16 @@ async def test_list_databases_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_list_databases_flattened(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_databases), "__call__") as call: @@ -800,7 +827,9 @@ def test_list_databases_flattened(): call.return_value = spanner_database_admin.ListDatabasesResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_databases(parent="parent_value",) + client.list_databases( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -812,13 +841,16 @@ def test_list_databases_flattened(): def test_list_databases_flattened_error(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + 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_databases( - spanner_database_admin.ListDatabasesRequest(), parent="parent_value", + spanner_database_admin.ListDatabasesRequest(), + parent="parent_value", ) @@ -838,7 +870,9 @@ async def test_list_databases_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_databases(parent="parent_value",) + response = await client.list_databases( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -859,13 +893,15 @@ async def test_list_databases_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.list_databases( - spanner_database_admin.ListDatabasesRequest(), parent="parent_value", + spanner_database_admin.ListDatabasesRequest(), + parent="parent_value", ) def test_list_databases_pager(transport_name: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -881,10 +917,14 @@ def test_list_databases_pager(transport_name: str = "grpc"): next_page_token="abc", ), spanner_database_admin.ListDatabasesResponse( - databases=[], next_page_token="def", + databases=[], + next_page_token="def", ), spanner_database_admin.ListDatabasesResponse( - databases=[spanner_database_admin.Database(),], next_page_token="ghi", + databases=[ + spanner_database_admin.Database(), + ], + next_page_token="ghi", ), spanner_database_admin.ListDatabasesResponse( databases=[ @@ -910,7 +950,8 @@ def test_list_databases_pager(transport_name: str = "grpc"): def test_list_databases_pages(transport_name: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -926,10 +967,14 @@ def test_list_databases_pages(transport_name: str = "grpc"): next_page_token="abc", ), spanner_database_admin.ListDatabasesResponse( - databases=[], next_page_token="def", + databases=[], + next_page_token="def", ), spanner_database_admin.ListDatabasesResponse( - databases=[spanner_database_admin.Database(),], next_page_token="ghi", + databases=[ + spanner_database_admin.Database(), + ], + next_page_token="ghi", ), spanner_database_admin.ListDatabasesResponse( databases=[ @@ -946,7 +991,9 @@ def test_list_databases_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_databases_async_pager(): - client = DatabaseAdminAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = DatabaseAdminAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -963,10 +1010,14 @@ async def test_list_databases_async_pager(): next_page_token="abc", ), spanner_database_admin.ListDatabasesResponse( - databases=[], next_page_token="def", + databases=[], + next_page_token="def", ), spanner_database_admin.ListDatabasesResponse( - databases=[spanner_database_admin.Database(),], next_page_token="ghi", + databases=[ + spanner_database_admin.Database(), + ], + next_page_token="ghi", ), spanner_database_admin.ListDatabasesResponse( databases=[ @@ -976,7 +1027,9 @@ async def test_list_databases_async_pager(): ), RuntimeError, ) - async_pager = await client.list_databases(request={},) + async_pager = await client.list_databases( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -988,7 +1041,9 @@ async def test_list_databases_async_pager(): @pytest.mark.asyncio async def test_list_databases_async_pages(): - client = DatabaseAdminAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = DatabaseAdminAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1005,10 +1060,14 @@ async def test_list_databases_async_pages(): next_page_token="abc", ), spanner_database_admin.ListDatabasesResponse( - databases=[], next_page_token="def", + databases=[], + next_page_token="def", ), spanner_database_admin.ListDatabasesResponse( - databases=[spanner_database_admin.Database(),], next_page_token="ghi", + databases=[ + spanner_database_admin.Database(), + ], + next_page_token="ghi", ), spanner_database_admin.ListDatabasesResponse( databases=[ @@ -1026,11 +1085,16 @@ async def test_list_databases_async_pages(): @pytest.mark.parametrize( - "request_type", [spanner_database_admin.CreateDatabaseRequest, dict,] + "request_type", + [ + spanner_database_admin.CreateDatabaseRequest, + dict, + ], ) def test_create_database(request_type, transport: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1056,7 +1120,8 @@ def test_create_database_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1073,7 +1138,8 @@ async def test_create_database_async( request_type=spanner_database_admin.CreateDatabaseRequest, ): client = DatabaseAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1103,7 +1169,9 @@ async def test_create_database_async_from_dict(): def test_create_database_field_headers(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1123,7 +1191,10 @@ def test_create_database_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1152,11 +1223,16 @@ async def test_create_database_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_create_database_flattened(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_database), "__call__") as call: @@ -1165,7 +1241,8 @@ def test_create_database_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_database( - parent="parent_value", create_statement="create_statement_value", + parent="parent_value", + create_statement="create_statement_value", ) # Establish that the underlying call was made with the expected @@ -1181,7 +1258,9 @@ def test_create_database_flattened(): def test_create_database_flattened_error(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1210,7 +1289,8 @@ async def test_create_database_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_database( - parent="parent_value", create_statement="create_statement_value", + parent="parent_value", + create_statement="create_statement_value", ) # Establish that the underlying call was made with the expected @@ -1242,11 +1322,16 @@ async def test_create_database_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [spanner_database_admin.GetDatabaseRequest, dict,] + "request_type", + [ + spanner_database_admin.GetDatabaseRequest, + dict, + ], ) def test_get_database(request_type, transport: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1283,7 +1368,8 @@ def test_get_database_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1300,7 +1386,8 @@ async def test_get_database_async( request_type=spanner_database_admin.GetDatabaseRequest, ): client = DatabaseAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1341,7 +1428,9 @@ async def test_get_database_async_from_dict(): def test_get_database_field_headers(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1361,7 +1450,10 @@ def test_get_database_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1390,11 +1482,16 @@ async def test_get_database_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_get_database_flattened(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_database), "__call__") as call: @@ -1402,7 +1499,9 @@ def test_get_database_flattened(): call.return_value = spanner_database_admin.Database() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_database(name="name_value",) + client.get_database( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1414,13 +1513,16 @@ def test_get_database_flattened(): def test_get_database_flattened_error(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + 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_database( - spanner_database_admin.GetDatabaseRequest(), name="name_value", + spanner_database_admin.GetDatabaseRequest(), + name="name_value", ) @@ -1440,7 +1542,9 @@ async def test_get_database_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_database(name="name_value",) + response = await client.get_database( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1461,16 +1565,22 @@ async def test_get_database_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_database( - spanner_database_admin.GetDatabaseRequest(), name="name_value", + spanner_database_admin.GetDatabaseRequest(), + name="name_value", ) @pytest.mark.parametrize( - "request_type", [spanner_database_admin.UpdateDatabaseDdlRequest, dict,] + "request_type", + [ + spanner_database_admin.UpdateDatabaseDdlRequest, + dict, + ], ) def test_update_database_ddl(request_type, transport: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1498,7 +1608,8 @@ def test_update_database_ddl_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1517,7 +1628,8 @@ async def test_update_database_ddl_async( request_type=spanner_database_admin.UpdateDatabaseDdlRequest, ): client = DatabaseAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1549,7 +1661,9 @@ async def test_update_database_ddl_async_from_dict(): def test_update_database_ddl_field_headers(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1571,7 +1685,10 @@ def test_update_database_ddl_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1602,11 +1719,16 @@ async def test_update_database_ddl_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] def test_update_database_ddl_flattened(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1617,7 +1739,8 @@ def test_update_database_ddl_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_database_ddl( - database="database_value", statements=["statements_value"], + database="database_value", + statements=["statements_value"], ) # Establish that the underlying call was made with the expected @@ -1633,7 +1756,9 @@ def test_update_database_ddl_flattened(): def test_update_database_ddl_flattened_error(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1664,7 +1789,8 @@ async def test_update_database_ddl_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.update_database_ddl( - database="database_value", statements=["statements_value"], + database="database_value", + statements=["statements_value"], ) # Establish that the underlying call was made with the expected @@ -1696,11 +1822,16 @@ async def test_update_database_ddl_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [spanner_database_admin.DropDatabaseRequest, dict,] + "request_type", + [ + spanner_database_admin.DropDatabaseRequest, + dict, + ], ) def test_drop_database(request_type, transport: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1726,7 +1857,8 @@ def test_drop_database_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1743,7 +1875,8 @@ async def test_drop_database_async( request_type=spanner_database_admin.DropDatabaseRequest, ): client = DatabaseAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1771,7 +1904,9 @@ async def test_drop_database_async_from_dict(): def test_drop_database_field_headers(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1791,7 +1926,10 @@ def test_drop_database_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1818,11 +1956,16 @@ async def test_drop_database_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] def test_drop_database_flattened(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.drop_database), "__call__") as call: @@ -1830,7 +1973,9 @@ def test_drop_database_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.drop_database(database="database_value",) + client.drop_database( + database="database_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1842,13 +1987,16 @@ def test_drop_database_flattened(): def test_drop_database_flattened_error(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + 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.drop_database( - spanner_database_admin.DropDatabaseRequest(), database="database_value", + spanner_database_admin.DropDatabaseRequest(), + database="database_value", ) @@ -1866,7 +2014,9 @@ async def test_drop_database_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.drop_database(database="database_value",) + response = await client.drop_database( + database="database_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1887,16 +2037,22 @@ async def test_drop_database_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.drop_database( - spanner_database_admin.DropDatabaseRequest(), database="database_value", + spanner_database_admin.DropDatabaseRequest(), + database="database_value", ) @pytest.mark.parametrize( - "request_type", [spanner_database_admin.GetDatabaseDdlRequest, dict,] + "request_type", + [ + spanner_database_admin.GetDatabaseDdlRequest, + dict, + ], ) def test_get_database_ddl(request_type, transport: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1925,7 +2081,8 @@ def test_get_database_ddl_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1942,7 +2099,8 @@ async def test_get_database_ddl_async( request_type=spanner_database_admin.GetDatabaseDdlRequest, ): client = DatabaseAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1975,7 +2133,9 @@ async def test_get_database_ddl_async_from_dict(): def test_get_database_ddl_field_headers(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1995,7 +2155,10 @@ def test_get_database_ddl_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2024,11 +2187,16 @@ async def test_get_database_ddl_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] def test_get_database_ddl_flattened(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_database_ddl), "__call__") as call: @@ -2036,7 +2204,9 @@ def test_get_database_ddl_flattened(): call.return_value = spanner_database_admin.GetDatabaseDdlResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_database_ddl(database="database_value",) + client.get_database_ddl( + database="database_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2048,13 +2218,16 @@ def test_get_database_ddl_flattened(): def test_get_database_ddl_flattened_error(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + 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_database_ddl( - spanner_database_admin.GetDatabaseDdlRequest(), database="database_value", + spanner_database_admin.GetDatabaseDdlRequest(), + database="database_value", ) @@ -2074,7 +2247,9 @@ async def test_get_database_ddl_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_database_ddl(database="database_value",) + response = await client.get_database_ddl( + database="database_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2095,14 +2270,22 @@ async def test_get_database_ddl_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_database_ddl( - spanner_database_admin.GetDatabaseDdlRequest(), database="database_value", + spanner_database_admin.GetDatabaseDdlRequest(), + database="database_value", ) -@pytest.mark.parametrize("request_type", [iam_policy_pb2.SetIamPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.SetIamPolicyRequest, + dict, + ], +) def test_set_iam_policy(request_type, transport: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2112,7 +2295,10 @@ def test_set_iam_policy(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.set_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -2130,7 +2316,8 @@ def test_set_iam_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2146,7 +2333,8 @@ async def test_set_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy_pb2.SetIamPolicyRequest ): client = DatabaseAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2157,7 +2345,10 @@ async def test_set_iam_policy_async( with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.set_iam_policy(request) @@ -2178,7 +2369,9 @@ async def test_set_iam_policy_async_from_dict(): def test_set_iam_policy_field_headers(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2198,7 +2391,10 @@ def test_set_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2225,11 +2421,16 @@ async def test_set_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_set_iam_policy_from_dict_foreign(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -2244,7 +2445,9 @@ def test_set_iam_policy_from_dict_foreign(): def test_set_iam_policy_flattened(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -2252,7 +2455,9 @@ def test_set_iam_policy_flattened(): call.return_value = policy_pb2.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.set_iam_policy(resource="resource_value",) + client.set_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2264,13 +2469,16 @@ def test_set_iam_policy_flattened(): def test_set_iam_policy_flattened_error(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.set_iam_policy( - iam_policy_pb2.SetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.SetIamPolicyRequest(), + resource="resource_value", ) @@ -2288,7 +2496,9 @@ async def test_set_iam_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.set_iam_policy(resource="resource_value",) + response = await client.set_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2309,14 +2519,22 @@ async def test_set_iam_policy_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.set_iam_policy( - iam_policy_pb2.SetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.SetIamPolicyRequest(), + resource="resource_value", ) -@pytest.mark.parametrize("request_type", [iam_policy_pb2.GetIamPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.GetIamPolicyRequest, + dict, + ], +) def test_get_iam_policy(request_type, transport: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2326,7 +2544,10 @@ def test_get_iam_policy(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.get_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -2344,7 +2565,8 @@ def test_get_iam_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2360,7 +2582,8 @@ async def test_get_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy_pb2.GetIamPolicyRequest ): client = DatabaseAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2371,7 +2594,10 @@ async def test_get_iam_policy_async( with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.get_iam_policy(request) @@ -2392,7 +2618,9 @@ async def test_get_iam_policy_async_from_dict(): def test_get_iam_policy_field_headers(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2412,7 +2640,10 @@ def test_get_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2439,11 +2670,16 @@ async def test_get_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_get_iam_policy_from_dict_foreign(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -2458,7 +2694,9 @@ def test_get_iam_policy_from_dict_foreign(): def test_get_iam_policy_flattened(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2466,7 +2704,9 @@ def test_get_iam_policy_flattened(): call.return_value = policy_pb2.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_iam_policy(resource="resource_value",) + client.get_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2478,13 +2718,16 @@ def test_get_iam_policy_flattened(): def test_get_iam_policy_flattened_error(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_iam_policy( - iam_policy_pb2.GetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.GetIamPolicyRequest(), + resource="resource_value", ) @@ -2502,7 +2745,9 @@ async def test_get_iam_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_iam_policy(resource="resource_value",) + response = await client.get_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2523,16 +2768,22 @@ async def test_get_iam_policy_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_iam_policy( - iam_policy_pb2.GetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.GetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.parametrize( - "request_type", [iam_policy_pb2.TestIamPermissionsRequest, dict,] + "request_type", + [ + iam_policy_pb2.TestIamPermissionsRequest, + dict, + ], ) def test_test_iam_permissions(request_type, transport: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2563,7 +2814,8 @@ def test_test_iam_permissions_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2582,7 +2834,8 @@ async def test_test_iam_permissions_async( request_type=iam_policy_pb2.TestIamPermissionsRequest, ): client = DatabaseAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2617,7 +2870,9 @@ async def test_test_iam_permissions_async_from_dict(): def test_test_iam_permissions_field_headers(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2639,7 +2894,10 @@ def test_test_iam_permissions_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2670,11 +2928,16 @@ async def test_test_iam_permissions_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_test_iam_permissions_from_dict_foreign(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.test_iam_permissions), "__call__" @@ -2691,7 +2954,9 @@ def test_test_iam_permissions_from_dict_foreign(): def test_test_iam_permissions_flattened(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2702,7 +2967,8 @@ def test_test_iam_permissions_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.test_iam_permissions( - resource="resource_value", permissions=["permissions_value"], + resource="resource_value", + permissions=["permissions_value"], ) # Establish that the underlying call was made with the expected @@ -2718,7 +2984,9 @@ def test_test_iam_permissions_flattened(): def test_test_iam_permissions_flattened_error(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2749,7 +3017,8 @@ async def test_test_iam_permissions_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.test_iam_permissions( - resource="resource_value", permissions=["permissions_value"], + resource="resource_value", + permissions=["permissions_value"], ) # Establish that the underlying call was made with the expected @@ -2780,10 +3049,17 @@ async def test_test_iam_permissions_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [gsad_backup.CreateBackupRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + gsad_backup.CreateBackupRequest, + dict, + ], +) def test_create_backup(request_type, transport: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2809,7 +3085,8 @@ def test_create_backup_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2825,7 +3102,8 @@ async def test_create_backup_async( transport: str = "grpc_asyncio", request_type=gsad_backup.CreateBackupRequest ): client = DatabaseAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2855,7 +3133,9 @@ async def test_create_backup_async_from_dict(): def test_create_backup_field_headers(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2875,7 +3155,10 @@ def test_create_backup_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2904,11 +3187,16 @@ async def test_create_backup_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_create_backup_flattened(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + 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: @@ -2938,7 +3226,9 @@ def test_create_backup_flattened(): def test_create_backup_flattened_error(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3005,10 +3295,17 @@ async def test_create_backup_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [backup.CopyBackupRequest, dict,]) -def test_copy_backup(request_type, transport: str = "grpc"): +@pytest.mark.parametrize( + "request_type", + [ + backup.CopyBackupRequest, + dict, + ], +) +def test_copy_backup(request_type, transport: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3034,7 +3331,8 @@ def test_copy_backup_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3050,7 +3348,8 @@ async def test_copy_backup_async( transport: str = "grpc_asyncio", request_type=backup.CopyBackupRequest ): client = DatabaseAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3080,7 +3379,9 @@ async def test_copy_backup_async_from_dict(): def test_copy_backup_field_headers(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3100,7 +3401,10 @@ def test_copy_backup_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -3129,11 +3433,16 @@ async def test_copy_backup_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_copy_backup_flattened(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.copy_backup), "__call__") as call: @@ -3167,7 +3476,9 @@ def test_copy_backup_flattened(): def test_copy_backup_flattened_error(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3240,10 +3551,17 @@ async def test_copy_backup_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [backup.GetBackupRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + backup.GetBackupRequest, + dict, + ], +) def test_get_backup(request_type, transport: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3284,7 +3602,8 @@ def test_get_backup_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3300,7 +3619,8 @@ async def test_get_backup_async( transport: str = "grpc_asyncio", request_type=backup.GetBackupRequest ): client = DatabaseAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3345,7 +3665,9 @@ async def test_get_backup_async_from_dict(): def test_get_backup_field_headers(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3365,7 +3687,10 @@ def test_get_backup_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -3392,11 +3717,16 @@ async def test_get_backup_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_get_backup_flattened(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + 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: @@ -3404,7 +3734,9 @@ def test_get_backup_flattened(): 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",) + client.get_backup( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3416,13 +3748,16 @@ def test_get_backup_flattened(): def test_get_backup_flattened_error(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + 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", + backup.GetBackupRequest(), + name="name_value", ) @@ -3440,7 +3775,9 @@ async def test_get_backup_flattened_async(): 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",) + response = await client.get_backup( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3461,14 +3798,22 @@ async def test_get_backup_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_backup( - backup.GetBackupRequest(), name="name_value", + backup.GetBackupRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [gsad_backup.UpdateBackupRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + gsad_backup.UpdateBackupRequest, + dict, + ], +) def test_update_backup(request_type, transport: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3509,7 +3854,8 @@ def test_update_backup_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3525,7 +3871,8 @@ async def test_update_backup_async( transport: str = "grpc_asyncio", request_type=gsad_backup.UpdateBackupRequest ): client = DatabaseAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3570,7 +3917,9 @@ async def test_update_backup_async_from_dict(): def test_update_backup_field_headers(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3590,7 +3939,10 @@ def test_update_backup_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "backup.name=backup.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "backup.name=backup.name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -3617,11 +3969,16 @@ async def test_update_backup_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "backup.name=backup.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "backup.name=backup.name/value", + ) in kw["metadata"] def test_update_backup_flattened(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + 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: @@ -3647,7 +4004,9 @@ def test_update_backup_flattened(): def test_update_backup_flattened_error(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3706,10 +4065,17 @@ async def test_update_backup_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [backup.DeleteBackupRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + backup.DeleteBackupRequest, + dict, + ], +) def test_delete_backup(request_type, transport: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3735,7 +4101,8 @@ def test_delete_backup_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3751,7 +4118,8 @@ async def test_delete_backup_async( transport: str = "grpc_asyncio", request_type=backup.DeleteBackupRequest ): client = DatabaseAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3779,7 +4147,9 @@ async def test_delete_backup_async_from_dict(): def test_delete_backup_field_headers(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3799,7 +4169,10 @@ def test_delete_backup_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -3826,11 +4199,16 @@ async def test_delete_backup_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_delete_backup_flattened(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + 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: @@ -3838,7 +4216,9 @@ def test_delete_backup_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_backup(name="name_value",) + client.delete_backup( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3850,13 +4230,16 @@ def test_delete_backup_flattened(): def test_delete_backup_flattened_error(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + 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", + backup.DeleteBackupRequest(), + name="name_value", ) @@ -3874,7 +4257,9 @@ async def test_delete_backup_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_backup(name="name_value",) + response = await client.delete_backup( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3895,14 +4280,22 @@ async def test_delete_backup_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.delete_backup( - backup.DeleteBackupRequest(), name="name_value", + backup.DeleteBackupRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [backup.ListBackupsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + backup.ListBackupsRequest, + dict, + ], +) def test_list_backups(request_type, transport: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3931,7 +4324,8 @@ def test_list_backups_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3947,7 +4341,8 @@ async def test_list_backups_async( transport: str = "grpc_asyncio", request_type=backup.ListBackupsRequest ): client = DatabaseAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3958,7 +4353,9 @@ async def test_list_backups_async( 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",) + backup.ListBackupsResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_backups(request) @@ -3978,7 +4375,9 @@ async def test_list_backups_async_from_dict(): def test_list_backups_field_headers(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3998,7 +4397,10 @@ def test_list_backups_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -4027,11 +4429,16 @@ async def test_list_backups_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_list_backups_flattened(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + 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: @@ -4039,7 +4446,9 @@ def test_list_backups_flattened(): 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",) + client.list_backups( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -4051,13 +4460,16 @@ def test_list_backups_flattened(): def test_list_backups_flattened_error(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + 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", + backup.ListBackupsRequest(), + parent="parent_value", ) @@ -4077,7 +4489,9 @@ async def test_list_backups_flattened_async(): ) # 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",) + response = await client.list_backups( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -4098,13 +4512,15 @@ async def test_list_backups_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.list_backups( - backup.ListBackupsRequest(), parent="parent_value", + backup.ListBackupsRequest(), + parent="parent_value", ) def test_list_backups_pager(transport_name: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4112,14 +4528,29 @@ def test_list_backups_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( backup.ListBackupsResponse( - backups=[backup.Backup(), backup.Backup(), backup.Backup(),], + 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", + backups=[], + next_page_token="def", + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + ], + next_page_token="ghi", + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + backup.Backup(), + ], ), - backup.ListBackupsResponse(backups=[backup.Backup(), backup.Backup(),],), RuntimeError, ) @@ -4138,7 +4569,8 @@ def test_list_backups_pager(transport_name: str = "grpc"): def test_list_backups_pages(transport_name: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4146,14 +4578,29 @@ def test_list_backups_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( backup.ListBackupsResponse( - backups=[backup.Backup(), backup.Backup(), backup.Backup(),], + 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", + backups=[], + next_page_token="def", + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + ], + next_page_token="ghi", + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + backup.Backup(), + ], ), - backup.ListBackupsResponse(backups=[backup.Backup(), backup.Backup(),],), RuntimeError, ) pages = list(client.list_backups(request={}).pages) @@ -4163,7 +4610,9 @@ def test_list_backups_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_backups_async_pager(): - client = DatabaseAdminAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = DatabaseAdminAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4172,17 +4621,34 @@ async def test_list_backups_async_pager(): # Set the response to a series of pages. call.side_effect = ( backup.ListBackupsResponse( - backups=[backup.Backup(), backup.Backup(), backup.Backup(),], + 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", + backups=[], + next_page_token="def", + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + ], + next_page_token="ghi", + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + backup.Backup(), + ], ), - backup.ListBackupsResponse(backups=[backup.Backup(), backup.Backup(),],), RuntimeError, ) - async_pager = await client.list_backups(request={},) + async_pager = await client.list_backups( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -4194,7 +4660,9 @@ async def test_list_backups_async_pager(): @pytest.mark.asyncio async def test_list_backups_async_pages(): - client = DatabaseAdminAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = DatabaseAdminAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4203,14 +4671,29 @@ async def test_list_backups_async_pages(): # Set the response to a series of pages. call.side_effect = ( backup.ListBackupsResponse( - backups=[backup.Backup(), backup.Backup(), backup.Backup(),], + 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", + backups=[], + next_page_token="def", + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + ], + next_page_token="ghi", + ), + backup.ListBackupsResponse( + backups=[ + backup.Backup(), + backup.Backup(), + ], ), - backup.ListBackupsResponse(backups=[backup.Backup(), backup.Backup(),],), RuntimeError, ) pages = [] @@ -4221,11 +4704,16 @@ async def test_list_backups_async_pages(): @pytest.mark.parametrize( - "request_type", [spanner_database_admin.RestoreDatabaseRequest, dict,] + "request_type", + [ + spanner_database_admin.RestoreDatabaseRequest, + dict, + ], ) def test_restore_database(request_type, transport: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4251,7 +4739,8 @@ def test_restore_database_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4268,7 +4757,8 @@ async def test_restore_database_async( request_type=spanner_database_admin.RestoreDatabaseRequest, ): client = DatabaseAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4298,7 +4788,9 @@ async def test_restore_database_async_from_dict(): def test_restore_database_field_headers(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -4318,7 +4810,10 @@ def test_restore_database_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -4347,11 +4842,16 @@ async def test_restore_database_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_restore_database_flattened(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.restore_database), "__call__") as call: @@ -4379,7 +4879,9 @@ def test_restore_database_flattened(): def test_restore_database_flattened_error(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4445,11 +4947,16 @@ async def test_restore_database_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [spanner_database_admin.ListDatabaseOperationsRequest, dict,] + "request_type", + [ + spanner_database_admin.ListDatabaseOperationsRequest, + dict, + ], ) def test_list_database_operations(request_type, transport: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4480,7 +4987,8 @@ def test_list_database_operations_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4499,7 +5007,8 @@ async def test_list_database_operations_async( request_type=spanner_database_admin.ListDatabaseOperationsRequest, ): client = DatabaseAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4534,7 +5043,9 @@ async def test_list_database_operations_async_from_dict(): def test_list_database_operations_field_headers(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -4556,7 +5067,10 @@ def test_list_database_operations_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -4587,11 +5101,16 @@ async def test_list_database_operations_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_list_database_operations_flattened(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4601,7 +5120,9 @@ def test_list_database_operations_flattened(): call.return_value = spanner_database_admin.ListDatabaseOperationsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_database_operations(parent="parent_value",) + client.list_database_operations( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -4613,7 +5134,9 @@ def test_list_database_operations_flattened(): def test_list_database_operations_flattened_error(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4642,7 +5165,9 @@ async def test_list_database_operations_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_database_operations(parent="parent_value",) + response = await client.list_database_operations( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -4670,7 +5195,8 @@ async def test_list_database_operations_flattened_error_async(): def test_list_database_operations_pager(transport_name: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4688,13 +5214,20 @@ def test_list_database_operations_pager(transport_name: str = "grpc"): next_page_token="abc", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[], next_page_token="def", + operations=[], + next_page_token="def", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[operations_pb2.Operation(),], next_page_token="ghi", + operations=[ + operations_pb2.Operation(), + ], + next_page_token="ghi", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[operations_pb2.Operation(), operations_pb2.Operation(),], + operations=[ + operations_pb2.Operation(), + operations_pb2.Operation(), + ], ), RuntimeError, ) @@ -4714,7 +5247,8 @@ def test_list_database_operations_pager(transport_name: str = "grpc"): def test_list_database_operations_pages(transport_name: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4732,13 +5266,20 @@ def test_list_database_operations_pages(transport_name: str = "grpc"): next_page_token="abc", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[], next_page_token="def", + operations=[], + next_page_token="def", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[operations_pb2.Operation(),], next_page_token="ghi", + operations=[ + operations_pb2.Operation(), + ], + next_page_token="ghi", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[operations_pb2.Operation(), operations_pb2.Operation(),], + operations=[ + operations_pb2.Operation(), + operations_pb2.Operation(), + ], ), RuntimeError, ) @@ -4749,7 +5290,9 @@ def test_list_database_operations_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_database_operations_async_pager(): - client = DatabaseAdminAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = DatabaseAdminAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4768,17 +5311,26 @@ async def test_list_database_operations_async_pager(): next_page_token="abc", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[], next_page_token="def", + operations=[], + next_page_token="def", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[operations_pb2.Operation(),], next_page_token="ghi", + operations=[ + operations_pb2.Operation(), + ], + next_page_token="ghi", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[operations_pb2.Operation(), operations_pb2.Operation(),], + operations=[ + operations_pb2.Operation(), + operations_pb2.Operation(), + ], ), RuntimeError, ) - async_pager = await client.list_database_operations(request={},) + async_pager = await client.list_database_operations( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -4790,7 +5342,9 @@ async def test_list_database_operations_async_pager(): @pytest.mark.asyncio async def test_list_database_operations_async_pages(): - client = DatabaseAdminAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = DatabaseAdminAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4809,13 +5363,20 @@ async def test_list_database_operations_async_pages(): next_page_token="abc", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[], next_page_token="def", + operations=[], + next_page_token="def", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[operations_pb2.Operation(),], next_page_token="ghi", + operations=[ + operations_pb2.Operation(), + ], + next_page_token="ghi", ), spanner_database_admin.ListDatabaseOperationsResponse( - operations=[operations_pb2.Operation(), operations_pb2.Operation(),], + operations=[ + operations_pb2.Operation(), + operations_pb2.Operation(), + ], ), RuntimeError, ) @@ -4826,10 +5387,17 @@ async def test_list_database_operations_async_pages(): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [backup.ListBackupOperationsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + backup.ListBackupOperationsRequest, + dict, + ], +) def test_list_backup_operations(request_type, transport: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4860,7 +5428,8 @@ def test_list_backup_operations_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4878,7 +5447,8 @@ async def test_list_backup_operations_async( transport: str = "grpc_asyncio", request_type=backup.ListBackupOperationsRequest ): client = DatabaseAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4913,7 +5483,9 @@ async def test_list_backup_operations_async_from_dict(): def test_list_backup_operations_field_headers(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -4935,7 +5507,10 @@ def test_list_backup_operations_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -4966,11 +5541,16 @@ async def test_list_backup_operations_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_list_backup_operations_flattened(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4980,7 +5560,9 @@ def test_list_backup_operations_flattened(): call.return_value = backup.ListBackupOperationsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_backup_operations(parent="parent_value",) + client.list_backup_operations( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -4992,13 +5574,16 @@ def test_list_backup_operations_flattened(): def test_list_backup_operations_flattened_error(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = DatabaseAdminClient( + 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_operations( - backup.ListBackupOperationsRequest(), parent="parent_value", + backup.ListBackupOperationsRequest(), + parent="parent_value", ) @@ -5020,7 +5605,9 @@ async def test_list_backup_operations_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_backup_operations(parent="parent_value",) + response = await client.list_backup_operations( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -5041,13 +5628,15 @@ async def test_list_backup_operations_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.list_backup_operations( - backup.ListBackupOperationsRequest(), parent="parent_value", + backup.ListBackupOperationsRequest(), + parent="parent_value", ) def test_list_backup_operations_pager(transport_name: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5064,12 +5653,21 @@ def test_list_backup_operations_pager(transport_name: str = "grpc"): ], next_page_token="abc", ), - backup.ListBackupOperationsResponse(operations=[], next_page_token="def",), backup.ListBackupOperationsResponse( - operations=[operations_pb2.Operation(),], next_page_token="ghi", + operations=[], + next_page_token="def", + ), + backup.ListBackupOperationsResponse( + operations=[ + operations_pb2.Operation(), + ], + next_page_token="ghi", ), backup.ListBackupOperationsResponse( - operations=[operations_pb2.Operation(), operations_pb2.Operation(),], + operations=[ + operations_pb2.Operation(), + operations_pb2.Operation(), + ], ), RuntimeError, ) @@ -5089,7 +5687,8 @@ def test_list_backup_operations_pager(transport_name: str = "grpc"): def test_list_backup_operations_pages(transport_name: str = "grpc"): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5106,12 +5705,21 @@ def test_list_backup_operations_pages(transport_name: str = "grpc"): ], next_page_token="abc", ), - backup.ListBackupOperationsResponse(operations=[], next_page_token="def",), backup.ListBackupOperationsResponse( - operations=[operations_pb2.Operation(),], next_page_token="ghi", + operations=[], + next_page_token="def", + ), + backup.ListBackupOperationsResponse( + operations=[ + operations_pb2.Operation(), + ], + next_page_token="ghi", ), backup.ListBackupOperationsResponse( - operations=[operations_pb2.Operation(), operations_pb2.Operation(),], + operations=[ + operations_pb2.Operation(), + operations_pb2.Operation(), + ], ), RuntimeError, ) @@ -5122,7 +5730,9 @@ def test_list_backup_operations_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_backup_operations_async_pager(): - client = DatabaseAdminAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = DatabaseAdminAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5140,16 +5750,27 @@ async def test_list_backup_operations_async_pager(): ], next_page_token="abc", ), - backup.ListBackupOperationsResponse(operations=[], next_page_token="def",), backup.ListBackupOperationsResponse( - operations=[operations_pb2.Operation(),], next_page_token="ghi", + operations=[], + next_page_token="def", + ), + backup.ListBackupOperationsResponse( + operations=[ + operations_pb2.Operation(), + ], + next_page_token="ghi", ), backup.ListBackupOperationsResponse( - operations=[operations_pb2.Operation(), operations_pb2.Operation(),], + operations=[ + operations_pb2.Operation(), + operations_pb2.Operation(), + ], ), RuntimeError, ) - async_pager = await client.list_backup_operations(request={},) + async_pager = await client.list_backup_operations( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -5161,7 +5782,9 @@ async def test_list_backup_operations_async_pager(): @pytest.mark.asyncio async def test_list_backup_operations_async_pages(): - client = DatabaseAdminAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = DatabaseAdminAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5179,12 +5802,21 @@ async def test_list_backup_operations_async_pages(): ], next_page_token="abc", ), - backup.ListBackupOperationsResponse(operations=[], next_page_token="def",), backup.ListBackupOperationsResponse( - operations=[operations_pb2.Operation(),], next_page_token="ghi", + operations=[], + next_page_token="def", ), backup.ListBackupOperationsResponse( - operations=[operations_pb2.Operation(), operations_pb2.Operation(),], + operations=[ + operations_pb2.Operation(), + ], + next_page_token="ghi", + ), + backup.ListBackupOperationsResponse( + operations=[ + operations_pb2.Operation(), + operations_pb2.Operation(), + ], ), RuntimeError, ) @@ -5202,7 +5834,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -5222,7 +5855,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = DatabaseAdminClient(client_options=options, transport=transport,) + client = DatabaseAdminClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -5238,7 +5874,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = DatabaseAdminClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -5283,8 +5920,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.DatabaseAdminGrpcTransport,) + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.DatabaseAdminGrpcTransport, + ) def test_database_admin_base_transport_error(): @@ -5351,7 +5993,8 @@ def test_database_admin_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.DatabaseAdminTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -5521,7 +6164,8 @@ def test_database_admin_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.DatabaseAdminGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -5533,7 +6177,8 @@ def test_database_admin_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.DatabaseAdminGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -5640,12 +6285,16 @@ def test_database_admin_transport_channel_mtls_with_adc(transport_class): def test_database_admin_grpc_lro_client(): client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + 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,) + 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 @@ -5653,12 +6302,16 @@ def test_database_admin_grpc_lro_client(): def test_database_admin_grpc_lro_async_client(): client = DatabaseAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + 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,) + 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 @@ -5669,7 +6322,9 @@ def test_backup_path(): instance = "clam" backup = "whelk" expected = "projects/{project}/instances/{instance}/backups/{backup}".format( - project=project, instance=instance, backup=backup, + project=project, + instance=instance, + backup=backup, ) actual = DatabaseAdminClient.backup_path(project, instance, backup) assert expected == actual @@ -5694,7 +6349,10 @@ def test_crypto_key_path(): key_ring = "winkle" crypto_key = "nautilus" expected = "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format( - project=project, location=location, key_ring=key_ring, crypto_key=crypto_key, + project=project, + location=location, + key_ring=key_ring, + crypto_key=crypto_key, ) actual = DatabaseAdminClient.crypto_key_path( project, location, key_ring, crypto_key @@ -5755,7 +6413,9 @@ def test_database_path(): instance = "clam" database = "whelk" expected = "projects/{project}/instances/{instance}/databases/{database}".format( - project=project, instance=instance, database=database, + project=project, + instance=instance, + database=database, ) actual = DatabaseAdminClient.database_path(project, instance, database) assert expected == actual @@ -5778,7 +6438,8 @@ def test_instance_path(): project = "cuttlefish" instance = "mussel" expected = "projects/{project}/instances/{instance}".format( - project=project, instance=instance, + project=project, + instance=instance, ) actual = DatabaseAdminClient.instance_path(project, instance) assert expected == actual @@ -5818,7 +6479,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "squid" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = DatabaseAdminClient.common_folder_path(folder) assert expected == actual @@ -5836,7 +6499,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "whelk" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = DatabaseAdminClient.common_organization_path(organization) assert expected == actual @@ -5854,7 +6519,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "oyster" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = DatabaseAdminClient.common_project_path(project) assert expected == actual @@ -5874,7 +6541,8 @@ def test_common_location_path(): project = "cuttlefish" location = "mussel" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = DatabaseAdminClient.common_location_path(project, location) assert expected == actual @@ -5899,7 +6567,8 @@ def test_client_with_default_client_info(): transports.DatabaseAdminTransport, "_prep_wrapped_messages" ) as prep: client = DatabaseAdminClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -5908,7 +6577,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = DatabaseAdminClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -5916,7 +6586,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = DatabaseAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/spanner_admin_instance_v1/test_instance_admin.py b/tests/unit/gapic/spanner_admin_instance_v1/test_instance_admin.py index caef9d05d9..85309bd8ad 100644 --- a/tests/unit/gapic/spanner_admin_instance_v1/test_instance_admin.py +++ b/tests/unit/gapic/spanner_admin_instance_v1/test_instance_admin.py @@ -99,7 +99,11 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", [InstanceAdminClient, InstanceAdminAsyncClient,] + "client_class", + [ + InstanceAdminClient, + InstanceAdminAsyncClient, + ], ) def test_instance_admin_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() @@ -141,7 +145,11 @@ def test_instance_admin_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", [InstanceAdminClient, InstanceAdminAsyncClient,] + "client_class", + [ + InstanceAdminClient, + InstanceAdminAsyncClient, + ], ) def test_instance_admin_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() @@ -505,7 +513,9 @@ def test_instance_admin_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -649,11 +659,16 @@ def test_instance_admin_client_create_channel_credentials_file( @pytest.mark.parametrize( - "request_type", [spanner_instance_admin.ListInstanceConfigsRequest, dict,] + "request_type", + [ + spanner_instance_admin.ListInstanceConfigsRequest, + dict, + ], ) def test_list_instance_configs(request_type, transport: str = "grpc"): client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -684,7 +699,8 @@ def test_list_instance_configs_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -703,7 +719,8 @@ async def test_list_instance_configs_async( request_type=spanner_instance_admin.ListInstanceConfigsRequest, ): client = InstanceAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -738,7 +755,9 @@ async def test_list_instance_configs_async_from_dict(): def test_list_instance_configs_field_headers(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -760,7 +779,10 @@ def test_list_instance_configs_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -791,11 +813,16 @@ async def test_list_instance_configs_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_list_instance_configs_flattened(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -805,7 +832,9 @@ def test_list_instance_configs_flattened(): call.return_value = spanner_instance_admin.ListInstanceConfigsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_instance_configs(parent="parent_value",) + client.list_instance_configs( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -817,13 +846,16 @@ def test_list_instance_configs_flattened(): def test_list_instance_configs_flattened_error(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + 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_instance_configs( - spanner_instance_admin.ListInstanceConfigsRequest(), parent="parent_value", + spanner_instance_admin.ListInstanceConfigsRequest(), + parent="parent_value", ) @@ -845,7 +877,9 @@ async def test_list_instance_configs_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_instance_configs(parent="parent_value",) + response = await client.list_instance_configs( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -866,13 +900,15 @@ async def test_list_instance_configs_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.list_instance_configs( - spanner_instance_admin.ListInstanceConfigsRequest(), parent="parent_value", + spanner_instance_admin.ListInstanceConfigsRequest(), + parent="parent_value", ) def test_list_instance_configs_pager(transport_name: str = "grpc"): client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -890,10 +926,13 @@ def test_list_instance_configs_pager(transport_name: str = "grpc"): next_page_token="abc", ), spanner_instance_admin.ListInstanceConfigsResponse( - instance_configs=[], next_page_token="def", + instance_configs=[], + next_page_token="def", ), spanner_instance_admin.ListInstanceConfigsResponse( - instance_configs=[spanner_instance_admin.InstanceConfig(),], + instance_configs=[ + spanner_instance_admin.InstanceConfig(), + ], next_page_token="ghi", ), spanner_instance_admin.ListInstanceConfigsResponse( @@ -922,7 +961,8 @@ def test_list_instance_configs_pager(transport_name: str = "grpc"): def test_list_instance_configs_pages(transport_name: str = "grpc"): client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -940,10 +980,13 @@ def test_list_instance_configs_pages(transport_name: str = "grpc"): next_page_token="abc", ), spanner_instance_admin.ListInstanceConfigsResponse( - instance_configs=[], next_page_token="def", + instance_configs=[], + next_page_token="def", ), spanner_instance_admin.ListInstanceConfigsResponse( - instance_configs=[spanner_instance_admin.InstanceConfig(),], + instance_configs=[ + spanner_instance_admin.InstanceConfig(), + ], next_page_token="ghi", ), spanner_instance_admin.ListInstanceConfigsResponse( @@ -961,7 +1004,9 @@ def test_list_instance_configs_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_instance_configs_async_pager(): - client = InstanceAdminAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = InstanceAdminAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -980,10 +1025,13 @@ async def test_list_instance_configs_async_pager(): next_page_token="abc", ), spanner_instance_admin.ListInstanceConfigsResponse( - instance_configs=[], next_page_token="def", + instance_configs=[], + next_page_token="def", ), spanner_instance_admin.ListInstanceConfigsResponse( - instance_configs=[spanner_instance_admin.InstanceConfig(),], + instance_configs=[ + spanner_instance_admin.InstanceConfig(), + ], next_page_token="ghi", ), spanner_instance_admin.ListInstanceConfigsResponse( @@ -994,7 +1042,9 @@ async def test_list_instance_configs_async_pager(): ), RuntimeError, ) - async_pager = await client.list_instance_configs(request={},) + async_pager = await client.list_instance_configs( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -1008,7 +1058,9 @@ async def test_list_instance_configs_async_pager(): @pytest.mark.asyncio async def test_list_instance_configs_async_pages(): - client = InstanceAdminAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = InstanceAdminAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1027,10 +1079,13 @@ async def test_list_instance_configs_async_pages(): next_page_token="abc", ), spanner_instance_admin.ListInstanceConfigsResponse( - instance_configs=[], next_page_token="def", + instance_configs=[], + next_page_token="def", ), spanner_instance_admin.ListInstanceConfigsResponse( - instance_configs=[spanner_instance_admin.InstanceConfig(),], + instance_configs=[ + spanner_instance_admin.InstanceConfig(), + ], next_page_token="ghi", ), spanner_instance_admin.ListInstanceConfigsResponse( @@ -1049,11 +1104,16 @@ async def test_list_instance_configs_async_pages(): @pytest.mark.parametrize( - "request_type", [spanner_instance_admin.GetInstanceConfigRequest, dict,] + "request_type", + [ + spanner_instance_admin.GetInstanceConfigRequest, + dict, + ], ) def test_get_instance_config(request_type, transport: str = "grpc"): client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1088,7 +1148,8 @@ def test_get_instance_config_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1107,7 +1168,8 @@ async def test_get_instance_config_async( request_type=spanner_instance_admin.GetInstanceConfigRequest, ): client = InstanceAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1146,7 +1208,9 @@ async def test_get_instance_config_async_from_dict(): def test_get_instance_config_field_headers(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1168,7 +1232,10 @@ def test_get_instance_config_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1199,11 +1266,16 @@ async def test_get_instance_config_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_get_instance_config_flattened(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1213,7 +1285,9 @@ def test_get_instance_config_flattened(): call.return_value = spanner_instance_admin.InstanceConfig() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_instance_config(name="name_value",) + client.get_instance_config( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1225,13 +1299,16 @@ def test_get_instance_config_flattened(): def test_get_instance_config_flattened_error(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + 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_instance_config( - spanner_instance_admin.GetInstanceConfigRequest(), name="name_value", + spanner_instance_admin.GetInstanceConfigRequest(), + name="name_value", ) @@ -1253,7 +1330,9 @@ async def test_get_instance_config_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_instance_config(name="name_value",) + response = await client.get_instance_config( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1274,16 +1353,22 @@ async def test_get_instance_config_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_instance_config( - spanner_instance_admin.GetInstanceConfigRequest(), name="name_value", + spanner_instance_admin.GetInstanceConfigRequest(), + name="name_value", ) @pytest.mark.parametrize( - "request_type", [spanner_instance_admin.ListInstancesRequest, dict,] + "request_type", + [ + spanner_instance_admin.ListInstancesRequest, + dict, + ], ) def test_list_instances(request_type, transport: str = "grpc"): client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1312,7 +1397,8 @@ def test_list_instances_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1329,7 +1415,8 @@ async def test_list_instances_async( request_type=spanner_instance_admin.ListInstancesRequest, ): client = InstanceAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1362,7 +1449,9 @@ async def test_list_instances_async_from_dict(): def test_list_instances_field_headers(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1382,7 +1471,10 @@ def test_list_instances_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1411,11 +1503,16 @@ async def test_list_instances_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_list_instances_flattened(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_instances), "__call__") as call: @@ -1423,7 +1520,9 @@ def test_list_instances_flattened(): call.return_value = spanner_instance_admin.ListInstancesResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_instances(parent="parent_value",) + client.list_instances( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1435,13 +1534,16 @@ def test_list_instances_flattened(): def test_list_instances_flattened_error(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + 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_instances( - spanner_instance_admin.ListInstancesRequest(), parent="parent_value", + spanner_instance_admin.ListInstancesRequest(), + parent="parent_value", ) @@ -1461,7 +1563,9 @@ async def test_list_instances_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_instances(parent="parent_value",) + response = await client.list_instances( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1482,13 +1586,15 @@ async def test_list_instances_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.list_instances( - spanner_instance_admin.ListInstancesRequest(), parent="parent_value", + spanner_instance_admin.ListInstancesRequest(), + parent="parent_value", ) def test_list_instances_pager(transport_name: str = "grpc"): client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1504,10 +1610,14 @@ def test_list_instances_pager(transport_name: str = "grpc"): next_page_token="abc", ), spanner_instance_admin.ListInstancesResponse( - instances=[], next_page_token="def", + instances=[], + next_page_token="def", ), spanner_instance_admin.ListInstancesResponse( - instances=[spanner_instance_admin.Instance(),], next_page_token="ghi", + instances=[ + spanner_instance_admin.Instance(), + ], + next_page_token="ghi", ), spanner_instance_admin.ListInstancesResponse( instances=[ @@ -1533,7 +1643,8 @@ def test_list_instances_pager(transport_name: str = "grpc"): def test_list_instances_pages(transport_name: str = "grpc"): client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1549,10 +1660,14 @@ def test_list_instances_pages(transport_name: str = "grpc"): next_page_token="abc", ), spanner_instance_admin.ListInstancesResponse( - instances=[], next_page_token="def", + instances=[], + next_page_token="def", ), spanner_instance_admin.ListInstancesResponse( - instances=[spanner_instance_admin.Instance(),], next_page_token="ghi", + instances=[ + spanner_instance_admin.Instance(), + ], + next_page_token="ghi", ), spanner_instance_admin.ListInstancesResponse( instances=[ @@ -1569,7 +1684,9 @@ def test_list_instances_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_instances_async_pager(): - client = InstanceAdminAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = InstanceAdminAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1586,10 +1703,14 @@ async def test_list_instances_async_pager(): next_page_token="abc", ), spanner_instance_admin.ListInstancesResponse( - instances=[], next_page_token="def", + instances=[], + next_page_token="def", ), spanner_instance_admin.ListInstancesResponse( - instances=[spanner_instance_admin.Instance(),], next_page_token="ghi", + instances=[ + spanner_instance_admin.Instance(), + ], + next_page_token="ghi", ), spanner_instance_admin.ListInstancesResponse( instances=[ @@ -1599,7 +1720,9 @@ async def test_list_instances_async_pager(): ), RuntimeError, ) - async_pager = await client.list_instances(request={},) + async_pager = await client.list_instances( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -1611,7 +1734,9 @@ async def test_list_instances_async_pager(): @pytest.mark.asyncio async def test_list_instances_async_pages(): - client = InstanceAdminAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = InstanceAdminAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1628,10 +1753,14 @@ async def test_list_instances_async_pages(): next_page_token="abc", ), spanner_instance_admin.ListInstancesResponse( - instances=[], next_page_token="def", + instances=[], + next_page_token="def", ), spanner_instance_admin.ListInstancesResponse( - instances=[spanner_instance_admin.Instance(),], next_page_token="ghi", + instances=[ + spanner_instance_admin.Instance(), + ], + next_page_token="ghi", ), spanner_instance_admin.ListInstancesResponse( instances=[ @@ -1649,11 +1778,16 @@ async def test_list_instances_async_pages(): @pytest.mark.parametrize( - "request_type", [spanner_instance_admin.GetInstanceRequest, dict,] + "request_type", + [ + spanner_instance_admin.GetInstanceRequest, + dict, + ], ) def test_get_instance(request_type, transport: str = "grpc"): client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1694,7 +1828,8 @@ def test_get_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1711,7 +1846,8 @@ async def test_get_instance_async( request_type=spanner_instance_admin.GetInstanceRequest, ): client = InstanceAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1756,7 +1892,9 @@ async def test_get_instance_async_from_dict(): def test_get_instance_field_headers(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1776,7 +1914,10 @@ def test_get_instance_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1805,11 +1946,16 @@ async def test_get_instance_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_get_instance_flattened(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_instance), "__call__") as call: @@ -1817,7 +1963,9 @@ def test_get_instance_flattened(): call.return_value = spanner_instance_admin.Instance() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_instance(name="name_value",) + client.get_instance( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1829,13 +1977,16 @@ def test_get_instance_flattened(): def test_get_instance_flattened_error(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + 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_instance( - spanner_instance_admin.GetInstanceRequest(), name="name_value", + spanner_instance_admin.GetInstanceRequest(), + name="name_value", ) @@ -1855,7 +2006,9 @@ async def test_get_instance_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_instance(name="name_value",) + response = await client.get_instance( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1876,16 +2029,22 @@ async def test_get_instance_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_instance( - spanner_instance_admin.GetInstanceRequest(), name="name_value", + spanner_instance_admin.GetInstanceRequest(), + name="name_value", ) @pytest.mark.parametrize( - "request_type", [spanner_instance_admin.CreateInstanceRequest, dict,] + "request_type", + [ + spanner_instance_admin.CreateInstanceRequest, + dict, + ], ) def test_create_instance(request_type, transport: str = "grpc"): client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1911,7 +2070,8 @@ def test_create_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1928,7 +2088,8 @@ async def test_create_instance_async( request_type=spanner_instance_admin.CreateInstanceRequest, ): client = InstanceAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1958,7 +2119,9 @@ async def test_create_instance_async_from_dict(): def test_create_instance_field_headers(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1978,7 +2141,10 @@ def test_create_instance_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2007,11 +2173,16 @@ async def test_create_instance_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_create_instance_flattened(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_instance), "__call__") as call: @@ -2041,7 +2212,9 @@ def test_create_instance_flattened(): def test_create_instance_flattened_error(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2109,11 +2282,16 @@ async def test_create_instance_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [spanner_instance_admin.UpdateInstanceRequest, dict,] + "request_type", + [ + spanner_instance_admin.UpdateInstanceRequest, + dict, + ], ) def test_update_instance(request_type, transport: str = "grpc"): client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2139,7 +2317,8 @@ def test_update_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2156,7 +2335,8 @@ async def test_update_instance_async( request_type=spanner_instance_admin.UpdateInstanceRequest, ): client = InstanceAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2186,7 +2366,9 @@ async def test_update_instance_async_from_dict(): def test_update_instance_field_headers(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2206,9 +2388,10 @@ def test_update_instance_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "instance.name=instance.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "instance.name=instance.name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2237,13 +2420,16 @@ async def test_update_instance_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "instance.name=instance.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "instance.name=instance.name/value", + ) in kw["metadata"] def test_update_instance_flattened(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_instance), "__call__") as call: @@ -2269,7 +2455,9 @@ def test_update_instance_flattened(): def test_update_instance_flattened_error(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2331,11 +2519,16 @@ async def test_update_instance_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [spanner_instance_admin.DeleteInstanceRequest, dict,] + "request_type", + [ + spanner_instance_admin.DeleteInstanceRequest, + dict, + ], ) def test_delete_instance(request_type, transport: str = "grpc"): client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2361,7 +2554,8 @@ def test_delete_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2378,7 +2572,8 @@ async def test_delete_instance_async( request_type=spanner_instance_admin.DeleteInstanceRequest, ): client = InstanceAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2406,7 +2601,9 @@ async def test_delete_instance_async_from_dict(): def test_delete_instance_field_headers(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2426,7 +2623,10 @@ def test_delete_instance_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2453,11 +2653,16 @@ async def test_delete_instance_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_delete_instance_flattened(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_instance), "__call__") as call: @@ -2465,7 +2670,9 @@ def test_delete_instance_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_instance(name="name_value",) + client.delete_instance( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2477,13 +2684,16 @@ def test_delete_instance_flattened(): def test_delete_instance_flattened_error(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + 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_instance( - spanner_instance_admin.DeleteInstanceRequest(), name="name_value", + spanner_instance_admin.DeleteInstanceRequest(), + name="name_value", ) @@ -2501,7 +2711,9 @@ async def test_delete_instance_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_instance(name="name_value",) + response = await client.delete_instance( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2522,14 +2734,22 @@ async def test_delete_instance_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.delete_instance( - spanner_instance_admin.DeleteInstanceRequest(), name="name_value", + spanner_instance_admin.DeleteInstanceRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [iam_policy_pb2.SetIamPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.SetIamPolicyRequest, + dict, + ], +) def test_set_iam_policy(request_type, transport: str = "grpc"): client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2539,7 +2759,10 @@ def test_set_iam_policy(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.set_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -2557,7 +2780,8 @@ def test_set_iam_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2573,7 +2797,8 @@ async def test_set_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy_pb2.SetIamPolicyRequest ): client = InstanceAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2584,7 +2809,10 @@ async def test_set_iam_policy_async( with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.set_iam_policy(request) @@ -2605,7 +2833,9 @@ async def test_set_iam_policy_async_from_dict(): def test_set_iam_policy_field_headers(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2625,7 +2855,10 @@ def test_set_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2652,11 +2885,16 @@ async def test_set_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_set_iam_policy_from_dict_foreign(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -2671,7 +2909,9 @@ def test_set_iam_policy_from_dict_foreign(): def test_set_iam_policy_flattened(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -2679,7 +2919,9 @@ def test_set_iam_policy_flattened(): call.return_value = policy_pb2.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.set_iam_policy(resource="resource_value",) + client.set_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2691,13 +2933,16 @@ def test_set_iam_policy_flattened(): def test_set_iam_policy_flattened_error(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.set_iam_policy( - iam_policy_pb2.SetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.SetIamPolicyRequest(), + resource="resource_value", ) @@ -2715,7 +2960,9 @@ async def test_set_iam_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.set_iam_policy(resource="resource_value",) + response = await client.set_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2736,14 +2983,22 @@ async def test_set_iam_policy_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.set_iam_policy( - iam_policy_pb2.SetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.SetIamPolicyRequest(), + resource="resource_value", ) -@pytest.mark.parametrize("request_type", [iam_policy_pb2.GetIamPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.GetIamPolicyRequest, + dict, + ], +) def test_get_iam_policy(request_type, transport: str = "grpc"): client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2753,7 +3008,10 @@ def test_get_iam_policy(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.get_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -2771,7 +3029,8 @@ def test_get_iam_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2787,7 +3046,8 @@ async def test_get_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy_pb2.GetIamPolicyRequest ): client = InstanceAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2798,7 +3058,10 @@ async def test_get_iam_policy_async( with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.get_iam_policy(request) @@ -2819,7 +3082,9 @@ async def test_get_iam_policy_async_from_dict(): def test_get_iam_policy_field_headers(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2839,7 +3104,10 @@ def test_get_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2866,11 +3134,16 @@ async def test_get_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_get_iam_policy_from_dict_foreign(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -2885,7 +3158,9 @@ def test_get_iam_policy_from_dict_foreign(): def test_get_iam_policy_flattened(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2893,7 +3168,9 @@ def test_get_iam_policy_flattened(): call.return_value = policy_pb2.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_iam_policy(resource="resource_value",) + client.get_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2905,13 +3182,16 @@ def test_get_iam_policy_flattened(): def test_get_iam_policy_flattened_error(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_iam_policy( - iam_policy_pb2.GetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.GetIamPolicyRequest(), + resource="resource_value", ) @@ -2929,7 +3209,9 @@ async def test_get_iam_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_iam_policy(resource="resource_value",) + response = await client.get_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2950,16 +3232,22 @@ async def test_get_iam_policy_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_iam_policy( - iam_policy_pb2.GetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.GetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.parametrize( - "request_type", [iam_policy_pb2.TestIamPermissionsRequest, dict,] + "request_type", + [ + iam_policy_pb2.TestIamPermissionsRequest, + dict, + ], ) def test_test_iam_permissions(request_type, transport: str = "grpc"): client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2990,7 +3278,8 @@ def test_test_iam_permissions_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3009,7 +3298,8 @@ async def test_test_iam_permissions_async( request_type=iam_policy_pb2.TestIamPermissionsRequest, ): client = InstanceAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3044,7 +3334,9 @@ async def test_test_iam_permissions_async_from_dict(): def test_test_iam_permissions_field_headers(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3066,7 +3358,10 @@ def test_test_iam_permissions_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -3097,11 +3392,16 @@ async def test_test_iam_permissions_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_test_iam_permissions_from_dict_foreign(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.test_iam_permissions), "__call__" @@ -3118,7 +3418,9 @@ def test_test_iam_permissions_from_dict_foreign(): def test_test_iam_permissions_flattened(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3129,7 +3431,8 @@ def test_test_iam_permissions_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.test_iam_permissions( - resource="resource_value", permissions=["permissions_value"], + resource="resource_value", + permissions=["permissions_value"], ) # Establish that the underlying call was made with the expected @@ -3145,7 +3448,9 @@ def test_test_iam_permissions_flattened(): def test_test_iam_permissions_flattened_error(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3176,7 +3481,8 @@ async def test_test_iam_permissions_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.test_iam_permissions( - resource="resource_value", permissions=["permissions_value"], + resource="resource_value", + permissions=["permissions_value"], ) # Establish that the underlying call was made with the expected @@ -3214,7 +3520,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -3234,7 +3541,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = InstanceAdminClient(client_options=options, transport=transport,) + client = InstanceAdminClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -3250,7 +3560,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = InstanceAdminClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -3295,8 +3606,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.InstanceAdminGrpcTransport,) + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.InstanceAdminGrpcTransport, + ) def test_instance_admin_base_transport_error(): @@ -3355,7 +3671,8 @@ def test_instance_admin_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.InstanceAdminTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -3525,7 +3842,8 @@ def test_instance_admin_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.InstanceAdminGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -3537,7 +3855,8 @@ def test_instance_admin_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.InstanceAdminGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -3644,12 +3963,16 @@ def test_instance_admin_transport_channel_mtls_with_adc(transport_class): def test_instance_admin_grpc_lro_client(): client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + 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,) + 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 @@ -3657,12 +3980,16 @@ def test_instance_admin_grpc_lro_client(): def test_instance_admin_grpc_lro_async_client(): client = InstanceAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + 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,) + 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 @@ -3672,7 +3999,8 @@ def test_instance_path(): project = "squid" instance = "clam" expected = "projects/{project}/instances/{instance}".format( - project=project, instance=instance, + project=project, + instance=instance, ) actual = InstanceAdminClient.instance_path(project, instance) assert expected == actual @@ -3694,7 +4022,8 @@ def test_instance_config_path(): project = "oyster" instance_config = "nudibranch" expected = "projects/{project}/instanceConfigs/{instance_config}".format( - project=project, instance_config=instance_config, + project=project, + instance_config=instance_config, ) actual = InstanceAdminClient.instance_config_path(project, instance_config) assert expected == actual @@ -3734,7 +4063,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "scallop" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = InstanceAdminClient.common_folder_path(folder) assert expected == actual @@ -3752,7 +4083,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "squid" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = InstanceAdminClient.common_organization_path(organization) assert expected == actual @@ -3770,7 +4103,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "whelk" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = InstanceAdminClient.common_project_path(project) assert expected == actual @@ -3790,7 +4125,8 @@ def test_common_location_path(): project = "oyster" location = "nudibranch" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = InstanceAdminClient.common_location_path(project, location) assert expected == actual @@ -3815,7 +4151,8 @@ def test_client_with_default_client_info(): transports.InstanceAdminTransport, "_prep_wrapped_messages" ) as prep: client = InstanceAdminClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -3824,7 +4161,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = InstanceAdminClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -3832,7 +4170,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = InstanceAdminAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/spanner_v1/test_spanner.py b/tests/unit/gapic/spanner_v1/test_spanner.py index c207dc5fbc..f0c0f0bafc 100644 --- a/tests/unit/gapic/spanner_v1/test_spanner.py +++ b/tests/unit/gapic/spanner_v1/test_spanner.py @@ -88,7 +88,13 @@ def test__get_default_mtls_endpoint(): assert SpannerClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [SpannerClient, SpannerAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + SpannerClient, + SpannerAsyncClient, + ], +) def test_spanner_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -126,7 +132,13 @@ def test_spanner_client_service_account_always_use_jwt(transport_class, transpor use_jwt.assert_not_called() -@pytest.mark.parametrize("client_class", [SpannerClient, SpannerAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + SpannerClient, + SpannerAsyncClient, + ], +) def test_spanner_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -465,7 +477,9 @@ def test_spanner_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -596,10 +610,17 @@ def test_spanner_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [spanner.CreateSessionRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + spanner.CreateSessionRequest, + dict, + ], +) def test_create_session(request_type, transport: str = "grpc"): client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -609,7 +630,9 @@ def test_create_session(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_session), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = spanner.Session(name="name_value",) + call.return_value = spanner.Session( + name="name_value", + ) response = client.create_session(request) # Establish that the underlying gRPC stub method was called. @@ -626,7 +649,8 @@ def test_create_session_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -642,7 +666,8 @@ async def test_create_session_async( transport: str = "grpc_asyncio", request_type=spanner.CreateSessionRequest ): client = SpannerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -653,7 +678,9 @@ async def test_create_session_async( with mock.patch.object(type(client.transport.create_session), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - spanner.Session(name="name_value",) + spanner.Session( + name="name_value", + ) ) response = await client.create_session(request) @@ -673,7 +700,9 @@ async def test_create_session_async_from_dict(): def test_create_session_field_headers(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -693,12 +722,17 @@ def test_create_session_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_create_session_field_headers_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -718,11 +752,16 @@ async def test_create_session_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] def test_create_session_flattened(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_session), "__call__") as call: @@ -730,7 +769,9 @@ def test_create_session_flattened(): call.return_value = spanner.Session() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.create_session(database="database_value",) + client.create_session( + database="database_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -742,19 +783,24 @@ def test_create_session_flattened(): def test_create_session_flattened_error(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + 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_session( - spanner.CreateSessionRequest(), database="database_value", + spanner.CreateSessionRequest(), + database="database_value", ) @pytest.mark.asyncio async def test_create_session_flattened_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_session), "__call__") as call: @@ -764,7 +810,9 @@ async def test_create_session_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(spanner.Session()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.create_session(database="database_value",) + response = await client.create_session( + database="database_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -777,20 +825,30 @@ async def test_create_session_flattened_async(): @pytest.mark.asyncio async def test_create_session_flattened_error_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.create_session( - spanner.CreateSessionRequest(), database="database_value", + spanner.CreateSessionRequest(), + database="database_value", ) -@pytest.mark.parametrize("request_type", [spanner.BatchCreateSessionsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + spanner.BatchCreateSessionsRequest, + dict, + ], +) def test_batch_create_sessions(request_type, transport: str = "grpc"): client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -818,7 +876,8 @@ def test_batch_create_sessions_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -836,7 +895,8 @@ async def test_batch_create_sessions_async( transport: str = "grpc_asyncio", request_type=spanner.BatchCreateSessionsRequest ): client = SpannerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -868,7 +928,9 @@ async def test_batch_create_sessions_async_from_dict(): def test_batch_create_sessions_field_headers(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -890,12 +952,17 @@ def test_batch_create_sessions_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_batch_create_sessions_field_headers_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -919,11 +986,16 @@ async def test_batch_create_sessions_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] def test_batch_create_sessions_flattened(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -934,7 +1006,8 @@ def test_batch_create_sessions_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.batch_create_sessions( - database="database_value", session_count=1420, + database="database_value", + session_count=1420, ) # Establish that the underlying call was made with the expected @@ -950,7 +1023,9 @@ def test_batch_create_sessions_flattened(): def test_batch_create_sessions_flattened_error(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -964,7 +1039,9 @@ def test_batch_create_sessions_flattened_error(): @pytest.mark.asyncio async def test_batch_create_sessions_flattened_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -979,7 +1056,8 @@ async def test_batch_create_sessions_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.batch_create_sessions( - database="database_value", session_count=1420, + database="database_value", + session_count=1420, ) # Establish that the underlying call was made with the expected @@ -996,7 +1074,9 @@ async def test_batch_create_sessions_flattened_async(): @pytest.mark.asyncio async def test_batch_create_sessions_flattened_error_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1008,10 +1088,17 @@ async def test_batch_create_sessions_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [spanner.GetSessionRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + spanner.GetSessionRequest, + dict, + ], +) def test_get_session(request_type, transport: str = "grpc"): client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1021,7 +1108,9 @@ def test_get_session(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_session), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = spanner.Session(name="name_value",) + call.return_value = spanner.Session( + name="name_value", + ) response = client.get_session(request) # Establish that the underlying gRPC stub method was called. @@ -1038,7 +1127,8 @@ def test_get_session_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1054,7 +1144,8 @@ async def test_get_session_async( transport: str = "grpc_asyncio", request_type=spanner.GetSessionRequest ): client = SpannerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1065,7 +1156,9 @@ async def test_get_session_async( with mock.patch.object(type(client.transport.get_session), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - spanner.Session(name="name_value",) + spanner.Session( + name="name_value", + ) ) response = await client.get_session(request) @@ -1085,7 +1178,9 @@ async def test_get_session_async_from_dict(): def test_get_session_field_headers(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1105,12 +1200,17 @@ def test_get_session_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_session_field_headers_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1130,11 +1230,16 @@ async def test_get_session_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_get_session_flattened(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_session), "__call__") as call: @@ -1142,7 +1247,9 @@ def test_get_session_flattened(): call.return_value = spanner.Session() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_session(name="name_value",) + client.get_session( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1154,19 +1261,24 @@ def test_get_session_flattened(): def test_get_session_flattened_error(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + 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_session( - spanner.GetSessionRequest(), name="name_value", + spanner.GetSessionRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_get_session_flattened_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_session), "__call__") as call: @@ -1176,7 +1288,9 @@ async def test_get_session_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(spanner.Session()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_session(name="name_value",) + response = await client.get_session( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1189,20 +1303,30 @@ async def test_get_session_flattened_async(): @pytest.mark.asyncio async def test_get_session_flattened_error_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_session( - spanner.GetSessionRequest(), name="name_value", + spanner.GetSessionRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [spanner.ListSessionsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + spanner.ListSessionsRequest, + dict, + ], +) def test_list_sessions(request_type, transport: str = "grpc"): client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1231,7 +1355,8 @@ def test_list_sessions_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1247,7 +1372,8 @@ async def test_list_sessions_async( transport: str = "grpc_asyncio", request_type=spanner.ListSessionsRequest ): client = SpannerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1258,7 +1384,9 @@ async def test_list_sessions_async( with mock.patch.object(type(client.transport.list_sessions), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - spanner.ListSessionsResponse(next_page_token="next_page_token_value",) + spanner.ListSessionsResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_sessions(request) @@ -1278,7 +1406,9 @@ async def test_list_sessions_async_from_dict(): def test_list_sessions_field_headers(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1298,12 +1428,17 @@ def test_list_sessions_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_sessions_field_headers_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1325,11 +1460,16 @@ async def test_list_sessions_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "database=database/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "database=database/value", + ) in kw["metadata"] def test_list_sessions_flattened(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_sessions), "__call__") as call: @@ -1337,7 +1477,9 @@ def test_list_sessions_flattened(): call.return_value = spanner.ListSessionsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_sessions(database="database_value",) + client.list_sessions( + database="database_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1349,19 +1491,24 @@ def test_list_sessions_flattened(): def test_list_sessions_flattened_error(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + 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_sessions( - spanner.ListSessionsRequest(), database="database_value", + spanner.ListSessionsRequest(), + database="database_value", ) @pytest.mark.asyncio async def test_list_sessions_flattened_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_sessions), "__call__") as call: @@ -1373,7 +1520,9 @@ async def test_list_sessions_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_sessions(database="database_value",) + response = await client.list_sessions( + database="database_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1386,19 +1535,23 @@ async def test_list_sessions_flattened_async(): @pytest.mark.asyncio async def test_list_sessions_flattened_error_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_sessions( - spanner.ListSessionsRequest(), database="database_value", + spanner.ListSessionsRequest(), + database="database_value", ) def test_list_sessions_pager(transport_name: str = "grpc"): client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1406,15 +1559,28 @@ def test_list_sessions_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( spanner.ListSessionsResponse( - sessions=[spanner.Session(), spanner.Session(), spanner.Session(),], + sessions=[ + spanner.Session(), + spanner.Session(), + spanner.Session(), + ], next_page_token="abc", ), - spanner.ListSessionsResponse(sessions=[], next_page_token="def",), spanner.ListSessionsResponse( - sessions=[spanner.Session(),], next_page_token="ghi", + sessions=[], + next_page_token="def", ), spanner.ListSessionsResponse( - sessions=[spanner.Session(), spanner.Session(),], + sessions=[ + spanner.Session(), + ], + next_page_token="ghi", + ), + spanner.ListSessionsResponse( + sessions=[ + spanner.Session(), + spanner.Session(), + ], ), RuntimeError, ) @@ -1434,7 +1600,8 @@ def test_list_sessions_pager(transport_name: str = "grpc"): def test_list_sessions_pages(transport_name: str = "grpc"): client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1442,15 +1609,28 @@ def test_list_sessions_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( spanner.ListSessionsResponse( - sessions=[spanner.Session(), spanner.Session(), spanner.Session(),], + sessions=[ + spanner.Session(), + spanner.Session(), + spanner.Session(), + ], next_page_token="abc", ), - spanner.ListSessionsResponse(sessions=[], next_page_token="def",), spanner.ListSessionsResponse( - sessions=[spanner.Session(),], next_page_token="ghi", + sessions=[], + next_page_token="def", ), spanner.ListSessionsResponse( - sessions=[spanner.Session(), spanner.Session(),], + sessions=[ + spanner.Session(), + ], + next_page_token="ghi", + ), + spanner.ListSessionsResponse( + sessions=[ + spanner.Session(), + spanner.Session(), + ], ), RuntimeError, ) @@ -1461,7 +1641,9 @@ def test_list_sessions_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_sessions_async_pager(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1470,19 +1652,34 @@ async def test_list_sessions_async_pager(): # Set the response to a series of pages. call.side_effect = ( spanner.ListSessionsResponse( - sessions=[spanner.Session(), spanner.Session(), spanner.Session(),], + sessions=[ + spanner.Session(), + spanner.Session(), + spanner.Session(), + ], next_page_token="abc", ), - spanner.ListSessionsResponse(sessions=[], next_page_token="def",), spanner.ListSessionsResponse( - sessions=[spanner.Session(),], next_page_token="ghi", + sessions=[], + next_page_token="def", ), spanner.ListSessionsResponse( - sessions=[spanner.Session(), spanner.Session(),], + sessions=[ + spanner.Session(), + ], + next_page_token="ghi", + ), + spanner.ListSessionsResponse( + sessions=[ + spanner.Session(), + spanner.Session(), + ], ), RuntimeError, ) - async_pager = await client.list_sessions(request={},) + async_pager = await client.list_sessions( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -1494,7 +1691,9 @@ async def test_list_sessions_async_pager(): @pytest.mark.asyncio async def test_list_sessions_async_pages(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1503,15 +1702,28 @@ async def test_list_sessions_async_pages(): # Set the response to a series of pages. call.side_effect = ( spanner.ListSessionsResponse( - sessions=[spanner.Session(), spanner.Session(), spanner.Session(),], + sessions=[ + spanner.Session(), + spanner.Session(), + spanner.Session(), + ], next_page_token="abc", ), - spanner.ListSessionsResponse(sessions=[], next_page_token="def",), spanner.ListSessionsResponse( - sessions=[spanner.Session(),], next_page_token="ghi", + sessions=[], + next_page_token="def", + ), + spanner.ListSessionsResponse( + sessions=[ + spanner.Session(), + ], + next_page_token="ghi", ), spanner.ListSessionsResponse( - sessions=[spanner.Session(), spanner.Session(),], + sessions=[ + spanner.Session(), + spanner.Session(), + ], ), RuntimeError, ) @@ -1522,10 +1734,17 @@ async def test_list_sessions_async_pages(): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [spanner.DeleteSessionRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + spanner.DeleteSessionRequest, + dict, + ], +) def test_delete_session(request_type, transport: str = "grpc"): client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1551,7 +1770,8 @@ def test_delete_session_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1567,7 +1787,8 @@ async def test_delete_session_async( transport: str = "grpc_asyncio", request_type=spanner.DeleteSessionRequest ): client = SpannerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1595,7 +1816,9 @@ async def test_delete_session_async_from_dict(): def test_delete_session_field_headers(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1615,12 +1838,17 @@ def test_delete_session_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_delete_session_field_headers_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1640,11 +1868,16 @@ async def test_delete_session_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_delete_session_flattened(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_session), "__call__") as call: @@ -1652,7 +1885,9 @@ def test_delete_session_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_session(name="name_value",) + client.delete_session( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1664,19 +1899,24 @@ def test_delete_session_flattened(): def test_delete_session_flattened_error(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + 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_session( - spanner.DeleteSessionRequest(), name="name_value", + spanner.DeleteSessionRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_delete_session_flattened_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_session), "__call__") as call: @@ -1686,7 +1926,9 @@ async def test_delete_session_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_session(name="name_value",) + response = await client.delete_session( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1699,20 +1941,30 @@ async def test_delete_session_flattened_async(): @pytest.mark.asyncio async def test_delete_session_flattened_error_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.delete_session( - spanner.DeleteSessionRequest(), name="name_value", + spanner.DeleteSessionRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [spanner.ExecuteSqlRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + spanner.ExecuteSqlRequest, + dict, + ], +) def test_execute_sql(request_type, transport: str = "grpc"): client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1738,7 +1990,8 @@ def test_execute_sql_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1754,7 +2007,8 @@ async def test_execute_sql_async( transport: str = "grpc_asyncio", request_type=spanner.ExecuteSqlRequest ): client = SpannerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1784,7 +2038,9 @@ async def test_execute_sql_async_from_dict(): def test_execute_sql_field_headers(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1804,12 +2060,17 @@ def test_execute_sql_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_execute_sql_field_headers_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1831,13 +2092,23 @@ async def test_execute_sql_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [spanner.ExecuteSqlRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + spanner.ExecuteSqlRequest, + dict, + ], +) def test_execute_streaming_sql(request_type, transport: str = "grpc"): client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1866,7 +2137,8 @@ def test_execute_streaming_sql_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1884,7 +2156,8 @@ async def test_execute_streaming_sql_async( transport: str = "grpc_asyncio", request_type=spanner.ExecuteSqlRequest ): client = SpannerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1918,7 +2191,9 @@ async def test_execute_streaming_sql_async_from_dict(): def test_execute_streaming_sql_field_headers(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1940,12 +2215,17 @@ def test_execute_streaming_sql_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_execute_streaming_sql_field_headers_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1970,13 +2250,23 @@ async def test_execute_streaming_sql_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [spanner.ExecuteBatchDmlRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + spanner.ExecuteBatchDmlRequest, + dict, + ], +) def test_execute_batch_dml(request_type, transport: str = "grpc"): client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2004,7 +2294,8 @@ def test_execute_batch_dml_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2022,7 +2313,8 @@ async def test_execute_batch_dml_async( transport: str = "grpc_asyncio", request_type=spanner.ExecuteBatchDmlRequest ): client = SpannerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2054,7 +2346,9 @@ async def test_execute_batch_dml_async_from_dict(): def test_execute_batch_dml_field_headers(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2076,12 +2370,17 @@ def test_execute_batch_dml_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_execute_batch_dml_field_headers_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2105,13 +2404,23 @@ async def test_execute_batch_dml_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [spanner.ReadRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + spanner.ReadRequest, + dict, + ], +) def test_read(request_type, transport: str = "grpc"): client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2137,7 +2446,8 @@ def test_read_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2153,7 +2463,8 @@ async def test_read_async( transport: str = "grpc_asyncio", request_type=spanner.ReadRequest ): client = SpannerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2183,7 +2494,9 @@ async def test_read_async_from_dict(): def test_read_field_headers(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2203,12 +2516,17 @@ def test_read_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_read_field_headers_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2230,13 +2548,23 @@ async def test_read_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [spanner.ReadRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + spanner.ReadRequest, + dict, + ], +) def test_streaming_read(request_type, transport: str = "grpc"): client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2263,7 +2591,8 @@ def test_streaming_read_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2279,7 +2608,8 @@ async def test_streaming_read_async( transport: str = "grpc_asyncio", request_type=spanner.ReadRequest ): client = SpannerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2311,7 +2641,9 @@ async def test_streaming_read_async_from_dict(): def test_streaming_read_field_headers(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2331,12 +2663,17 @@ def test_streaming_read_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_streaming_read_field_headers_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2359,13 +2696,23 @@ async def test_streaming_read_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [spanner.BeginTransactionRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + spanner.BeginTransactionRequest, + dict, + ], +) def test_begin_transaction(request_type, transport: str = "grpc"): client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2377,7 +2724,9 @@ def test_begin_transaction(request_type, transport: str = "grpc"): type(client.transport.begin_transaction), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = transaction.Transaction(id=b"id_blob",) + call.return_value = transaction.Transaction( + id=b"id_blob", + ) response = client.begin_transaction(request) # Establish that the underlying gRPC stub method was called. @@ -2394,7 +2743,8 @@ def test_begin_transaction_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2412,7 +2762,8 @@ async def test_begin_transaction_async( transport: str = "grpc_asyncio", request_type=spanner.BeginTransactionRequest ): client = SpannerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2425,7 +2776,9 @@ async def test_begin_transaction_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - transaction.Transaction(id=b"id_blob",) + transaction.Transaction( + id=b"id_blob", + ) ) response = await client.begin_transaction(request) @@ -2445,7 +2798,9 @@ async def test_begin_transaction_async_from_dict(): def test_begin_transaction_field_headers(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2467,12 +2822,17 @@ def test_begin_transaction_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_begin_transaction_field_headers_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2496,11 +2856,16 @@ async def test_begin_transaction_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] def test_begin_transaction_flattened(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2528,7 +2893,9 @@ def test_begin_transaction_flattened(): def test_begin_transaction_flattened_error(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2542,7 +2909,9 @@ def test_begin_transaction_flattened_error(): @pytest.mark.asyncio async def test_begin_transaction_flattened_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2575,7 +2944,9 @@ async def test_begin_transaction_flattened_async(): @pytest.mark.asyncio async def test_begin_transaction_flattened_error_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2587,10 +2958,17 @@ async def test_begin_transaction_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [spanner.CommitRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + spanner.CommitRequest, + dict, + ], +) def test_commit(request_type, transport: str = "grpc"): client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2616,7 +2994,8 @@ def test_commit_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2632,7 +3011,8 @@ async def test_commit_async( transport: str = "grpc_asyncio", request_type=spanner.CommitRequest ): client = SpannerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2662,7 +3042,9 @@ async def test_commit_async_from_dict(): def test_commit_field_headers(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2682,12 +3064,17 @@ def test_commit_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_commit_field_headers_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2709,11 +3096,16 @@ async def test_commit_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] def test_commit_flattened(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.commit), "__call__") as call: @@ -2748,7 +3140,9 @@ def test_commit_flattened(): def test_commit_flattened_error(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2766,7 +3160,9 @@ def test_commit_flattened_error(): @pytest.mark.asyncio async def test_commit_flattened_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.commit), "__call__") as call: @@ -2806,7 +3202,9 @@ async def test_commit_flattened_async(): @pytest.mark.asyncio async def test_commit_flattened_error_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2822,10 +3220,17 @@ async def test_commit_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [spanner.RollbackRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + spanner.RollbackRequest, + dict, + ], +) def test_rollback(request_type, transport: str = "grpc"): client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2851,7 +3256,8 @@ def test_rollback_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2867,7 +3273,8 @@ async def test_rollback_async( transport: str = "grpc_asyncio", request_type=spanner.RollbackRequest ): client = SpannerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2895,7 +3302,9 @@ async def test_rollback_async_from_dict(): def test_rollback_field_headers(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2915,12 +3324,17 @@ def test_rollback_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_rollback_field_headers_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2940,11 +3354,16 @@ async def test_rollback_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] def test_rollback_flattened(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.rollback), "__call__") as call: @@ -2953,7 +3372,8 @@ def test_rollback_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.rollback( - session="session_value", transaction_id=b"transaction_id_blob", + session="session_value", + transaction_id=b"transaction_id_blob", ) # Establish that the underlying call was made with the expected @@ -2969,7 +3389,9 @@ def test_rollback_flattened(): def test_rollback_flattened_error(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2983,7 +3405,9 @@ def test_rollback_flattened_error(): @pytest.mark.asyncio async def test_rollback_flattened_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.rollback), "__call__") as call: @@ -2994,7 +3418,8 @@ async def test_rollback_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.rollback( - session="session_value", transaction_id=b"transaction_id_blob", + session="session_value", + transaction_id=b"transaction_id_blob", ) # Establish that the underlying call was made with the expected @@ -3011,7 +3436,9 @@ async def test_rollback_flattened_async(): @pytest.mark.asyncio async def test_rollback_flattened_error_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3023,10 +3450,17 @@ async def test_rollback_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [spanner.PartitionQueryRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + spanner.PartitionQueryRequest, + dict, + ], +) def test_partition_query(request_type, transport: str = "grpc"): client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3052,7 +3486,8 @@ def test_partition_query_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3068,7 +3503,8 @@ async def test_partition_query_async( transport: str = "grpc_asyncio", request_type=spanner.PartitionQueryRequest ): client = SpannerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3098,7 +3534,9 @@ async def test_partition_query_async_from_dict(): def test_partition_query_field_headers(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3118,12 +3556,17 @@ def test_partition_query_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_partition_query_field_headers_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3145,13 +3588,23 @@ async def test_partition_query_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [spanner.PartitionReadRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + spanner.PartitionReadRequest, + dict, + ], +) def test_partition_read(request_type, transport: str = "grpc"): client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3177,7 +3630,8 @@ def test_partition_read_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3193,7 +3647,8 @@ async def test_partition_read_async( transport: str = "grpc_asyncio", request_type=spanner.PartitionReadRequest ): client = SpannerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3223,7 +3678,9 @@ async def test_partition_read_async_from_dict(): def test_partition_read_field_headers(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3243,12 +3700,17 @@ def test_partition_read_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_partition_read_field_headers_async(): - client = SpannerAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SpannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3270,7 +3732,10 @@ async def test_partition_read_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "session=session/value", + ) in kw["metadata"] def test_credentials_transport_error(): @@ -3280,7 +3745,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -3300,7 +3766,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = SpannerClient(client_options=options, transport=transport,) + client = SpannerClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -3316,7 +3785,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = SpannerClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -3346,7 +3816,10 @@ def test_transport_get_channel(): @pytest.mark.parametrize( "transport_class", - [transports.SpannerGrpcTransport, transports.SpannerGrpcAsyncIOTransport,], + [ + transports.SpannerGrpcTransport, + transports.SpannerGrpcAsyncIOTransport, + ], ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. @@ -3358,8 +3831,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.SpannerGrpcTransport,) + client = SpannerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.SpannerGrpcTransport, + ) def test_spanner_base_transport_error(): @@ -3418,7 +3896,8 @@ def test_spanner_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.SpannerTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -3459,7 +3938,10 @@ def test_spanner_auth_adc(): @pytest.mark.parametrize( "transport_class", - [transports.SpannerGrpcTransport, transports.SpannerGrpcAsyncIOTransport,], + [ + transports.SpannerGrpcTransport, + transports.SpannerGrpcAsyncIOTransport, + ], ) def test_spanner_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use @@ -3582,7 +4064,8 @@ def test_spanner_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.SpannerGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -3594,7 +4077,8 @@ def test_spanner_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.SpannerGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -3698,7 +4182,9 @@ def test_database_path(): instance = "clam" database = "whelk" expected = "projects/{project}/instances/{instance}/databases/{database}".format( - project=project, instance=instance, database=database, + project=project, + instance=instance, + database=database, ) actual = SpannerClient.database_path(project, instance, database) assert expected == actual @@ -3723,7 +4209,10 @@ def test_session_path(): database = "winkle" session = "nautilus" expected = "projects/{project}/instances/{instance}/databases/{database}/sessions/{session}".format( - project=project, instance=instance, database=database, session=session, + project=project, + instance=instance, + database=database, + session=session, ) actual = SpannerClient.session_path(project, instance, database, session) assert expected == actual @@ -3765,7 +4254,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "oyster" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = SpannerClient.common_folder_path(folder) assert expected == actual @@ -3783,7 +4274,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "cuttlefish" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = SpannerClient.common_organization_path(organization) assert expected == actual @@ -3801,7 +4294,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "winkle" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = SpannerClient.common_project_path(project) assert expected == actual @@ -3821,7 +4316,8 @@ def test_common_location_path(): project = "scallop" location = "abalone" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = SpannerClient.common_location_path(project, location) assert expected == actual @@ -3846,7 +4342,8 @@ def test_client_with_default_client_info(): transports.SpannerTransport, "_prep_wrapped_messages" ) as prep: client = SpannerClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -3855,7 +4352,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = SpannerClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -3863,7 +4361,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = SpannerAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/spanner_dbapi/test_connect.py b/tests/unit/spanner_dbapi/test_connect.py index f4dfe28a96..948659d595 100644 --- a/tests/unit/spanner_dbapi/test_connect.py +++ b/tests/unit/spanner_dbapi/test_connect.py @@ -70,7 +70,12 @@ def test_w_explicit(self, mock_client): database = instance.database.return_value connection = connect( - INSTANCE, DATABASE, PROJECT, credentials, pool=pool, user_agent=USER_AGENT, + INSTANCE, + DATABASE, + PROJECT, + credentials, + pool=pool, + user_agent=USER_AGENT, ) self.assertIsInstance(connection, Connection) @@ -107,7 +112,9 @@ def test_w_credential_file_path(self, mock_client): factory = mock_client.from_service_account_json factory.assert_called_once_with( - credentials_path, project=PROJECT, client_info=mock.ANY, + credentials_path, + project=PROJECT, + client_info=mock.ANY, ) client_info = factory.call_args_list[0][1]["client_info"] self.assertEqual(client_info.user_agent, USER_AGENT) diff --git a/tests/unit/spanner_dbapi/test_connection.py b/tests/unit/spanner_dbapi/test_connection.py index 0eea3eaf5b..7902de6405 100644 --- a/tests/unit/spanner_dbapi/test_connection.py +++ b/tests/unit/spanner_dbapi/test_connection.py @@ -134,7 +134,11 @@ def test_read_only_not_retried(self): connection.retry_transaction = mock.Mock() cursor = connection.cursor() - cursor._itr = mock.Mock(__next__=mock.Mock(side_effect=Aborted("Aborted"),)) + cursor._itr = mock.Mock( + __next__=mock.Mock( + side_effect=Aborted("Aborted"), + ) + ) cursor.fetchone() cursor.fetchall() @@ -574,7 +578,10 @@ def test_retry_aborted_retry(self, mock_client): connection.retry_transaction() run_mock.assert_has_calls( - (mock.call(statement, retried=True), mock.call(statement, retried=True),) + ( + mock.call(statement, retried=True), + mock.call(statement, retried=True), + ) ) def test_retry_transaction_raise_max_internal_retries(self): @@ -631,7 +638,10 @@ def test_retry_aborted_retry_without_delay(self, mock_client): connection.retry_transaction() run_mock.assert_has_calls( - (mock.call(statement, retried=True), mock.call(statement, retried=True),) + ( + mock.call(statement, retried=True), + mock.call(statement, retried=True), + ) ) def test_retry_transaction_w_multiple_statement(self): diff --git a/tests/unit/spanner_dbapi/test_cursor.py b/tests/unit/spanner_dbapi/test_cursor.py index 51732bc1b0..71e4a96d6e 100644 --- a/tests/unit/spanner_dbapi/test_cursor.py +++ b/tests/unit/spanner_dbapi/test_cursor.py @@ -106,7 +106,9 @@ def test_do_execute_update(self): def run_helper(ret_value): transaction.execute_update.return_value = ret_value res = cursor._do_execute_update( - transaction=transaction, sql="SELECT * WHERE true", params={}, + transaction=transaction, + sql="SELECT * WHERE true", + params={}, ) return res diff --git a/tests/unit/spanner_dbapi/test_parse_utils.py b/tests/unit/spanner_dbapi/test_parse_utils.py index 994b02d615..b0f363299b 100644 --- a/tests/unit/spanner_dbapi/test_parse_utils.py +++ b/tests/unit/spanner_dbapi/test_parse_utils.py @@ -425,5 +425,6 @@ def test_insert_from_select(self): ARGS = [5, "data2", "data3"] self.assertEqual( - parse_insert(SQL, ARGS), {"sql_params_list": [(SQL, ARGS)]}, + parse_insert(SQL, ARGS), + {"sql_params_list": [(SQL, ARGS)]}, ) diff --git a/tests/unit/spanner_dbapi/test_parser.py b/tests/unit/spanner_dbapi/test_parser.py index 994d4966d3..dd99f6fa4b 100644 --- a/tests/unit/spanner_dbapi/test_parser.py +++ b/tests/unit/spanner_dbapi/test_parser.py @@ -172,7 +172,7 @@ def test_a_args_homogeneous(self): from google.cloud.spanner_dbapi.parser import a_args from google.cloud.spanner_dbapi.parser import terminal - a_obj = a_args([a_args([terminal(10 ** i)]) for i in range(10)]) + a_obj = a_args([a_args([terminal(10**i)]) for i in range(10)]) self.assertTrue(a_obj.homogenous()) a_obj = a_args([a_args([[object()]]) for _ in range(10)]) @@ -193,7 +193,7 @@ def test_values(self): from google.cloud.spanner_dbapi.parser import terminal from google.cloud.spanner_dbapi.parser import values - a_obj = a_args([a_args([terminal(10 ** i)]) for i in range(10)]) + a_obj = a_args([a_args([terminal(10**i)]) for i in range(10)]) self.assertEqual(str(values(a_obj)), "VALUES%s" % str(a_obj)) def test_expect(self): diff --git a/tests/unit/test__helpers.py b/tests/unit/test__helpers.py index f6d1539221..b18adfa6fe 100644 --- a/tests/unit/test__helpers.py +++ b/tests/unit/test__helpers.py @@ -113,7 +113,7 @@ def test_w_invalid_bytes(self): def test_w_explicit_unicode(self): from google.protobuf.struct_pb2 import Value - TEXT = u"TEXT" + TEXT = "TEXT" value_pb = self._callFUT(TEXT) self.assertIsInstance(value_pb, Value) self.assertEqual(value_pb.string_value, TEXT) @@ -122,21 +122,21 @@ def test_w_list(self): from google.protobuf.struct_pb2 import Value from google.protobuf.struct_pb2 import ListValue - value_pb = self._callFUT([u"a", u"b", u"c"]) + value_pb = self._callFUT(["a", "b", "c"]) self.assertIsInstance(value_pb, Value) self.assertIsInstance(value_pb.list_value, ListValue) values = value_pb.list_value.values - self.assertEqual([value.string_value for value in values], [u"a", u"b", u"c"]) + self.assertEqual([value.string_value for value in values], ["a", "b", "c"]) def test_w_tuple(self): from google.protobuf.struct_pb2 import Value from google.protobuf.struct_pb2 import ListValue - value_pb = self._callFUT((u"a", u"b", u"c")) + value_pb = self._callFUT(("a", "b", "c")) self.assertIsInstance(value_pb, Value) self.assertIsInstance(value_pb.list_value, ListValue) values = value_pb.list_value.values - self.assertEqual([value.string_value for value in values], [u"a", u"b", u"c"]) + self.assertEqual([value.string_value for value in values], ["a", "b", "c"]) def test_w_bool(self): from google.protobuf.struct_pb2 import Value @@ -290,7 +290,9 @@ def test_w_numeric_precision_and_scale_invalid(self): for value, err_msg in cases: with self.subTest(value=value, err_msg=err_msg): self.assertRaisesRegex( - ValueError, err_msg, lambda: self._callFUT(value), + ValueError, + err_msg, + lambda: self._callFUT(value), ) def test_w_json(self): @@ -321,7 +323,7 @@ def test_empty(self): def test_w_single_value(self): from google.protobuf.struct_pb2 import ListValue - VALUE = u"value" + VALUE = "value" result = self._callFUT(values=[VALUE]) self.assertIsInstance(result, ListValue) self.assertEqual(len(result.values), 1) @@ -330,7 +332,7 @@ def test_w_single_value(self): def test_w_multiple_values(self): from google.protobuf.struct_pb2 import ListValue - VALUE_1 = u"value" + VALUE_1 = "value" VALUE_2 = 42 result = self._callFUT(values=[VALUE_1, VALUE_2]) self.assertIsInstance(result, ListValue) @@ -363,7 +365,7 @@ def test_w_single_values(self): def test_w_multiple_values(self): from google.protobuf.struct_pb2 import ListValue - values = [[0, u"A"], [1, u"B"]] + values = [[0, "A"], [1, "B"]] result = self._callFUT(values=values) self.assertEqual(len(result), len(values)) for found, expected in zip(result, values): @@ -394,7 +396,7 @@ def test_w_string(self): from google.cloud.spanner_v1 import Type from google.cloud.spanner_v1 import TypeCode - VALUE = u"Value" + VALUE = "Value" field_type = Type(code=TypeCode.STRING) value_pb = Value(string_value=VALUE) @@ -537,7 +539,7 @@ def test_w_struct(self): from google.cloud.spanner_v1 import TypeCode from google.cloud.spanner_v1._helpers import _make_list_value_pb - VALUES = [u"phred", 32] + VALUES = ["phred", 32] struct_type_pb = StructType( fields=[ StructType.Field(name="name", type_=Type(code=TypeCode.STRING)), @@ -621,7 +623,7 @@ def test_non_empty(self): from google.cloud.spanner_v1 import TypeCode from google.cloud.spanner_v1._helpers import _make_list_value_pbs - VALUES = [[u"phred", 32], [u"bharney", 31]] + VALUES = [["phred", 32], ["bharney", 31]] struct_type_pb = StructType( fields=[ StructType.Field(name="name", type_=Type(code=TypeCode.STRING)), diff --git a/tests/unit/test_backup.py b/tests/unit/test_backup.py index 035a2c9605..00621c2148 100644 --- a/tests/unit/test_backup.py +++ b/tests/unit/test_backup.py @@ -241,17 +241,23 @@ def test_create_grpc_error(self): self.BACKUP_ID, instance, database=self.DATABASE_NAME, expire_time=timestamp ) - backup_pb = Backup(database=self.DATABASE_NAME, expire_time=timestamp,) + backup_pb = Backup( + database=self.DATABASE_NAME, + expire_time=timestamp, + ) with self.assertRaises(GoogleAPICallError): backup.create() request = CreateBackupRequest( - parent=self.INSTANCE_NAME, backup_id=self.BACKUP_ID, backup=backup_pb, + parent=self.INSTANCE_NAME, + backup_id=self.BACKUP_ID, + backup=backup_pb, ) api.create_backup.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", backup.name)], + request=request, + metadata=[("google-cloud-resource-prefix", backup.name)], ) def test_create_already_exists(self): @@ -269,17 +275,23 @@ def test_create_already_exists(self): self.BACKUP_ID, instance, database=self.DATABASE_NAME, expire_time=timestamp ) - backup_pb = Backup(database=self.DATABASE_NAME, expire_time=timestamp,) + backup_pb = Backup( + database=self.DATABASE_NAME, + expire_time=timestamp, + ) with self.assertRaises(Conflict): backup.create() request = CreateBackupRequest( - parent=self.INSTANCE_NAME, backup_id=self.BACKUP_ID, backup=backup_pb, + parent=self.INSTANCE_NAME, + backup_id=self.BACKUP_ID, + backup=backup_pb, ) api.create_backup.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", backup.name)], + request=request, + metadata=[("google-cloud-resource-prefix", backup.name)], ) def test_create_instance_not_found(self): @@ -297,17 +309,23 @@ def test_create_instance_not_found(self): self.BACKUP_ID, instance, database=self.DATABASE_NAME, expire_time=timestamp ) - backup_pb = Backup(database=self.DATABASE_NAME, expire_time=timestamp,) + backup_pb = Backup( + database=self.DATABASE_NAME, + expire_time=timestamp, + ) with self.assertRaises(NotFound): backup.create() request = CreateBackupRequest( - parent=self.INSTANCE_NAME, backup_id=self.BACKUP_ID, backup=backup_pb, + parent=self.INSTANCE_NAME, + backup_id=self.BACKUP_ID, + backup=backup_pb, ) api.create_backup.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", backup.name)], + request=request, + metadata=[("google-cloud-resource-prefix", backup.name)], ) def test_create_expire_time_not_set(self): @@ -370,7 +388,8 @@ def test_create_success(self): ) api.create_backup.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", backup.name)], + request=request, + metadata=[("google-cloud-resource-prefix", backup.name)], ) def test_create_w_invalid_encryption_config(self): @@ -585,7 +604,10 @@ def test_update_expire_time_grpc_error(self): with self.assertRaises(Unknown): backup.update_expire_time(expire_time) - backup_update = Backup(name=self.BACKUP_NAME, expire_time=expire_time,) + backup_update = Backup( + name=self.BACKUP_NAME, + expire_time=expire_time, + ) update_mask = {"paths": ["expire_time"]} api.update_backup.assert_called_once_with( backup=backup_update, @@ -607,7 +629,10 @@ def test_update_expire_time_not_found(self): with self.assertRaises(NotFound): backup.update_expire_time(expire_time) - backup_update = Backup(name=self.BACKUP_NAME, expire_time=expire_time,) + backup_update = Backup( + name=self.BACKUP_NAME, + expire_time=expire_time, + ) update_mask = {"paths": ["expire_time"]} api.update_backup.assert_called_once_with( backup=backup_update, @@ -627,7 +652,10 @@ def test_update_expire_time_success(self): backup.update_expire_time(expire_time) - backup_update = Backup(name=self.BACKUP_NAME, expire_time=expire_time,) + backup_update = Backup( + name=self.BACKUP_NAME, + expire_time=expire_time, + ) update_mask = {"paths": ["expire_time"]} api.update_backup.assert_called_once_with( backup=backup_update, diff --git a/tests/unit/test_batch.py b/tests/unit/test_batch.py index d6af07ce7e..2d685acfbf 100644 --- a/tests/unit/test_batch.py +++ b/tests/unit/test_batch.py @@ -20,8 +20,8 @@ TABLE_NAME = "citizens" COLUMNS = ["email", "first_name", "last_name", "age"] VALUES = [ - [u"phred@exammple.com", u"Phred", u"Phlyntstone", 32], - [u"bharney@example.com", u"Bharney", u"Rhubble", 31], + ["phred@exammple.com", "Phred", "Phlyntstone", 32], + ["bharney@example.com", "Bharney", "Rhubble", 31], ] BASE_ATTRIBUTES = { "db.type": "spanner", @@ -293,16 +293,21 @@ def _test_commit_with_request_options(self, request_options=None): ) def test_commit_w_request_tag_success(self): - request_options = RequestOptions(request_tag="tag-1",) + request_options = RequestOptions( + request_tag="tag-1", + ) self._test_commit_with_request_options(request_options=request_options) def test_commit_w_transaction_tag_success(self): - request_options = RequestOptions(transaction_tag="tag-1-1",) + request_options = RequestOptions( + transaction_tag="tag-1-1", + ) self._test_commit_with_request_options(request_options=request_options) def test_commit_w_request_and_transaction_tag_success(self): request_options = RequestOptions( - request_tag="tag-1", transaction_tag="tag-1-1", + request_tag="tag-1", + transaction_tag="tag-1-1", ) self._test_commit_with_request_options(request_options=request_options) @@ -412,7 +417,9 @@ def __init__(self, **kwargs): self.__dict__.update(**kwargs) def commit( - self, request=None, metadata=None, + self, + request=None, + metadata=None, ): from google.api_core.exceptions import Unknown diff --git a/tests/unit/test_database.py b/tests/unit/test_database.py index df5554d153..9cabc99945 100644 --- a/tests/unit/test_database.py +++ b/tests/unit/test_database.py @@ -777,7 +777,9 @@ def test_update_ddl_grpc_error(self): database.update_ddl(DDL_STATEMENTS) expected_request = UpdateDatabaseDdlRequest( - database=self.DATABASE_NAME, statements=DDL_STATEMENTS, operation_id="", + database=self.DATABASE_NAME, + statements=DDL_STATEMENTS, + operation_id="", ) api.update_database_ddl.assert_called_once_with( @@ -801,7 +803,9 @@ def test_update_ddl_not_found(self): database.update_ddl(DDL_STATEMENTS) expected_request = UpdateDatabaseDdlRequest( - database=self.DATABASE_NAME, statements=DDL_STATEMENTS, operation_id="", + database=self.DATABASE_NAME, + statements=DDL_STATEMENTS, + operation_id="", ) api.update_database_ddl.assert_called_once_with( @@ -826,7 +830,9 @@ def test_update_ddl(self): self.assertIs(future, op_future) expected_request = UpdateDatabaseDdlRequest( - database=self.DATABASE_NAME, statements=DDL_STATEMENTS, operation_id="", + database=self.DATABASE_NAME, + statements=DDL_STATEMENTS, + operation_id="", ) api.update_database_ddl.assert_called_once_with( @@ -1071,12 +1077,14 @@ def test_execute_partitioned_dml_w_request_options(self): def test_execute_partitioned_dml_w_trx_tag_ignored(self): self._execute_partitioned_dml_helper( - dml=DML_W_PARAM, request_options=RequestOptions(transaction_tag="trx-tag"), + dml=DML_W_PARAM, + request_options=RequestOptions(transaction_tag="trx-tag"), ) def test_execute_partitioned_dml_w_req_tag_used(self): self._execute_partitioned_dml_helper( - dml=DML_W_PARAM, request_options=RequestOptions(request_tag="req-tag"), + dml=DML_W_PARAM, + request_options=RequestOptions(request_tag="req-tag"), ) def test_execute_partitioned_dml_wo_params_retry_aborted(self): @@ -1598,7 +1606,8 @@ def test_context_mgr_success(self): request_options=RequestOptions(transaction_tag=self.TRANSACTION_TAG), ) api.commit.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", database.name)], + request=request, + metadata=[("google-cloud-resource-prefix", database.name)], ) def test_context_mgr_w_commit_stats_success(self): @@ -1641,7 +1650,8 @@ def test_context_mgr_w_commit_stats_success(self): request_options=RequestOptions(), ) api.commit.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", database.name)], + request=request, + metadata=[("google-cloud-resource-prefix", database.name)], ) database.logger.info.assert_called_once_with( @@ -1681,7 +1691,8 @@ def test_context_mgr_w_commit_stats_error(self): request_options=RequestOptions(), ) api.commit.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", database.name)], + request=request, + metadata=[("google-cloud-resource-prefix", database.name)], ) database.logger.info.assert_not_called() diff --git a/tests/unit/test_keyset.py b/tests/unit/test_keyset.py index 86a814c752..a7bad4070d 100644 --- a/tests/unit/test_keyset.py +++ b/tests/unit/test_keyset.py @@ -30,19 +30,19 @@ def test_ctor_no_start_no_end(self): self._make_one() def test_ctor_w_start_open_and_start_closed(self): - KEY_1 = [u"key_1"] - KEY_2 = [u"key_2"] + KEY_1 = ["key_1"] + KEY_2 = ["key_2"] with self.assertRaises(ValueError): self._make_one(start_open=KEY_1, start_closed=KEY_2) def test_ctor_w_end_open_and_end_closed(self): - KEY_1 = [u"key_1"] - KEY_2 = [u"key_2"] + KEY_1 = ["key_1"] + KEY_2 = ["key_2"] with self.assertRaises(ValueError): self._make_one(end_open=KEY_1, end_closed=KEY_2) def test_ctor_w_only_start_open(self): - KEY_1 = [u"key_1"] + KEY_1 = ["key_1"] krange = self._make_one(start_open=KEY_1) self.assertEqual(krange.start_open, KEY_1) self.assertEqual(krange.start_closed, None) @@ -50,7 +50,7 @@ def test_ctor_w_only_start_open(self): self.assertEqual(krange.end_closed, []) def test_ctor_w_only_start_closed(self): - KEY_1 = [u"key_1"] + KEY_1 = ["key_1"] krange = self._make_one(start_closed=KEY_1) self.assertEqual(krange.start_open, None) self.assertEqual(krange.start_closed, KEY_1) @@ -58,7 +58,7 @@ def test_ctor_w_only_start_closed(self): self.assertEqual(krange.end_closed, []) def test_ctor_w_only_end_open(self): - KEY_1 = [u"key_1"] + KEY_1 = ["key_1"] krange = self._make_one(end_open=KEY_1) self.assertEqual(krange.start_open, None) self.assertEqual(krange.start_closed, []) @@ -66,7 +66,7 @@ def test_ctor_w_only_end_open(self): self.assertEqual(krange.end_closed, None) def test_ctor_w_only_end_closed(self): - KEY_1 = [u"key_1"] + KEY_1 = ["key_1"] krange = self._make_one(end_closed=KEY_1) self.assertEqual(krange.start_open, None) self.assertEqual(krange.start_closed, []) @@ -74,8 +74,8 @@ def test_ctor_w_only_end_closed(self): self.assertEqual(krange.end_closed, KEY_1) def test_ctor_w_start_open_and_end_closed(self): - KEY_1 = [u"key_1"] - KEY_2 = [u"key_2"] + KEY_1 = ["key_1"] + KEY_2 = ["key_2"] krange = self._make_one(start_open=KEY_1, end_closed=KEY_2) self.assertEqual(krange.start_open, KEY_1) self.assertEqual(krange.start_closed, None) @@ -83,8 +83,8 @@ def test_ctor_w_start_open_and_end_closed(self): self.assertEqual(krange.end_closed, KEY_2) def test_ctor_w_start_closed_and_end_open(self): - KEY_1 = [u"key_1"] - KEY_2 = [u"key_2"] + KEY_1 = ["key_1"] + KEY_2 = ["key_2"] krange = self._make_one(start_closed=KEY_1, end_open=KEY_2) self.assertEqual(krange.start_open, None) self.assertEqual(krange.start_closed, KEY_1) @@ -92,24 +92,24 @@ def test_ctor_w_start_closed_and_end_open(self): self.assertEqual(krange.end_closed, None) def test___eq___self(self): - key_1 = [u"key_1"] + key_1 = ["key_1"] krange = self._make_one(end_open=key_1) self.assertEqual(krange, krange) def test___eq___other_type(self): - key_1 = [u"key_1"] + key_1 = ["key_1"] krange = self._make_one(end_open=key_1) self.assertNotEqual(krange, object()) def test___eq___other_hit(self): - key_1 = [u"key_1"] + key_1 = ["key_1"] krange = self._make_one(end_open=key_1) other = self._make_one(end_open=key_1) self.assertEqual(krange, other) def test___eq___other(self): - key_1 = [u"key_1"] - key_2 = [u"key_2"] + key_1 = ["key_1"] + key_2 = ["key_2"] krange = self._make_one(end_open=key_1) other = self._make_one(start_closed=key_2, end_open=key_1) self.assertNotEqual(krange, other) @@ -117,18 +117,21 @@ def test___eq___other(self): def test_to_pb_w_start_closed_and_end_open(self): from google.cloud.spanner_v1.types.keys import KeyRange as KeyRangePB - key1 = u"key_1" - key2 = u"key_2" + key1 = "key_1" + key2 = "key_2" key_range = self._make_one(start_closed=[key1], end_open=[key2]) key_range_pb = key_range._to_pb() - expected = KeyRangePB(start_closed=[key1], end_open=[key2],) + expected = KeyRangePB( + start_closed=[key1], + end_open=[key2], + ) self.assertEqual(key_range_pb, expected) def test_to_pb_w_start_open_and_end_closed(self): from google.cloud.spanner_v1.types.keys import KeyRange as KeyRangePB - key1 = u"key_1" - key2 = u"key_2" + key1 = "key_1" + key2 = "key_2" key_range = self._make_one(start_open=[key1], end_closed=[key2]) key_range_pb = key_range._to_pb() expected = KeyRangePB(start_open=[key1], end_closed=[key2]) @@ -137,28 +140,28 @@ def test_to_pb_w_start_open_and_end_closed(self): def test_to_pb_w_empty_list(self): from google.cloud.spanner_v1.types.keys import KeyRange as KeyRangePB - key = u"key" + key = "key" key_range = self._make_one(start_closed=[], end_closed=[key]) key_range_pb = key_range._to_pb() expected = KeyRangePB(start_closed=[], end_closed=[key]) self.assertEqual(key_range_pb, expected) def test_to_dict_w_start_closed_and_end_open(self): - key1 = u"key_1" - key2 = u"key_2" + key1 = "key_1" + key2 = "key_2" key_range = self._make_one(start_closed=[key1], end_open=[key2]) expected = {"start_closed": [key1], "end_open": [key2]} self.assertEqual(key_range._to_dict(), expected) def test_to_dict_w_start_open_and_end_closed(self): - key1 = u"key_1" - key2 = u"key_2" + key1 = "key_1" + key2 = "key_2" key_range = self._make_one(start_open=[key1], end_closed=[key2]) expected = {"start_open": [key1], "end_closed": [key2]} self.assertEqual(key_range._to_dict(), expected) def test_to_dict_w_end_closed(self): - key = u"key" + key = "key" key_range = self._make_one(end_closed=[key]) expected = {"end_closed": [key]} self.assertEqual(key_range._to_dict(), expected) @@ -181,7 +184,7 @@ def test_ctor_w_all(self): self.assertEqual(keyset.ranges, []) def test_ctor_w_keys(self): - KEYS = [[u"key1"], [u"key2"]] + KEYS = [["key1"], ["key2"]] keyset = self._make_one(keys=KEYS) @@ -192,8 +195,8 @@ def test_ctor_w_keys(self): def test_ctor_w_ranges(self): from google.cloud.spanner_v1.keyset import KeyRange - range_1 = KeyRange(start_closed=[u"key1"], end_open=[u"key3"]) - range_2 = KeyRange(start_open=[u"key5"], end_closed=[u"key6"]) + range_1 = KeyRange(start_closed=["key1"], end_open=["key3"]) + range_2 = KeyRange(start_open=["key5"], end_closed=["key6"]) keyset = self._make_one(ranges=[range_1, range_2]) @@ -209,8 +212,8 @@ def test_ctor_w_all_and_keys(self): def test_ctor_w_all_and_ranges(self): from google.cloud.spanner_v1.keyset import KeyRange - range_1 = KeyRange(start_closed=[u"key1"], end_open=[u"key3"]) - range_2 = KeyRange(start_open=[u"key5"], end_closed=[u"key6"]) + range_1 = KeyRange(start_closed=["key1"], end_open=["key3"]) + range_2 = KeyRange(start_open=["key5"], end_closed=["key6"]) with self.assertRaises(ValueError): self._make_one(all_=True, ranges=[range_1, range_2]) @@ -229,13 +232,13 @@ def test___eq___w_all_hit(self): self.assertEqual(keyset, other) def test___eq___w_all_miss(self): - keys = [[u"key1"], [u"key2"]] + keys = [["key1"], ["key2"]] keyset = self._make_one(all_=True) other = self._make_one(keys=keys) self.assertNotEqual(keyset, other) def test___eq___w_keys_hit(self): - keys = [[u"key1"], [u"key2"]] + keys = [["key1"], ["key2"]] keyset = self._make_one(keys=keys) other = self._make_one(keys=keys) @@ -243,7 +246,7 @@ def test___eq___w_keys_hit(self): self.assertEqual(keyset, other) def test___eq___w_keys_miss(self): - keys = [[u"key1"], [u"key2"]] + keys = [["key1"], ["key2"]] keyset = self._make_one(keys=keys[:1]) other = self._make_one(keys=keys[1:]) @@ -253,8 +256,8 @@ def test___eq___w_keys_miss(self): def test___eq___w_ranges_hit(self): from google.cloud.spanner_v1.keyset import KeyRange - range_1 = KeyRange(start_closed=[u"key1"], end_open=[u"key3"]) - range_2 = KeyRange(start_open=[u"key5"], end_closed=[u"key6"]) + range_1 = KeyRange(start_closed=["key1"], end_open=["key3"]) + range_2 = KeyRange(start_open=["key5"], end_closed=["key6"]) keyset = self._make_one(ranges=[range_1, range_2]) other = self._make_one(ranges=[range_1, range_2]) @@ -264,8 +267,8 @@ def test___eq___w_ranges_hit(self): def test___eq___w_ranges_miss(self): from google.cloud.spanner_v1.keyset import KeyRange - range_1 = KeyRange(start_closed=[u"key1"], end_open=[u"key3"]) - range_2 = KeyRange(start_open=[u"key5"], end_closed=[u"key6"]) + range_1 = KeyRange(start_closed=["key1"], end_open=["key3"]) + range_2 = KeyRange(start_open=["key5"], end_closed=["key6"]) keyset = self._make_one(ranges=[range_1]) other = self._make_one(ranges=[range_2]) @@ -287,7 +290,7 @@ def test_to_pb_w_all(self): def test_to_pb_w_only_keys(self): from google.cloud.spanner_v1 import KeySetPB - KEYS = [[u"key1"], [u"key2"]] + KEYS = [["key1"], ["key2"]] keyset = self._make_one(keys=KEYS) result = keyset._to_pb() @@ -307,10 +310,10 @@ def test_to_pb_w_only_ranges(self): from google.cloud.spanner_v1 import KeySetPB from google.cloud.spanner_v1.keyset import KeyRange - KEY_1 = u"KEY_1" - KEY_2 = u"KEY_2" - KEY_3 = u"KEY_3" - KEY_4 = u"KEY_4" + KEY_1 = "KEY_1" + KEY_2 = "KEY_2" + KEY_3 = "KEY_3" + KEY_4 = "KEY_4" RANGES = [ KeyRange(start_open=KEY_1, end_closed=KEY_2), KeyRange(start_closed=KEY_3, end_open=KEY_4), @@ -337,7 +340,7 @@ def test_to_dict_w_all(self): self.assertEqual(keyset._to_dict(), expected) def test_to_dict_w_only_keys(self): - KEYS = [[u"key1"], [u"key2"]] + KEYS = [["key1"], ["key2"]] keyset = self._make_one(keys=KEYS) expected = {"keys": KEYS, "ranges": []} @@ -346,10 +349,10 @@ def test_to_dict_w_only_keys(self): def test_to_dict_w_only_ranges(self): from google.cloud.spanner_v1.keyset import KeyRange - key_1 = u"KEY_1" - key_2 = u"KEY_2" - key_3 = u"KEY_3" - key_4 = u"KEY_4" + key_1 = "KEY_1" + key_2 = "KEY_2" + key_3 = "KEY_3" + key_4 = "KEY_4" ranges = [ KeyRange(start_open=[key_1], end_closed=[key_2]), KeyRange(start_closed=[key_3], end_open=[key_4]), @@ -377,7 +380,7 @@ def test_from_dict_w_all(self): def test_from_dict_w_keys(self): klass = self._get_target_class() - keys = [[u"key1"], [u"key2"]] + keys = [["key1"], ["key2"]] mapping = {"keys": keys} keyset = klass._from_dict(mapping) @@ -390,10 +393,10 @@ def test_from_dict_w_ranges(self): from google.cloud.spanner_v1.keyset import KeyRange klass = self._get_target_class() - key_1 = u"KEY_1" - key_2 = u"KEY_2" - key_3 = u"KEY_3" - key_4 = u"KEY_4" + key_1 = "KEY_1" + key_2 = "KEY_2" + key_3 = "KEY_3" + key_4 = "KEY_4" mapping = { "ranges": [ {"start_open": [key_1], "end_closed": [key_2]}, diff --git a/tests/unit/test_session.py b/tests/unit/test_session.py index fe78567f6b..0f297654bb 100644 --- a/tests/unit/test_session.py +++ b/tests/unit/test_session.py @@ -140,7 +140,9 @@ def test_create_ok(self): self.assertEqual(session.session_id, self.SESSION_ID) - request = CreateSessionRequest(database=database.name,) + request = CreateSessionRequest( + database=database.name, + ) gax_api.create_session.assert_called_once_with( request=request, metadata=[("google-cloud-resource-prefix", database.name)] @@ -167,11 +169,13 @@ def test_create_w_labels(self): self.assertEqual(session.session_id, self.SESSION_ID) request = CreateSessionRequest( - database=database.name, session=SessionPB(labels=labels), + database=database.name, + session=SessionPB(labels=labels), ) gax_api.create_session.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", database.name)], + request=request, + metadata=[("google-cloud-resource-prefix", database.name)], ) self.assertSpanAttributes( @@ -334,10 +338,14 @@ def test_ping_hit(self): session.ping() - request = ExecuteSqlRequest(session=self.SESSION_NAME, sql="SELECT 1",) + request = ExecuteSqlRequest( + session=self.SESSION_NAME, + sql="SELECT 1", + ) gax_api.execute_sql.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", database.name)], + request=request, + metadata=[("google-cloud-resource-prefix", database.name)], ) def test_ping_miss(self): @@ -354,10 +362,14 @@ def test_ping_miss(self): with self.assertRaises(NotFound): session.ping() - request = ExecuteSqlRequest(session=self.SESSION_NAME, sql="SELECT 1",) + request = ExecuteSqlRequest( + session=self.SESSION_NAME, + sql="SELECT 1", + ) gax_api.execute_sql.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", database.name)], + request=request, + metadata=[("google-cloud-resource-prefix", database.name)], ) def test_ping_error(self): @@ -374,10 +386,14 @@ def test_ping_error(self): with self.assertRaises(Unknown): session.ping() - request = ExecuteSqlRequest(session=self.SESSION_NAME, sql="SELECT 1",) + request = ExecuteSqlRequest( + session=self.SESSION_NAME, + sql="SELECT 1", + ) gax_api.execute_sql.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", database.name)], + request=request, + metadata=[("google-cloud-resource-prefix", database.name)], ) def test_delete_wo_session_id(self): @@ -833,7 +849,8 @@ def unit_of_work(txn, *args, **kw): request_options=RequestOptions(), ) gax_api.commit.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", database.name)], + request=request, + metadata=[("google-cloud-resource-prefix", database.name)], ) def test_run_in_transaction_w_commit_error(self): @@ -884,7 +901,8 @@ def unit_of_work(txn, *args, **kw): request_options=RequestOptions(), ) gax_api.commit.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", database.name)], + request=request, + metadata=[("google-cloud-resource-prefix", database.name)], ) def test_run_in_transaction_w_abort_no_retry_metadata(self): @@ -1141,7 +1159,8 @@ def unit_of_work(txn, *args, **kw): request_options=RequestOptions(), ) gax_api.commit.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", database.name)], + request=request, + metadata=[("google-cloud-resource-prefix", database.name)], ) def test_run_in_transaction_w_abort_w_retry_metadata_deadline(self): @@ -1232,7 +1251,8 @@ def _time(_results=[1, 1.5]): request_options=RequestOptions(), ) gax_api.commit.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", database.name)], + request=request, + metadata=[("google-cloud-resource-prefix", database.name)], ) def test_run_in_transaction_w_timeout(self): @@ -1388,7 +1408,8 @@ def unit_of_work(txn, *args, **kw): request_options=RequestOptions(), ) gax_api.commit.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", database.name)], + request=request, + metadata=[("google-cloud-resource-prefix", database.name)], ) database.logger.info.assert_called_once_with( "CommitStats: mutation_count: 4\n", extra={"commit_stats": commit_stats} @@ -1451,7 +1472,8 @@ def unit_of_work(txn, *args, **kw): request_options=RequestOptions(), ) gax_api.commit.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", database.name)], + request=request, + metadata=[("google-cloud-resource-prefix", database.name)], ) database.logger.info.assert_not_called() @@ -1520,7 +1542,8 @@ def unit_of_work(txn, *args, **kw): request_options=RequestOptions(transaction_tag=transaction_tag), ) gax_api.commit.assert_called_once_with( - request=request, metadata=[("google-cloud-resource-prefix", database.name)], + request=request, + metadata=[("google-cloud-resource-prefix", database.name)], ) def test_delay_helper_w_no_delay(self): diff --git a/tests/unit/test_snapshot.py b/tests/unit/test_snapshot.py index ef162fd29d..5b515f1bbb 100644 --- a/tests/unit/test_snapshot.py +++ b/tests/unit/test_snapshot.py @@ -420,7 +420,7 @@ def _read_helper( from google.cloud.spanner_v1.keyset import KeySet from google.cloud.spanner_v1._helpers import _make_value_pb - VALUES = [[u"bharney", 31], [u"phred", 32]] + VALUES = [["bharney", 31], ["phred", 32]] VALUE_PBS = [[_make_value_pb(item) for item in row] for row in VALUES] struct_type_pb = StructType( fields=[ @@ -541,16 +541,21 @@ def test_read_wo_multi_use(self): self._read_helper(multi_use=False) def test_read_w_request_tag_success(self): - request_options = RequestOptions(request_tag="tag-1",) + request_options = RequestOptions( + request_tag="tag-1", + ) self._read_helper(multi_use=False, request_options=request_options) def test_read_w_transaction_tag_success(self): - request_options = RequestOptions(transaction_tag="tag-1-1",) + request_options = RequestOptions( + transaction_tag="tag-1-1", + ) self._read_helper(multi_use=False, request_options=request_options) def test_read_w_request_and_transaction_tag_success(self): request_options = RequestOptions( - request_tag="tag-1", transaction_tag="tag-1-1", + request_tag="tag-1", + transaction_tag="tag-1-1", ) self._read_helper(multi_use=False, request_options=request_options) @@ -650,7 +655,7 @@ def _execute_sql_helper( _merge_query_options, ) - VALUES = [[u"bharney", u"rhubbyl", 31], [u"phred", u"phlyntstone", 32]] + VALUES = [["bharney", "rhubbyl", 31], ["phred", "phlyntstone", 32]] VALUE_PBS = [[_make_value_pb(item) for item in row] for row in VALUES] MODE = 2 # PROFILE struct_type_pb = StructType( @@ -807,16 +812,21 @@ def test_execute_sql_w_request_options(self): ) def test_execute_sql_w_request_tag_success(self): - request_options = RequestOptions(request_tag="tag-1",) + request_options = RequestOptions( + request_tag="tag-1", + ) self._execute_sql_helper(multi_use=False, request_options=request_options) def test_execute_sql_w_transaction_tag_success(self): - request_options = RequestOptions(transaction_tag="tag-1-1",) + request_options = RequestOptions( + transaction_tag="tag-1-1", + ) self._execute_sql_helper(multi_use=False, request_options=request_options) def test_execute_sql_w_request_and_transaction_tag_success(self): request_options = RequestOptions( - request_tag="tag-1", transaction_tag="tag-1-1", + request_tag="tag-1", + transaction_tag="tag-1-1", ) self._execute_sql_helper(multi_use=False, request_options=request_options) diff --git a/tests/unit/test_streamed.py b/tests/unit/test_streamed.py index de0c8875bf..2714ddfb45 100644 --- a/tests/unit/test_streamed.py +++ b/tests/unit/test_streamed.py @@ -171,11 +171,11 @@ def test__merge_chunk_numeric(self): streamed = self._make_one(iterator) FIELDS = [self._make_scalar_field("total", TypeCode.NUMERIC)] streamed._metadata = self._make_result_set_metadata(FIELDS) - streamed._pending_chunk = self._make_value(u"1234.") - chunk = self._make_value(u"5678") + streamed._pending_chunk = self._make_value("1234.") + chunk = self._make_value("5678") merged = streamed._merge_chunk(chunk) - self.assertEqual(merged.string_value, u"1234.5678") + self.assertEqual(merged.string_value, "1234.5678") def test__merge_chunk_int64(self): from google.cloud.spanner_v1 import TypeCode @@ -198,11 +198,11 @@ def test__merge_chunk_float64_nan_string(self): streamed = self._make_one(iterator) FIELDS = [self._make_scalar_field("weight", TypeCode.FLOAT64)] streamed._metadata = self._make_result_set_metadata(FIELDS) - streamed._pending_chunk = self._make_value(u"Na") - chunk = self._make_value(u"N") + streamed._pending_chunk = self._make_value("Na") + chunk = self._make_value("N") merged = streamed._merge_chunk(chunk) - self.assertEqual(merged.string_value, u"NaN") + self.assertEqual(merged.string_value, "NaN") def test__merge_chunk_float64_w_empty(self): from google.cloud.spanner_v1 import TypeCode @@ -238,12 +238,12 @@ def test__merge_chunk_string(self): streamed = self._make_one(iterator) FIELDS = [self._make_scalar_field("name", TypeCode.STRING)] streamed._metadata = self._make_result_set_metadata(FIELDS) - streamed._pending_chunk = self._make_value(u"phred") - chunk = self._make_value(u"wylma") + streamed._pending_chunk = self._make_value("phred") + chunk = self._make_value("wylma") merged = streamed._merge_chunk(chunk) - self.assertEqual(merged.string_value, u"phredwylma") + self.assertEqual(merged.string_value, "phredwylma") self.assertIsNone(streamed._pending_chunk) def test__merge_chunk_string_w_bytes(self): @@ -254,21 +254,21 @@ def test__merge_chunk_string_w_bytes(self): FIELDS = [self._make_scalar_field("image", TypeCode.BYTES)] streamed._metadata = self._make_result_set_metadata(FIELDS) streamed._pending_chunk = self._make_value( - u"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA" - u"6fptVAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA\n" + "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA" + "6fptVAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA\n" ) chunk = self._make_value( - u"B3RJTUUH4QQGFwsBTL3HMwAAABJpVFh0Q29tbWVudAAAAAAAU0FNUExF" - u"MG3E+AAAAApJREFUCNdj\nYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\n" + "B3RJTUUH4QQGFwsBTL3HMwAAABJpVFh0Q29tbWVudAAAAAAAU0FNUExF" + "MG3E+AAAAApJREFUCNdj\nYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\n" ) merged = streamed._merge_chunk(chunk) self.assertEqual( merged.string_value, - u"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAACXBIWXMAAAsTAAAL" - u"EwEAmpwYAAAA\nB3RJTUUH4QQGFwsBTL3HMwAAABJpVFh0Q29tbWVudAAAAAAAU0" - u"FNUExFMG3E+AAAAApJREFUCNdj\nYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\n", + "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAACXBIWXMAAAsTAAAL" + "EwEAmpwYAAAA\nB3RJTUUH4QQGFwsBTL3HMwAAABJpVFh0Q29tbWVudAAAAAAAU0" + "FNUExFMG3E+AAAAApJREFUCNdj\nYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\n", ) self.assertIsNone(streamed._pending_chunk) @@ -332,12 +332,12 @@ def test__merge_chunk_array_of_string_with_empty(self): streamed = self._make_one(iterator) FIELDS = [self._make_array_field("name", element_type_code=TypeCode.STRING)] streamed._metadata = self._make_result_set_metadata(FIELDS) - streamed._pending_chunk = self._make_list_value([u"A", u"B", u"C"]) + streamed._pending_chunk = self._make_list_value(["A", "B", "C"]) chunk = self._make_list_value([]) merged = streamed._merge_chunk(chunk) - expected = self._make_list_value([u"A", u"B", u"C"]) + expected = self._make_list_value(["A", "B", "C"]) self.assertEqual(merged, expected) self.assertIsNone(streamed._pending_chunk) @@ -348,12 +348,12 @@ def test__merge_chunk_array_of_string(self): streamed = self._make_one(iterator) FIELDS = [self._make_array_field("name", element_type_code=TypeCode.STRING)] streamed._metadata = self._make_result_set_metadata(FIELDS) - streamed._pending_chunk = self._make_list_value([u"A", u"B", u"C"]) - chunk = self._make_list_value([u"D", u"E"]) + streamed._pending_chunk = self._make_list_value(["A", "B", "C"]) + chunk = self._make_list_value(["D", "E"]) merged = streamed._merge_chunk(chunk) - expected = self._make_list_value([u"A", u"B", u"CD", u"E"]) + expected = self._make_list_value(["A", "B", "CD", "E"]) self.assertEqual(merged, expected) self.assertIsNone(streamed._pending_chunk) @@ -364,12 +364,12 @@ def test__merge_chunk_array_of_string_with_null(self): streamed = self._make_one(iterator) FIELDS = [self._make_array_field("name", element_type_code=TypeCode.STRING)] streamed._metadata = self._make_result_set_metadata(FIELDS) - streamed._pending_chunk = self._make_list_value([u"A", u"B", u"C"]) - chunk = self._make_list_value([None, u"D", u"E"]) + streamed._pending_chunk = self._make_list_value(["A", "B", "C"]) + chunk = self._make_list_value([None, "D", "E"]) merged = streamed._merge_chunk(chunk) - expected = self._make_list_value([u"A", u"B", u"C", None, u"D", u"E"]) + expected = self._make_list_value(["A", "B", "C", None, "D", "E"]) self.assertEqual(merged, expected) self.assertIsNone(streamed._pending_chunk) @@ -380,10 +380,10 @@ def test__merge_chunk_array_of_string_with_null_pending(self): streamed = self._make_one(iterator) FIELDS = [self._make_array_field("name", element_type_code=TypeCode.STRING)] streamed._metadata = self._make_result_set_metadata(FIELDS) - streamed._pending_chunk = self._make_list_value([u"A", u"B", u"C", None]) - chunk = self._make_list_value([u"D", u"E"]) + streamed._pending_chunk = self._make_list_value(["A", "B", "C", None]) + chunk = self._make_list_value(["D", "E"]) merged = streamed._merge_chunk(chunk) - expected = self._make_list_value([u"A", u"B", u"C", None, u"D", u"E"]) + expected = self._make_list_value(["A", "B", "C", None, "D", "E"]) self.assertEqual(merged, expected) self.assertIsNone(streamed._pending_chunk) @@ -434,14 +434,14 @@ def test__merge_chunk_array_of_array_of_string(self): streamed._metadata = self._make_result_set_metadata(FIELDS) streamed._pending_chunk = self._make_list_value( value_pbs=[ - self._make_list_value([u"A", u"B"]), - self._make_list_value([u"C"]), + self._make_list_value(["A", "B"]), + self._make_list_value(["C"]), ] ) chunk = self._make_list_value( value_pbs=[ - self._make_list_value([u"D"]), - self._make_list_value([u"E", u"F"]), + self._make_list_value(["D"]), + self._make_list_value(["E", "F"]), ] ) @@ -449,9 +449,9 @@ def test__merge_chunk_array_of_array_of_string(self): expected = self._make_list_value( value_pbs=[ - self._make_list_value([u"A", u"B"]), - self._make_list_value([u"CD"]), - self._make_list_value([u"E", u"F"]), + self._make_list_value(["A", "B"]), + self._make_list_value(["CD"]), + self._make_list_value(["E", "F"]), ] ) self.assertEqual(merged, expected) @@ -467,14 +467,14 @@ def test__merge_chunk_array_of_struct(self): ) FIELDS = [self._make_array_field("test", element_type=struct_type)] streamed._metadata = self._make_result_set_metadata(FIELDS) - partial = self._make_list_value([u"Phred "]) + partial = self._make_list_value(["Phred "]) streamed._pending_chunk = self._make_list_value(value_pbs=[partial]) - rest = self._make_list_value([u"Phlyntstone", 31]) + rest = self._make_list_value(["Phlyntstone", 31]) chunk = self._make_list_value(value_pbs=[rest]) merged = streamed._merge_chunk(chunk) - struct = self._make_list_value([u"Phred Phlyntstone", 31]) + struct = self._make_list_value(["Phred Phlyntstone", 31]) expected = self._make_list_value(value_pbs=[struct]) self.assertEqual(merged, expected) self.assertIsNone(streamed._pending_chunk) @@ -489,7 +489,7 @@ def test__merge_chunk_array_of_struct_with_empty(self): ) FIELDS = [self._make_array_field("test", element_type=struct_type)] streamed._metadata = self._make_result_set_metadata(FIELDS) - partial = self._make_list_value([u"Phred "]) + partial = self._make_list_value(["Phred "]) streamed._pending_chunk = self._make_list_value(value_pbs=[partial]) rest = self._make_list_value([]) chunk = self._make_list_value(value_pbs=[rest]) @@ -514,14 +514,14 @@ def test__merge_chunk_array_of_struct_unmergeable(self): ) FIELDS = [self._make_array_field("test", element_type=struct_type)] streamed._metadata = self._make_result_set_metadata(FIELDS) - partial = self._make_list_value([u"Phred Phlyntstone", True]) + partial = self._make_list_value(["Phred Phlyntstone", True]) streamed._pending_chunk = self._make_list_value(value_pbs=[partial]) rest = self._make_list_value([True]) chunk = self._make_list_value(value_pbs=[rest]) merged = streamed._merge_chunk(chunk) - struct = self._make_list_value([u"Phred Phlyntstone", True, True]) + struct = self._make_list_value(["Phred Phlyntstone", True, True]) expected = self._make_list_value(value_pbs=[struct]) self.assertEqual(merged, expected) self.assertIsNone(streamed._pending_chunk) @@ -534,14 +534,14 @@ def test__merge_chunk_array_of_struct_unmergeable_split(self): ) FIELDS = [self._make_array_field("test", element_type=struct_type)] streamed._metadata = self._make_result_set_metadata(FIELDS) - partial = self._make_list_value([u"Phred Phlyntstone", 1.65]) + partial = self._make_list_value(["Phred Phlyntstone", 1.65]) streamed._pending_chunk = self._make_list_value(value_pbs=[partial]) rest = self._make_list_value(["brown"]) chunk = self._make_list_value(value_pbs=[rest]) merged = streamed._merge_chunk(chunk) - struct = self._make_list_value([u"Phred Phlyntstone", 1.65, "brown"]) + struct = self._make_list_value(["Phred Phlyntstone", 1.65, "brown"]) expected = self._make_list_value(value_pbs=[struct]) self.assertEqual(merged, expected) self.assertIsNone(streamed._pending_chunk) @@ -573,7 +573,7 @@ def test_merge_values_empty_and_partial(self): self._make_scalar_field("married", TypeCode.BOOL), ] streamed._metadata = self._make_result_set_metadata(FIELDS) - BARE = [u"Phred Phlyntstone", 42] + BARE = ["Phred Phlyntstone", 42] VALUES = [self._make_value(bare) for bare in BARE] streamed._current_row = [] streamed._merge_values(VALUES) @@ -591,7 +591,7 @@ def test_merge_values_empty_and_filled(self): self._make_scalar_field("married", TypeCode.BOOL), ] streamed._metadata = self._make_result_set_metadata(FIELDS) - BARE = [u"Phred Phlyntstone", 42, True] + BARE = ["Phred Phlyntstone", 42, True] VALUES = [self._make_value(bare) for bare in BARE] streamed._current_row = [] streamed._merge_values(VALUES) @@ -610,13 +610,13 @@ def test_merge_values_empty_and_filled_plus(self): ] streamed._metadata = self._make_result_set_metadata(FIELDS) BARE = [ - u"Phred Phlyntstone", + "Phred Phlyntstone", 42, True, - u"Bharney Rhubble", + "Bharney Rhubble", 39, True, - u"Wylma Phlyntstone", + "Wylma Phlyntstone", ] VALUES = [self._make_value(bare) for bare in BARE] streamed._current_row = [] @@ -635,7 +635,7 @@ def test_merge_values_partial_and_empty(self): self._make_scalar_field("married", TypeCode.BOOL), ] streamed._metadata = self._make_result_set_metadata(FIELDS) - BEFORE = [u"Phred Phlyntstone"] + BEFORE = ["Phred Phlyntstone"] streamed._current_row[:] = BEFORE streamed._merge_values([]) self.assertEqual(list(streamed), []) @@ -652,7 +652,7 @@ def test_merge_values_partial_and_partial(self): self._make_scalar_field("married", TypeCode.BOOL), ] streamed._metadata = self._make_result_set_metadata(FIELDS) - BEFORE = [u"Phred Phlyntstone"] + BEFORE = ["Phred Phlyntstone"] streamed._current_row[:] = BEFORE MERGED = [42] TO_MERGE = [self._make_value(item) for item in MERGED] @@ -671,7 +671,7 @@ def test_merge_values_partial_and_filled(self): self._make_scalar_field("married", TypeCode.BOOL), ] streamed._metadata = self._make_result_set_metadata(FIELDS) - BEFORE = [u"Phred Phlyntstone"] + BEFORE = ["Phred Phlyntstone"] streamed._current_row[:] = BEFORE MERGED = [42, True] TO_MERGE = [self._make_value(item) for item in MERGED] @@ -690,9 +690,9 @@ def test_merge_values_partial_and_filled_plus(self): self._make_scalar_field("married", TypeCode.BOOL), ] streamed._metadata = self._make_result_set_metadata(FIELDS) - BEFORE = [self._make_value(u"Phred Phlyntstone")] + BEFORE = [self._make_value("Phred Phlyntstone")] streamed._current_row[:] = BEFORE - MERGED = [42, True, u"Bharney Rhubble", 39, True, u"Wylma Phlyntstone"] + MERGED = [42, True, "Bharney Rhubble", 39, True, "Wylma Phlyntstone"] TO_MERGE = [self._make_value(item) for item in MERGED] VALUES = BEFORE + MERGED streamed._merge_values(TO_MERGE) @@ -757,7 +757,7 @@ def test_consume_next_first_set_partial(self): self._make_scalar_field("married", TypeCode.BOOL), ] metadata = self._make_result_set_metadata(FIELDS, transaction_id=TXN_ID) - BARE = [u"Phred Phlyntstone", 42] + BARE = ["Phred Phlyntstone", 42] VALUES = [self._make_value(bare) for bare in BARE] result_set = self._make_partial_result_set(VALUES, metadata=metadata) iterator = _MockCancellableIterator(result_set) @@ -779,7 +779,7 @@ def test_consume_next_first_set_partial_existing_txn_id(self): self._make_scalar_field("married", TypeCode.BOOL), ] metadata = self._make_result_set_metadata(FIELDS, transaction_id=b"") - BARE = [u"Phred Phlyntstone", 42] + BARE = ["Phred Phlyntstone", 42] VALUES = [self._make_value(bare) for bare in BARE] result_set = self._make_partial_result_set(VALUES, metadata=metadata) iterator = _MockCancellableIterator(result_set) @@ -799,7 +799,7 @@ def test_consume_next_w_partial_result(self): self._make_scalar_field("age", TypeCode.INT64), self._make_scalar_field("married", TypeCode.BOOL), ] - VALUES = [self._make_value(u"Phred ")] + VALUES = [self._make_value("Phred ")] result_set = self._make_partial_result_set(VALUES, chunked_value=True) iterator = _MockCancellableIterator(result_set) streamed = self._make_one(iterator) @@ -818,24 +818,24 @@ def test_consume_next_w_pending_chunk(self): self._make_scalar_field("married", TypeCode.BOOL), ] BARE = [ - u"Phlyntstone", + "Phlyntstone", 42, True, - u"Bharney Rhubble", + "Bharney Rhubble", 39, True, - u"Wylma Phlyntstone", + "Wylma Phlyntstone", ] VALUES = [self._make_value(bare) for bare in BARE] result_set = self._make_partial_result_set(VALUES) iterator = _MockCancellableIterator(result_set) streamed = self._make_one(iterator) streamed._metadata = self._make_result_set_metadata(FIELDS) - streamed._pending_chunk = self._make_value(u"Phred ") + streamed._pending_chunk = self._make_value("Phred ") streamed._consume_next() self.assertEqual( list(streamed), - [[u"Phred Phlyntstone", BARE[1], BARE[2]], [BARE[3], BARE[4], BARE[5]]], + [["Phred Phlyntstone", BARE[1], BARE[2]], [BARE[3], BARE[4], BARE[5]]], ) self.assertEqual(streamed._current_row, [BARE[6]]) self.assertIsNone(streamed._pending_chunk) @@ -852,7 +852,7 @@ def test_consume_next_last_set(self): stats = self._make_result_set_stats( rows_returned="1", elapsed_time="1.23 secs", cpu_time="0.98 secs" ) - BARE = [u"Phred Phlyntstone", 42, True] + BARE = ["Phred Phlyntstone", 42, True] VALUES = [self._make_value(bare) for bare in BARE] result_set = self._make_partial_result_set(VALUES, stats=stats) iterator = _MockCancellableIterator(result_set) @@ -879,7 +879,7 @@ def test___iter___one_result_set_partial(self): self._make_scalar_field("married", TypeCode.BOOL), ] metadata = self._make_result_set_metadata(FIELDS) - BARE = [u"Phred Phlyntstone", 42] + BARE = ["Phred Phlyntstone", 42] VALUES = [self._make_value(bare) for bare in BARE] for val in VALUES: self.assertIsInstance(val, Value) @@ -902,13 +902,13 @@ def test___iter___multiple_result_sets_filled(self): ] metadata = self._make_result_set_metadata(FIELDS) BARE = [ - u"Phred Phlyntstone", + "Phred Phlyntstone", 42, True, - u"Bharney Rhubble", + "Bharney Rhubble", 39, True, - u"Wylma Phlyntstone", + "Wylma Phlyntstone", 41, True, ] @@ -939,15 +939,15 @@ def test___iter___w_existing_rows_read(self): self._make_scalar_field("married", TypeCode.BOOL), ] metadata = self._make_result_set_metadata(FIELDS) - ALREADY = [[u"Pebbylz Phlyntstone", 4, False], [u"Dino Rhubble", 4, False]] + ALREADY = [["Pebbylz Phlyntstone", 4, False], ["Dino Rhubble", 4, False]] BARE = [ - u"Phred Phlyntstone", + "Phred Phlyntstone", 42, True, - u"Bharney Rhubble", + "Bharney Rhubble", 39, True, - u"Wylma Phlyntstone", + "Wylma Phlyntstone", 41, True, ] @@ -1113,11 +1113,11 @@ def _normalize_int_array(cell): def _normalize_float(cell): - if cell == u"Infinity": + if cell == "Infinity": return float("inf") - if cell == u"-Infinity": + if cell == "-Infinity": return float("-inf") - if cell == u"NaN": + if cell == "NaN": return float("nan") if cell is not None: return float(cell) diff --git a/tests/unit/test_transaction.py b/tests/unit/test_transaction.py index d11a3495fe..d4d9c99c02 100644 --- a/tests/unit/test_transaction.py +++ b/tests/unit/test_transaction.py @@ -388,16 +388,21 @@ def test_commit_w_return_commit_stats(self): self._commit_helper(return_commit_stats=True) def test_commit_w_request_tag_success(self): - request_options = RequestOptions(request_tag="tag-1",) + request_options = RequestOptions( + request_tag="tag-1", + ) self._commit_helper(request_options=request_options) def test_commit_w_transaction_tag_ignored_success(self): - request_options = RequestOptions(transaction_tag="tag-1-1",) + request_options = RequestOptions( + transaction_tag="tag-1-1", + ) self._commit_helper(request_options=request_options) def test_commit_w_request_and_transaction_tag_success(self): request_options = RequestOptions( - request_tag="tag-1", transaction_tag="tag-1-1", + request_tag="tag-1", + transaction_tag="tag-1-1", ) self._commit_helper(request_options=request_options) @@ -545,16 +550,21 @@ def test_execute_update_new_transaction(self): self._execute_update_helper() def test_execute_update_w_request_tag_success(self): - request_options = RequestOptions(request_tag="tag-1",) + request_options = RequestOptions( + request_tag="tag-1", + ) self._execute_update_helper(request_options=request_options) def test_execute_update_w_transaction_tag_success(self): - request_options = RequestOptions(transaction_tag="tag-1-1",) + request_options = RequestOptions( + transaction_tag="tag-1-1", + ) self._execute_update_helper(request_options=request_options) def test_execute_update_w_request_and_transaction_tag_success(self): request_options = RequestOptions( - request_tag="tag-1", transaction_tag="tag-1-1", + request_tag="tag-1", + transaction_tag="tag-1-1", ) self._execute_update_helper(request_options=request_options) @@ -717,16 +727,21 @@ def test_batch_update_wo_errors(self): ) def test_batch_update_w_request_tag_success(self): - request_options = RequestOptions(request_tag="tag-1",) + request_options = RequestOptions( + request_tag="tag-1", + ) self._batch_update_helper(request_options=request_options) def test_batch_update_w_transaction_tag_success(self): - request_options = RequestOptions(transaction_tag="tag-1-1",) + request_options = RequestOptions( + transaction_tag="tag-1-1", + ) self._batch_update_helper(request_options=request_options) def test_batch_update_w_request_and_transaction_tag_success(self): request_options = RequestOptions( - request_tag="tag-1", transaction_tag="tag-1-1", + request_tag="tag-1", + transaction_tag="tag-1-1", ) self._batch_update_helper(request_options=request_options) @@ -874,7 +889,9 @@ def rollback(self, session=None, transaction_id=None, metadata=None): return self._rollback_response def commit( - self, request=None, metadata=None, + self, + request=None, + metadata=None, ): assert not request.single_use_transaction self._committed = ( From 04a742ea2c378bec5b8a72f0473913294775974b Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 6 Apr 2022 15:51:14 -0600 Subject: [PATCH 11/16] chore(python): add license header to auto-label.yaml (#709) Source-Link: https://github.com/googleapis/synthtool/commit/eb78c980b52c7c6746d2edb77d9cf7aaa99a2aab Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163 Co-authored-by: Owl Bot --- .flake8 | 2 +- .github/.OwlBot.lock.yaml | 3 +- .github/auto-label.yaml | 15 ++++++ .pre-commit-config.yaml | 2 +- noxfile.py | 105 ++++++++++++++++++++++++++++++-------- 5 files changed, 104 insertions(+), 23 deletions(-) create mode 100644 .github/auto-label.yaml diff --git a/.flake8 b/.flake8 index 29227d4cf4..2e43874986 100644 --- a/.flake8 +++ b/.flake8 @@ -16,7 +16,7 @@ # Generated by synthtool. DO NOT EDIT! [flake8] -ignore = E203, E266, E501, W503 +ignore = E203, E231, E266, E501, W503 exclude = # Exclude generated code. **/proto/** diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 87dd006115..bc893c979e 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe + digest: sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163 +# created: 2022-04-06T10:30:21.687684602Z diff --git a/.github/auto-label.yaml b/.github/auto-label.yaml new file mode 100644 index 0000000000..41bff0b537 --- /dev/null +++ b/.github/auto-label.yaml @@ -0,0 +1,15 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +requestsize: + enabled: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62eb5a77d9..46d237160f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/psf/black - rev: 19.10b0 + rev: 22.3.0 hooks: - id: black - repo: https://gitlab.com/pycqa/flake8 diff --git a/noxfile.py b/noxfile.py index b00d81b102..08bf4e705e 100644 --- a/noxfile.py +++ b/noxfile.py @@ -20,16 +20,40 @@ import os import pathlib import shutil +import warnings import nox - BLACK_VERSION = "black==22.3.0" BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" -SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] + UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"] +UNIT_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "asyncmock", + "pytest", + "pytest-cov", + "pytest-asyncio", +] +UNIT_TEST_EXTERNAL_DEPENDENCIES = [] +UNIT_TEST_LOCAL_DEPENDENCIES = [] +UNIT_TEST_DEPENDENCIES = [] +UNIT_TEST_EXTRAS = [] +UNIT_TEST_EXTRAS_BY_PYTHON = {} + +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] +SYSTEM_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "pytest", + "google-cloud-testutils", +] +SYSTEM_TEST_EXTERNAL_DEPENDENCIES = [] +SYSTEM_TEST_LOCAL_DEPENDENCIES = [] +SYSTEM_TEST_DEPENDENCIES = [] +SYSTEM_TEST_EXTRAS = [] +SYSTEM_TEST_EXTRAS_BY_PYTHON = {} CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() @@ -81,23 +105,41 @@ def lint_setup_py(session): session.run("python", "setup.py", "check", "--restructuredtext", "--strict") +def install_unittest_dependencies(session, *constraints): + standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES + session.install(*standard_deps, *constraints) + + if UNIT_TEST_EXTERNAL_DEPENDENCIES: + warnings.warn( + "'unit_test_external_dependencies' is deprecated. Instead, please " + "use 'unit_test_dependencies' or 'unit_test_local_dependencies'.", + DeprecationWarning, + ) + session.install(*UNIT_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_LOCAL_DEPENDENCIES: + session.install(*UNIT_TEST_LOCAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_EXTRAS_BY_PYTHON: + extras = UNIT_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif UNIT_TEST_EXTRAS: + extras = UNIT_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + def default(session): # Install all test dependencies, then install this package in-place. constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) - session.install( - "mock", - "asyncmock", - "pytest", - "pytest-cov", - "pytest-asyncio", - "-c", - constraints_path, - ) - - session.install("-e", ".", "-c", constraints_path) + install_unittest_dependencies(session, "-c", constraints_path) # Run py.test against the unit tests. session.run( @@ -142,6 +184,35 @@ def unit(session): default(session) +def install_systemtest_dependencies(session, *constraints): + + # Use pre-release gRPC for system tests. + session.install("--pre", "grpcio") + + session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTERNAL_DEPENDENCIES: + session.install(*SYSTEM_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_LOCAL_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_LOCAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTRAS_BY_PYTHON: + extras = SYSTEM_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif SYSTEM_TEST_EXTRAS: + extras = SYSTEM_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) def system(session): """Run the system test suite.""" @@ -172,13 +243,7 @@ def system(session): if not system_test_exists and not system_test_folder_exists: session.skip("System tests were not found") - # Use pre-release gRPC for system tests. - session.install("--pre", "grpcio") - - # Install all test dependencies, then install this package into the - # virtualenv's dist-packages. - session.install("mock", "pytest", "google-cloud-testutils", "-c", constraints_path) - session.install("-e", ".[tracing]", "-c", constraints_path) + install_systemtest_dependencies(session, "-c", constraints_path) # Run py.test against the system tests. if system_test_exists: From 879c55bfa03500cfc2dc8b91e28b72d4b2750193 Mon Sep 17 00:00:00 2001 From: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Date: Thu, 7 Apr 2022 09:15:04 -0600 Subject: [PATCH 12/16] chore: allow releases from previous major versions (#708) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: allow releases from previous major versions * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: add config to owlbot.py * chore: update postprocessor SHA Co-authored-by: Owl Bot --- .github/.OwlBot.lock.yaml | 3 +-- .github/release-please.yml | 12 ++++++++++++ owlbot.py | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index bc893c979e..51b61ba529 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163 -# created: 2022-04-06T10:30:21.687684602Z + digest: sha256:266a3407f0bb34374f49b6556ee20ee819374587246dcc19405b502ec70113b6 diff --git a/.github/release-please.yml b/.github/release-please.yml index 466597e5b1..5161ab347c 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1,2 +1,14 @@ releaseType: python handleGHRelease: true +# NOTE: this section is generated by synthtool.languages.python +# See https://github.com/googleapis/synthtool/blob/master/synthtool/languages/python.py +branches: +- branch: v2 + handleGHRelease: true + releaseType: python +- branch: v1 + handleGHRelease: true + releaseType: python +- branch: v0 + handleGHRelease: true + releaseType: python diff --git a/owlbot.py b/owlbot.py index 673a1a8a70..31f458d691 100644 --- a/owlbot.py +++ b/owlbot.py @@ -160,6 +160,7 @@ def get_staging_dirs( # Update samples folder in CONTRIBUTING.rst s.replace("CONTRIBUTING.rst", "samples/snippets", "samples/samples") +python.configure_previous_major_version_branches() # ---------------------------------------------------------------------------- # Samples templates # ---------------------------------------------------------------------------- From e54899cc692d5583e979b77a1c1bdd82b81a5983 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sat, 9 Apr 2022 20:05:30 -0400 Subject: [PATCH 13/16] chore(python): refactor unit / system test dependency install (#700) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: upgrade black in noxfile.py to 22.3.0 Source-Link: https://github.com/googleapis/synthtool/commit/0dcf73928241fa27d7768e14c435e3d9f526beac Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:9ce2de2e0a59b6ae3b1eb216f441ee0dea59b1cfc08109d03613916d09d25a35 * ci: add extras for system tests * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- noxfile.py | 4 +++- owlbot.py | 17 +++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/noxfile.py b/noxfile.py index 08bf4e705e..efe3b70104 100644 --- a/noxfile.py +++ b/noxfile.py @@ -52,7 +52,9 @@ SYSTEM_TEST_EXTERNAL_DEPENDENCIES = [] SYSTEM_TEST_LOCAL_DEPENDENCIES = [] SYSTEM_TEST_DEPENDENCIES = [] -SYSTEM_TEST_EXTRAS = [] +SYSTEM_TEST_EXTRAS = [ + "tracing", +] SYSTEM_TEST_EXTRAS_BY_PYTHON = {} CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() diff --git a/owlbot.py b/owlbot.py index 31f458d691..a3a048fffb 100644 --- a/owlbot.py +++ b/owlbot.py @@ -137,14 +137,19 @@ def get_staging_dirs( # Add templated files # ---------------------------------------------------------------------------- templated_files = common.py_library( - microgenerator=True, samples=True, cov_level=99, split_system_tests=True, + microgenerator=True, + samples=True, + cov_level=99, + split_system_tests=True, + system_test_extras=["tracing"], ) -s.move(templated_files, +s.move( + templated_files, excludes=[ - ".coveragerc", - ".github/workflows", # exclude gh actions as credentials are needed for tests - ] - ) + ".coveragerc", + ".github/workflows", # exclude gh actions as credentials are needed for tests + ], +) # Ensure CI runs on a new instance each time s.replace( From 7642eba1d9c66525ea1ca6f36dd91c759ed3cbde Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 14 Apr 2022 21:42:31 +0000 Subject: [PATCH 14/16] chore: use gapic-generator-python 0.65.1 (#717) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 441524537 Source-Link: https://github.com/googleapis/googleapis/commit/2a273915b3f70fe86c9d2a75470a0b83e48d0abf Source-Link: https://github.com/googleapis/googleapis-gen/commit/ab6756a48c89b5bcb9fb73443cb8e55d574f4643 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWI2NzU2YTQ4Yzg5YjViY2I5ZmI3MzQ0M2NiOGU1NWQ1NzRmNDY0MyJ9 feat: AuditConfig for IAM v1 fix(deps): require grpc-google-iam-v1 >=0.12.4 --- .../services/database_admin/async_client.py | 115 +- .../services/database_admin/client.py | 115 +- .../database_admin/transports/base.py | 5 + .../database_admin/transports/grpc.py | 4 + .../services/instance_admin/async_client.py | 107 +- .../services/instance_admin/client.py | 107 +- .../instance_admin/transports/base.py | 5 + .../instance_admin/transports/grpc.py | 4 + .../types/spanner_instance_admin.py | 2 +- .../services/spanner/async_client.py | 15 +- .../spanner_v1/services/spanner/client.py | 16 +- .../services/spanner/transports/base.py | 5 + .../services/spanner/transports/grpc.py | 4 + google/cloud/spanner_v1/types/__init__.py | 8 +- google/cloud/spanner_v1/types/query_plan.py | 2 +- google/cloud/spanner_v1/types/spanner.py | 8 +- ...et_metadata_spanner admin database_v1.json | 1654 +++++++++++++++-- ...et_metadata_spanner admin instance_v1.json | 960 +++++++++- .../snippet_metadata_spanner_v1.json | 1198 +++++++++++- ...ted_database_admin_get_iam_policy_async.py | 3 +- ...ated_database_admin_get_iam_policy_sync.py | 3 +- ...ted_database_admin_set_iam_policy_async.py | 3 +- ...ated_database_admin_set_iam_policy_sync.py | 3 +- ...tabase_admin_test_iam_permissions_async.py | 3 +- ...atabase_admin_test_iam_permissions_sync.py | 3 +- ...ted_instance_admin_get_iam_policy_async.py | 3 +- ...ated_instance_admin_get_iam_policy_sync.py | 3 +- ...ted_instance_admin_set_iam_policy_async.py | 3 +- ...ated_instance_admin_set_iam_policy_sync.py | 3 +- ...stance_admin_test_iam_permissions_async.py | 3 +- ...nstance_admin_test_iam_permissions_sync.py | 3 +- ...ixup_spanner_admin_database_v1_keywords.py | 2 +- ...ixup_spanner_admin_instance_v1_keywords.py | 2 +- setup.py | 2 +- testing/constraints-3.6.txt | 2 +- .../test_database_admin.py | 100 +- .../test_instance_admin.py | 88 +- tests/unit/gapic/spanner_v1/test_spanner.py | 81 +- 38 files changed, 4021 insertions(+), 626 deletions(-) diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py b/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py index 750c3dd5f5..c5d38710bf 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -371,7 +371,6 @@ async def create_database( is [Database][google.spanner.admin.database.v1.Database], if successful. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -611,7 +610,6 @@ async def update_database_ddl( [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. The operation has no response. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -770,7 +768,6 @@ async def drop_database( ``expire_time``. Note: Cloud Spanner might continue to accept requests for a few seconds after the database has been deleted. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -865,7 +862,6 @@ async def get_database_ddl( schema updates, those may be queried using the [Operations][google.longrunning.Operations] API. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -980,17 +976,17 @@ async def set_iam_policy( permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. - .. code-block:: python from google.cloud import spanner_admin_database_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_set_iam_policy(): # Create a client client = spanner_admin_database_v1.DatabaseAdminClient() # Initialize request argument(s) - request = spanner_admin_database_v1.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) @@ -1021,21 +1017,26 @@ def sample_set_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1050,17 +1051,17 @@ def sample_set_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1071,11 +1072,12 @@ def sample_set_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -1142,17 +1144,17 @@ async def get_iam_policy( permission on [resource][google.iam.v1.GetIamPolicyRequest.resource]. - .. code-block:: python from google.cloud import spanner_admin_database_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_get_iam_policy(): # Create a client client = spanner_admin_database_v1.DatabaseAdminClient() # Initialize request argument(s) - request = spanner_admin_database_v1.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) @@ -1183,21 +1185,26 @@ def sample_get_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1212,17 +1219,17 @@ def sample_get_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1233,11 +1240,12 @@ def sample_get_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -1315,17 +1323,17 @@ async def test_iam_permissions( in a NOT_FOUND error if the user has ``spanner.backups.list`` permission on the containing instance. - .. code-block:: python from google.cloud import spanner_admin_database_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_test_iam_permissions(): # Create a client client = spanner_admin_database_v1.DatabaseAdminClient() # Initialize request argument(s) - request = spanner_admin_database_v1.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) @@ -1438,7 +1446,6 @@ async def create_backup( backup creation per database. Backup creation of different databases can run concurrently. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -1588,7 +1595,6 @@ async def copy_backup( copying and delete the backup. Concurrent CopyBackup requests can run on the same source backup. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -1741,7 +1747,6 @@ async def get_backup( r"""Gets metadata on a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -1847,7 +1852,6 @@ async def update_backup( r"""Updates a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -1971,7 +1975,6 @@ async def delete_backup( r"""Deletes a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -2068,7 +2071,6 @@ async def list_backups( ordered by ``create_time`` in descending order, starting from the most recent ``create_time``. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -2207,7 +2209,6 @@ async def restore_database( without waiting for the optimize operation associated with the first restore to complete. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -2356,7 +2357,6 @@ async def list_database_operations( completed/failed/canceled within the last 7 days, and pending operations. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -2487,7 +2487,6 @@ async def list_backup_operations( ``operation.metadata.value.progress.start_time`` in descending order starting from the most recently started operation. - .. code-block:: python from google.cloud import spanner_admin_database_v1 diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/client.py b/google/cloud/spanner_admin_database_v1/services/database_admin/client.py index 3e300807c9..19bbf83097 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/client.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -662,7 +662,6 @@ def create_database( is [Database][google.spanner.admin.database.v1.Database], if successful. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -892,7 +891,6 @@ def update_database_ddl( [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. The operation has no response. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -1041,7 +1039,6 @@ def drop_database( ``expire_time``. Note: Cloud Spanner might continue to accept requests for a few seconds after the database has been deleted. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -1126,7 +1123,6 @@ def get_database_ddl( schema updates, those may be queried using the [Operations][google.longrunning.Operations] API. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -1231,17 +1227,17 @@ def set_iam_policy( permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. - .. code-block:: python from google.cloud import spanner_admin_database_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_set_iam_policy(): # Create a client client = spanner_admin_database_v1.DatabaseAdminClient() # Initialize request argument(s) - request = spanner_admin_database_v1.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) @@ -1272,21 +1268,26 @@ def sample_set_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1301,17 +1302,17 @@ def sample_set_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1322,11 +1323,12 @@ def sample_set_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -1390,17 +1392,17 @@ def get_iam_policy( permission on [resource][google.iam.v1.GetIamPolicyRequest.resource]. - .. code-block:: python from google.cloud import spanner_admin_database_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_get_iam_policy(): # Create a client client = spanner_admin_database_v1.DatabaseAdminClient() # Initialize request argument(s) - request = spanner_admin_database_v1.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) @@ -1431,21 +1433,26 @@ def sample_get_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1460,17 +1467,17 @@ def sample_get_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1481,11 +1488,12 @@ def sample_get_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -1550,17 +1558,17 @@ def test_iam_permissions( in a NOT_FOUND error if the user has ``spanner.backups.list`` permission on the containing instance. - .. code-block:: python from google.cloud import spanner_admin_database_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_test_iam_permissions(): # Create a client client = spanner_admin_database_v1.DatabaseAdminClient() # Initialize request argument(s) - request = spanner_admin_database_v1.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) @@ -1671,7 +1679,6 @@ def create_backup( backup creation per database. Backup creation of different databases can run concurrently. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -1821,7 +1828,6 @@ def copy_backup( copying and delete the backup. Concurrent CopyBackup requests can run on the same source backup. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -1974,7 +1980,6 @@ def get_backup( r"""Gets metadata on a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -2070,7 +2075,6 @@ def update_backup( r"""Updates a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -2184,7 +2188,6 @@ def delete_backup( r"""Deletes a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -2271,7 +2274,6 @@ def list_backups( ordered by ``create_time`` in descending order, starting from the most recent ``create_time``. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -2400,7 +2402,6 @@ def restore_database( without waiting for the optimize operation associated with the first restore to complete. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -2549,7 +2550,6 @@ def list_database_operations( completed/failed/canceled within the last 7 days, and pending operations. - .. code-block:: python from google.cloud import spanner_admin_database_v1 @@ -2672,7 +2672,6 @@ def list_backup_operations( ``operation.metadata.value.progress.start_time`` in descending order starting from the most recently started operation. - .. code-block:: python from google.cloud import spanner_admin_database_v1 diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py index 21f27aeaf6..1a93ed842a 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py @@ -90,6 +90,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -533,5 +534,9 @@ def list_backup_operations( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("DatabaseAdminTransport",) diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py index 70b1c8158a..18e9341dca 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py @@ -861,5 +861,9 @@ def list_backup_operations( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("DatabaseAdminGrpcTransport",) diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py index 1d79ac996e..4bbd9558c2 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -244,7 +244,6 @@ async def list_instance_configs( r"""Lists the supported instance configurations for a given project. - .. code-block:: python from google.cloud import spanner_admin_instance_v1 @@ -365,7 +364,6 @@ async def get_instance_config( r"""Gets information about a particular instance configuration. - .. code-block:: python from google.cloud import spanner_admin_instance_v1 @@ -738,7 +736,6 @@ async def create_instance( is [Instance][google.spanner.admin.instance.v1.Instance], if successful. - .. code-block:: python from google.cloud import spanner_admin_instance_v1 @@ -922,7 +919,6 @@ async def update_instance( on resource [name][google.spanner.admin.instance.v1.Instance.name]. - .. code-block:: python from google.cloud import spanner_admin_instance_v1 @@ -1068,7 +1064,6 @@ async def delete_instance( irrevocably disappear from the API. All data in the databases is permanently deleted. - .. code-block:: python from google.cloud import spanner_admin_instance_v1 @@ -1167,17 +1162,17 @@ async def set_iam_policy( Authorization requires ``spanner.instances.setIamPolicy`` on [resource][google.iam.v1.SetIamPolicyRequest.resource]. - .. code-block:: python from google.cloud import spanner_admin_instance_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_set_iam_policy(): # Create a client client = spanner_admin_instance_v1.InstanceAdminClient() # Initialize request argument(s) - request = spanner_admin_instance_v1.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) @@ -1208,21 +1203,26 @@ def sample_set_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1237,17 +1237,17 @@ def sample_set_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1258,11 +1258,12 @@ def sample_set_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -1325,17 +1326,17 @@ async def get_iam_policy( Authorization requires ``spanner.instances.getIamPolicy`` on [resource][google.iam.v1.GetIamPolicyRequest.resource]. - .. code-block:: python from google.cloud import spanner_admin_instance_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_get_iam_policy(): # Create a client client = spanner_admin_instance_v1.InstanceAdminClient() # Initialize request argument(s) - request = spanner_admin_instance_v1.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) @@ -1366,21 +1367,26 @@ def sample_get_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1395,17 +1401,17 @@ def sample_get_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1416,11 +1422,12 @@ def sample_get_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -1495,17 +1502,17 @@ async def test_iam_permissions( ``spanner.instances.list`` permission on the containing Google Cloud Project. Otherwise returns an empty set of permissions. - .. code-block:: python from google.cloud import spanner_admin_instance_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_test_iam_permissions(): # Create a client client = spanner_admin_instance_v1.InstanceAdminClient() # Initialize request argument(s) - request = spanner_admin_instance_v1.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py index 1ebf127487..9df92c95e6 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -477,7 +477,6 @@ def list_instance_configs( r"""Lists the supported instance configurations for a given project. - .. code-block:: python from google.cloud import spanner_admin_instance_v1 @@ -588,7 +587,6 @@ def get_instance_config( r"""Gets information about a particular instance configuration. - .. code-block:: python from google.cloud import spanner_admin_instance_v1 @@ -931,7 +929,6 @@ def create_instance( is [Instance][google.spanner.admin.instance.v1.Instance], if successful. - .. code-block:: python from google.cloud import spanner_admin_instance_v1 @@ -1115,7 +1112,6 @@ def update_instance( on resource [name][google.spanner.admin.instance.v1.Instance.name]. - .. code-block:: python from google.cloud import spanner_admin_instance_v1 @@ -1261,7 +1257,6 @@ def delete_instance( irrevocably disappear from the API. All data in the databases is permanently deleted. - .. code-block:: python from google.cloud import spanner_admin_instance_v1 @@ -1350,17 +1345,17 @@ def set_iam_policy( Authorization requires ``spanner.instances.setIamPolicy`` on [resource][google.iam.v1.SetIamPolicyRequest.resource]. - .. code-block:: python from google.cloud import spanner_admin_instance_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_set_iam_policy(): # Create a client client = spanner_admin_instance_v1.InstanceAdminClient() # Initialize request argument(s) - request = spanner_admin_instance_v1.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) @@ -1391,21 +1386,26 @@ def sample_set_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1420,17 +1420,17 @@ def sample_set_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1441,11 +1441,12 @@ def sample_set_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -1505,17 +1506,17 @@ def get_iam_policy( Authorization requires ``spanner.instances.getIamPolicy`` on [resource][google.iam.v1.GetIamPolicyRequest.resource]. - .. code-block:: python from google.cloud import spanner_admin_instance_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_get_iam_policy(): # Create a client client = spanner_admin_instance_v1.InstanceAdminClient() # Initialize request argument(s) - request = spanner_admin_instance_v1.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) @@ -1546,21 +1547,26 @@ def sample_get_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1575,17 +1581,17 @@ def sample_get_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1596,11 +1602,12 @@ def sample_get_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -1662,17 +1669,17 @@ def test_iam_permissions( ``spanner.instances.list`` permission on the containing Google Cloud Project. Otherwise returns an empty set of permissions. - .. code-block:: python from google.cloud import spanner_admin_instance_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_test_iam_permissions(): # Create a client client = spanner_admin_instance_v1.InstanceAdminClient() # Initialize request argument(s) - request = spanner_admin_instance_v1.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py index 3f9888c363..bff88baf0c 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py @@ -88,6 +88,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -358,5 +359,9 @@ def test_iam_permissions( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("InstanceAdminTransport",) diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py index 012c2dce2e..1cb4b3d6ba 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py @@ -656,5 +656,9 @@ def test_iam_permissions( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("InstanceAdminGrpcTransport",) diff --git a/google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py b/google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py index 5b964a7935..c4434b53b8 100644 --- a/google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py +++ b/google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py @@ -167,7 +167,7 @@ class Instance(proto.Message): the state must be either omitted or set to ``CREATING``. For [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance], the state must be either omitted or set to ``READY``. - labels (Sequence[google.cloud.spanner_admin_instance_v1.types.Instance.LabelsEntry]): + labels (Mapping[str, str]): Cloud Labels are a flexible and lightweight mechanism for organizing cloud resources into groups that reflect a customer's organizational needs and deployment strategies. diff --git a/google/cloud/spanner_v1/services/spanner/async_client.py b/google/cloud/spanner_v1/services/spanner/async_client.py index a9dc85cb22..e831c1c9b4 100644 --- a/google/cloud/spanner_v1/services/spanner/async_client.py +++ b/google/cloud/spanner_v1/services/spanner/async_client.py @@ -18,6 +18,7 @@ import re from typing import ( Dict, + Mapping, Optional, AsyncIterable, Awaitable, @@ -244,7 +245,6 @@ async def create_session( Idle sessions can be kept alive by sending a trivial SQL query periodically, e.g., ``"SELECT 1"``. - .. code-block:: python from google.cloud import spanner_v1 @@ -351,7 +351,6 @@ async def batch_create_sessions( the clients. See https://goo.gl/TgSFN2 for best practices on session cache management. - .. code-block:: python from google.cloud import spanner_v1 @@ -473,7 +472,6 @@ async def get_session( exist. This is mainly useful for determining whether a session is still alive. - .. code-block:: python from google.cloud import spanner_v1 @@ -695,7 +693,6 @@ async def delete_session( with it. This will asynchronously trigger cancellation of any operations that are running with this session. - .. code-block:: python from google.cloud import spanner_v1 @@ -800,7 +797,6 @@ async def execute_sql( [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] instead. - .. code-block:: python from google.cloud import spanner_v1 @@ -890,7 +886,6 @@ def execute_streaming_sql( individual row in the result set can exceed 100 MiB, and no column value can exceed 10 MiB. - .. code-block:: python from google.cloud import spanner_v1 @@ -983,7 +978,6 @@ async def execute_batch_dml( Execution stops after the first failed statement; the remaining statements are not executed. - .. code-block:: python from google.cloud import spanner_v1 @@ -1122,7 +1116,6 @@ async def read( calling [StreamingRead][google.spanner.v1.Spanner.StreamingRead] instead. - .. code-block:: python from google.cloud import spanner_v1 @@ -1213,7 +1206,6 @@ def streaming_read( the result set can exceed 100 MiB, and no column value can exceed 10 MiB. - .. code-block:: python from google.cloud import spanner_v1 @@ -1300,7 +1292,6 @@ async def begin_transaction( [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a side-effect. - .. code-block:: python from google.cloud import spanner_v1 @@ -1430,7 +1421,6 @@ async def commit( perform another read from the database to see the state of things as they are now. - .. code-block:: python from google.cloud import spanner_v1 @@ -1585,7 +1575,6 @@ async def rollback( transaction is not found. ``Rollback`` never returns ``ABORTED``. - .. code-block:: python from google.cloud import spanner_v1 @@ -1700,7 +1689,6 @@ async def partition_query( to resume the query, and the whole operation must be restarted from the beginning. - .. code-block:: python from google.cloud import spanner_v1 @@ -1801,7 +1789,6 @@ async def partition_read( to resume the read, and the whole operation must be restarted from the beginning. - .. code-block:: python from google.cloud import spanner_v1 diff --git a/google/cloud/spanner_v1/services/spanner/client.py b/google/cloud/spanner_v1/services/spanner/client.py index 42fb0a9a9c..a9203fb6a3 100644 --- a/google/cloud/spanner_v1/services/spanner/client.py +++ b/google/cloud/spanner_v1/services/spanner/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Iterable, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Iterable, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -487,7 +487,6 @@ def create_session( Idle sessions can be kept alive by sending a trivial SQL query periodically, e.g., ``"SELECT 1"``. - .. code-block:: python from google.cloud import spanner_v1 @@ -585,7 +584,6 @@ def batch_create_sessions( the clients. See https://goo.gl/TgSFN2 for best practices on session cache management. - .. code-block:: python from google.cloud import spanner_v1 @@ -698,7 +696,6 @@ def get_session( exist. This is mainly useful for determining whether a session is still alive. - .. code-block:: python from google.cloud import spanner_v1 @@ -902,7 +899,6 @@ def delete_session( with it. This will asynchronously trigger cancellation of any operations that are running with this session. - .. code-block:: python from google.cloud import spanner_v1 @@ -998,7 +994,6 @@ def execute_sql( [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] instead. - .. code-block:: python from google.cloud import spanner_v1 @@ -1080,7 +1075,6 @@ def execute_streaming_sql( individual row in the result set can exceed 100 MiB, and no column value can exceed 10 MiB. - .. code-block:: python from google.cloud import spanner_v1 @@ -1174,7 +1168,6 @@ def execute_batch_dml( Execution stops after the first failed statement; the remaining statements are not executed. - .. code-block:: python from google.cloud import spanner_v1 @@ -1305,7 +1298,6 @@ def read( calling [StreamingRead][google.spanner.v1.Spanner.StreamingRead] instead. - .. code-block:: python from google.cloud import spanner_v1 @@ -1388,7 +1380,6 @@ def streaming_read( the result set can exceed 100 MiB, and no column value can exceed 10 MiB. - .. code-block:: python from google.cloud import spanner_v1 @@ -1476,7 +1467,6 @@ def begin_transaction( [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a side-effect. - .. code-block:: python from google.cloud import spanner_v1 @@ -1597,7 +1587,6 @@ def commit( perform another read from the database to see the state of things as they are now. - .. code-block:: python from google.cloud import spanner_v1 @@ -1743,7 +1732,6 @@ def rollback( transaction is not found. ``Rollback`` never returns ``ABORTED``. - .. code-block:: python from google.cloud import spanner_v1 @@ -1849,7 +1837,6 @@ def partition_query( to resume the query, and the whole operation must be restarted from the beginning. - .. code-block:: python from google.cloud import spanner_v1 @@ -1942,7 +1929,6 @@ def partition_read( to resume the read, and the whole operation must be restarted from the beginning. - .. code-block:: python from google.cloud import spanner_v1 diff --git a/google/cloud/spanner_v1/services/spanner/transports/base.py b/google/cloud/spanner_v1/services/spanner/transports/base.py index 0066447c79..608c894a9a 100644 --- a/google/cloud/spanner_v1/services/spanner/transports/base.py +++ b/google/cloud/spanner_v1/services/spanner/transports/base.py @@ -87,6 +87,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -470,5 +471,9 @@ def partition_read( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("SpannerTransport",) diff --git a/google/cloud/spanner_v1/services/spanner/transports/grpc.py b/google/cloud/spanner_v1/services/spanner/transports/grpc.py index ba84345989..86a3ca9967 100644 --- a/google/cloud/spanner_v1/services/spanner/transports/grpc.py +++ b/google/cloud/spanner_v1/services/spanner/transports/grpc.py @@ -754,5 +754,9 @@ def partition_read( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("SpannerGrpcTransport",) diff --git a/google/cloud/spanner_v1/types/__init__.py b/google/cloud/spanner_v1/types/__init__.py index 1ad35d70ed..c8d97aa910 100644 --- a/google/cloud/spanner_v1/types/__init__.py +++ b/google/cloud/spanner_v1/types/__init__.py @@ -13,12 +13,16 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .commit_response import CommitResponse +from .commit_response import ( + CommitResponse, +) from .keys import ( KeyRange, KeySet, ) -from .mutation import Mutation +from .mutation import ( + Mutation, +) from .query_plan import ( PlanNode, QueryPlan, diff --git a/google/cloud/spanner_v1/types/query_plan.py b/google/cloud/spanner_v1/types/query_plan.py index 76467cf6ab..465e9972be 100644 --- a/google/cloud/spanner_v1/types/query_plan.py +++ b/google/cloud/spanner_v1/types/query_plan.py @@ -126,7 +126,7 @@ class ShortRepresentation(proto.Message): description (str): A string representation of the expression subtree rooted at this node. - subqueries (Sequence[google.cloud.spanner_v1.types.PlanNode.ShortRepresentation.SubqueriesEntry]): + subqueries (Mapping[str, int]): A mapping of (subquery variable name) -> (subquery node id) for cases where the ``description`` string of this node references a ``SCALAR`` subquery contained in the expression diff --git a/google/cloud/spanner_v1/types/spanner.py b/google/cloud/spanner_v1/types/spanner.py index 2a94ded3fe..f6cacdc323 100644 --- a/google/cloud/spanner_v1/types/spanner.py +++ b/google/cloud/spanner_v1/types/spanner.py @@ -135,7 +135,7 @@ class Session(proto.Message): name (str): Output only. The name of the session. This is always system-assigned. - labels (Sequence[google.cloud.spanner_v1.types.Session.LabelsEntry]): + labels (Mapping[str, str]): The labels for the session. - Label keys must be between 1 and 63 characters long and @@ -398,7 +398,7 @@ class ExecuteSqlRequest(proto.Message): It is an error to execute a SQL statement with unbound parameters. - param_types (Sequence[google.cloud.spanner_v1.types.ExecuteSqlRequest.ParamTypesEntry]): + param_types (Mapping[str, google.cloud.spanner_v1.types.Type]): It is not always possible for Cloud Spanner to infer the right SQL type from a JSON value. For example, values of type ``BYTES`` and values of type ``STRING`` both appear in @@ -645,7 +645,7 @@ class Statement(proto.Message): It is an error to execute a SQL statement with unbound parameters. - param_types (Sequence[google.cloud.spanner_v1.types.ExecuteBatchDmlRequest.Statement.ParamTypesEntry]): + param_types (Mapping[str, google.cloud.spanner_v1.types.Type]): It is not always possible for Cloud Spanner to infer the right SQL type from a JSON value. For example, values of type ``BYTES`` and values of type ``STRING`` both appear in @@ -845,7 +845,7 @@ class PartitionQueryRequest(proto.Message): It is an error to execute a SQL statement with unbound parameters. - param_types (Sequence[google.cloud.spanner_v1.types.PartitionQueryRequest.ParamTypesEntry]): + param_types (Mapping[str, google.cloud.spanner_v1.types.Type]): It is not always possible for Cloud Spanner to infer the right SQL type from a JSON value. For example, values of type ``BYTES`` and values of type ``STRING`` both appear in diff --git a/samples/generated_samples/snippet_metadata_spanner admin database_v1.json b/samples/generated_samples/snippet_metadata_spanner admin database_v1.json index 5564ff3d37..8487879c25 100644 --- a/samples/generated_samples/snippet_metadata_spanner admin database_v1.json +++ b/samples/generated_samples/snippet_metadata_spanner admin database_v1.json @@ -1,16 +1,73 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.spanner.admin.database.v1", + "version": "v1" + } + ], + "language": "PYTHON", + "name": "google-cloud-spanner-admin-database" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient", + "shortName": "DatabaseAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient.copy_backup", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "CopyBackup" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.CopyBackupRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "backup_id", + "type": "str" + }, + { + "name": "source_backup", + "type": "str" + }, + { + "name": "expire_time", + "type": "google.protobuf.timestamp_pb2.Timestamp" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "copy_backup" }, + "description": "Sample for CopyBackup", "file": "spanner_v1_generated_database_admin_copy_backup_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_CopyBackup_async", "segments": [ { @@ -43,18 +100,66 @@ "start": 48, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_copy_backup_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient", + "shortName": "DatabaseAdminClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient.copy_backup", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "CopyBackup" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.CopyBackupRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "backup_id", + "type": "str" + }, + { + "name": "source_backup", + "type": "str" + }, + { + "name": "expire_time", + "type": "google.protobuf.timestamp_pb2.Timestamp" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "copy_backup" }, + "description": "Sample for CopyBackup", "file": "spanner_v1_generated_database_admin_copy_backup_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_CopyBackup_sync", "segments": [ { @@ -87,19 +192,63 @@ "start": 48, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_copy_backup_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient", + "shortName": "DatabaseAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient.create_backup", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "CreateBackup" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.CreateBackupRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "backup", + "type": "google.cloud.spanner_admin_database_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, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_backup" }, + "description": "Sample for CreateBackup", "file": "spanner_v1_generated_database_admin_create_backup_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_CreateBackup_async", "segments": [ { @@ -132,18 +281,62 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_create_backup_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient", + "shortName": "DatabaseAdminClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient.create_backup", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "CreateBackup" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.CreateBackupRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "backup", + "type": "google.cloud.spanner_admin_database_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, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_backup" }, + "description": "Sample for CreateBackup", "file": "spanner_v1_generated_database_admin_create_backup_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_CreateBackup_sync", "segments": [ { @@ -176,19 +369,59 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_create_backup_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient", + "shortName": "DatabaseAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient.create_database", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "CreateDatabase" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.CreateDatabaseRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "create_statement", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_database" }, + "description": "Sample for CreateDatabase", "file": "spanner_v1_generated_database_admin_create_database_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_CreateDatabase_async", "segments": [ { @@ -221,18 +454,58 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_create_database_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient", + "shortName": "DatabaseAdminClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient.create_database", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "CreateDatabase" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.CreateDatabaseRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "create_statement", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_database" }, + "description": "Sample for CreateDatabase", "file": "spanner_v1_generated_database_admin_create_database_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_CreateDatabase_sync", "segments": [ { @@ -265,19 +538,54 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_create_database_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient", + "shortName": "DatabaseAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient.delete_backup", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackup", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "DeleteBackup" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_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, str]" + } + ], + "shortName": "delete_backup" }, + "description": "Sample for DeleteBackup", "file": "spanner_v1_generated_database_admin_delete_backup_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_DeleteBackup_async", "segments": [ { @@ -308,18 +616,53 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_delete_backup_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient", + "shortName": "DatabaseAdminClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient.delete_backup", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackup", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "DeleteBackup" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_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, str]" + } + ], + "shortName": "delete_backup" }, + "description": "Sample for DeleteBackup", "file": "spanner_v1_generated_database_admin_delete_backup_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_DeleteBackup_sync", "segments": [ { @@ -350,19 +693,54 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_delete_backup_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient", + "shortName": "DatabaseAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient.drop_database", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.DropDatabase", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "DropDatabase" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.DropDatabaseRequest" + }, + { + "name": "database", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "drop_database" }, + "description": "Sample for DropDatabase", "file": "spanner_v1_generated_database_admin_drop_database_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_DropDatabase_async", "segments": [ { @@ -393,18 +771,53 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_drop_database_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient", + "shortName": "DatabaseAdminClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient.drop_database", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.DropDatabase", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "DropDatabase" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.DropDatabaseRequest" + }, + { + "name": "database", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "drop_database" }, + "description": "Sample for DropDatabase", "file": "spanner_v1_generated_database_admin_drop_database_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_DropDatabase_sync", "segments": [ { @@ -435,19 +848,55 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_drop_database_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient", + "shortName": "DatabaseAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient.get_backup", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.GetBackup", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "GetBackup" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_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, str]" + } + ], + "resultType": "google.cloud.spanner_admin_database_v1.types.Backup", + "shortName": "get_backup" }, + "description": "Sample for GetBackup", "file": "spanner_v1_generated_database_admin_get_backup_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_GetBackup_async", "segments": [ { @@ -480,18 +929,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_get_backup_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient", + "shortName": "DatabaseAdminClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient.get_backup", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.GetBackup", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "GetBackup" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_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, str]" + } + ], + "resultType": "google.cloud.spanner_admin_database_v1.types.Backup", + "shortName": "get_backup" }, + "description": "Sample for GetBackup", "file": "spanner_v1_generated_database_admin_get_backup_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_GetBackup_sync", "segments": [ { @@ -524,19 +1009,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_get_backup_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient", + "shortName": "DatabaseAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient.get_database_ddl", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "GetDatabaseDdl" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.GetDatabaseDdlRequest" + }, + { + "name": "database", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_admin_database_v1.types.GetDatabaseDdlResponse", + "shortName": "get_database_ddl" }, + "description": "Sample for GetDatabaseDdl", "file": "spanner_v1_generated_database_admin_get_database_ddl_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_GetDatabaseDdl_async", "segments": [ { @@ -569,18 +1090,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_get_database_ddl_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient", + "shortName": "DatabaseAdminClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient.get_database_ddl", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "GetDatabaseDdl" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.GetDatabaseDdlRequest" + }, + { + "name": "database", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_admin_database_v1.types.GetDatabaseDdlResponse", + "shortName": "get_database_ddl" }, + "description": "Sample for GetDatabaseDdl", "file": "spanner_v1_generated_database_admin_get_database_ddl_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_GetDatabaseDdl_sync", "segments": [ { @@ -613,19 +1170,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_get_database_ddl_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient", + "shortName": "DatabaseAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient.get_database", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.GetDatabase", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "GetDatabase" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.GetDatabaseRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_admin_database_v1.types.Database", + "shortName": "get_database" }, + "description": "Sample for GetDatabase", "file": "spanner_v1_generated_database_admin_get_database_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_GetDatabase_async", "segments": [ { @@ -658,18 +1251,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_get_database_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient", + "shortName": "DatabaseAdminClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient.get_database", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.GetDatabase", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "GetDatabase" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.GetDatabaseRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_admin_database_v1.types.Database", + "shortName": "get_database" }, + "description": "Sample for GetDatabase", "file": "spanner_v1_generated_database_admin_get_database_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_GetDatabase_sync", "segments": [ { @@ -702,108 +1331,216 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_get_database_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient", + "shortName": "DatabaseAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient.get_iam_policy", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.GetIamPolicy", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "GetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" }, + "description": "Sample for GetIamPolicy", "file": "spanner_v1_generated_database_admin_get_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_GetIamPolicy_async", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_get_iam_policy_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient", + "shortName": "DatabaseAdminClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient.get_iam_policy", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.GetIamPolicy", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "GetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" }, + "description": "Sample for GetIamPolicy", "file": "spanner_v1_generated_database_admin_get_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_GetIamPolicy_sync", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_get_iam_policy_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient", + "shortName": "DatabaseAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient.list_backup_operations", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "ListBackupOperations" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.ListBackupOperationsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_admin_database_v1.services.database_admin.pagers.ListBackupOperationsAsyncPager", + "shortName": "list_backup_operations" }, + "description": "Sample for ListBackupOperations", "file": "spanner_v1_generated_database_admin_list_backup_operations_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_ListBackupOperations_async", "segments": [ { @@ -836,18 +1573,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_list_backup_operations_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient", + "shortName": "DatabaseAdminClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient.list_backup_operations", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "ListBackupOperations" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.ListBackupOperationsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_admin_database_v1.services.database_admin.pagers.ListBackupOperationsPager", + "shortName": "list_backup_operations" }, + "description": "Sample for ListBackupOperations", "file": "spanner_v1_generated_database_admin_list_backup_operations_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_ListBackupOperations_sync", "segments": [ { @@ -880,19 +1653,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_list_backup_operations_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient", + "shortName": "DatabaseAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient.list_backups", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.ListBackups", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "ListBackups" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_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, str]" + } + ], + "resultType": "google.cloud.spanner_admin_database_v1.services.database_admin.pagers.ListBackupsAsyncPager", + "shortName": "list_backups" }, + "description": "Sample for ListBackups", "file": "spanner_v1_generated_database_admin_list_backups_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_ListBackups_async", "segments": [ { @@ -925,18 +1734,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_list_backups_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient", + "shortName": "DatabaseAdminClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient.list_backups", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.ListBackups", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "ListBackups" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_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, str]" + } + ], + "resultType": "google.cloud.spanner_admin_database_v1.services.database_admin.pagers.ListBackupsPager", + "shortName": "list_backups" }, + "description": "Sample for ListBackups", "file": "spanner_v1_generated_database_admin_list_backups_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_ListBackups_sync", "segments": [ { @@ -969,19 +1814,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_list_backups_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient", + "shortName": "DatabaseAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient.list_database_operations", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "ListDatabaseOperations" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.ListDatabaseOperationsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_admin_database_v1.services.database_admin.pagers.ListDatabaseOperationsAsyncPager", + "shortName": "list_database_operations" }, + "description": "Sample for ListDatabaseOperations", "file": "spanner_v1_generated_database_admin_list_database_operations_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_ListDatabaseOperations_async", "segments": [ { @@ -1014,18 +1895,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_list_database_operations_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient", + "shortName": "DatabaseAdminClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient.list_database_operations", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "ListDatabaseOperations" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.ListDatabaseOperationsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_admin_database_v1.services.database_admin.pagers.ListDatabaseOperationsPager", + "shortName": "list_database_operations" }, + "description": "Sample for ListDatabaseOperations", "file": "spanner_v1_generated_database_admin_list_database_operations_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_ListDatabaseOperations_sync", "segments": [ { @@ -1058,19 +1975,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_list_database_operations_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient", + "shortName": "DatabaseAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient.list_databases", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "ListDatabases" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.ListDatabasesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_admin_database_v1.services.database_admin.pagers.ListDatabasesAsyncPager", + "shortName": "list_databases" }, + "description": "Sample for ListDatabases", "file": "spanner_v1_generated_database_admin_list_databases_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_ListDatabases_async", "segments": [ { @@ -1103,18 +2056,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_list_databases_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient", + "shortName": "DatabaseAdminClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient.list_databases", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "ListDatabases" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.ListDatabasesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_admin_database_v1.services.database_admin.pagers.ListDatabasesPager", + "shortName": "list_databases" }, + "description": "Sample for ListDatabases", "file": "spanner_v1_generated_database_admin_list_databases_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_ListDatabases_sync", "segments": [ { @@ -1147,19 +2136,63 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_list_databases_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient", + "shortName": "DatabaseAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient.restore_database", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "RestoreDatabase" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.RestoreDatabaseRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "database_id", + "type": "str" + }, + { + "name": "backup", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "restore_database" }, + "description": "Sample for RestoreDatabase", "file": "spanner_v1_generated_database_admin_restore_database_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_RestoreDatabase_async", "segments": [ { @@ -1192,18 +2225,62 @@ "start": 48, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_restore_database_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient", + "shortName": "DatabaseAdminClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient.restore_database", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "RestoreDatabase" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.RestoreDatabaseRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "database_id", + "type": "str" + }, + { + "name": "backup", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "restore_database" }, + "description": "Sample for RestoreDatabase", "file": "spanner_v1_generated_database_admin_restore_database_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_RestoreDatabase_sync", "segments": [ { @@ -1236,197 +2313,389 @@ "start": 48, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_restore_database_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient", + "shortName": "DatabaseAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient.set_iam_policy", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.SetIamPolicy", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "SetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" }, + "description": "Sample for SetIamPolicy", "file": "spanner_v1_generated_database_admin_set_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_SetIamPolicy_async", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_set_iam_policy_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient", + "shortName": "DatabaseAdminClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient.set_iam_policy", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.SetIamPolicy", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "SetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" }, + "description": "Sample for SetIamPolicy", "file": "spanner_v1_generated_database_admin_set_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_SetIamPolicy_sync", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_set_iam_policy_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient", + "shortName": "DatabaseAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient.test_iam_permissions", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.TestIamPermissions", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "TestIamPermissions" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "permissions", + "type": "Sequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" }, + "description": "Sample for TestIamPermissions", "file": "spanner_v1_generated_database_admin_test_iam_permissions_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_TestIamPermissions_async", "segments": [ { - "end": 45, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 46, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 39, - "start": 34, + "end": 40, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 43, + "start": 41, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 43, + "end": 47, + "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_test_iam_permissions_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient", + "shortName": "DatabaseAdminClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient.test_iam_permissions", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.TestIamPermissions", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "TestIamPermissions" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "permissions", + "type": "Sequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" }, + "description": "Sample for TestIamPermissions", "file": "spanner_v1_generated_database_admin_test_iam_permissions_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_TestIamPermissions_sync", "segments": [ { - "end": 45, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 46, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 39, - "start": 34, + "end": 40, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 43, + "start": 41, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 43, + "end": 47, + "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_test_iam_permissions_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient", + "shortName": "DatabaseAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient.update_backup", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "UpdateBackup" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.UpdateBackupRequest" + }, + { + "name": "backup", + "type": "google.cloud.spanner_admin_database_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, str]" + } + ], + "resultType": "google.cloud.spanner_admin_database_v1.types.Backup", + "shortName": "update_backup" }, + "description": "Sample for UpdateBackup", "file": "spanner_v1_generated_database_admin_update_backup_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_UpdateBackup_async", "segments": [ { @@ -1459,18 +2728,58 @@ "start": 41, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_update_backup_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient", + "shortName": "DatabaseAdminClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient.update_backup", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "UpdateBackup" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.UpdateBackupRequest" + }, + { + "name": "backup", + "type": "google.cloud.spanner_admin_database_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, str]" + } + ], + "resultType": "google.cloud.spanner_admin_database_v1.types.Backup", + "shortName": "update_backup" }, + "description": "Sample for UpdateBackup", "file": "spanner_v1_generated_database_admin_update_backup_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_UpdateBackup_sync", "segments": [ { @@ -1503,19 +2812,59 @@ "start": 41, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_update_backup_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient", + "shortName": "DatabaseAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminAsyncClient.update_database_ddl", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "UpdateDatabaseDdl" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.UpdateDatabaseDdlRequest" + }, + { + "name": "database", + "type": "str" + }, + { + "name": "statements", + "type": "Sequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_database_ddl" }, + "description": "Sample for UpdateDatabaseDdl", "file": "spanner_v1_generated_database_admin_update_database_ddl_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_UpdateDatabaseDdl_async", "segments": [ { @@ -1548,18 +2897,58 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_update_database_ddl_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient", + "shortName": "DatabaseAdminClient" + }, + "fullName": "google.cloud.spanner_admin_database_v1.DatabaseAdminClient.update_database_ddl", "method": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl", "service": { + "fullName": "google.spanner.admin.database.v1.DatabaseAdmin", "shortName": "DatabaseAdmin" }, "shortName": "UpdateDatabaseDdl" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_database_v1.types.UpdateDatabaseDdlRequest" + }, + { + "name": "database", + "type": "str" + }, + { + "name": "statements", + "type": "Sequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_database_ddl" }, + "description": "Sample for UpdateDatabaseDdl", "file": "spanner_v1_generated_database_admin_update_database_ddl_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_DatabaseAdmin_UpdateDatabaseDdl_sync", "segments": [ { @@ -1592,7 +2981,8 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_database_admin_update_database_ddl_sync.py" } ] } diff --git a/samples/generated_samples/snippet_metadata_spanner admin instance_v1.json b/samples/generated_samples/snippet_metadata_spanner admin instance_v1.json index 07c69a762e..fbdf96b9c7 100644 --- a/samples/generated_samples/snippet_metadata_spanner admin instance_v1.json +++ b/samples/generated_samples/snippet_metadata_spanner admin instance_v1.json @@ -1,16 +1,69 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.spanner.admin.instance.v1", + "version": "v1" + } + ], + "language": "PYTHON", + "name": "google-cloud-spanner-admin-instance" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminAsyncClient", + "shortName": "InstanceAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminAsyncClient.create_instance", "method": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance", "service": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin", "shortName": "InstanceAdmin" }, "shortName": "CreateInstance" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_instance_v1.types.CreateInstanceRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "instance_id", + "type": "str" + }, + { + "name": "instance", + "type": "google.cloud.spanner_admin_instance_v1.types.Instance" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_instance" }, + "description": "Sample for CreateInstance", "file": "spanner_v1_generated_instance_admin_create_instance_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_InstanceAdmin_CreateInstance_async", "segments": [ { @@ -43,18 +96,62 @@ "start": 53, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_instance_admin_create_instance_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminClient", + "shortName": "InstanceAdminClient" + }, + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminClient.create_instance", "method": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance", "service": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin", "shortName": "InstanceAdmin" }, "shortName": "CreateInstance" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_instance_v1.types.CreateInstanceRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "instance_id", + "type": "str" + }, + { + "name": "instance", + "type": "google.cloud.spanner_admin_instance_v1.types.Instance" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_instance" }, + "description": "Sample for CreateInstance", "file": "spanner_v1_generated_instance_admin_create_instance_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_InstanceAdmin_CreateInstance_sync", "segments": [ { @@ -87,19 +184,54 @@ "start": 53, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_instance_admin_create_instance_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminAsyncClient", + "shortName": "InstanceAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminAsyncClient.delete_instance", "method": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstance", "service": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin", "shortName": "InstanceAdmin" }, "shortName": "DeleteInstance" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_instance_v1.types.DeleteInstanceRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_instance" }, + "description": "Sample for DeleteInstance", "file": "spanner_v1_generated_instance_admin_delete_instance_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_InstanceAdmin_DeleteInstance_async", "segments": [ { @@ -130,18 +262,53 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_instance_admin_delete_instance_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminClient", + "shortName": "InstanceAdminClient" + }, + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminClient.delete_instance", "method": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstance", "service": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin", "shortName": "InstanceAdmin" }, "shortName": "DeleteInstance" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_instance_v1.types.DeleteInstanceRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_instance" }, + "description": "Sample for DeleteInstance", "file": "spanner_v1_generated_instance_admin_delete_instance_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_InstanceAdmin_DeleteInstance_sync", "segments": [ { @@ -172,108 +339,216 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_instance_admin_delete_instance_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminAsyncClient", + "shortName": "InstanceAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminAsyncClient.get_iam_policy", "method": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin.GetIamPolicy", "service": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin", "shortName": "InstanceAdmin" }, "shortName": "GetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" }, + "description": "Sample for GetIamPolicy", "file": "spanner_v1_generated_instance_admin_get_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_InstanceAdmin_GetIamPolicy_async", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_instance_admin_get_iam_policy_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminClient", + "shortName": "InstanceAdminClient" + }, + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminClient.get_iam_policy", "method": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin.GetIamPolicy", "service": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin", "shortName": "InstanceAdmin" }, "shortName": "GetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" }, + "description": "Sample for GetIamPolicy", "file": "spanner_v1_generated_instance_admin_get_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_InstanceAdmin_GetIamPolicy_sync", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_instance_admin_get_iam_policy_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminAsyncClient", + "shortName": "InstanceAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminAsyncClient.get_instance_config", "method": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin.GetInstanceConfig", "service": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin", "shortName": "InstanceAdmin" }, "shortName": "GetInstanceConfig" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_instance_v1.types.GetInstanceConfigRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_admin_instance_v1.types.InstanceConfig", + "shortName": "get_instance_config" }, + "description": "Sample for GetInstanceConfig", "file": "spanner_v1_generated_instance_admin_get_instance_config_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_InstanceAdmin_GetInstanceConfig_async", "segments": [ { @@ -306,18 +581,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_instance_admin_get_instance_config_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminClient", + "shortName": "InstanceAdminClient" + }, + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminClient.get_instance_config", "method": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin.GetInstanceConfig", "service": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin", "shortName": "InstanceAdmin" }, "shortName": "GetInstanceConfig" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_instance_v1.types.GetInstanceConfigRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_admin_instance_v1.types.InstanceConfig", + "shortName": "get_instance_config" }, + "description": "Sample for GetInstanceConfig", "file": "spanner_v1_generated_instance_admin_get_instance_config_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_InstanceAdmin_GetInstanceConfig_sync", "segments": [ { @@ -350,19 +661,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_instance_admin_get_instance_config_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminAsyncClient", + "shortName": "InstanceAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminAsyncClient.get_instance", "method": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin.GetInstance", "service": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin", "shortName": "InstanceAdmin" }, "shortName": "GetInstance" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_instance_v1.types.GetInstanceRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_admin_instance_v1.types.Instance", + "shortName": "get_instance" }, + "description": "Sample for GetInstance", "file": "spanner_v1_generated_instance_admin_get_instance_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_InstanceAdmin_GetInstance_async", "segments": [ { @@ -395,18 +742,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_instance_admin_get_instance_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminClient", + "shortName": "InstanceAdminClient" + }, + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminClient.get_instance", "method": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin.GetInstance", "service": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin", "shortName": "InstanceAdmin" }, "shortName": "GetInstance" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_instance_v1.types.GetInstanceRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_admin_instance_v1.types.Instance", + "shortName": "get_instance" }, + "description": "Sample for GetInstance", "file": "spanner_v1_generated_instance_admin_get_instance_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_InstanceAdmin_GetInstance_sync", "segments": [ { @@ -439,19 +822,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_instance_admin_get_instance_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminAsyncClient", + "shortName": "InstanceAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminAsyncClient.list_instance_configs", "method": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs", "service": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin", "shortName": "InstanceAdmin" }, "shortName": "ListInstanceConfigs" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_instance_v1.types.ListInstanceConfigsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_admin_instance_v1.services.instance_admin.pagers.ListInstanceConfigsAsyncPager", + "shortName": "list_instance_configs" }, + "description": "Sample for ListInstanceConfigs", "file": "spanner_v1_generated_instance_admin_list_instance_configs_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_InstanceAdmin_ListInstanceConfigs_async", "segments": [ { @@ -484,18 +903,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_instance_admin_list_instance_configs_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminClient", + "shortName": "InstanceAdminClient" + }, + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminClient.list_instance_configs", "method": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs", "service": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin", "shortName": "InstanceAdmin" }, "shortName": "ListInstanceConfigs" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_instance_v1.types.ListInstanceConfigsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_admin_instance_v1.services.instance_admin.pagers.ListInstanceConfigsPager", + "shortName": "list_instance_configs" }, + "description": "Sample for ListInstanceConfigs", "file": "spanner_v1_generated_instance_admin_list_instance_configs_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_InstanceAdmin_ListInstanceConfigs_sync", "segments": [ { @@ -528,19 +983,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_instance_admin_list_instance_configs_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminAsyncClient", + "shortName": "InstanceAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminAsyncClient.list_instances", "method": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin.ListInstances", "service": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin", "shortName": "InstanceAdmin" }, "shortName": "ListInstances" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_instance_v1.types.ListInstancesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_admin_instance_v1.services.instance_admin.pagers.ListInstancesAsyncPager", + "shortName": "list_instances" }, + "description": "Sample for ListInstances", "file": "spanner_v1_generated_instance_admin_list_instances_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_InstanceAdmin_ListInstances_async", "segments": [ { @@ -573,18 +1064,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_instance_admin_list_instances_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminClient", + "shortName": "InstanceAdminClient" + }, + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminClient.list_instances", "method": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin.ListInstances", "service": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin", "shortName": "InstanceAdmin" }, "shortName": "ListInstances" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_instance_v1.types.ListInstancesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_admin_instance_v1.services.instance_admin.pagers.ListInstancesPager", + "shortName": "list_instances" }, + "description": "Sample for ListInstances", "file": "spanner_v1_generated_instance_admin_list_instances_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_InstanceAdmin_ListInstances_sync", "segments": [ { @@ -617,197 +1144,389 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_instance_admin_list_instances_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminAsyncClient", + "shortName": "InstanceAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminAsyncClient.set_iam_policy", "method": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin.SetIamPolicy", "service": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin", "shortName": "InstanceAdmin" }, "shortName": "SetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" }, + "description": "Sample for SetIamPolicy", "file": "spanner_v1_generated_instance_admin_set_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_InstanceAdmin_SetIamPolicy_async", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_instance_admin_set_iam_policy_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminClient", + "shortName": "InstanceAdminClient" + }, + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminClient.set_iam_policy", "method": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin.SetIamPolicy", "service": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin", "shortName": "InstanceAdmin" }, "shortName": "SetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" }, + "description": "Sample for SetIamPolicy", "file": "spanner_v1_generated_instance_admin_set_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_InstanceAdmin_SetIamPolicy_sync", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_instance_admin_set_iam_policy_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminAsyncClient", + "shortName": "InstanceAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminAsyncClient.test_iam_permissions", "method": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin.TestIamPermissions", "service": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin", "shortName": "InstanceAdmin" }, "shortName": "TestIamPermissions" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "permissions", + "type": "Sequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" }, + "description": "Sample for TestIamPermissions", "file": "spanner_v1_generated_instance_admin_test_iam_permissions_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_InstanceAdmin_TestIamPermissions_async", "segments": [ { - "end": 45, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 46, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 39, - "start": 34, + "end": 40, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 43, + "start": 41, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 43, + "end": 47, + "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_instance_admin_test_iam_permissions_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminClient", + "shortName": "InstanceAdminClient" + }, + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminClient.test_iam_permissions", "method": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin.TestIamPermissions", "service": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin", "shortName": "InstanceAdmin" }, "shortName": "TestIamPermissions" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "permissions", + "type": "Sequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" }, + "description": "Sample for TestIamPermissions", "file": "spanner_v1_generated_instance_admin_test_iam_permissions_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_InstanceAdmin_TestIamPermissions_sync", "segments": [ { - "end": 45, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 46, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 39, - "start": 34, + "end": 40, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 43, + "start": 41, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 43, + "end": 47, + "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_instance_admin_test_iam_permissions_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminAsyncClient", + "shortName": "InstanceAdminAsyncClient" + }, + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminAsyncClient.update_instance", "method": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance", "service": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin", "shortName": "InstanceAdmin" }, "shortName": "UpdateInstance" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_instance_v1.types.UpdateInstanceRequest" + }, + { + "name": "instance", + "type": "google.cloud.spanner_admin_instance_v1.types.Instance" + }, + { + "name": "field_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_instance" }, + "description": "Sample for UpdateInstance", "file": "spanner_v1_generated_instance_admin_update_instance_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_InstanceAdmin_UpdateInstance_async", "segments": [ { @@ -840,18 +1559,58 @@ "start": 51, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_instance_admin_update_instance_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminClient", + "shortName": "InstanceAdminClient" + }, + "fullName": "google.cloud.spanner_admin_instance_v1.InstanceAdminClient.update_instance", "method": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance", "service": { + "fullName": "google.spanner.admin.instance.v1.InstanceAdmin", "shortName": "InstanceAdmin" }, "shortName": "UpdateInstance" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_admin_instance_v1.types.UpdateInstanceRequest" + }, + { + "name": "instance", + "type": "google.cloud.spanner_admin_instance_v1.types.Instance" + }, + { + "name": "field_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_instance" }, + "description": "Sample for UpdateInstance", "file": "spanner_v1_generated_instance_admin_update_instance_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_InstanceAdmin_UpdateInstance_sync", "segments": [ { @@ -884,7 +1643,8 @@ "start": 51, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_instance_admin_update_instance_sync.py" } ] } diff --git a/samples/generated_samples/snippet_metadata_spanner_v1.json b/samples/generated_samples/snippet_metadata_spanner_v1.json index 3303488e27..5eb8233307 100644 --- a/samples/generated_samples/snippet_metadata_spanner_v1.json +++ b/samples/generated_samples/snippet_metadata_spanner_v1.json @@ -1,16 +1,65 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.spanner.v1", + "version": "v1" + } + ], + "language": "PYTHON", + "name": "google-cloud-spanner" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient", + "shortName": "SpannerAsyncClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient.batch_create_sessions", "method": { + "fullName": "google.spanner.v1.Spanner.BatchCreateSessions", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "BatchCreateSessions" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.BatchCreateSessionsRequest" + }, + { + "name": "database", + "type": "str" + }, + { + "name": "session_count", + "type": "int" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.types.BatchCreateSessionsResponse", + "shortName": "batch_create_sessions" }, + "description": "Sample for BatchCreateSessions", "file": "spanner_v1_generated_spanner_batch_create_sessions_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_BatchCreateSessions_async", "segments": [ { @@ -43,18 +92,58 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_batch_create_sessions_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_v1.SpannerClient", + "shortName": "SpannerClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerClient.batch_create_sessions", "method": { + "fullName": "google.spanner.v1.Spanner.BatchCreateSessions", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "BatchCreateSessions" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.BatchCreateSessionsRequest" + }, + { + "name": "database", + "type": "str" + }, + { + "name": "session_count", + "type": "int" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.types.BatchCreateSessionsResponse", + "shortName": "batch_create_sessions" }, + "description": "Sample for BatchCreateSessions", "file": "spanner_v1_generated_spanner_batch_create_sessions_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_BatchCreateSessions_sync", "segments": [ { @@ -87,19 +176,59 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_batch_create_sessions_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient", + "shortName": "SpannerAsyncClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient.begin_transaction", "method": { + "fullName": "google.spanner.v1.Spanner.BeginTransaction", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "BeginTransaction" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.BeginTransactionRequest" + }, + { + "name": "session", + "type": "str" + }, + { + "name": "options", + "type": "google.cloud.spanner_v1.types.TransactionOptions" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.types.Transaction", + "shortName": "begin_transaction" }, + "description": "Sample for BeginTransaction", "file": "spanner_v1_generated_spanner_begin_transaction_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_BeginTransaction_async", "segments": [ { @@ -132,18 +261,58 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_begin_transaction_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_v1.SpannerClient", + "shortName": "SpannerClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerClient.begin_transaction", "method": { + "fullName": "google.spanner.v1.Spanner.BeginTransaction", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "BeginTransaction" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.BeginTransactionRequest" + }, + { + "name": "session", + "type": "str" + }, + { + "name": "options", + "type": "google.cloud.spanner_v1.types.TransactionOptions" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.types.Transaction", + "shortName": "begin_transaction" }, + "description": "Sample for BeginTransaction", "file": "spanner_v1_generated_spanner_begin_transaction_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_BeginTransaction_sync", "segments": [ { @@ -176,19 +345,67 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_begin_transaction_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient", + "shortName": "SpannerAsyncClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient.commit", "method": { + "fullName": "google.spanner.v1.Spanner.Commit", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "Commit" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.CommitRequest" + }, + { + "name": "session", + "type": "str" + }, + { + "name": "transaction_id", + "type": "bytes" + }, + { + "name": "mutations", + "type": "Sequence[google.cloud.spanner_v1.types.Mutation]" + }, + { + "name": "single_use_transaction", + "type": "google.cloud.spanner_v1.types.TransactionOptions" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.types.CommitResponse", + "shortName": "commit" }, + "description": "Sample for Commit", "file": "spanner_v1_generated_spanner_commit_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_Commit_async", "segments": [ { @@ -221,18 +438,66 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_commit_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_v1.SpannerClient", + "shortName": "SpannerClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerClient.commit", "method": { + "fullName": "google.spanner.v1.Spanner.Commit", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "Commit" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.CommitRequest" + }, + { + "name": "session", + "type": "str" + }, + { + "name": "transaction_id", + "type": "bytes" + }, + { + "name": "mutations", + "type": "Sequence[google.cloud.spanner_v1.types.Mutation]" + }, + { + "name": "single_use_transaction", + "type": "google.cloud.spanner_v1.types.TransactionOptions" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.types.CommitResponse", + "shortName": "commit" }, + "description": "Sample for Commit", "file": "spanner_v1_generated_spanner_commit_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_Commit_sync", "segments": [ { @@ -265,19 +530,55 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_commit_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient", + "shortName": "SpannerAsyncClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient.create_session", "method": { + "fullName": "google.spanner.v1.Spanner.CreateSession", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "CreateSession" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.CreateSessionRequest" + }, + { + "name": "database", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.types.Session", + "shortName": "create_session" }, + "description": "Sample for CreateSession", "file": "spanner_v1_generated_spanner_create_session_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_CreateSession_async", "segments": [ { @@ -310,18 +611,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_create_session_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_v1.SpannerClient", + "shortName": "SpannerClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerClient.create_session", "method": { + "fullName": "google.spanner.v1.Spanner.CreateSession", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "CreateSession" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.CreateSessionRequest" + }, + { + "name": "database", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.types.Session", + "shortName": "create_session" }, + "description": "Sample for CreateSession", "file": "spanner_v1_generated_spanner_create_session_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_CreateSession_sync", "segments": [ { @@ -354,19 +691,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_create_session_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient", + "shortName": "SpannerAsyncClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient.delete_session", "method": { + "fullName": "google.spanner.v1.Spanner.DeleteSession", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "DeleteSession" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.DeleteSessionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_session" }, + "description": "Sample for DeleteSession", "file": "spanner_v1_generated_spanner_delete_session_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_DeleteSession_async", "segments": [ { @@ -397,18 +769,53 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_delete_session_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_v1.SpannerClient", + "shortName": "SpannerClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerClient.delete_session", "method": { + "fullName": "google.spanner.v1.Spanner.DeleteSession", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "DeleteSession" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.DeleteSessionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_session" }, + "description": "Sample for DeleteSession", "file": "spanner_v1_generated_spanner_delete_session_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_DeleteSession_sync", "segments": [ { @@ -439,19 +846,51 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_delete_session_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient", + "shortName": "SpannerAsyncClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient.execute_batch_dml", "method": { + "fullName": "google.spanner.v1.Spanner.ExecuteBatchDml", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "ExecuteBatchDml" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.ExecuteBatchDmlRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.types.ExecuteBatchDmlResponse", + "shortName": "execute_batch_dml" }, + "description": "Sample for ExecuteBatchDml", "file": "spanner_v1_generated_spanner_execute_batch_dml_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_ExecuteBatchDml_async", "segments": [ { @@ -484,18 +923,50 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_execute_batch_dml_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_v1.SpannerClient", + "shortName": "SpannerClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerClient.execute_batch_dml", "method": { + "fullName": "google.spanner.v1.Spanner.ExecuteBatchDml", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "ExecuteBatchDml" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.ExecuteBatchDmlRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.types.ExecuteBatchDmlResponse", + "shortName": "execute_batch_dml" }, + "description": "Sample for ExecuteBatchDml", "file": "spanner_v1_generated_spanner_execute_batch_dml_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_ExecuteBatchDml_sync", "segments": [ { @@ -528,19 +999,51 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_execute_batch_dml_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient", + "shortName": "SpannerAsyncClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient.execute_sql", "method": { + "fullName": "google.spanner.v1.Spanner.ExecuteSql", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "ExecuteSql" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.ExecuteSqlRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.types.ResultSet", + "shortName": "execute_sql" }, + "description": "Sample for ExecuteSql", "file": "spanner_v1_generated_spanner_execute_sql_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_ExecuteSql_async", "segments": [ { @@ -573,18 +1076,50 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_execute_sql_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_v1.SpannerClient", + "shortName": "SpannerClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerClient.execute_sql", "method": { + "fullName": "google.spanner.v1.Spanner.ExecuteSql", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "ExecuteSql" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.ExecuteSqlRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.types.ResultSet", + "shortName": "execute_sql" }, + "description": "Sample for ExecuteSql", "file": "spanner_v1_generated_spanner_execute_sql_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_ExecuteSql_sync", "segments": [ { @@ -617,19 +1152,51 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_execute_sql_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient", + "shortName": "SpannerAsyncClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient.execute_streaming_sql", "method": { + "fullName": "google.spanner.v1.Spanner.ExecuteStreamingSql", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "ExecuteStreamingSql" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.ExecuteSqlRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "Iterable[google.cloud.spanner_v1.types.PartialResultSet]", + "shortName": "execute_streaming_sql" }, + "description": "Sample for ExecuteStreamingSql", "file": "spanner_v1_generated_spanner_execute_streaming_sql_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_ExecuteStreamingSql_async", "segments": [ { @@ -662,18 +1229,50 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_execute_streaming_sql_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_v1.SpannerClient", + "shortName": "SpannerClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerClient.execute_streaming_sql", "method": { + "fullName": "google.spanner.v1.Spanner.ExecuteStreamingSql", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "ExecuteStreamingSql" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.ExecuteSqlRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "Iterable[google.cloud.spanner_v1.types.PartialResultSet]", + "shortName": "execute_streaming_sql" }, + "description": "Sample for ExecuteStreamingSql", "file": "spanner_v1_generated_spanner_execute_streaming_sql_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_ExecuteStreamingSql_sync", "segments": [ { @@ -706,19 +1305,55 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_execute_streaming_sql_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient", + "shortName": "SpannerAsyncClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient.get_session", "method": { + "fullName": "google.spanner.v1.Spanner.GetSession", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "GetSession" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.GetSessionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.types.Session", + "shortName": "get_session" }, + "description": "Sample for GetSession", "file": "spanner_v1_generated_spanner_get_session_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_GetSession_async", "segments": [ { @@ -751,18 +1386,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_get_session_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_v1.SpannerClient", + "shortName": "SpannerClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerClient.get_session", "method": { + "fullName": "google.spanner.v1.Spanner.GetSession", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "GetSession" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.GetSessionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.types.Session", + "shortName": "get_session" }, + "description": "Sample for GetSession", "file": "spanner_v1_generated_spanner_get_session_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_GetSession_sync", "segments": [ { @@ -795,19 +1466,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_get_session_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient", + "shortName": "SpannerAsyncClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient.list_sessions", "method": { + "fullName": "google.spanner.v1.Spanner.ListSessions", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "ListSessions" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.ListSessionsRequest" + }, + { + "name": "database", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.services.spanner.pagers.ListSessionsAsyncPager", + "shortName": "list_sessions" }, + "description": "Sample for ListSessions", "file": "spanner_v1_generated_spanner_list_sessions_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_ListSessions_async", "segments": [ { @@ -840,18 +1547,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_list_sessions_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_v1.SpannerClient", + "shortName": "SpannerClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerClient.list_sessions", "method": { + "fullName": "google.spanner.v1.Spanner.ListSessions", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "ListSessions" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.ListSessionsRequest" + }, + { + "name": "database", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.services.spanner.pagers.ListSessionsPager", + "shortName": "list_sessions" }, + "description": "Sample for ListSessions", "file": "spanner_v1_generated_spanner_list_sessions_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_ListSessions_sync", "segments": [ { @@ -884,19 +1627,51 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_list_sessions_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient", + "shortName": "SpannerAsyncClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient.partition_query", "method": { + "fullName": "google.spanner.v1.Spanner.PartitionQuery", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "PartitionQuery" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.PartitionQueryRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.types.PartitionResponse", + "shortName": "partition_query" }, + "description": "Sample for PartitionQuery", "file": "spanner_v1_generated_spanner_partition_query_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_PartitionQuery_async", "segments": [ { @@ -929,18 +1704,50 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_partition_query_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_v1.SpannerClient", + "shortName": "SpannerClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerClient.partition_query", "method": { + "fullName": "google.spanner.v1.Spanner.PartitionQuery", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "PartitionQuery" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.PartitionQueryRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.types.PartitionResponse", + "shortName": "partition_query" }, + "description": "Sample for PartitionQuery", "file": "spanner_v1_generated_spanner_partition_query_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_PartitionQuery_sync", "segments": [ { @@ -973,19 +1780,51 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_partition_query_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient", + "shortName": "SpannerAsyncClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient.partition_read", "method": { + "fullName": "google.spanner.v1.Spanner.PartitionRead", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "PartitionRead" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.PartitionReadRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.types.PartitionResponse", + "shortName": "partition_read" }, + "description": "Sample for PartitionRead", "file": "spanner_v1_generated_spanner_partition_read_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_PartitionRead_async", "segments": [ { @@ -1018,18 +1857,50 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_partition_read_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_v1.SpannerClient", + "shortName": "SpannerClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerClient.partition_read", "method": { + "fullName": "google.spanner.v1.Spanner.PartitionRead", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "PartitionRead" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.PartitionReadRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.types.PartitionResponse", + "shortName": "partition_read" }, + "description": "Sample for PartitionRead", "file": "spanner_v1_generated_spanner_partition_read_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_PartitionRead_sync", "segments": [ { @@ -1062,19 +1933,51 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_partition_read_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient", + "shortName": "SpannerAsyncClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient.read", "method": { + "fullName": "google.spanner.v1.Spanner.Read", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "Read" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.ReadRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.types.ResultSet", + "shortName": "read" }, + "description": "Sample for Read", "file": "spanner_v1_generated_spanner_read_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_Read_async", "segments": [ { @@ -1107,18 +2010,50 @@ "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_read_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_v1.SpannerClient", + "shortName": "SpannerClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerClient.read", "method": { + "fullName": "google.spanner.v1.Spanner.Read", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "Read" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.ReadRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.spanner_v1.types.ResultSet", + "shortName": "read" }, + "description": "Sample for Read", "file": "spanner_v1_generated_spanner_read_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_Read_sync", "segments": [ { @@ -1151,19 +2086,58 @@ "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_read_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient", + "shortName": "SpannerAsyncClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient.rollback", "method": { + "fullName": "google.spanner.v1.Spanner.Rollback", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "Rollback" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.RollbackRequest" + }, + { + "name": "session", + "type": "str" + }, + { + "name": "transaction_id", + "type": "bytes" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "rollback" }, + "description": "Sample for Rollback", "file": "spanner_v1_generated_spanner_rollback_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_Rollback_async", "segments": [ { @@ -1194,18 +2168,57 @@ "end": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_rollback_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_v1.SpannerClient", + "shortName": "SpannerClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerClient.rollback", "method": { + "fullName": "google.spanner.v1.Spanner.Rollback", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "Rollback" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.RollbackRequest" + }, + { + "name": "session", + "type": "str" + }, + { + "name": "transaction_id", + "type": "bytes" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "rollback" }, + "description": "Sample for Rollback", "file": "spanner_v1_generated_spanner_rollback_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_Rollback_sync", "segments": [ { @@ -1236,19 +2249,51 @@ "end": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_rollback_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient", + "shortName": "SpannerAsyncClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerAsyncClient.streaming_read", "method": { + "fullName": "google.spanner.v1.Spanner.StreamingRead", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "StreamingRead" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.ReadRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "Iterable[google.cloud.spanner_v1.types.PartialResultSet]", + "shortName": "streaming_read" }, + "description": "Sample for StreamingRead", "file": "spanner_v1_generated_spanner_streaming_read_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_StreamingRead_async", "segments": [ { @@ -1281,18 +2326,50 @@ "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_streaming_read_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.spanner_v1.SpannerClient", + "shortName": "SpannerClient" + }, + "fullName": "google.cloud.spanner_v1.SpannerClient.streaming_read", "method": { + "fullName": "google.spanner.v1.Spanner.StreamingRead", "service": { + "fullName": "google.spanner.v1.Spanner", "shortName": "Spanner" }, "shortName": "StreamingRead" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.spanner_v1.types.ReadRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "Iterable[google.cloud.spanner_v1.types.PartialResultSet]", + "shortName": "streaming_read" }, + "description": "Sample for StreamingRead", "file": "spanner_v1_generated_spanner_streaming_read_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "spanner_v1_generated_Spanner_StreamingRead_sync", "segments": [ { @@ -1325,7 +2402,8 @@ "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "spanner_v1_generated_spanner_streaming_read_sync.py" } ] } diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_get_iam_policy_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_get_iam_policy_async.py index b9ef3174d4..1959177243 100644 --- a/samples/generated_samples/spanner_v1_generated_database_admin_get_iam_policy_async.py +++ b/samples/generated_samples/spanner_v1_generated_database_admin_get_iam_policy_async.py @@ -25,6 +25,7 @@ # [START spanner_v1_generated_DatabaseAdmin_GetIamPolicy_async] from google.cloud import spanner_admin_database_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_get_iam_policy(): @@ -32,7 +33,7 @@ async def sample_get_iam_policy(): client = spanner_admin_database_v1.DatabaseAdminAsyncClient() # Initialize request argument(s) - request = spanner_admin_database_v1.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_get_iam_policy_sync.py b/samples/generated_samples/spanner_v1_generated_database_admin_get_iam_policy_sync.py index 41c61972c6..9be30edfd6 100644 --- a/samples/generated_samples/spanner_v1_generated_database_admin_get_iam_policy_sync.py +++ b/samples/generated_samples/spanner_v1_generated_database_admin_get_iam_policy_sync.py @@ -25,6 +25,7 @@ # [START spanner_v1_generated_DatabaseAdmin_GetIamPolicy_sync] from google.cloud import spanner_admin_database_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_get_iam_policy(): @@ -32,7 +33,7 @@ def sample_get_iam_policy(): client = spanner_admin_database_v1.DatabaseAdminClient() # Initialize request argument(s) - request = spanner_admin_database_v1.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_set_iam_policy_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_set_iam_policy_async.py index 598b532ec5..98c7e11f73 100644 --- a/samples/generated_samples/spanner_v1_generated_database_admin_set_iam_policy_async.py +++ b/samples/generated_samples/spanner_v1_generated_database_admin_set_iam_policy_async.py @@ -25,6 +25,7 @@ # [START spanner_v1_generated_DatabaseAdmin_SetIamPolicy_async] from google.cloud import spanner_admin_database_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_set_iam_policy(): @@ -32,7 +33,7 @@ async def sample_set_iam_policy(): client = spanner_admin_database_v1.DatabaseAdminAsyncClient() # Initialize request argument(s) - request = spanner_admin_database_v1.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_set_iam_policy_sync.py b/samples/generated_samples/spanner_v1_generated_database_admin_set_iam_policy_sync.py index 64099fc14d..7afb87925a 100644 --- a/samples/generated_samples/spanner_v1_generated_database_admin_set_iam_policy_sync.py +++ b/samples/generated_samples/spanner_v1_generated_database_admin_set_iam_policy_sync.py @@ -25,6 +25,7 @@ # [START spanner_v1_generated_DatabaseAdmin_SetIamPolicy_sync] from google.cloud import spanner_admin_database_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_set_iam_policy(): @@ -32,7 +33,7 @@ def sample_set_iam_policy(): client = spanner_admin_database_v1.DatabaseAdminClient() # Initialize request argument(s) - request = spanner_admin_database_v1.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_test_iam_permissions_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_test_iam_permissions_async.py index 2c1bcf70c9..9708cba8b0 100644 --- a/samples/generated_samples/spanner_v1_generated_database_admin_test_iam_permissions_async.py +++ b/samples/generated_samples/spanner_v1_generated_database_admin_test_iam_permissions_async.py @@ -25,6 +25,7 @@ # [START spanner_v1_generated_DatabaseAdmin_TestIamPermissions_async] from google.cloud import spanner_admin_database_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_test_iam_permissions(): @@ -32,7 +33,7 @@ async def sample_test_iam_permissions(): client = spanner_admin_database_v1.DatabaseAdminAsyncClient() # Initialize request argument(s) - request = spanner_admin_database_v1.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_test_iam_permissions_sync.py b/samples/generated_samples/spanner_v1_generated_database_admin_test_iam_permissions_sync.py index 1ebc5140e9..b0aa0f62fb 100644 --- a/samples/generated_samples/spanner_v1_generated_database_admin_test_iam_permissions_sync.py +++ b/samples/generated_samples/spanner_v1_generated_database_admin_test_iam_permissions_sync.py @@ -25,6 +25,7 @@ # [START spanner_v1_generated_DatabaseAdmin_TestIamPermissions_sync] from google.cloud import spanner_admin_database_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_test_iam_permissions(): @@ -32,7 +33,7 @@ def sample_test_iam_permissions(): client = spanner_admin_database_v1.DatabaseAdminClient() # Initialize request argument(s) - request = spanner_admin_database_v1.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_get_iam_policy_async.py b/samples/generated_samples/spanner_v1_generated_instance_admin_get_iam_policy_async.py index 01f1b4e3d2..d052e15b6d 100644 --- a/samples/generated_samples/spanner_v1_generated_instance_admin_get_iam_policy_async.py +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_get_iam_policy_async.py @@ -25,6 +25,7 @@ # [START spanner_v1_generated_InstanceAdmin_GetIamPolicy_async] from google.cloud import spanner_admin_instance_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_get_iam_policy(): @@ -32,7 +33,7 @@ async def sample_get_iam_policy(): client = spanner_admin_instance_v1.InstanceAdminAsyncClient() # Initialize request argument(s) - request = spanner_admin_instance_v1.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_get_iam_policy_sync.py b/samples/generated_samples/spanner_v1_generated_instance_admin_get_iam_policy_sync.py index 8de214c9bb..0c172f5b8d 100644 --- a/samples/generated_samples/spanner_v1_generated_instance_admin_get_iam_policy_sync.py +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_get_iam_policy_sync.py @@ -25,6 +25,7 @@ # [START spanner_v1_generated_InstanceAdmin_GetIamPolicy_sync] from google.cloud import spanner_admin_instance_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_get_iam_policy(): @@ -32,7 +33,7 @@ def sample_get_iam_policy(): client = spanner_admin_instance_v1.InstanceAdminClient() # Initialize request argument(s) - request = spanner_admin_instance_v1.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_set_iam_policy_async.py b/samples/generated_samples/spanner_v1_generated_instance_admin_set_iam_policy_async.py index ee5d8280ab..25d90383d8 100644 --- a/samples/generated_samples/spanner_v1_generated_instance_admin_set_iam_policy_async.py +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_set_iam_policy_async.py @@ -25,6 +25,7 @@ # [START spanner_v1_generated_InstanceAdmin_SetIamPolicy_async] from google.cloud import spanner_admin_instance_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_set_iam_policy(): @@ -32,7 +33,7 @@ async def sample_set_iam_policy(): client = spanner_admin_instance_v1.InstanceAdminAsyncClient() # Initialize request argument(s) - request = spanner_admin_instance_v1.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_set_iam_policy_sync.py b/samples/generated_samples/spanner_v1_generated_instance_admin_set_iam_policy_sync.py index ea140d4e43..76ae1c544d 100644 --- a/samples/generated_samples/spanner_v1_generated_instance_admin_set_iam_policy_sync.py +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_set_iam_policy_sync.py @@ -25,6 +25,7 @@ # [START spanner_v1_generated_InstanceAdmin_SetIamPolicy_sync] from google.cloud import spanner_admin_instance_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_set_iam_policy(): @@ -32,7 +33,7 @@ def sample_set_iam_policy(): client = spanner_admin_instance_v1.InstanceAdminClient() # Initialize request argument(s) - request = spanner_admin_instance_v1.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_test_iam_permissions_async.py b/samples/generated_samples/spanner_v1_generated_instance_admin_test_iam_permissions_async.py index 63a65aee57..0669b2b8b6 100644 --- a/samples/generated_samples/spanner_v1_generated_instance_admin_test_iam_permissions_async.py +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_test_iam_permissions_async.py @@ -25,6 +25,7 @@ # [START spanner_v1_generated_InstanceAdmin_TestIamPermissions_async] from google.cloud import spanner_admin_instance_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_test_iam_permissions(): @@ -32,7 +33,7 @@ async def sample_test_iam_permissions(): client = spanner_admin_instance_v1.InstanceAdminAsyncClient() # Initialize request argument(s) - request = spanner_admin_instance_v1.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_test_iam_permissions_sync.py b/samples/generated_samples/spanner_v1_generated_instance_admin_test_iam_permissions_sync.py index 55a400649f..a2bad7d92b 100644 --- a/samples/generated_samples/spanner_v1_generated_instance_admin_test_iam_permissions_sync.py +++ b/samples/generated_samples/spanner_v1_generated_instance_admin_test_iam_permissions_sync.py @@ -25,6 +25,7 @@ # [START spanner_v1_generated_InstanceAdmin_TestIamPermissions_sync] from google.cloud import spanner_admin_instance_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_test_iam_permissions(): @@ -32,7 +33,7 @@ def sample_test_iam_permissions(): client = spanner_admin_instance_v1.InstanceAdminClient() # Initialize request argument(s) - request = spanner_admin_instance_v1.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) diff --git a/scripts/fixup_spanner_admin_database_v1_keywords.py b/scripts/fixup_spanner_admin_database_v1_keywords.py index 5c11670473..af7791c4ad 100644 --- a/scripts/fixup_spanner_admin_database_v1_keywords.py +++ b/scripts/fixup_spanner_admin_database_v1_keywords.py @@ -53,7 +53,7 @@ class spanner_admin_databaseCallTransformer(cst.CSTTransformer): 'list_database_operations': ('parent', 'filter', 'page_size', 'page_token', ), 'list_databases': ('parent', 'page_size', 'page_token', ), 'restore_database': ('parent', 'database_id', 'backup', 'encryption_config', ), - 'set_iam_policy': ('resource', 'policy', ), + 'set_iam_policy': ('resource', 'policy', 'update_mask', ), 'test_iam_permissions': ('resource', 'permissions', ), 'update_backup': ('backup', 'update_mask', ), 'update_database_ddl': ('database', 'statements', 'operation_id', ), diff --git a/scripts/fixup_spanner_admin_instance_v1_keywords.py b/scripts/fixup_spanner_admin_instance_v1_keywords.py index 4142cf7000..7b8b1c9895 100644 --- a/scripts/fixup_spanner_admin_instance_v1_keywords.py +++ b/scripts/fixup_spanner_admin_instance_v1_keywords.py @@ -46,7 +46,7 @@ class spanner_admin_instanceCallTransformer(cst.CSTTransformer): 'get_instance_config': ('name', ), 'list_instance_configs': ('parent', 'page_size', 'page_token', ), 'list_instances': ('parent', 'page_size', 'page_token', 'filter', ), - 'set_iam_policy': ('resource', 'policy', ), + 'set_iam_policy': ('resource', 'policy', 'update_mask', ), 'test_iam_permissions': ('resource', 'permissions', ), 'update_instance': ('instance', 'field_mask', ), } diff --git a/setup.py b/setup.py index 3da9372306..534fa4cb09 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,7 @@ # Until this issue is closed # https://github.com/googleapis/google-cloud-python/issues/10566 "google-cloud-core >= 1.4.1, < 3.0dev", - "grpc-google-iam-v1 >= 0.12.3, < 0.13dev", + "grpc-google-iam-v1 >= 0.12.4, <1.0.0dev", "proto-plus >= 1.15.0, != 1.19.6", "sqlparse >= 0.3.0", "packaging >= 14.3", diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index 7ceb82cd99..4c581a9373 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -7,7 +7,7 @@ # Then this file should have foo==1.14.0 google-api-core==1.31.5 google-cloud-core==1.4.1 -grpc-google-iam-v1==0.12.3 +grpc-google-iam-v1==0.12.4 libcst==0.2.5 proto-plus==1.15.0 sqlparse==0.3.0 diff --git a/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py b/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py index 4052f1a787..bf1a442f66 100644 --- a/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py +++ b/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py @@ -106,24 +106,24 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - DatabaseAdminClient, - DatabaseAdminAsyncClient, + (DatabaseAdminClient, "grpc"), + (DatabaseAdminAsyncClient, "grpc_asyncio"), ], ) -def test_database_admin_client_from_service_account_info(client_class): +def test_database_admin_client_from_service_account_info(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "spanner.googleapis.com:443" + assert client.transport._host == ("spanner.googleapis.com:443") @pytest.mark.parametrize( @@ -152,27 +152,31 @@ def test_database_admin_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - DatabaseAdminClient, - DatabaseAdminAsyncClient, + (DatabaseAdminClient, "grpc"), + (DatabaseAdminAsyncClient, "grpc_asyncio"), ], ) -def test_database_admin_client_from_service_account_file(client_class): +def test_database_admin_client_from_service_account_file(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "spanner.googleapis.com:443" + assert client.transport._host == ("spanner.googleapis.com:443") def test_database_admin_client_get_transport_class(): @@ -1032,7 +1036,7 @@ async def test_list_databases_async_pager(): ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -1078,7 +1082,9 @@ async def test_list_databases_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_databases(request={})).pages: + async for page_ in ( + await client.list_databases(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -2439,6 +2445,7 @@ def test_set_iam_policy_from_dict_foreign(): request={ "resource": "resource_value", "policy": policy_pb2.Policy(version=774), + "update_mask": field_mask_pb2.FieldMask(paths=["paths_value"]), } ) call.assert_called() @@ -4651,7 +4658,7 @@ async def test_list_backups_async_pager(): ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -4697,7 +4704,9 @@ async def test_list_backups_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_backups(request={})).pages: + async for page_ in ( + await client.list_backups(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -5333,7 +5342,7 @@ async def test_list_database_operations_async_pager(): ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -5381,7 +5390,9 @@ async def test_list_database_operations_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_database_operations(request={})).pages: + async for page_ in ( + await client.list_database_operations(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -5773,7 +5784,7 @@ async def test_list_backup_operations_async_pager(): ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -5821,7 +5832,9 @@ async def test_list_backup_operations_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_backup_operations(request={})).pages: + async for page_ in ( + await client.list_backup_operations(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -5918,6 +5931,19 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = DatabaseAdminClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = DatabaseAdminClient( @@ -5982,6 +6008,14 @@ def test_database_admin_base_transport(): 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_database_admin_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -6139,24 +6173,40 @@ def test_database_admin_grpc_transport_client_cert_source_for_mtls(transport_cla ) -def test_database_admin_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_database_admin_host_no_port(transport_name): client = DatabaseAdminClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="spanner.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "spanner.googleapis.com:443" + assert client.transport._host == ("spanner.googleapis.com:443") -def test_database_admin_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_database_admin_host_with_port(transport_name): client = DatabaseAdminClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="spanner.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "spanner.googleapis.com:8000" + assert client.transport._host == ("spanner.googleapis.com:8000") def test_database_admin_grpc_transport_channel(): diff --git a/tests/unit/gapic/spanner_admin_instance_v1/test_instance_admin.py b/tests/unit/gapic/spanner_admin_instance_v1/test_instance_admin.py index 85309bd8ad..59e7134f41 100644 --- a/tests/unit/gapic/spanner_admin_instance_v1/test_instance_admin.py +++ b/tests/unit/gapic/spanner_admin_instance_v1/test_instance_admin.py @@ -99,24 +99,24 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - InstanceAdminClient, - InstanceAdminAsyncClient, + (InstanceAdminClient, "grpc"), + (InstanceAdminAsyncClient, "grpc_asyncio"), ], ) -def test_instance_admin_client_from_service_account_info(client_class): +def test_instance_admin_client_from_service_account_info(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "spanner.googleapis.com:443" + assert client.transport._host == ("spanner.googleapis.com:443") @pytest.mark.parametrize( @@ -145,27 +145,31 @@ def test_instance_admin_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - InstanceAdminClient, - InstanceAdminAsyncClient, + (InstanceAdminClient, "grpc"), + (InstanceAdminAsyncClient, "grpc_asyncio"), ], ) -def test_instance_admin_client_from_service_account_file(client_class): +def test_instance_admin_client_from_service_account_file(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "spanner.googleapis.com:443" + assert client.transport._host == ("spanner.googleapis.com:443") def test_instance_admin_client_get_transport_class(): @@ -1047,7 +1051,7 @@ async def test_list_instance_configs_async_pager(): ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -1097,7 +1101,9 @@ async def test_list_instance_configs_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_instance_configs(request={})).pages: + async for page_ in ( + await client.list_instance_configs(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -1725,7 +1731,7 @@ async def test_list_instances_async_pager(): ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -1771,7 +1777,9 @@ async def test_list_instances_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_instances(request={})).pages: + async for page_ in ( + await client.list_instances(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -2903,6 +2911,7 @@ def test_set_iam_policy_from_dict_foreign(): request={ "resource": "resource_value", "policy": policy_pb2.Policy(version=774), + "update_mask": field_mask_pb2.FieldMask(paths=["paths_value"]), } ) call.assert_called() @@ -3604,6 +3613,19 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = InstanceAdminClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = InstanceAdminClient( @@ -3660,6 +3682,14 @@ def test_instance_admin_base_transport(): 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_instance_admin_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -3817,24 +3847,40 @@ def test_instance_admin_grpc_transport_client_cert_source_for_mtls(transport_cla ) -def test_instance_admin_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_instance_admin_host_no_port(transport_name): client = InstanceAdminClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="spanner.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "spanner.googleapis.com:443" + assert client.transport._host == ("spanner.googleapis.com:443") -def test_instance_admin_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_instance_admin_host_with_port(transport_name): client = InstanceAdminClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="spanner.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "spanner.googleapis.com:8000" + assert client.transport._host == ("spanner.googleapis.com:8000") def test_instance_admin_grpc_transport_channel(): diff --git a/tests/unit/gapic/spanner_v1/test_spanner.py b/tests/unit/gapic/spanner_v1/test_spanner.py index f0c0f0bafc..d4df289e48 100644 --- a/tests/unit/gapic/spanner_v1/test_spanner.py +++ b/tests/unit/gapic/spanner_v1/test_spanner.py @@ -89,24 +89,24 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - SpannerClient, - SpannerAsyncClient, + (SpannerClient, "grpc"), + (SpannerAsyncClient, "grpc_asyncio"), ], ) -def test_spanner_client_from_service_account_info(client_class): +def test_spanner_client_from_service_account_info(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "spanner.googleapis.com:443" + assert client.transport._host == ("spanner.googleapis.com:443") @pytest.mark.parametrize( @@ -133,27 +133,31 @@ def test_spanner_client_service_account_always_use_jwt(transport_class, transpor @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - SpannerClient, - SpannerAsyncClient, + (SpannerClient, "grpc"), + (SpannerAsyncClient, "grpc_asyncio"), ], ) -def test_spanner_client_from_service_account_file(client_class): +def test_spanner_client_from_service_account_file(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "spanner.googleapis.com:443" + assert client.transport._host == ("spanner.googleapis.com:443") def test_spanner_client_get_transport_class(): @@ -1682,7 +1686,7 @@ async def test_list_sessions_async_pager(): ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -1728,7 +1732,9 @@ async def test_list_sessions_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_sessions(request={})).pages: + async for page_ in ( + await client.list_sessions(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -3829,6 +3835,19 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = SpannerClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = SpannerClient( @@ -3885,6 +3904,14 @@ def test_spanner_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_spanner_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -4039,24 +4066,40 @@ def test_spanner_grpc_transport_client_cert_source_for_mtls(transport_class): ) -def test_spanner_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_spanner_host_no_port(transport_name): client = SpannerClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="spanner.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "spanner.googleapis.com:443" + assert client.transport._host == ("spanner.googleapis.com:443") -def test_spanner_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_spanner_host_with_port(transport_name): client = SpannerClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="spanner.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "spanner.googleapis.com:8000" + assert client.transport._host == ("spanner.googleapis.com:8000") def test_spanner_grpc_transport_channel(): From 265e20711510aafc956552e9684ab7a39074bf70 Mon Sep 17 00:00:00 2001 From: Vikash Singh <3116482+vi3k6i5@users.noreply.github.com> Date: Wed, 20 Apr 2022 12:33:33 +0530 Subject: [PATCH 15/16] fix: add NOT_FOUND error check in __exit__ method of SessionCheckout. (#718) * fix: Inside SnapshotCheckout __exit__ block check if NotFound exception was raised for the session and create new session if needed * test: add test for SnapshotCheckout __exit__ checks * refactor: lint fixes * test: add test case for NotFound Error in SessionCheckout context but unrelated to Sessions --- google/cloud/spanner_v1/database.py | 6 +++ tests/unit/test_database.py | 61 ++++++++++++++++++++++++++++- 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/google/cloud/spanner_v1/database.py b/google/cloud/spanner_v1/database.py index 5dc41e525e..90916bc710 100644 --- a/google/cloud/spanner_v1/database.py +++ b/google/cloud/spanner_v1/database.py @@ -868,6 +868,12 @@ def __enter__(self): def __exit__(self, exc_type, exc_val, exc_tb): """End ``with`` block.""" + if isinstance(exc_val, NotFound): + # If NotFound exception occurs inside the with block + # then we validate if the session still exists. + if not self._session.exists(): + self._session = self._database._pool._new_session() + self._session.create() self._database._pool.put(self._session) diff --git a/tests/unit/test_database.py b/tests/unit/test_database.py index 9cabc99945..bd47a2ac31 100644 --- a/tests/unit/test_database.py +++ b/tests/unit/test_database.py @@ -17,7 +17,6 @@ import mock from google.api_core import gapic_v1 - from google.cloud.spanner_v1.param_types import INT64 from google.api_core.retry import Retry @@ -1792,6 +1791,66 @@ class Testing(Exception): self.assertIs(pool._session, session) + def test_context_mgr_session_not_found_error(self): + from google.cloud.exceptions import NotFound + + database = _Database(self.DATABASE_NAME) + session = _Session(database, name="session-1") + session.exists = mock.MagicMock(return_value=False) + pool = database._pool = _Pool() + new_session = _Session(database, name="session-2") + new_session.create = mock.MagicMock(return_value=[]) + pool._new_session = mock.MagicMock(return_value=new_session) + + pool.put(session) + checkout = self._make_one(database) + + self.assertEqual(pool._session, session) + with self.assertRaises(NotFound): + with checkout as _: + raise NotFound("Session not found") + # Assert that session-1 was removed from pool and new session was added. + self.assertEqual(pool._session, new_session) + + def test_context_mgr_table_not_found_error(self): + from google.cloud.exceptions import NotFound + + database = _Database(self.DATABASE_NAME) + session = _Session(database, name="session-1") + session.exists = mock.MagicMock(return_value=True) + pool = database._pool = _Pool() + pool._new_session = mock.MagicMock(return_value=[]) + + pool.put(session) + checkout = self._make_one(database) + + self.assertEqual(pool._session, session) + with self.assertRaises(NotFound): + with checkout as _: + raise NotFound("Table not found") + # Assert that session-1 was not removed from pool. + self.assertEqual(pool._session, session) + pool._new_session.assert_not_called() + + def test_context_mgr_unknown_error(self): + database = _Database(self.DATABASE_NAME) + session = _Session(database) + pool = database._pool = _Pool() + pool._new_session = mock.MagicMock(return_value=[]) + pool.put(session) + checkout = self._make_one(database) + + class Testing(Exception): + pass + + self.assertEqual(pool._session, session) + with self.assertRaises(Testing): + with checkout as _: + raise Testing("Unknown error.") + # Assert that session-1 was not removed from pool. + self.assertEqual(pool._session, session) + pool._new_session.assert_not_called() + class TestBatchSnapshot(_BaseTest): TABLE = "table_name" From 9c9ad66747986b7ee99b17aff1139262dcd4637e Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 20 Apr 2022 14:04:33 +0530 Subject: [PATCH 16/16] chore(main): release 3.14.0 (#682) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 22 ++++++++++++++++++++++ setup.py | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e84502a3b..70a1735bb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,28 @@ [1]: https://pypi.org/project/google-cloud-spanner/#history +## [3.14.0](https://github.com/googleapis/python-spanner/compare/v3.13.0...v3.14.0) (2022-04-20) + + +### Features + +* add support for Cross region backup proto changes ([#691](https://github.com/googleapis/python-spanner/issues/691)) ([8ac62cb](https://github.com/googleapis/python-spanner/commit/8ac62cb83ee5525d6233dcc34919dcbf9471461b)) +* add support for spanner copy backup feature ([#600](https://github.com/googleapis/python-spanner/issues/600)) ([97faf6c](https://github.com/googleapis/python-spanner/commit/97faf6c11f985f128446bc7d9e99a22362bd1bc1)) +* AuditConfig for IAM v1 ([7642eba](https://github.com/googleapis/python-spanner/commit/7642eba1d9c66525ea1ca6f36dd91c759ed3cbde)) + + +### Bug Fixes + +* add NOT_FOUND error check in __exit__ method of SessionCheckout. ([#718](https://github.com/googleapis/python-spanner/issues/718)) ([265e207](https://github.com/googleapis/python-spanner/commit/265e20711510aafc956552e9684ab7a39074bf70)) +* **deps:** require google-api-core>=1.31.5, >=2.3.2 ([#685](https://github.com/googleapis/python-spanner/issues/685)) ([7a46a27](https://github.com/googleapis/python-spanner/commit/7a46a27bacbdcb1e72888bd93dfce93c439ceae2)) +* **deps:** require grpc-google-iam-v1 >=0.12.4 ([7642eba](https://github.com/googleapis/python-spanner/commit/7642eba1d9c66525ea1ca6f36dd91c759ed3cbde)) +* **deps:** require proto-plus>=1.15.0 ([7a46a27](https://github.com/googleapis/python-spanner/commit/7a46a27bacbdcb1e72888bd93dfce93c439ceae2)) + + +### Documentation + +* add generated snippets ([#680](https://github.com/googleapis/python-spanner/issues/680)) ([f21dac4](https://github.com/googleapis/python-spanner/commit/f21dac4c47cb6a6a85fd282b8e5de966b467b1b6)) + ## [3.13.0](https://github.com/googleapis/python-spanner/compare/v3.12.1...v3.13.0) (2022-02-04) diff --git a/setup.py b/setup.py index 534fa4cb09..28fd020ab5 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ name = "google-cloud-spanner" description = "Cloud Spanner API client library" -version = "3.13.0" +version = "3.14.0" # Should be one of: # 'Development Status :: 3 - Alpha' # 'Development Status :: 4 - Beta'