google-cloud-ndb 2.7.0__tar.gz → 2.7.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {google_cloud_ndb-2.7.0/google_cloud_ndb.egg-info → google_cloud_ndb-2.7.2}/PKG-INFO +2 -2
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/client.py +95 -12
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/model.py +15 -4
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/version.py +1 -1
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2/google_cloud_ndb.egg-info}/PKG-INFO +2 -2
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/setup.py +1 -1
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/AUTHORS +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/LICENSE +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/README.md +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/__init__.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/_batch.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/_cache.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/_datastore_api.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/_datastore_query.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/_datastore_types.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/_eventloop.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/_gql.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/_legacy_entity_pb.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/_legacy_protocol_buffer.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/_options.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/_remote.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/_retry.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/_transaction.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/blobstore.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/context.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/django_middleware.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/exceptions.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/global_cache.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/key.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/metadata.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/msgprop.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/polymodel.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/query.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/stats.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/tasklets.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/utils.py +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google_cloud_ndb.egg-info/SOURCES.txt +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google_cloud_ndb.egg-info/dependency_links.txt +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google_cloud_ndb.egg-info/not-zip-safe +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google_cloud_ndb.egg-info/requires.txt +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google_cloud_ndb.egg-info/top_level.txt +0 -0
- {google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/setup.cfg +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: google-cloud-ndb
|
|
3
|
-
Version: 2.7.
|
|
3
|
+
Version: 2.7.2
|
|
4
4
|
Summary: NDB library for Google Cloud Datastore
|
|
5
5
|
Home-page: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-ndb
|
|
6
6
|
Author: Google LLC
|
|
7
7
|
Author-email: googleapis-packages@google.com
|
|
8
8
|
License: Apache 2.0
|
|
9
9
|
Project-URL: Documentation, https://googleapis.dev/python/python-ndb/latest
|
|
10
|
-
Project-URL: Issue Tracker, https://github.com/googleapis/google-cloud-python/
|
|
10
|
+
Project-URL: Issue Tracker, https://github.com/googleapis/google-cloud-python/issues
|
|
11
11
|
Platform: Posix; MacOS X; Windows
|
|
12
12
|
Classifier: Development Status :: 5 - Production/Stable
|
|
13
13
|
Classifier: Intended Audience :: Developers
|
|
@@ -16,11 +16,16 @@
|
|
|
16
16
|
|
|
17
17
|
import contextlib
|
|
18
18
|
import os
|
|
19
|
+
from collections.abc import Mapping
|
|
20
|
+
from typing import Any
|
|
19
21
|
|
|
20
22
|
import google.api_core.client_options
|
|
21
23
|
import grpc
|
|
22
24
|
import requests
|
|
25
|
+
from google.api_core import universe
|
|
23
26
|
from google.api_core.gapic_v1 import client_info
|
|
27
|
+
from google.auth import compute_engine
|
|
28
|
+
from google.auth import credentials as auth_credentials
|
|
24
29
|
from google.cloud.datastore_v1.services.datastore.transports import (
|
|
25
30
|
grpc as datastore_grpc,
|
|
26
31
|
)
|
|
@@ -31,6 +36,18 @@ from google.cloud.ndb import __version__
|
|
|
31
36
|
from google.cloud.ndb import context as context_module
|
|
32
37
|
from google.cloud.ndb import key as key_module
|
|
33
38
|
|
|
39
|
+
try:
|
|
40
|
+
# google.auth.aio was added in google-auth 2.28.0; older supported versions
|
|
41
|
+
# only provide synchronous AnonymousCredentials.
|
|
42
|
+
from google.auth.aio import credentials as _aio_credentials
|
|
43
|
+
|
|
44
|
+
_ANONYMOUS_CREDENTIAL_TYPES: tuple[type, ...] = (
|
|
45
|
+
auth_credentials.AnonymousCredentials,
|
|
46
|
+
_aio_credentials.AnonymousCredentials,
|
|
47
|
+
)
|
|
48
|
+
except ImportError: # pragma: NO COVER
|
|
49
|
+
_ANONYMOUS_CREDENTIAL_TYPES = (auth_credentials.AnonymousCredentials,)
|
|
50
|
+
|
|
34
51
|
_CLIENT_INFO = client_info.ClientInfo(
|
|
35
52
|
user_agent="google-cloud-ndb/{}".format(__version__)
|
|
36
53
|
)
|
|
@@ -38,6 +55,64 @@ _CLIENT_INFO = client_info.ClientInfo(
|
|
|
38
55
|
DATASTORE_API_HOST = "datastore.googleapis.com"
|
|
39
56
|
|
|
40
57
|
|
|
58
|
+
# TODO(universe-domain): Replace with
|
|
59
|
+
# google.api_core.universe.resolve_client_universe once
|
|
60
|
+
# testing/constraints-3.10.txt exceeds google-api-core 2.44.0.
|
|
61
|
+
def _resolve_client_universe(client_options=None):
|
|
62
|
+
"""Resolve a client's universe domain from ``client_options`` or the environment."""
|
|
63
|
+
if client_options is None:
|
|
64
|
+
options_universe = None
|
|
65
|
+
elif isinstance(client_options, Mapping):
|
|
66
|
+
options_universe = client_options.get("universe_domain")
|
|
67
|
+
elif isinstance(client_options, google.api_core.client_options.ClientOptions):
|
|
68
|
+
options_universe = client_options.universe_domain
|
|
69
|
+
else:
|
|
70
|
+
raise TypeError(
|
|
71
|
+
"client_options must be a ClientOptions instance, Mapping, or None; "
|
|
72
|
+
f"got {type(client_options).__name__}"
|
|
73
|
+
)
|
|
74
|
+
return universe.determine_domain(
|
|
75
|
+
options_universe,
|
|
76
|
+
os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN"),
|
|
77
|
+
).strip()
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
# TODO(universe-domain): Replace with
|
|
81
|
+
# google.api_core.universe.validate_credentials_universe once
|
|
82
|
+
# testing/constraints-3.10.txt exceeds google-api-core 2.44.0.
|
|
83
|
+
def _validate_credentials_universe(
|
|
84
|
+
client_universe: str,
|
|
85
|
+
credentials: Any,
|
|
86
|
+
) -> None:
|
|
87
|
+
"""Validate that resolved client credentials match ``client_universe``.
|
|
88
|
+
|
|
89
|
+
Call on ``self._credentials`` after ``super().__init__()`` or Application
|
|
90
|
+
Default Credentials resolution rather than on the raw constructor
|
|
91
|
+
``credentials`` argument (which is ``None`` before ADC loads), and never
|
|
92
|
+
inside ``Credentials.before_request()``. Exempts ``None``, synchronous and
|
|
93
|
+
asynchronous ``AnonymousCredentials``, and ``compute_engine.Credentials``
|
|
94
|
+
whose universe domain is not yet cached in memory (avoiding synchronous
|
|
95
|
+
Metadata Server HTTP requests during client initialization).
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
client_universe: Resolved universe domain of the client.
|
|
99
|
+
credentials: Resolved credentials bound to the client, or ``None`` (in
|
|
100
|
+
which case validation is skipped).
|
|
101
|
+
|
|
102
|
+
Raises:
|
|
103
|
+
google.api_core.universe.UniverseMismatchError: If ``credentials`` has
|
|
104
|
+
an in-memory universe domain configured for a different universe
|
|
105
|
+
than ``client_universe``.
|
|
106
|
+
"""
|
|
107
|
+
if credentials is None or isinstance(credentials, _ANONYMOUS_CREDENTIAL_TYPES):
|
|
108
|
+
return
|
|
109
|
+
if isinstance(credentials, compute_engine.Credentials) and not getattr(
|
|
110
|
+
credentials, "_universe_domain_cached", False
|
|
111
|
+
):
|
|
112
|
+
return
|
|
113
|
+
universe.compare_domains(client_universe, credentials)
|
|
114
|
+
|
|
115
|
+
|
|
41
116
|
def _get_gcd_project():
|
|
42
117
|
"""Gets the GCD application ID if it can be inferred."""
|
|
43
118
|
return os.getenv(environment_vars.GCD_DATASET)
|
|
@@ -104,27 +179,29 @@ class Client(google_client.ClientWithProject):
|
|
|
104
179
|
database=None,
|
|
105
180
|
):
|
|
106
181
|
self.namespace = namespace
|
|
107
|
-
self.host = os.environ.get(environment_vars.GCD_HOST, DATASTORE_API_HOST)
|
|
108
182
|
self.client_info = _CLIENT_INFO
|
|
109
183
|
self._client_options = client_options
|
|
110
184
|
self.database = database
|
|
111
185
|
|
|
112
186
|
# Use insecure connection when using Datastore Emulator, otherwise
|
|
113
187
|
# use secure connection
|
|
114
|
-
|
|
188
|
+
emulator_host = os.environ.get(environment_vars.GCD_HOST)
|
|
189
|
+
emulator = bool(emulator_host)
|
|
115
190
|
self.secure = not emulator
|
|
116
191
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
192
|
+
if isinstance(client_options, Mapping):
|
|
193
|
+
client_options = google.api_core.client_options.from_dict(client_options)
|
|
194
|
+
|
|
195
|
+
universe_domain = _resolve_client_universe(client_options)
|
|
196
|
+
self._universe_domain = universe_domain
|
|
197
|
+
|
|
198
|
+
# Use Datastore API host from client_options if provided, otherwise
|
|
199
|
+
# template using the resolved universe_domain.
|
|
200
|
+
api_endpoint = f"datastore.{universe_domain}"
|
|
201
|
+
if client_options is not None and client_options.api_endpoint:
|
|
202
|
+
api_endpoint = client_options.api_endpoint
|
|
126
203
|
|
|
127
|
-
self.host =
|
|
204
|
+
self.host = emulator_host or api_endpoint
|
|
128
205
|
|
|
129
206
|
if emulator:
|
|
130
207
|
# When using the emulator, in theory, the client shouldn't need to
|
|
@@ -153,6 +230,7 @@ class Client(google_client.ClientWithProject):
|
|
|
153
230
|
],
|
|
154
231
|
)
|
|
155
232
|
else:
|
|
233
|
+
_validate_credentials_universe(self._universe_domain, self._credentials)
|
|
156
234
|
user_agent = self.client_info.to_user_agent()
|
|
157
235
|
channel = _helpers.make_secure_channel(
|
|
158
236
|
self._credentials, user_agent, self.host
|
|
@@ -238,6 +316,11 @@ class Client(google_client.ClientWithProject):
|
|
|
238
316
|
# Finish up any work left to do on the event loop
|
|
239
317
|
context.eventloop.run()
|
|
240
318
|
|
|
319
|
+
@property
|
|
320
|
+
def universe_domain(self):
|
|
321
|
+
"""The universe domain used by the client."""
|
|
322
|
+
return self._universe_domain
|
|
323
|
+
|
|
241
324
|
@property
|
|
242
325
|
def _http(self):
|
|
243
326
|
"""Getter for object used for HTTP transport.
|
|
@@ -352,6 +352,17 @@ Rollback = exceptions.Rollback
|
|
|
352
352
|
_getfullargspec = inspect.getfullargspec
|
|
353
353
|
|
|
354
354
|
|
|
355
|
+
def _utcnow():
|
|
356
|
+
"""Return the current UTC time as a naive :class:`~datetime.datetime`.
|
|
357
|
+
|
|
358
|
+
``datetime.datetime.utcnow()`` is deprecated since Python 3.12 and
|
|
359
|
+
scheduled for removal. Its replacement, ``datetime.datetime.now(timezone.utc)``,
|
|
360
|
+
returns an offset-aware value, but ``ndb`` stores and compares naive
|
|
361
|
+
datetimes presumed to be UTC, so the offset is stripped again here.
|
|
362
|
+
"""
|
|
363
|
+
return datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None)
|
|
364
|
+
|
|
365
|
+
|
|
355
366
|
class KindError(exceptions.BadValueError):
|
|
356
367
|
"""Raised when an implementation for a kind can't be found.
|
|
357
368
|
|
|
@@ -2092,7 +2103,7 @@ class Property(ModelAttribute):
|
|
|
2092
2103
|
# A custom 'meaning' for compressed properties.
|
|
2093
2104
|
_MEANING_URI_COMPRESSED = "ZLIB"
|
|
2094
2105
|
# The Epoch (a zero POSIX timestamp).
|
|
2095
|
-
_EPOCH = datetime.datetime
|
|
2106
|
+
_EPOCH = datetime.datetime(1970, 1, 1)
|
|
2096
2107
|
# This is awkward but there seems to be no faster way to inspect
|
|
2097
2108
|
# what union member is present. datastore_types.FromPropertyPb(),
|
|
2098
2109
|
# the undisputed authority, has the same series of if-elif blocks.
|
|
@@ -3933,7 +3944,7 @@ class DateTimeProperty(Property):
|
|
|
3933
3944
|
|
|
3934
3945
|
Subclasses will override this to return different forms of "now".
|
|
3935
3946
|
"""
|
|
3936
|
-
return
|
|
3947
|
+
return _utcnow()
|
|
3937
3948
|
|
|
3938
3949
|
def _prepare_for_put(self, entity):
|
|
3939
3950
|
"""Sets the current timestamp when "auto" is set.
|
|
@@ -4055,7 +4066,7 @@ class DateProperty(DateTimeProperty):
|
|
|
4055
4066
|
@staticmethod
|
|
4056
4067
|
def _now():
|
|
4057
4068
|
"""datetime.datetime: Return current date."""
|
|
4058
|
-
return
|
|
4069
|
+
return _utcnow().date()
|
|
4059
4070
|
|
|
4060
4071
|
|
|
4061
4072
|
class TimeProperty(DateTimeProperty):
|
|
@@ -4124,7 +4135,7 @@ class TimeProperty(DateTimeProperty):
|
|
|
4124
4135
|
@staticmethod
|
|
4125
4136
|
def _now():
|
|
4126
4137
|
"""datetime.datetime: Return current time."""
|
|
4127
|
-
return
|
|
4138
|
+
return _utcnow().time()
|
|
4128
4139
|
|
|
4129
4140
|
|
|
4130
4141
|
class StructuredProperty(Property):
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: google-cloud-ndb
|
|
3
|
-
Version: 2.7.
|
|
3
|
+
Version: 2.7.2
|
|
4
4
|
Summary: NDB library for Google Cloud Datastore
|
|
5
5
|
Home-page: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-ndb
|
|
6
6
|
Author: Google LLC
|
|
7
7
|
Author-email: googleapis-packages@google.com
|
|
8
8
|
License: Apache 2.0
|
|
9
9
|
Project-URL: Documentation, https://googleapis.dev/python/python-ndb/latest
|
|
10
|
-
Project-URL: Issue Tracker, https://github.com/googleapis/google-cloud-python/
|
|
10
|
+
Project-URL: Issue Tracker, https://github.com/googleapis/google-cloud-python/issues
|
|
11
11
|
Platform: Posix; MacOS X; Windows
|
|
12
12
|
Classifier: Development Status :: 5 - Production/Stable
|
|
13
13
|
Classifier: Intended Audience :: Developers
|
|
@@ -60,7 +60,7 @@ def main():
|
|
|
60
60
|
url="https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-ndb",
|
|
61
61
|
project_urls={
|
|
62
62
|
"Documentation": "https://googleapis.dev/python/python-ndb/latest",
|
|
63
|
-
"Issue Tracker": "https://github.com/googleapis/google-cloud-python/
|
|
63
|
+
"Issue Tracker": "https://github.com/googleapis/google-cloud-python/issues",
|
|
64
64
|
},
|
|
65
65
|
classifiers=[
|
|
66
66
|
"Development Status :: 5 - Production/Stable",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google/cloud/ndb/_legacy_protocol_buffer.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{google_cloud_ndb-2.7.0 → google_cloud_ndb-2.7.2}/google_cloud_ndb.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|