2 from collections.abc import Iterable, Sequence
3 from typing import Callable, NoReturn, Type
4 from typing_extensions import Literal
6 from google.cloud.ndb import exceptions, key as key_module, query as query_module, tasklets as tasklets_module
9 Rollback = exceptions.Rollback
13 class KindError(exceptions.BadValueError): ...
14 class InvalidPropertyError(exceptions.Error): ...
16 BadProjectionError = InvalidPropertyError
18 class UnprojectedPropertyError(exceptions.Error): ...
19 class ReadonlyPropertyError(exceptions.Error): ...
20 class ComputedPropertyError(ReadonlyPropertyError): ...
21 class UserNotFoundError(exceptions.Error): ...
24 def __ne__(self, other: object) -> bool: ...
26 DirectionT = Literal["asc", "desc"]
28 class IndexProperty(_NotEqualMixin):
29 def __new__(cls, name: str, direction: DirectionT) -> IndexProperty: ...
31 def name(self) -> str: ...
33 def direction(self) -> DirectionT: ...
34 def __eq__(self, other: object) -> bool: ...
35 def __hash__(self) -> int: ...
37 class Index(_NotEqualMixin):
38 def __new__(cls, kind: str, properties: list[IndexProperty], ancestor: bool) -> Index: ...
40 def kind(self) -> str: ...
42 def properties(self) -> list[IndexProperty]: ...
44 def ancestor(self) -> bool: ...
45 def __eq__(self, other) -> bool: ...
46 def __hash__(self) -> int: ...
48 class IndexState(_NotEqualMixin):
49 def __new__(cls, definition, state, id): ...
51 def definition(self): ...
56 def __eq__(self, other) -> bool: ...
57 def __hash__(self) -> int: ...
60 def __new__(cls, *args, **kwargs) -> ModelAdapter: ...
62 def make_connection(*args, **kwargs) -> NoReturn: ...
64 class ModelAttribute: ...
66 class _BaseValue(_NotEqualMixin):
68 def __init__(self, b_val) -> None: ...
69 def __eq__(self, other) -> bool: ...
70 def __hash__(self) -> int: ...
72 class Property(ModelAttribute):
75 name: str | None = ...,
76 indexed: bool | None = ...,
77 repeated: bool | None = ...,
78 required: bool | None = ...,
79 default: object | None = ...,
80 choices: Iterable[object] | None = ...,
81 validator: Callable[[Property], object] | None = ...,
82 verbose_name: str | None = ...,
83 write_empty_list: bool | None = ...,
85 def __eq__(self, value: object) -> query_module.FilterNode: ... # type: ignore[override]
86 def __ne__(self, value: object) -> query_module.FilterNode: ... # type: ignore[override]
87 def __lt__(self, value: object) -> query_module.FilterNode: ...
88 def __le__(self, value: object) -> query_module.FilterNode: ...
89 def __gt__(self, value: object) -> query_module.FilterNode: ...
90 def __ge__(self, value: object) -> query_module.FilterNode: ...
91 def IN(self, value: Iterable[object]) -> query_module.DisjunctionNode | query_module.FilterNode | query_module.FalseNode: ...
92 def __neg__(self) -> query_module.PropertyOrder: ...
93 def __pos__(self) -> query_module.PropertyOrder: ...
94 def __set__(self, entity: Model, value: object) -> None: ...
95 def __delete__(self, entity: Model) -> None: ...
97 class ModelKey(Property):
98 def __init__(self) -> None: ...
99 def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> key_module.Key | list[key_module.Key] | None: ...
101 class BooleanProperty(Property):
102 def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> bool | list[bool] | None: ...
104 class IntegerProperty(Property):
105 def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> int | list[int] | None: ...
107 class FloatProperty(Property):
108 def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> float | list[float] | None: ...
110 class _CompressedValue(bytes):
112 def __init__(self, z_val: bytes) -> None: ...
113 def __eq__(self, other: object) -> bool: ...
114 def __hash__(self) -> NoReturn: ...
116 class BlobProperty(Property):
119 name: str | None = ...,
120 compressed: bool | None = ...,
121 indexed: bool | None = ...,
122 repeated: bool | None = ...,
123 required: bool | None = ...,
124 default: bytes | None = ...,
125 choices: Iterable[bytes] | None = ...,
126 validator: Callable[[Property], object] | None = ...,
127 verbose_name: str | None = ...,
128 write_empty_list: bool | None = ...,
130 def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> bytes | list[bytes] | None: ...
132 class CompressedTextProperty(BlobProperty):
133 def __init__(self, *args, **kwargs) -> None: ...
135 class TextProperty(Property):
136 def __new__(cls, *args, **kwargs): ...
137 def __init__(self, *args, **kwargs) -> None: ...
138 def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> str | list[str] | None: ...
140 class StringProperty(TextProperty):
141 def __init__(self, *args, **kwargs) -> None: ...
143 class GeoPtProperty(Property): ...
144 class PickleProperty(BlobProperty): ...
146 class JsonProperty(BlobProperty):
149 name: str | None = ...,
150 compressed: bool | None = ...,
151 json_type: type | None = ...,
152 indexed: bool | None = ...,
153 repeated: bool | None = ...,
154 required: bool | None = ...,
155 default: object | None = ...,
156 choices: Iterable[object] | None = ...,
157 validator: Callable[[Property], object] | None = ...,
158 verbose_name: str | None = ...,
159 write_empty_list: bool | None = ...,
163 def __init__(self, email: str | None = ..., _auth_domain: str | None = ..., _user_id: str | None = ...) -> None: ...
164 def nickname(self) -> str: ...
166 def user_id(self) -> str | None: ...
167 def auth_domain(self) -> str: ...
168 def __hash__(self) -> int: ...
169 def __eq__(self, other: object) -> bool: ...
170 def __lt__(self, other: object) -> bool: ...
172 class UserProperty(Property):
175 name: str | None = ...,
176 auto_current_user: bool | None = ...,
177 auto_current_user_add: bool | None = ...,
178 indexed: bool | None = ...,
179 repeated: bool | None = ...,
180 required: bool | None = ...,
181 default: bytes | None = ...,
182 choices: Iterable[bytes] | None = ...,
183 validator: Callable[[Property], object] | None = ...,
184 verbose_name: str | None = ...,
185 write_empty_list: bool | None = ...,
188 class KeyProperty(Property):
191 name: str | None = ...,
192 kind: Type[Model] | str | None = ...,
193 indexed: bool | None = ...,
194 repeated: bool | None = ...,
195 required: bool | None = ...,
196 default: key_module.Key | None = ...,
197 choices: Iterable[key_module.Key] | None = ...,
198 validator: Callable[[Property, key_module.Key], bool] | None = ...,
199 verbose_name: str | None = ...,
200 write_empty_list: bool | None = ...,
203 class BlobKeyProperty(Property): ...
205 class DateTimeProperty(Property):
208 name: str | None = ...,
209 auto_now: bool | None = ...,
210 auto_now_add: bool | None = ...,
211 tzinfo: datetime.tzinfo | None = ...,
212 indexed: bool | None = ...,
213 repeated: bool | None = ...,
214 required: bool | None = ...,
215 default: datetime.datetime | None = ...,
216 choices: Iterable[datetime.datetime] | None = ...,
217 validator: Callable[[Property, object], bool] | None = ...,
218 verbose_name: str | None = ...,
219 write_empty_list: bool | None = ...,
222 class DateProperty(DateTimeProperty): ...
223 class TimeProperty(DateTimeProperty): ...
225 class StructuredProperty(Property):
226 def __init__(self, model_class: type, name: str | None = ..., **kwargs) -> None: ...
227 def __getattr__(self, attrname): ...
228 def IN(self, value: Iterable[object]) -> query_module.DisjunctionNode | query_module.FalseNode: ...
230 class LocalStructuredProperty(BlobProperty):
231 def __init__(self, model_class: Type[Model], **kwargs) -> None: ...
233 class GenericProperty(Property):
234 def __init__(self, name: str | None = ..., compressed: bool = ..., **kwargs) -> None: ...
236 class ComputedProperty(GenericProperty):
239 func: Callable[[Model], object],
240 name: str | None = ...,
241 indexed: bool | None = ...,
242 repeated: bool | None = ...,
243 verbose_name: str | None = ...,
246 class MetaModel(type):
247 def __init__(cls, name: str, bases, classdict) -> None: ...
249 class Model(_NotEqualMixin, metaclass=MetaModel):
251 def __init__(_self, **kwargs) -> None: ...
252 def __hash__(self) -> NoReturn: ...
253 def __eq__(self, other: object) -> bool: ...
255 def gql(cls: Type[Model], query_string: str, *args, **kwargs) -> query_module.Query: ...
256 def put(self, **kwargs): ...
257 def put_async(self, **kwargs) -> tasklets_module.Future: ...
259 def query(cls: Type[Model], *args, **kwargs) -> query_module.Query: ...
263 size: int | None = ...,
264 max: int | None = ...,
265 parent: key_module.Key | None = ...,
266 retries: int | None = ...,
267 timeout: float | None = ...,
268 deadline: float | None = ...,
269 use_cache: bool | None = ...,
270 use_global_cache: bool | None = ...,
271 global_cache_timeout: int | None = ...,
272 use_datastore: bool | None = ...,
273 use_memcache: bool | None = ...,
274 memcache_timeout: int | None = ...,
275 max_memcache_items: int | None = ...,
276 force_writes: bool | None = ...,
278 ) -> tuple[key_module.Key, key_module.Key]: ...
280 def allocate_ids_async(
282 size: int | None = ...,
283 max: int | None = ...,
284 parent: key_module.Key | None = ...,
285 retries: int | None = ...,
286 timeout: float | None = ...,
287 deadline: float | None = ...,
288 use_cache: bool | None = ...,
289 use_global_cache: bool | None = ...,
290 global_cache_timeout: int | None = ...,
291 use_datastore: bool | None = ...,
292 use_memcache: bool | None = ...,
293 memcache_timeout: int | None = ...,
294 max_memcache_items: int | None = ...,
295 force_writes: bool | None = ...,
297 ) -> tasklets_module.Future: ...
301 id: int | str | None,
302 parent: key_module.Key | None = ...,
303 namespace: str | None = ...,
304 project: str | None = ...,
305 app: str | None = ...,
306 read_consistency: Literal["EVENTUAL"] | None = ...,
307 read_policy: Literal["EVENTUAL"] | None = ...,
308 transaction: bytes | None = ...,
309 retries: int | None = ...,
310 timeout: float | None = ...,
311 deadline: float | None = ...,
312 use_cache: bool | None = ...,
313 use_global_cache: bool | None = ...,
314 global_cache_timeout: int | None = ...,
315 use_datastore: bool | None = ...,
316 use_memcache: bool | None = ...,
317 memcache_timeout: int | None = ...,
318 max_memcache_items: int | None = ...,
319 force_writes: bool | None = ...,
321 ) -> tasklets_module.Future: ...
326 parent: key_module.Key | None = ...,
327 namespace: str | None = ...,
328 project: str | None = ...,
329 app: str | None = ...,
330 read_consistency: Literal["EVENTUAL"] | None = ...,
331 read_policy: Literal["EVENTUAL"] | None = ...,
332 transaction: bytes | None = ...,
333 retries: int | None = ...,
334 timeout: float | None = ...,
335 deadline: float | None = ...,
336 use_cache: bool | None = ...,
337 use_global_cache: bool | None = ...,
338 global_cache_timeout: int | None = ...,
339 use_datastore: bool | None = ...,
340 use_memcache: bool | None = ...,
341 memcache_timeout: int | None = ...,
342 max_memcache_items: int | None = ...,
343 force_writes: bool | None = ...,
345 ) -> Model | None: ...
350 parent: key_module.Key | None = ...,
351 namespace: str | None = ...,
352 project: str | None = ...,
353 app: str | None = ...,
354 read_consistency: Literal["EVENTUAL"] | None = ...,
355 read_policy: Literal["EVENTUAL"] | None = ...,
356 transaction: bytes | None = ...,
357 retries: int | None = ...,
358 timeout: float | None = ...,
359 deadline: float | None = ...,
360 use_cache: bool | None = ...,
361 use_global_cache: bool | None = ...,
362 global_cache_timeout: int | None = ...,
363 use_datastore: bool | None = ...,
364 use_memcache: bool | None = ...,
365 memcache_timeout: int | None = ...,
366 max_memcache_items: int | None = ...,
367 force_writes: bool | None = ...,
372 def get_or_insert_async(
375 parent: key_module.Key | None = ...,
376 namespace: str | None = ...,
377 project: str | None = ...,
378 app: str | None = ...,
379 read_consistency: Literal["EVENTUAL"] | None = ...,
380 read_policy: Literal["EVENTUAL"] | None = ...,
381 transaction: bytes | None = ...,
382 retries: int | None = ...,
383 timeout: float | None = ...,
384 deadline: float | None = ...,
385 use_cache: bool | None = ...,
386 use_global_cache: bool | None = ...,
387 global_cache_timeout: int | None = ...,
388 use_datastore: bool | None = ...,
389 use_memcache: bool | None = ...,
390 memcache_timeout: int | None = ...,
391 max_memcache_items: int | None = ...,
392 force_writes: bool | None = ...,
395 ) -> tasklets_module.Future: ...
396 def populate(self, **kwargs) -> None: ...
397 def has_complete_key(self) -> bool: ...
400 include: list[object] | tuple[object, object] | set[object] | None = ...,
401 exclude: list[object] | tuple[object, object] | set[object] | None = ...,
404 class Expando(Model):
405 def __getattr__(self, name: str): ...
406 def __setattr__(self, name: str, value) -> None: ...
407 def __delattr__(self, name: str) -> None: ...
410 keys: Sequence[Type[key_module.Key]],
411 read_consistency: Literal["EVENTUAL"] | None = ...,
412 read_policy: Literal["EVENTUAL"] | None = ...,
413 transaction: bytes | None = ...,
414 retries: int | None = ...,
415 timeout: float | None = ...,
416 deadline: float | None = ...,
417 use_cache: bool | None = ...,
418 use_global_cache: bool | None = ...,
419 global_cache_timeout: int | None = ...,
420 use_datastore: bool | None = ...,
421 use_memcache: bool | None = ...,
422 memcache_timeout: int | None = ...,
423 max_memcache_items: int | None = ...,
424 force_writes: bool | None = ...,
425 _options: object | None = ...,
426 ) -> list[Type[tasklets_module.Future]]: ...
428 keys: Sequence[Type[key_module.Key]],
429 read_consistency: Literal["EVENTUAL"] | None = ...,
430 read_policy: Literal["EVENTUAL"] | None = ...,
431 transaction: bytes | None = ...,
432 retries: int | None = ...,
433 timeout: float | None = ...,
434 deadline: float | None = ...,
435 use_cache: bool | None = ...,
436 use_global_cache: bool | None = ...,
437 global_cache_timeout: int | None = ...,
438 use_datastore: bool | None = ...,
439 use_memcache: bool | None = ...,
440 memcache_timeout: int | None = ...,
441 max_memcache_items: int | None = ...,
442 force_writes: bool | None = ...,
443 _options: object | None = ...,
444 ) -> list[Type[Model] | None]: ...
446 entities: list[Type[Model]],
447 retries: int | None = ...,
448 timeout: float | None = ...,
449 deadline: float | None = ...,
450 use_cache: bool | None = ...,
451 use_global_cache: bool | None = ...,
452 global_cache_timeout: int | None = ...,
453 use_datastore: bool | None = ...,
454 use_memcache: bool | None = ...,
455 memcache_timeout: int | None = ...,
456 max_memcache_items: int | None = ...,
457 force_writes: bool | None = ...,
458 _options: object | None = ...,
459 ) -> list[tasklets_module.Future]: ...
461 entities: list[Model],
462 retries: int | None = ...,
463 timeout: float | None = ...,
464 deadline: float | None = ...,
465 use_cache: bool | None = ...,
466 use_global_cache: bool | None = ...,
467 global_cache_timeout: int | None = ...,
468 use_datastore: bool | None = ...,
469 use_memcache: bool | None = ...,
470 memcache_timeout: int | None = ...,
471 max_memcache_items: int | None = ...,
472 force_writes: bool | None = ...,
473 _options: object | None = ...,
474 ) -> list[key_module.Key]: ...
475 def delete_multi_async(
476 keys: list[key_module.Key],
477 retries: int | None = ...,
478 timeout: float | None = ...,
479 deadline: float | None = ...,
480 use_cache: bool | None = ...,
481 use_global_cache: bool | None = ...,
482 global_cache_timeout: int | None = ...,
483 use_datastore: bool | None = ...,
484 use_memcache: bool | None = ...,
485 memcache_timeout: int | None = ...,
486 max_memcache_items: int | None = ...,
487 force_writes: bool | None = ...,
488 _options: object | None = ...,
489 ) -> list[tasklets_module.Future]: ...
491 keys: Sequence[key_module.Key],
492 retries: int | None = ...,
493 timeout: float | None = ...,
494 deadline: float | None = ...,
495 use_cache: bool | None = ...,
496 use_global_cache: bool | None = ...,
497 global_cache_timeout: int | None = ...,
498 use_datastore: bool | None = ...,
499 use_memcache: bool | None = ...,
500 memcache_timeout: int | None = ...,
501 max_memcache_items: int | None = ...,
502 force_writes: bool | None = ...,
503 _options: object | None = ...,
505 def get_indexes_async(**options: object) -> NoReturn: ...
506 def get_indexes(**options: object) -> NoReturn: ...