8000 feat(spanner): Add support for Cloud Spanner Scheduled Backups (#540) · googleapis/python-datastore@7fd218b · GitHub
[go: up one dir, main page]

Skip to content
< 8000 script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/sessions-1e75b15ae60a.js">

Commit 7fd218b

Browse files
feat(spanner): Add support for Cloud Spanner Scheduled Backups (#540)
* chore: Update gapic-generator-python to v1.18.0 PiperOrigin-RevId: 638650618 Source-Link: googleapis/googleapis@6330f03 Source-Link: googleapis/googleapis-gen@44fa4f1 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDRmYTRmMTk3OWRjNDVjMTc3OGZkN2NhZjEzZjhlNjFjNmQxY2FlOCJ9 feat: New PropertyMask field which allows partial commits, lookups, and query results PiperOrigin-RevId: 635449160 Source-Link: googleapis/googleapis@dde0ec1 Source-Link: googleapis/googleapis-gen@8caa60d Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOGNhYTYwZDlhZWE4Mjk2NGExOWNkZjhmYWY5MTM4NDkxMWRiOGJkZCJ9 chore: Update gapic-generator-python to v1.17.1 PiperOrigin-RevId: 629071173 Source-Link: googleapis/googleapis@4afa392 Source-Link: googleapis/googleapis-gen@16dbbb4 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTZkYmJiNGQwNDU3ZGI1ZTYxYWM5Zjk5YjBkNTJhNDYxNTQ0NTVhYyJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat(spanner): Add support for Cloud Spanner Scheduled Backups PiperOrigin-RevId: 649277844 Source-Link: googleapis/googleapis@fd7efa2 Source-Link: googleapis/googleapis-gen@50be251 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNTBiZTI1MTMyOWQ4ZGI1YjU1NTYyNmViZDQ4ODY3MjFmNTQ3ZDNjYyJ9 * 🦉 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 <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent c86b51e commit 7fd218b

File tree

16 files changed

+2203
-303
lines changed

16 files changed

+2203
-303
lines changed

google/cloud/datastore_admin_v1/services/datastore_admin/async_client.py

Lines changed: 56 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import re
1919
from typing import (
2020
Dict,
21+
Callable,
2122
Mapping,
2223
MutableMapping,
2324
MutableSequence,
@@ -37,6 +38,7 @@
3738
from google.auth import credentials as ga_credentials # type: ignore
3839
from google.oauth2 import service_account # type: ignore
3940

41+
4042
try:
4143
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None]
4244
except AttributeError: # pragma: NO COVER
@@ -250,7 +252,9 @@ def __init__(
250252
self,
251253
*,
252254
credentials: Optional[ga_credentials.Credentials] = None,
253-
transport: Union[str, DatastoreAdminTransport] = "grpc_asyncio",
255+
transport: Optional[
256+
Union[str, DatastoreAdminTransport, Callable[..., DatastoreAdminTransport]]
257+
] = "grpc_asyncio",
254258
client_options: Optional[ClientOptions] = None,
255259
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
256260
) -> None:
@@ -262,9 +266,11 @@ def __init__(
262266
credentials identify the application to the service; if none
263267
are specified, the client will attempt to ascertain the
264268
credentials from the environment.
265-
transport (Union[str, ~.DatastoreAdminTransport]): The
266-
transport to use. If set to None, a transport is chosen
267-
automatically.
269+
transport (Optional[Union[str,DatastoreAdminTransport,Callable[..., DatastoreAdminTransport]]]):
270+
The transport to use, or a Callable that constructs and returns a new transport to use.
271+
If a Callable is given, it will be called with the same set of initialization
272+
arguments as used in the DatastoreAdminTransport constructor.
273+
If set to None, a transport is chosen automatically.
268274
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
269275
Custom options for the client.
270276
@@ -429,8 +435,8 @@ async def sample_export_entities():
429435
430436
"""
431437
# Create or coerce a protobuf request object.
432-
# Quick check: If we got a request object, we should *not* have
433-
# gotten any keyword arguments that map to the request.
438+
# - Quick check: If we got a request object, we should *not* have
439+
# gotten any keyword arguments that map to the request.
434440
has_flattened_params = any(
435441
[project_id, labels, entity_filter, output_url_prefix]
436442
)
@@ -440,7 +446,10 @@ async def sample_export_entities():
440446
"the individual field arguments should be set."
441447
)
442448

443-
request = datastore_admin.ExportEntitiesRequest(request)
449+
# - Use the request object if provided (there's no risk of modifying the input as
450+
# there are no flattened fields), or create one.
451+
if not isinstance(request, datastore_admin.ExportEntitiesRequest):
452+
request = datastore_admin.ExportEntitiesRequest(request)
444453

445454
# If we have keyword arguments corresponding to fields on the
446455
# request, apply these.
@@ -456,11 +465,9 @@ async def sample_export_entities():
456465

457466
# Wrap the RPC method; this adds retry and timeout information,
458467
# and friendly error handling.
459-
rpc = gapic_v1.method_async.wrap_method(
460-
self._client._transport.export_entities,
461-
default_timeout=60.0,
462-
client_info=DEFAULT_CLIENT_INFO,
463-
)
468+
rpc = self._client._transport._wrapped_methods[
469+
self._client._transport.export_entities
470+
]
464471

465472
# Certain fields should be provided within the metadata header;
466473
# add these here.
@@ -613,16 +620,19 @@ async def sample_import_entities():
613620
614621
"""
615622
# Create or coerce a protobuf request object.
616-
# Quick check: If we got a request object, we should *not* have
617-
# gotten any keyword arguments that map to the request.
623+
# - Quick check: If we got a request object, we should *not* have
624+
# gotten any keyword arguments that map to the request.
618625
has_flattened_params = any([project_id, labels, input_url, entity_filter])
619626
if request is not None and has_flattened_params:
620627
raise ValueError(
621628
"If the `request` argument is set, then none of "
622629
"the individual field arguments should be set."
623630
)
624631

625-
request = datastore_admin.ImportEntitiesRequest(request)
632+
# - Use the request object if provided (there's no risk of modifying the input as
633+
# there are no flattened fields), or create one.
634+
if not isinstance(request, datastore_admin.ImportEntitiesRequest):
635+
request = datastore_admin.ImportEntitiesRequest(request)
626636

627637
# If we have keyword arguments corresponding to fields on the
628638
# request, apply these.
@@ -638,11 +648,9 @@ async def sample_import_entities():
638648

639649
# Wrap the RPC method; this adds retry and timeout information,
640650
# and friendly error handling.
641-
rpc = gapic_v1.method_async.wrap_method(
642-
self._client._transport.import_entities,
643-
default_timeout=60.0,
644-
client_info=DEFAULT_CLIENT_INFO,
645-
)
651+
rpc = self._client._transport._wrapped_methods[
652+
self._client._transport.import_entities
653+
]
646654

647655
# Certain fields should be provided within the metadata header;
648656
# add these here.
@@ -747,15 +755,16 @@ async def sample_create_index():
747755
748756
"""
749757
# Create or coerce a protobuf request object.
750-
request = datastore_admin.CreateIndexRequest(request)
758+
# - Use the request object if provided (there's no risk of modifying the input as
759+
# there are no flattened fields), or create one.
760+
if not isinstance(request, datastore_admin.CreateIndexRequest):
761+
request = datastore_admin.CreateIndexRequest(request)
751762

752763
# Wrap the RPC method; this adds retry and timeout information,
753764
# and friendly error handling.
754-
rpc = gapic_v1.method_async.wrap_method(
755-
self._client._transport.create_index,
756-
default_timeout=60.0,
757-
client_info=DEFAULT_CLIENT_INFO,
758-
)
765+
rpc = self._client._transport._wrapped_methods[
766+
self._client._transport.create_index
767+
]
759768

760769
# Certain fields should be provided within the metadata header;
761770
# add these here.
@@ -859,15 +868,16 @@ async def sample_delete_index():
859868
860869
"""
861870
# Create or coerce a protobuf request object.
862-
request = datastore_admin.DeleteIndexRequest(request)
871+
# - Use the request object if provided (there's no risk of modifying the input as
872+
# there are no flattened fields), or create one.
873+
if not isinstance(request, datastore_admin.DeleteIndexRequest):
874+
request = datastore_admin.DeleteIndexRequest(request)
863875

864876
# Wrap the RPC method; this adds retry and timeout information,
865877
# and friendly error handling.
866-
rpc = gapic_v1.method_async.wrap_method(
867-
self._client._transport.delete_index,
868-
default_timeout=60.0,
869-
client_info=DEFAULT_CLIENT_INFO,
870-
)
878+
rpc = self._client._transport._wrapped_methods[
879+
self._client._transport.delete_index
880+
]
871881

872882
# Certain fields should be provided within the metadata header;
873883
# add these here.
@@ -952,25 +962,16 @@ async def sample_get_index():
952962
Datastore composite index definition.
953963
"""
954964
# Create or coerce a protobuf request object.
955-
request = datastore_admin.GetIndexRequest(request)
965+
# - Use the request object if provided (there's no risk of modifying the input as
966+
# there are no flattened fields), or create one.
967+
if not isinstance(request, datastore_admin.GetIndexRequest):
968+
request = datastore_admin.GetIndexRequest(request)
956969

957970
# Wrap the RPC method; this adds retry and timeout information,
958971
# and friendly error handling.
959-
rpc = gapic_v1.method_async.wrap_method(
960-
self._client._transport.get_index,
961-
default_retry=retries.AsyncRetry(
962-
initial=0.1,
963-
maximum=60.0,
964-
multiplier=1.3,
965-
predicate=retries.if_exception_type(
966-
core_exceptions.DeadlineExceeded,
967-
core_exceptions.ServiceUnavailable,
968-
),
969-
deadline=60.0,
970-
),
971-
default_timeout=60.0,
972-
client_info=DEFAULT_CLIENT_INFO,
973-
)
972+
rpc = self._client._transport._wrapped_methods[
973+
self._client._transport.get_index
974+
]
974975

975976
# Certain fields should be provided within the metadata header;
976977
# add these here.
@@ -1056,25 +1057,16 @@ async def sample_list_indexes():
10561057
10571058
"""
10581059
# Create or coerce a protobuf request object.
1059-
request = datastore_admin.ListIndexesRequest(request)
1060+
# - Use the request object if provided (there's no risk of modifying the input as
1061+
# there are no flattened fields), or create one.
1062+
if not isinstance(request, datastore_admin.ListIndexesRequest):
1063+
request = datastore_admin.ListIndexesRequest(request)
10601064

10611065
# Wrap the RPC method; this adds retry and timeout information,
10621066
# and friendly error handling.
1063-
rpc = gapic_v1.method_async.wrap_method(
1064-
self._client._transport.list_indexes,
1065-
default_retry=retries.AsyncRetry(
1066-
initial=0.1,
1067-
maximum=60.0,
1068-
multiplier=1.3,
1069-
predicate=retries.if_exception_type(
1070-
core_exceptions.DeadlineExceeded,
1071-
core_exceptions.ServiceUnavailable,
1072-
),
1073-
deadline=60.0,
1074-
),
1075-
default_timeout=60.0,
1076-
client_info=DEFAULT_CLIENT_INFO,
1077-
)
1067+
rpc = self._client._transport._wrapped_methods[
1068+
self._client._transport.list_indexes
10000 1069+
]
10781070

10791071
# Certain fields should be provided within the metadata header;
10801072
# add these here.

google/cloud/datastore_admin_v1/services/datastore_admin/client.py

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import re
1919
from typing import (
2020
Dict,
21+
Callable,
2122
Mapping,
2223
MutableMapping,
2324
MutableSequence,
@@ -565,7 +566,9 @@ def __init__(
565566
self,
566567
*,
567568
credentials: Optional[ga_credentials.Credentials] = None,
568-
transport: Optional[Union[str, DatastoreAdminTransport]] = None,
569+
transport: Optional[
570+
Union[str, DatastoreAdminTransport, Callable[..., DatastoreAdminTransport]]
571+
] = None,
569572
client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
570573
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
571574
) -> None:
@@ -577,9 +580,11 @@ def __init__(
577580
credentials identify the application to the service; if none
578581
are specified, the client will attempt to ascertain the
579582
credentials from the environment.
580-
transport (Union[str, DatastoreAdminTransport]): The
581-
transport to use. If set to None, a transport is chosen
582-
automatically.
583+
transport (Optional[Union[str,DatastoreAdminTransport,Callable[..., DatastoreAdminTransport]]]):
584+
The transport to use, or a Callable that constructs and returns a new transport.
585+
If a Callable is given, it will be called with the same set of initialization
586+
arguments as used in the DatastoreAdminTransport constructor.
587+
If set to None, a transport is chosen automatically.
583588
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
584589
Custom options for the client.
585590
@@ -688,8 +693,15 @@ def __init__(
688693
api_key_value
689694
)
690695

691-
Transport = type(self).get_transport_class(cast(str, transport))
692-
self._transport = Transport(
696+
transport_init: Union[
697+
Type[DatastoreAdminTransport], Callable[..., DatastoreAdminTransport]
698+
] = (
699+
type(self).get_transport_class(transport)
700+
if isinstance(transport, str) or transport is None
701+
else cast(Callable[..., DatastoreAdminTransport], transport)
702+
)
703+
# initialize with the provided callable or the passed in class
704+
self._transport = transport_init(
693705
credentials=credentials,
694706
credentials_file=self._client_options.credentials_file,
695707
host=self._api_endpoint,
@@ -822,8 +834,8 @@ def sample_export_entities():
822834
823835
"""
824836
# Create or coerce a protobuf request object.
825-
# Quick check: If we got a request object, we should *not* have
826-
# gotten any keyword arguments that map to the request.
837+
# - Quick check: If we got a request object, we should *not* have
838+
# gotten any keyword arguments that map to the request.
827839
has_flattened_params = any(
828840
[project_id, labels, entity_filter, output_url_prefix]
829841
)
@@ -833,10 +845,8 @@ def sample_export_entities():
833845
"the individual field arguments should be set."
834846
)
835847

836-
# Minor optimization to avoid making a copy if the user passes
837-
# in a datastore_admin.ExportEntitiesRequest.
838-
# There's no risk of modifying the input as we've already verified
839-
# there are no flattened fields.
848+
# - Use the request object if provided (there's no risk of modifying the input as
849+
# there are no flattened fields), or create one.
840850
if not isinstance(request, datastore_admin.ExportEntitiesRequest):
841851
request = datastore_admin.ExportEntitiesRequest(request)
842852
# If we have keyword arguments corresponding to fields on the
@@ -1005,19 +1015,17 @@ def sample_import_entities():
10051015
10061016
"""
10071017
# Create or coerce a protobuf request object.
1008-
# Quick check: If we got a request object, we should *not* have
1009-
# gotten any keyword arguments that map to the request.
1018+
# - Quick check: If we got a request object, we should *not* have
1019+
# gotten any keyword arguments that map to the request.
10101020
has_flattened_params = any([project_id, labels, input_url, entity_filter])
10111021
if request is not None and has_flattened_params:
10121022
raise ValueError(
10131023
"If the `request` argument is set, then none of "
10141024
"the individual field arguments should be set."
10151025
)
10161026

1017-
# Minor optimization to avoid making a copy if the user passes
1018-
# in a datastore_admin.ImportEntitiesRequest.
1019-
# There's no risk of modifying the input as we've already verified
1020-
# there are no flattened fields.
1027+
# - Use the request object if provided (there's no risk of modifying the input as
1028+
# there are no flattened fields), or create one.
10211029
if not isinstance(request, datastore_admin.ImportEntitiesRequest):
10221030
request = datastore_admin.ImportEntitiesRequest(request)
10231031
# If we have keyword arguments corresponding to fields on the
@@ -1138,10 +1146,8 @@ def sample_create_index():
11381146
11391147
"""
11401148
# Create or coerce a protobuf request object.
1141-
# Minor optimization to avoid making a copy if the user passes
1142-
# in a datastore_admin.CreateIndexRequest.
1143-
# There's no risk of modifying the input as we've already verified
1144-
# there are no flattened fields.
1149+
# - Use the request object if provided (there's no risk of modifying the input as
1150+
# there are no flattened fields), or create one.
11451151
if not isinstance(request, datastore_admin.CreateIndexRequest):
11461152
request = datastore_admin.CreateIndexRequest(request)
11471153

@@ -1251,10 +1257,8 @@ def sample_delete_index():
12511257
12521258
"""
12531259
# Create or coerce a protobuf request object.
1254-
# Minor optimization to avoid making a copy if the user passes
1255-
# in a datastore_admin.DeleteIndexRequest.
1256-
# There's no risk of modifying the input as we've already verified
1257-
# there are no flattened fields.
1260+
# - Use the request object if provided (there's no risk of modifying the input as
1261+
# there are no flattened fields), or create one.
12581262
if not isinstance(request, datastore_admin.DeleteIndexRequest):
12591263
request = datastore_admin.DeleteIndexRequest(request)
12601264

@@ -1345,10 +1349,8 @@ def sample_get_index():
13451349
Datastore composite index definition.
13461350
"""
13471351
# Create or coerce a protobuf request object.
1348-
# Minor optimization to avoid making a copy if the user passes
1349-
# in a datastore_admin.GetIndexRequest.
1350-
# There's no risk of modifying the input as we've already verified
1351-
# there are no flattened fields.
1352+
# - Use the request object if provided (there's no risk of modifying the input as
1353+
# there are no flattened fields), or create one.
13521354
if not isinstance(request, datastore_admin.GetIndexRequest):
13531355
request = datastore_admin.GetIndexRequest(request)
13541356

@@ -1440,10 +1442,8 @@ def sample_list_indexes():
14401442
14411443
"""
14421444
# Create or coerce a protobuf request object.
1443-
# Minor optimization to avoid making a copy if the user passes
1444-
# in a datastore_admin.ListIndexesRequest.
1445-
# There's no risk of modifying the input as we've already verified
1446-
# there are no flattened fields.
1445+
# - Use the request object if provided (there's no risk of modifying the input as
1446+
# there are no flattened fields), or create one.
14471447
if not isinstance(request, datastore_admin.ListIndexesRequest):
14481448
request = datastore_admin.ListIndexesRequest(request)
14491449

google/cloud/datastore_admin_v1/services/datastore_admin/transports/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ def __init__(
8888

8989
# Save the scopes.
9090
self._scopes = scopes
91+
if not hasattr(self, "_ignore_credentials"):
92+
self._ignore_credentials: bool = False
9193

9294
# If no credentials are provided, then determine the appropriate
9395
# defaults.
@@ -100,7 +102,7 @@ def __init__(
100102
credentials, _ = google.auth.load_credentials_from_file(
101103
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
102104
)
103-
elif credentials is None:
105+
elif credentials is None and not self._ignore_credentials:
104106
credentials, _ = google.auth.default(
105107
**scopes_kwargs, quota_project_id=quota_project_id
106108
)

0 commit comments

Comments
 (0)
0