Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/google/cloud/firestore_v1/services/firestore/async_client.py: 35%
221 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-09 06:27 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-09 06:27 +0000
1# -*- coding: utf-8 -*-
2# Copyright 2023 Google LLC
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16from collections import OrderedDict
17import functools
18import re
19from typing import (
20 Dict,
21 Mapping,
22 MutableMapping,
23 MutableSequence,
24 Optional,
25 AsyncIterable,
26 Awaitable,
27 AsyncIterator,
28 Sequence,
29 Tuple,
30 Type,
31 Union,
32)
34from google.cloud.firestore_v1 import gapic_version as package_version
36from google.api_core.client_options import ClientOptions
37from google.api_core import exceptions as core_exceptions
38from google.api_core import gapic_v1
39from google.api_core import retry_async as retries
40from google.auth import credentials as ga_credentials # type: ignore
41from google.oauth2 import service_account # type: ignore
43try:
44 OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault]
45except AttributeError: # pragma: NO COVER
46 OptionalRetry = Union[retries.AsyncRetry, object] # type: ignore
48from google.cloud.firestore_v1.services.firestore import pagers
49from google.cloud.firestore_v1.types import aggregation_result
50from google.cloud.firestore_v1.types import common
51from google.cloud.firestore_v1.types import document
52from google.cloud.firestore_v1.types import document as gf_document
53from google.cloud.firestore_v1.types import firestore
54from google.cloud.firestore_v1.types import query
55from google.cloud.firestore_v1.types import write as gf_write
56from google.cloud.location import locations_pb2 # type: ignore
57from google.longrunning import operations_pb2 # type: ignore
58from google.protobuf import timestamp_pb2 # type: ignore
59from google.rpc import status_pb2 # type: ignore
60from .transports.base import FirestoreTransport, DEFAULT_CLIENT_INFO
61from .transports.grpc_asyncio import FirestoreGrpcAsyncIOTransport
62from .client import FirestoreClient
65class FirestoreAsyncClient:
66 """The Cloud Firestore service.
68 Cloud Firestore is a fast, fully managed, serverless,
69 cloud-native NoSQL document database that simplifies storing,
70 syncing, and querying data for your mobile, web, and IoT apps at
71 global scale. Its client libraries provide live synchronization
72 and offline support, while its security features and
73 integrations with Firebase and Google Cloud Platform accelerate
74 building truly serverless apps.
75 """
77 _client: FirestoreClient
79 DEFAULT_ENDPOINT = FirestoreClient.DEFAULT_ENDPOINT
80 DEFAULT_MTLS_ENDPOINT = FirestoreClient.DEFAULT_MTLS_ENDPOINT
82 common_billing_account_path = staticmethod(
83 FirestoreClient.common_billing_account_path
84 )
85 parse_common_billing_account_path = staticmethod(
86 FirestoreClient.parse_common_billing_account_path
87 )
88 common_folder_path = staticmethod(FirestoreClient.common_folder_path)
89 parse_common_folder_path = staticmethod(FirestoreClient.parse_common_folder_path)
90 common_organization_path = staticmethod(FirestoreClient.common_organization_path)
91 parse_common_organization_path = staticmethod(
92 FirestoreClient.parse_common_organization_path
93 )
94 common_project_path = staticmethod(FirestoreClient.common_project_path)
95 parse_common_project_path = staticmethod(FirestoreClient.parse_common_project_path)
96 common_location_path = staticmethod(FirestoreClient.common_location_path)
97 parse_common_location_path = staticmethod(
98 FirestoreClient.parse_common_location_path
99 )
101 @classmethod
102 def from_service_account_info(cls, info: dict, *args, **kwargs):
103 """Creates an instance of this client using the provided credentials
104 info.
106 Args:
107 info (dict): The service account private key info.
108 args: Additional arguments to pass to the constructor.
109 kwargs: Additional arguments to pass to the constructor.
111 Returns:
112 FirestoreAsyncClient: The constructed client.
113 """
114 return FirestoreClient.from_service_account_info.__func__(FirestoreAsyncClient, info, *args, **kwargs) # type: ignore
116 @classmethod
117 def from_service_account_file(cls, filename: str, *args, **kwargs):
118 """Creates an instance of this client using the provided credentials
119 file.
121 Args:
122 filename (str): The path to the service account private key json
123 file.
124 args: Additional arguments to pass to the constructor.
125 kwargs: Additional arguments to pass to the constructor.
127 Returns:
128 FirestoreAsyncClient: The constructed client.
129 """
130 return FirestoreClient.from_service_account_file.__func__(FirestoreAsyncClient, filename, *args, **kwargs) # type: ignore
132 from_service_account_json = from_service_account_file
134 @classmethod
135 def get_mtls_endpoint_and_cert_source(
136 cls, client_options: Optional[ClientOptions] = None
137 ):
138 """Return the API endpoint and client cert source for mutual TLS.
140 The client cert source is determined in the following order:
141 (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
142 client cert source is None.
143 (2) if `client_options.client_cert_source` is provided, use the provided one; if the
144 default client cert source exists, use the default one; otherwise the client cert
145 source is None.
147 The API endpoint is determined in the following order:
148 (1) if `client_options.api_endpoint` if provided, use the provided one.
149 (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
150 default mTLS endpoint; if the environment variable is "never", use the default API
151 endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
152 use the default API endpoint.
154 More details can be found at https://google.aip.dev/auth/4114.
156 Args:
157 client_options (google.api_core.client_options.ClientOptions): Custom options for the
158 client. Only the `api_endpoint` and `client_cert_source` properties may be used
159 in this method.
161 Returns:
162 Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
163 client cert source to use.
165 Raises:
166 google.auth.exceptions.MutualTLSChannelError: If any errors happen.
167 """
168 return FirestoreClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore
170 @property
171 def transport(self) -> FirestoreTransport:
172 """Returns the transport used by the client instance.
174 Returns:
175 FirestoreTransport: The transport used by the client instance.
176 """
177 return self._client.transport
179 get_transport_class = functools.partial(
180 type(FirestoreClient).get_transport_class, type(FirestoreClient)
181 )
183 def __init__(
184 self,
185 *,
186 credentials: Optional[ga_credentials.Credentials] = None,
187 transport: Union[str, FirestoreTransport] = "grpc_asyncio",
188 client_options: Optional[ClientOptions] = None,
189 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
190 ) -> None:
191 """Instantiates the firestore client.
193 Args:
194 credentials (Optional[google.auth.credentials.Credentials]): The
195 authorization credentials to attach to requests. These
196 credentials identify the application to the service; if none
197 are specified, the client will attempt to ascertain the
198 credentials from the environment.
199 transport (Union[str, ~.FirestoreTransport]): The
200 transport to use. If set to None, a transport is chosen
201 automatically.
202 client_options (ClientOptions): Custom options for the client. It
203 won't take effect if a ``transport`` instance is provided.
204 (1) The ``api_endpoint`` property can be used to override the
205 default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
206 environment variable can also be used to override the endpoint:
207 "always" (always use the default mTLS endpoint), "never" (always
208 use the default regular endpoint) and "auto" (auto switch to the
209 default mTLS endpoint if client certificate is present, this is
210 the default value). However, the ``api_endpoint`` property takes
211 precedence if provided.
212 (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
213 is "true", then the ``client_cert_source`` property can be used
214 to provide client certificate for mutual TLS transport. If
215 not provided, the default SSL client certificate will be used if
216 present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
217 set, no client certificate will be used.
219 Raises:
220 google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
221 creation failed for any reason.
222 """
223 self._client = FirestoreClient(
224 credentials=credentials,
225 transport=transport,
226 client_options=client_options,
227 client_info=client_info,
228 )
230 async def get_document(
231 self,
232 request: Optional[Union[firestore.GetDocumentRequest, dict]] = None,
233 *,
234 retry: OptionalRetry = gapic_v1.method.DEFAULT,
235 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
236 metadata: Sequence[Tuple[str, str]] = (),
237 ) -> document.Document:
238 r"""Gets a single document.
240 .. code-block:: python
242 # This snippet has been automatically generated and should be regarded as a
243 # code template only.
244 # It will require modifications to work:
245 # - It may require correct/in-range values for request initialization.
246 # - It may require specifying regional endpoints when creating the service
247 # client as shown in:
248 # https://googleapis.dev/python/google-api-core/latest/client_options.html
249 from google.cloud import firestore_v1
251 async def sample_get_document():
252 # Create a client
253 client = firestore_v1.FirestoreAsyncClient()
255 # Initialize request argument(s)
256 request = firestore_v1.GetDocumentRequest(
257 transaction=b'transaction_blob',
258 name="name_value",
259 )
261 # Make the request
262 response = await client.get_document(request=request)
264 # Handle the response
265 print(response)
267 Args:
268 request (Optional[Union[google.cloud.firestore_v1.types.GetDocumentRequest, dict]]):
269 The request object. The request for
270 [Firestore.GetDocument][google.firestore.v1.Firestore.GetDocument].
271 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
272 should be retried.
273 timeout (float): The timeout for this request.
274 metadata (Sequence[Tuple[str, str]]): Strings which should be
275 sent along with the request as metadata.
277 Returns:
278 google.cloud.firestore_v1.types.Document:
279 A Firestore document.
281 Must not exceed 1 MiB - 4 bytes.
283 """
284 # Create or coerce a protobuf request object.
285 request = firestore.GetDocumentRequest(request)
287 # Wrap the RPC method; this adds retry and timeout information,
288 # and friendly error handling.
289 rpc = gapic_v1.method_async.wrap_method(
290 self._client._transport.get_document,
291 default_retry=retries.AsyncRetry(
292 initial=0.1,
293 maximum=60.0,
294 multiplier=1.3,
295 predicate=retries.if_exception_type(
296 core_exceptions.DeadlineExceeded,
297 core_exceptions.InternalServerError,
298 core_exceptions.ResourceExhausted,
299 core_exceptions.ServiceUnavailable,
300 ),
301 deadline=60.0,
302 ),
303 default_timeout=60.0,
304 client_info=DEFAULT_CLIENT_INFO,
305 )
307 # Certain fields should be provided within the metadata header;
308 # add these here.
309 metadata = tuple(metadata) + (
310 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
311 )
313 # Send the request.
314 response = await rpc(
315 request,
316 retry=retry,
317 timeout=timeout,
318 metadata=metadata,
319 )
321 # Done; return the response.
322 return response
324 async def list_documents(
325 self,
326 request: Optional[Union[firestore.ListDocumentsRequest, dict]] = None,
327 *,
328 retry: OptionalRetry = gapic_v1.method.DEFAULT,
329 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
330 metadata: Sequence[Tuple[str, str]] = (),
331 ) -> pagers.ListDocumentsAsyncPager:
332 r"""Lists documents.
334 .. code-block:: python
336 # This snippet has been automatically generated and should be regarded as a
337 # code template only.
338 # It will require modifications to work:
339 # - It may require correct/in-range values for request initialization.
340 # - It may require specifying regional endpoints when creating the service
341 # client as shown in:
342 # https://googleapis.dev/python/google-api-core/latest/client_options.html
343 from google.cloud import firestore_v1
345 async def sample_list_documents():
346 # Create a client
347 client = firestore_v1.FirestoreAsyncClient()
349 # Initialize request argument(s)
350 request = firestore_v1.ListDocumentsRequest(
351 transaction=b'transaction_blob',
352 parent="parent_value",
353 )
355 # Make the request
356 page_result = client.list_documents(request=request)
358 # Handle the response
359 async for response in page_result:
360 print(response)
362 Args:
363 request (Optional[Union[google.cloud.firestore_v1.types.ListDocumentsRequest, dict]]):
364 The request object. The request for
365 [Firestore.ListDocuments][google.firestore.v1.Firestore.ListDocuments].
366 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
367 should be retried.
368 timeout (float): The timeout for this request.
369 metadata (Sequence[Tuple[str, str]]): Strings which should be
370 sent along with the request as metadata.
372 Returns:
373 google.cloud.firestore_v1.services.firestore.pagers.ListDocumentsAsyncPager:
374 The response for
375 [Firestore.ListDocuments][google.firestore.v1.Firestore.ListDocuments].
377 Iterating over this object will yield results and
378 resolve additional pages automatically.
380 """
381 # Create or coerce a protobuf request object.
382 request = firestore.ListDocumentsRequest(request)
384 # Wrap the RPC method; this adds retry and timeout information,
385 # and friendly error handling.
386 rpc = gapic_v1.method_async.wrap_method(
387 self._client._transport.list_documents,
388 default_retry=retries.AsyncRetry(
389 initial=0.1,
390 maximum=60.0,
391 multiplier=1.3,
392 predicate=retries.if_exception_type(
393 core_exceptions.DeadlineExceeded,
394 core_exceptions.InternalServerError,
395 core_exceptions.ResourceExhausted,
396 core_exceptions.ServiceUnavailable,
397 ),
398 deadline=60.0,
399 ),
400 default_timeout=60.0,
401 client_info=DEFAULT_CLIENT_INFO,
402 )
404 # Certain fields should be provided within the metadata header;
405 # add these here.
406 metadata = tuple(metadata) + (
407 gapic_v1.routing_header.to_grpc_metadata(
408 (
409 ("parent", request.parent),
410 ("collection_id", request.collection_id),
411 )
412 ),
413 )
415 # Send the request.
416 response = await rpc(
417 request,
418 retry=retry,
419 timeout=timeout,
420 metadata=metadata,
421 )
423 # This method is paged; wrap the response in a pager, which provides
424 # an `__aiter__` convenience method.
425 response = pagers.ListDocumentsAsyncPager(
426 method=rpc,
427 request=request,
428 response=response,
429 metadata=metadata,
430 )
432 # Done; return the response.
433 return response
435 async def update_document(
436 self,
437 request: Optional[Union[firestore.UpdateDocumentRequest, dict]] = None,
438 *,
439 document: Optional[gf_document.Document] = None,
440 update_mask: Optional[common.DocumentMask] = None,
441 retry: OptionalRetry = gapic_v1.method.DEFAULT,
442 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
443 metadata: Sequence[Tuple[str, str]] = (),
444 ) -> gf_document.Document:
445 r"""Updates or inserts a document.
447 .. code-block:: python
449 # This snippet has been automatically generated and should be regarded as a
450 # code template only.
451 # It will require modifications to work:
452 # - It may require correct/in-range values for request initialization.
453 # - It may require specifying regional endpoints when creating the service
454 # client as shown in:
455 # https://googleapis.dev/python/google-api-core/latest/client_options.html
456 from google.cloud import firestore_v1
458 async def sample_update_document():
459 # Create a client
460 client = firestore_v1.FirestoreAsyncClient()
462 # Initialize request argument(s)
463 request = firestore_v1.UpdateDocumentRequest(
464 )
466 # Make the request
467 response = await client.update_document(request=request)
469 # Handle the response
470 print(response)
472 Args:
473 request (Optional[Union[google.cloud.firestore_v1.types.UpdateDocumentRequest, dict]]):
474 The request object. The request for
475 [Firestore.UpdateDocument][google.firestore.v1.Firestore.UpdateDocument].
476 document (:class:`google.cloud.firestore_v1.types.Document`):
477 Required. The updated document.
478 Creates the document if it does not
479 already exist.
481 This corresponds to the ``document`` field
482 on the ``request`` instance; if ``request`` is provided, this
483 should not be set.
484 update_mask (:class:`google.cloud.firestore_v1.types.DocumentMask`):
485 The fields to update.
486 None of the field paths in the mask may
487 contain a reserved name.
489 If the document exists on the server and
490 has fields not referenced in the mask,
491 they are left unchanged.
492 Fields referenced in the mask, but not
493 present in the input document, are
494 deleted from the document on the server.
496 This corresponds to the ``update_mask`` field
497 on the ``request`` instance; if ``request`` is provided, this
498 should not be set.
499 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
500 should be retried.
501 timeout (float): The timeout for this request.
502 metadata (Sequence[Tuple[str, str]]): Strings which should be
503 sent along with the request as metadata.
505 Returns:
506 google.cloud.firestore_v1.types.Document:
507 A Firestore document.
509 Must not exceed 1 MiB - 4 bytes.
511 """
512 # Create or coerce a protobuf request object.
513 # Quick check: If we got a request object, we should *not* have
514 # gotten any keyword arguments that map to the request.
515 has_flattened_params = any([document, update_mask])
516 if request is not None and has_flattened_params:
517 raise ValueError(
518 "If the `request` argument is set, then none of "
519 "the individual field arguments should be set."
520 )
522 request = firestore.UpdateDocumentRequest(request)
524 # If we have keyword arguments corresponding to fields on the
525 # request, apply these.
526 if document is not None:
527 request.document = document
528 if update_mask is not None:
529 request.update_mask = update_mask
531 # Wrap the RPC method; this adds retry and timeout information,
532 # and friendly error handling.
533 rpc = gapic_v1.method_async.wrap_method(
534 self._client._transport.update_document,
535 default_retry=retries.AsyncRetry(
536 initial=0.1,
537 maximum=60.0,
538 multiplier=1.3,
539 predicate=retries.if_exception_type(
540 core_exceptions.ResourceExhausted,
541 core_exceptions.ServiceUnavailable,
542 ),
543 deadline=60.0,
544 ),
545 default_timeout=60.0,
546 client_info=DEFAULT_CLIENT_INFO,
547 )
549 # Certain fields should be provided within the metadata header;
550 # add these here.
551 metadata = tuple(metadata) + (
552 gapic_v1.routing_header.to_grpc_metadata(
553 (("document.name", request.document.name),)
554 ),
555 )
557 # Send the request.
558 response = await rpc(
559 request,
560 retry=retry,
561 timeout=timeout,
562 metadata=metadata,
563 )
565 # Done; return the response.
566 return response
568 async def delete_document(
569 self,
570 request: Optional[Union[firestore.DeleteDocumentRequest, dict]] = None,
571 *,
572 name: Optional[str] = None,
573 retry: OptionalRetry = gapic_v1.method.DEFAULT,
574 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
575 metadata: Sequence[Tuple[str, str]] = (),
576 ) -> None:
577 r"""Deletes a document.
579 .. code-block:: python
581 # This snippet has been automatically generated and should be regarded as a
582 # code template only.
583 # It will require modifications to work:
584 # - It may require correct/in-range values for request initialization.
585 # - It may require specifying regional endpoints when creating the service
586 # client as shown in:
587 # https://googleapis.dev/python/google-api-core/latest/client_options.html
588 from google.cloud import firestore_v1
590 async def sample_delete_document():
591 # Create a client
592 client = firestore_v1.FirestoreAsyncClient()
594 # Initialize request argument(s)
595 request = firestore_v1.DeleteDocumentRequest(
596 name="name_value",
597 )
599 # Make the request
600 await client.delete_document(request=request)
602 Args:
603 request (Optional[Union[google.cloud.firestore_v1.types.DeleteDocumentRequest, dict]]):
604 The request object. The request for
605 [Firestore.DeleteDocument][google.firestore.v1.Firestore.DeleteDocument].
606 name (:class:`str`):
607 Required. The resource name of the Document to delete.
608 In the format:
609 ``projects/{project_id}/databases/{database_id}/documents/{document_path}``.
611 This corresponds to the ``name`` field
612 on the ``request`` instance; if ``request`` is provided, this
613 should not be set.
614 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
615 should be retried.
616 timeout (float): The timeout for this request.
617 metadata (Sequence[Tuple[str, str]]): Strings which should be
618 sent along with the request as metadata.
619 """
620 # Create or coerce a protobuf request object.
621 # Quick check: If we got a request object, we should *not* have
622 # gotten any keyword arguments that map to the request.
623 has_flattened_params = any([name])
624 if request is not None and has_flattened_params:
625 raise ValueError(
626 "If the `request` argument is set, then none of "
627 "the individual field arguments should be set."
628 )
630 request = firestore.DeleteDocumentRequest(request)
632 # If we have keyword arguments corresponding to fields on the
633 # request, apply these.
634 if name is not None:
635 request.name = name
637 # Wrap the RPC method; this adds retry and timeout information,
638 # and friendly error handling.
639 rpc = gapic_v1.method_async.wrap_method(
640 self._client._transport.delete_document,
641 default_retry=retries.AsyncRetry(
642 initial=0.1,
643 maximum=60.0,
644 multiplier=1.3,
645 predicate=retries.if_exception_type(
646 core_exceptions.DeadlineExceeded,
647 core_exceptions.InternalServerError,
648 core_exceptions.ResourceExhausted,
649 core_exceptions.ServiceUnavailable,
650 ),
651 deadline=60.0,
652 ),
653 default_timeout=60.0,
654 client_info=DEFAULT_CLIENT_INFO,
655 )
657 # Certain fields should be provided within the metadata header;
658 # add these here.
659 metadata = tuple(metadata) + (
660 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
661 )
663 # Send the request.
664 await rpc(
665 request,
666 retry=retry,
667 timeout=timeout,
668 metadata=metadata,
669 )
671 def batch_get_documents(
672 self,
673 request: Optional[Union[firestore.BatchGetDocumentsRequest, dict]] = None,
674 *,
675 retry: OptionalRetry = gapic_v1.method.DEFAULT,
676 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
677 metadata: Sequence[Tuple[str, str]] = (),
678 ) -> Awaitable[AsyncIterable[firestore.BatchGetDocumentsResponse]]:
679 r"""Gets multiple documents.
681 Documents returned by this method are not guaranteed to
682 be returned in the same order that they were requested.
684 .. code-block:: python
686 # This snippet has been automatically generated and should be regarded as a
687 # code template only.
688 # It will require modifications to work:
689 # - It may require correct/in-range values for request initialization.
690 # - It may require specifying regional endpoints when creating the service
691 # client as shown in:
692 # https://googleapis.dev/python/google-api-core/latest/client_options.html
693 from google.cloud import firestore_v1
695 async def sample_batch_get_documents():
696 # Create a client
697 client = firestore_v1.FirestoreAsyncClient()
699 # Initialize request argument(s)
700 request = firestore_v1.BatchGetDocumentsRequest(
701 transaction=b'transaction_blob',
702 database="database_value",
703 )
705 # Make the request
706 stream = await client.batch_get_documents(request=request)
708 # Handle the response
709 async for response in stream:
710 print(response)
712 Args:
713 request (Optional[Union[google.cloud.firestore_v1.types.BatchGetDocumentsRequest, dict]]):
714 The request object. The request for
715 [Firestore.BatchGetDocuments][google.firestore.v1.Firestore.BatchGetDocuments].
716 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
717 should be retried.
718 timeout (float): The timeout for this request.
719 metadata (Sequence[Tuple[str, str]]): Strings which should be
720 sent along with the request as metadata.
722 Returns:
723 AsyncIterable[google.cloud.firestore_v1.types.BatchGetDocumentsResponse]:
724 The streamed response for
725 [Firestore.BatchGetDocuments][google.firestore.v1.Firestore.BatchGetDocuments].
727 """
728 # Create or coerce a protobuf request object.
729 request = firestore.BatchGetDocumentsRequest(request)
731 # Wrap the RPC method; this adds retry and timeout information,
732 # and friendly error handling.
733 rpc = gapic_v1.method_async.wrap_method(
734 self._client._transport.batch_get_documents,
735 default_retry=retries.AsyncRetry(
736 initial=0.1,
737 maximum=60.0,
738 multiplier=1.3,
739 predicate=retries.if_exception_type(
740 core_exceptions.DeadlineExceeded,
741 core_exceptions.InternalServerError,
742 core_exceptions.ResourceExhausted,
743 core_exceptions.ServiceUnavailable,
744 ),
745 deadline=300.0,
746 ),
747 default_timeout=300.0,
748 client_info=DEFAULT_CLIENT_INFO,
749 )
751 # Certain fields should be provided within the metadata header;
752 # add these here.
753 metadata = tuple(metadata) + (
754 gapic_v1.routing_header.to_grpc_metadata((("database", request.database),)),
755 )
757 # Send the request.
758 response = rpc(
759 request,
760 retry=retry,
761 timeout=timeout,
762 metadata=metadata,
763 )
765 # Done; return the response.
766 return response
768 async def begin_transaction(
769 self,
770 request: Optional[Union[firestore.BeginTransactionRequest, dict]] = None,
771 *,
772 database: Optional[str] = None,
773 retry: OptionalRetry = gapic_v1.method.DEFAULT,
774 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
775 metadata: Sequence[Tuple[str, str]] = (),
776 ) -> firestore.BeginTransactionResponse:
777 r"""Starts a new transaction.
779 .. code-block:: python
781 # This snippet has been automatically generated and should be regarded as a
782 # code template only.
783 # It will require modifications to work:
784 # - It may require correct/in-range values for request initialization.
785 # - It may require specifying regional endpoints when creating the service
786 # client as shown in:
787 # https://googleapis.dev/python/google-api-core/latest/client_options.html
788 from google.cloud import firestore_v1
790 async def sample_begin_transaction():
791 # Create a client
792 client = firestore_v1.FirestoreAsyncClient()
794 # Initialize request argument(s)
795 request = firestore_v1.BeginTransactionRequest(
796 database="database_value",
797 )
799 # Make the request
800 response = await client.begin_transaction(request=request)
802 # Handle the response
803 print(response)
805 Args:
806 request (Optional[Union[google.cloud.firestore_v1.types.BeginTransactionRequest, dict]]):
807 The request object. The request for
808 [Firestore.BeginTransaction][google.firestore.v1.Firestore.BeginTransaction].
809 database (:class:`str`):
810 Required. The database name. In the format:
811 ``projects/{project_id}/databases/{database_id}``.
813 This corresponds to the ``database`` field
814 on the ``request`` instance; if ``request`` is provided, this
815 should not be set.
816 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
817 should be retried.
818 timeout (float): The timeout for this request.
819 metadata (Sequence[Tuple[str, str]]): Strings which should be
820 sent along with the request as metadata.
822 Returns:
823 google.cloud.firestore_v1.types.BeginTransactionResponse:
824 The response for
825 [Firestore.BeginTransaction][google.firestore.v1.Firestore.BeginTransaction].
827 """
828 # Create or coerce a protobuf request object.
829 # Quick check: If we got a request object, we should *not* have
830 # gotten any keyword arguments that map to the request.
831 has_flattened_params = any([database])
832 if request is not None and has_flattened_params:
833 raise ValueError(
834 "If the `request` argument is set, then none of "
835 "the individual field arguments should be set."
836 )
838 request = firestore.BeginTransactionRequest(request)
840 # If we have keyword arguments corresponding to fields on the
841 # request, apply these.
842 if database is not None:
843 request.database = database
845 # Wrap the RPC method; this adds retry and timeout information,
846 # and friendly error handling.
847 rpc = gapic_v1.method_async.wrap_method(
848 self._client._transport.begin_transaction,
849 default_retry=retries.AsyncRetry(
850 initial=0.1,
851 maximum=60.0,
852 multiplier=1.3,
853 predicate=retries.if_exception_type(
854 core_exceptions.DeadlineExceeded,
855 core_exceptions.InternalServerError,
856 core_exceptions.ResourceExhausted,
857 core_exceptions.ServiceUnavailable,
858 ),
859 deadline=60.0,
860 ),
861 default_timeout=60.0,
862 client_info=DEFAULT_CLIENT_INFO,
863 )
865 # Certain fields should be provided within the metadata header;
866 # add these here.
867 metadata = tuple(metadata) + (
868 gapic_v1.routing_header.to_grpc_metadata((("database", request.database),)),
869 )
871 # Send the request.
872 response = await rpc(
873 request,
874 retry=retry,
875 timeout=timeout,
876 metadata=metadata,
877 )
879 # Done; return the response.
880 return response
882 async def commit(
883 self,
884 request: Optional[Union[firestore.CommitRequest, dict]] = None,
885 *,
886 database: Optional[str] = None,
887 writes: Optional[MutableSequence[gf_write.Write]] = None,
888 retry: OptionalRetry = gapic_v1.method.DEFAULT,
889 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
890 metadata: Sequence[Tuple[str, str]] = (),
891 ) -> firestore.CommitResponse:
892 r"""Commits a transaction, while optionally updating
893 documents.
895 .. code-block:: python
897 # This snippet has been automatically generated and should be regarded as a
898 # code template only.
899 # It will require modifications to work:
900 # - It may require correct/in-range values for request initialization.
901 # - It may require specifying regional endpoints when creating the service
902 # client as shown in:
903 # https://googleapis.dev/python/google-api-core/latest/client_options.html
904 from google.cloud import firestore_v1
906 async def sample_commit():
907 # Create a client
908 client = firestore_v1.FirestoreAsyncClient()
910 # Initialize request argument(s)
911 request = firestore_v1.CommitRequest(
912 database="database_value",
913 )
915 # Make the request
916 response = await client.commit(request=request)
918 # Handle the response
919 print(response)
921 Args:
922 request (Optional[Union[google.cloud.firestore_v1.types.CommitRequest, dict]]):
923 The request object. The request for
924 [Firestore.Commit][google.firestore.v1.Firestore.Commit].
925 database (:class:`str`):
926 Required. The database name. In the format:
927 ``projects/{project_id}/databases/{database_id}``.
929 This corresponds to the ``database`` field
930 on the ``request`` instance; if ``request`` is provided, this
931 should not be set.
932 writes (:class:`MutableSequence[google.cloud.firestore_v1.types.Write]`):
933 The writes to apply.
935 Always executed atomically and in order.
937 This corresponds to the ``writes`` field
938 on the ``request`` instance; if ``request`` is provided, this
939 should not be set.
940 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
941 should be retried.
942 timeout (float): The timeout for this request.
943 metadata (Sequence[Tuple[str, str]]): Strings which should be
944 sent along with the request as metadata.
946 Returns:
947 google.cloud.firestore_v1.types.CommitResponse:
948 The response for
949 [Firestore.Commit][google.firestore.v1.Firestore.Commit].
951 """
952 # Create or coerce a protobuf request object.
953 # Quick check: If we got a request object, we should *not* have
954 # gotten any keyword arguments that map to the request.
955 has_flattened_params = any([database, writes])
956 if request is not None and has_flattened_params:
957 raise ValueError(
958 "If the `request` argument is set, then none of "
959 "the individual field arguments should be set."
960 )
962 request = firestore.CommitRequest(request)
964 # If we have keyword arguments corresponding to fields on the
965 # request, apply these.
966 if database is not None:
967 request.database = database
968 if writes:
969 request.writes.extend(writes)
971 # Wrap the RPC method; this adds retry and timeout information,
972 # and friendly error handling.
973 rpc = gapic_v1.method_async.wrap_method(
974 self._client._transport.commit,
975 default_retry=retries.AsyncRetry(
976 initial=0.1,
977 maximum=60.0,
978 multiplier=1.3,
979 predicate=retries.if_exception_type(
980 core_exceptions.ResourceExhausted,
981 core_exceptions.ServiceUnavailable,
982 ),
983 deadline=60.0,
984 ),
985 default_timeout=60.0,
986 client_info=DEFAULT_CLIENT_INFO,
987 )
989 # Certain fields should be provided within the metadata header;
990 # add these here.
991 metadata = tuple(metadata) + (
992 gapic_v1.routing_header.to_grpc_metadata((("database", request.database),)),
993 )
995 # Send the request.
996 response = await rpc(
997 request,
998 retry=retry,
999 timeout=timeout,
1000 metadata=metadata,
1001 )
1003 # Done; return the response.
1004 return response
1006 async def rollback(
1007 self,
1008 request: Optional[Union[firestore.RollbackRequest, dict]] = None,
1009 *,
1010 database: Optional[str] = None,
1011 transaction: Optional[bytes] = None,
1012 retry: OptionalRetry = gapic_v1.method.DEFAULT,
1013 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1014 metadata: Sequence[Tuple[str, str]] = (),
1015 ) -> None:
1016 r"""Rolls back a transaction.
1018 .. code-block:: python
1020 # This snippet has been automatically generated and should be regarded as a
1021 # code template only.
1022 # It will require modifications to work:
1023 # - It may require correct/in-range values for request initialization.
1024 # - It may require specifying regional endpoints when creating the service
1025 # client as shown in:
1026 # https://googleapis.dev/python/google-api-core/latest/client_options.html
1027 from google.cloud import firestore_v1
1029 async def sample_rollback():
1030 # Create a client
1031 client = firestore_v1.FirestoreAsyncClient()
1033 # Initialize request argument(s)
1034 request = firestore_v1.RollbackRequest(
1035 database="database_value",
1036 transaction=b'transaction_blob',
1037 )
1039 # Make the request
1040 await client.rollback(request=request)
1042 Args:
1043 request (Optional[Union[google.cloud.firestore_v1.types.RollbackRequest, dict]]):
1044 The request object. The request for
1045 [Firestore.Rollback][google.firestore.v1.Firestore.Rollback].
1046 database (:class:`str`):
1047 Required. The database name. In the format:
1048 ``projects/{project_id}/databases/{database_id}``.
1050 This corresponds to the ``database`` field
1051 on the ``request`` instance; if ``request`` is provided, this
1052 should not be set.
1053 transaction (:class:`bytes`):
1054 Required. The transaction to roll
1055 back.
1057 This corresponds to the ``transaction`` field
1058 on the ``request`` instance; if ``request`` is provided, this
1059 should not be set.
1060 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1061 should be retried.
1062 timeout (float): The timeout for this request.
1063 metadata (Sequence[Tuple[str, str]]): Strings which should be
1064 sent along with the request as metadata.
1065 """
1066 # Create or coerce a protobuf request object.
1067 # Quick check: If we got a request object, we should *not* have
1068 # gotten any keyword arguments that map to the request.
1069 has_flattened_params = any([database, transaction])
1070 if request is not None and has_flattened_params:
1071 raise ValueError(
1072 "If the `request` argument is set, then none of "
1073 "the individual field arguments should be set."
1074 )
1076 request = firestore.RollbackRequest(request)
1078 # If we have keyword arguments corresponding to fields on the
1079 # request, apply these.
1080 if database is not None:
1081 request.database = database
1082 if transaction is not None:
1083 request.transaction = transaction
1085 # Wrap the RPC method; this adds retry and timeout information,
1086 # and friendly error handling.
1087 rpc = gapic_v1.method_async.wrap_method(
1088 self._client._transport.rollback,
1089 default_retry=retries.AsyncRetry(
1090 initial=0.1,
1091 maximum=60.0,
1092 multiplier=1.3,
1093 predicate=retries.if_exception_type(
1094 core_exceptions.DeadlineExceeded,
1095 core_exceptions.InternalServerError,
1096 core_exceptions.ResourceExhausted,
1097 core_exceptions.ServiceUnavailable,
1098 ),
1099 deadline=60.0,
1100 ),
1101 default_timeout=60.0,
1102 client_info=DEFAULT_CLIENT_INFO,
1103 )
1105 # Certain fields should be provided within the metadata header;
1106 # add these here.
1107 metadata = tuple(metadata) + (
1108 gapic_v1.routing_header.to_grpc_metadata((("database", request.database),)),
1109 )
1111 # Send the request.
1112 await rpc(
1113 request,
1114 retry=retry,
1115 timeout=timeout,
1116 metadata=metadata,
1117 )
1119 def run_query(
1120 self,
1121 request: Optional[Union[firestore.RunQueryRequest, dict]] = None,
1122 *,
1123 retry: OptionalRetry = gapic_v1.method.DEFAULT,
1124 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1125 metadata: Sequence[Tuple[str, str]] = (),
1126 ) -> Awaitable[AsyncIterable[firestore.RunQueryResponse]]:
1127 r"""Runs a query.
1129 .. code-block:: python
1131 # This snippet has been automatically generated and should be regarded as a
1132 # code template only.
1133 # It will require modifications to work:
1134 # - It may require correct/in-range values for request initialization.
1135 # - It may require specifying regional endpoints when creating the service
1136 # client as shown in:
1137 # https://googleapis.dev/python/google-api-core/latest/client_options.html
1138 from google.cloud import firestore_v1
1140 async def sample_run_query():
1141 # Create a client
1142 client = firestore_v1.FirestoreAsyncClient()
1144 # Initialize request argument(s)
1145 request = firestore_v1.RunQueryRequest(
1146 transaction=b'transaction_blob',
1147 parent="parent_value",
1148 )
1150 # Make the request
1151 stream = await client.run_query(request=request)
1153 # Handle the response
1154 async for response in stream:
1155 print(response)
1157 Args:
1158 request (Optional[Union[google.cloud.firestore_v1.types.RunQueryRequest, dict]]):
1159 The request object. The request for
1160 [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery].
1161 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1162 should be retried.
1163 timeout (float): The timeout for this request.
1164 metadata (Sequence[Tuple[str, str]]): Strings which should be
1165 sent along with the request as metadata.
1167 Returns:
1168 AsyncIterable[google.cloud.firestore_v1.types.RunQueryResponse]:
1169 The response for
1170 [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery].
1172 """
1173 # Create or coerce a protobuf request object.
1174 request = firestore.RunQueryRequest(request)
1176 # Wrap the RPC method; this adds retry and timeout information,
1177 # and friendly error handling.
1178 rpc = gapic_v1.method_async.wrap_method(
1179 self._client._transport.run_query,
1180 default_retry=retries.AsyncRetry(
1181 initial=0.1,
1182 maximum=60.0,
1183 multiplier=1.3,
1184 predicate=retries.if_exception_type(
1185 core_exceptions.DeadlineExceeded,
1186 core_exceptions.InternalServerError,
1187 core_exceptions.ResourceExhausted,
1188 core_exceptions.ServiceUnavailable,
1189 ),
1190 deadline=300.0,
1191 ),
1192 default_timeout=300.0,
1193 client_info=DEFAULT_CLIENT_INFO,
1194 )
1196 # Certain fields should be provided within the metadata header;
1197 # add these here.
1198 metadata = tuple(metadata) + (
1199 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1200 )
1202 # Send the request.
1203 response = rpc(
1204 request,
1205 retry=retry,
1206 timeout=timeout,
1207 metadata=metadata,
1208 )
1210 # Done; return the response.
1211 return response
1213 def run_aggregation_query(
1214 self,
1215 request: Optional[Union[firestore.RunAggregationQueryRequest, dict]] = None,
1216 *,
1217 retry: OptionalRetry = gapic_v1.method.DEFAULT,
1218 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1219 metadata: Sequence[Tuple[str, str]] = (),
1220 ) -> Awaitable[AsyncIterable[firestore.RunAggregationQueryResponse]]:
1221 r"""Runs an aggregation query.
1223 Rather than producing [Document][google.firestore.v1.Document]
1224 results like
1225 [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery],
1226 this API allows running an aggregation to produce a series of
1227 [AggregationResult][google.firestore.v1.AggregationResult]
1228 server-side.
1230 High-Level Example:
1232 ::
1234 -- Return the number of documents in table given a filter.
1235 SELECT COUNT(*) FROM ( SELECT * FROM k where a = true );
1237 .. code-block:: python
1239 # This snippet has been automatically generated and should be regarded as a
1240 # code template only.
1241 # It will require modifications to work:
1242 # - It may require correct/in-range values for request initialization.
1243 # - It may require specifying regional endpoints when creating the service
1244 # client as shown in:
1245 # https://googleapis.dev/python/google-api-core/latest/client_options.html
1246 from google.cloud import firestore_v1
1248 async def sample_run_aggregation_query():
1249 # Create a client
1250 client = firestore_v1.FirestoreAsyncClient()
1252 # Initialize request argument(s)
1253 request = firestore_v1.RunAggregationQueryRequest(
1254 transaction=b'transaction_blob',
1255 parent="parent_value",
1256 )
1258 # Make the request
1259 stream = await client.run_aggregation_query(request=request)
1261 # Handle the response
1262 async for response in stream:
1263 print(response)
1265 Args:
1266 request (Optional[Union[google.cloud.firestore_v1.types.RunAggregationQueryRequest, dict]]):
1267 The request object. The request for
1268 [Firestore.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery].
1269 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1270 should be retried.
1271 timeout (float): The timeout for this request.
1272 metadata (Sequence[Tuple[str, str]]): Strings which should be
1273 sent along with the request as metadata.
1275 Returns:
1276 AsyncIterable[google.cloud.firestore_v1.types.RunAggregationQueryResponse]:
1277 The response for
1278 [Firestore.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery].
1280 """
1281 # Create or coerce a protobuf request object.
1282 request = firestore.RunAggregationQueryRequest(request)
1284 # Wrap the RPC method; this adds retry and timeout information,
1285 # and friendly error handling.
1286 rpc = gapic_v1.method_async.wrap_method(
1287 self._client._transport.run_aggregation_query,
1288 default_retry=retries.AsyncRetry(
1289 initial=0.1,
1290 maximum=60.0,
1291 multiplier=1.3,
1292 predicate=retries.if_exception_type(
1293 core_exceptions.DeadlineExceeded,
1294 core_exceptions.InternalServerError,
1295 core_exceptions.ResourceExhausted,
1296 core_exceptions.ServiceUnavailable,
1297 ),
1298 deadline=300.0,
1299 ),
1300 default_timeout=300.0,
1301 client_info=DEFAULT_CLIENT_INFO,
1302 )
1304 # Certain fields should be provided within the metadata header;
1305 # add these here.
1306 metadata = tuple(metadata) + (
1307 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1308 )
1310 # Send the request.
1311 response = rpc(
1312 request,
1313 retry=retry,
1314 timeout=timeout,
1315 metadata=metadata,
1316 )
1318 # Done; return the response.
1319 return response
1321 async def partition_query(
1322 self,
1323 request: Optional[Union[firestore.PartitionQueryRequest, dict]] = None,
1324 *,
1325 retry: OptionalRetry = gapic_v1.method.DEFAULT,
1326 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1327 metadata: Sequence[Tuple[str, str]] = (),
1328 ) -> pagers.PartitionQueryAsyncPager:
1329 r"""Partitions a query by returning partition cursors
1330 that can be used to run the query in parallel. The
1331 returned partition cursors are split points that can be
1332 used by RunQuery as starting/end points for the query
1333 results.
1335 .. code-block:: python
1337 # This snippet has been automatically generated and should be regarded as a
1338 # code template only.
1339 # It will require modifications to work:
1340 # - It may require correct/in-range values for request initialization.
1341 # - It may require specifying regional endpoints when creating the service
1342 # client as shown in:
1343 # https://googleapis.dev/python/google-api-core/latest/client_options.html
1344 from google.cloud import firestore_v1
1346 async def sample_partition_query():
1347 # Create a client
1348 client = firestore_v1.FirestoreAsyncClient()
1350 # Initialize request argument(s)
1351 request = firestore_v1.PartitionQueryRequest(
1352 parent="parent_value",
1353 )
1355 # Make the request
1356 page_result = client.partition_query(request=request)
1358 # Handle the response
1359 async for response in page_result:
1360 print(response)
1362 Args:
1363 request (Optional[Union[google.cloud.firestore_v1.types.PartitionQueryRequest, dict]]):
1364 The request object. The request for
1365 [Firestore.PartitionQuery][google.firestore.v1.Firestore.PartitionQuery].
1366 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1367 should be retried.
1368 timeout (float): The timeout for this request.
1369 metadata (Sequence[Tuple[str, str]]): Strings which should be
1370 sent along with the request as metadata.
1372 Returns:
1373 google.cloud.firestore_v1.services.firestore.pagers.PartitionQueryAsyncPager:
1374 The response for
1375 [Firestore.PartitionQuery][google.firestore.v1.Firestore.PartitionQuery].
1377 Iterating over this object will yield results and
1378 resolve additional pages automatically.
1380 """
1381 # Create or coerce a protobuf request object.
1382 request = firestore.PartitionQueryRequest(request)
1384 # Wrap the RPC method; this adds retry and timeout information,
1385 # and friendly error handling.
1386 rpc = gapic_v1.method_async.wrap_method(
1387 self._client._transport.partition_query,
1388 default_retry=retries.AsyncRetry(
1389 initial=0.1,
1390 maximum=60.0,
1391 multiplier=1.3,
1392 predicate=retries.if_exception_type(
1393 core_exceptions.DeadlineExceeded,
1394 core_exceptions.InternalServerError,
1395 core_exceptions.ResourceExhausted,
1396 core_exceptions.ServiceUnavailable,
1397 ),
1398 deadline=300.0,
1399 ),
1400 default_timeout=300.0,
1401 client_info=DEFAULT_CLIENT_INFO,
1402 )
1404 # Certain fields should be provided within the metadata header;
1405 # add these here.
1406 metadata = tuple(metadata) + (
1407 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1408 )
1410 # Send the request.
1411 response = await rpc(
1412 request,
1413 retry=retry,
1414 timeout=timeout,
1415 metadata=metadata,
1416 )
1418 # This method is paged; wrap the response in a pager, which provides
1419 # an `__aiter__` convenience method.
1420 response = pagers.PartitionQueryAsyncPager(
1421 method=rpc,
1422 request=request,
1423 response=response,
1424 metadata=metadata,
1425 )
1427 # Done; return the response.
1428 return response
1430 def write(
1431 self,
1432 requests: Optional[AsyncIterator[firestore.WriteRequest]] = None,
1433 *,
1434 retry: OptionalRetry = gapic_v1.method.DEFAULT,
1435 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1436 metadata: Sequence[Tuple[str, str]] = (),
1437 ) -> Awaitable[AsyncIterable[firestore.WriteResponse]]:
1438 r"""Streams batches of document updates and deletes, in
1439 order. This method is only available via gRPC or
1440 WebChannel (not REST).
1442 .. code-block:: python
1444 # This snippet has been automatically generated and should be regarded as a
1445 # code template only.
1446 # It will require modifications to work:
1447 # - It may require correct/in-range values for request initialization.
1448 # - It may require specifying regional endpoints when creating the service
1449 # client as shown in:
1450 # https://googleapis.dev/python/google-api-core/latest/client_options.html
1451 from google.cloud import firestore_v1
1453 async def sample_write():
1454 # Create a client
1455 client = firestore_v1.FirestoreAsyncClient()
1457 # Initialize request argument(s)
1458 request = firestore_v1.WriteRequest(
1459 database="database_value",
1460 )
1462 # This method expects an iterator which contains
1463 # 'firestore_v1.WriteRequest' objects
1464 # Here we create a generator that yields a single `request` for
1465 # demonstrative purposes.
1466 requests = [request]
1468 def request_generator():
1469 for request in requests:
1470 yield request
1472 # Make the request
1473 stream = await client.write(requests=request_generator())
1475 # Handle the response
1476 async for response in stream:
1477 print(response)
1479 Args:
1480 requests (AsyncIterator[`google.cloud.firestore_v1.types.WriteRequest`]):
1481 The request object AsyncIterator. The request for
1482 [Firestore.Write][google.firestore.v1.Firestore.Write].
1484 The first request creates a stream, or resumes an
1485 existing one from a token.
1487 When creating a new stream, the server replies with a
1488 response containing only an ID and a token, to use in
1489 the next request.
1491 When resuming a stream, the server first streams any
1492 responses later than the given token, then a response
1493 containing only an up-to-date token, to use in the next
1494 request.
1495 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1496 should be retried.
1497 timeout (float): The timeout for this request.
1498 metadata (Sequence[Tuple[str, str]]): Strings which should be
1499 sent along with the request as metadata.
1501 Returns:
1502 AsyncIterable[google.cloud.firestore_v1.types.WriteResponse]:
1503 The response for
1504 [Firestore.Write][google.firestore.v1.Firestore.Write].
1506 """
1508 # Wrap the RPC method; this adds retry and timeout information,
1509 # and friendly error handling.
1510 rpc = gapic_v1.method_async.wrap_method(
1511 self._client._transport.write,
1512 default_timeout=86400.0,
1513 client_info=DEFAULT_CLIENT_INFO,
1514 )
1516 # Certain fields should be provided within the metadata header;
1517 # add these here.
1518 metadata = tuple(metadata) + (gapic_v1.routing_header.to_grpc_metadata(()),)
1520 # Send the request.
1521 response = rpc(
1522 requests,
1523 retry=retry,
1524 timeout=timeout,
1525 metadata=metadata,
1526 )
1528 # Done; return the response.
1529 return response
1531 def listen(
1532 self,
1533 requests: Optional[AsyncIterator[firestore.ListenRequest]] = None,
1534 *,
1535 retry: OptionalRetry = gapic_v1.method.DEFAULT,
1536 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1537 metadata: Sequence[Tuple[str, str]] = (),
1538 ) -> Awaitable[AsyncIterable[firestore.ListenResponse]]:
1539 r"""Listens to changes. This method is only available via
1540 gRPC or WebChannel (not REST).
1542 .. code-block:: python
1544 # This snippet has been automatically generated and should be regarded as a
1545 # code template only.
1546 # It will require modifications to work:
1547 # - It may require correct/in-range values for request initialization.
1548 # - It may require specifying regional endpoints when creating the service
1549 # client as shown in:
1550 # https://googleapis.dev/python/google-api-core/latest/client_options.html
1551 from google.cloud import firestore_v1
1553 async def sample_listen():
1554 # Create a client
1555 client = firestore_v1.FirestoreAsyncClient()
1557 # Initialize request argument(s)
1558 add_target = firestore_v1.Target()
1559 add_target.resume_token = b'resume_token_blob'
1561 request = firestore_v1.ListenRequest(
1562 add_target=add_target,
1563 database="database_value",
1564 )
1566 # This method expects an iterator which contains
1567 # 'firestore_v1.ListenRequest' objects
1568 # Here we create a generator that yields a single `request` for
1569 # demonstrative purposes.
1570 requests = [request]
1572 def request_generator():
1573 for request in requests:
1574 yield request
1576 # Make the request
1577 stream = await client.listen(requests=request_generator())
1579 # Handle the response
1580 async for response in stream:
1581 print(response)
1583 Args:
1584 requests (AsyncIterator[`google.cloud.firestore_v1.types.ListenRequest`]):
1585 The request object AsyncIterator. A request for
1586 [Firestore.Listen][google.firestore.v1.Firestore.Listen]
1587 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1588 should be retried.
1589 timeout (float): The timeout for this request.
1590 metadata (Sequence[Tuple[str, str]]): Strings which should be
1591 sent along with the request as metadata.
1593 Returns:
1594 AsyncIterable[google.cloud.firestore_v1.types.ListenResponse]:
1595 The response for
1596 [Firestore.Listen][google.firestore.v1.Firestore.Listen].
1598 """
1600 # Wrap the RPC method; this adds retry and timeout information,
1601 # and friendly error handling.
1602 rpc = gapic_v1.method_async.wrap_method(
1603 self._client._transport.listen,
1604 default_retry=retries.AsyncRetry(
1605 initial=0.1,
1606 maximum=60.0,
1607 multiplier=1.3,
1608 predicate=retries.if_exception_type(
1609 core_exceptions.DeadlineExceeded,
1610 core_exceptions.InternalServerError,
1611 core_exceptions.ResourceExhausted,
1612 core_exceptions.ServiceUnavailable,
1613 ),
1614 deadline=86400.0,
1615 ),
1616 default_timeout=86400.0,
1617 client_info=DEFAULT_CLIENT_INFO,
1618 )
1620 # Certain fields should be provided within the metadata header;
1621 # add these here.
1622 metadata = tuple(metadata) + (gapic_v1.routing_header.to_grpc_metadata(()),)
1624 # Send the request.
1625 response = rpc(
1626 requests,
1627 retry=retry,
1628 timeout=timeout,
1629 metadata=metadata,
1630 )
1632 # Done; return the response.
1633 return response
1635 async def list_collection_ids(
1636 self,
1637 request: Optional[Union[firestore.ListCollectionIdsRequest, dict]] = None,
1638 *,
1639 parent: Optional[str] = None,
1640 retry: OptionalRetry = gapic_v1.method.DEFAULT,
1641 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1642 metadata: Sequence[Tuple[str, str]] = (),
1643 ) -> pagers.ListCollectionIdsAsyncPager:
1644 r"""Lists all the collection IDs underneath a document.
1646 .. code-block:: python
1648 # This snippet has been automatically generated and should be regarded as a
1649 # code template only.
1650 # It will require modifications to work:
1651 # - It may require correct/in-range values for request initialization.
1652 # - It may require specifying regional endpoints when creating the service
1653 # client as shown in:
1654 # https://googleapis.dev/python/google-api-core/latest/client_options.html
1655 from google.cloud import firestore_v1
1657 async def sample_list_collection_ids():
1658 # Create a client
1659 client = firestore_v1.FirestoreAsyncClient()
1661 # Initialize request argument(s)
1662 request = firestore_v1.ListCollectionIdsRequest(
1663 parent="parent_value",
1664 )
1666 # Make the request
1667 page_result = client.list_collection_ids(request=request)
1669 # Handle the response
1670 async for response in page_result:
1671 print(response)
1673 Args:
1674 request (Optional[Union[google.cloud.firestore_v1.types.ListCollectionIdsRequest, dict]]):
1675 The request object. The request for
1676 [Firestore.ListCollectionIds][google.firestore.v1.Firestore.ListCollectionIds].
1677 parent (:class:`str`):
1678 Required. The parent document. In the format:
1679 ``projects/{project_id}/databases/{database_id}/documents/{document_path}``.
1680 For example:
1681 ``projects/my-project/databases/my-database/documents/chatrooms/my-chatroom``
1683 This corresponds to the ``parent`` field
1684 on the ``request`` instance; if ``request`` is provided, this
1685 should not be set.
1686 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1687 should be retried.
1688 timeout (float): The timeout for this request.
1689 metadata (Sequence[Tuple[str, str]]): Strings which should be
1690 sent along with the request as metadata.
1692 Returns:
1693 google.cloud.firestore_v1.services.firestore.pagers.ListCollectionIdsAsyncPager:
1694 The response from
1695 [Firestore.ListCollectionIds][google.firestore.v1.Firestore.ListCollectionIds].
1697 Iterating over this object will yield results and
1698 resolve additional pages automatically.
1700 """
1701 # Create or coerce a protobuf request object.
1702 # Quick check: If we got a request object, we should *not* have
1703 # gotten any keyword arguments that map to the request.
1704 has_flattened_params = any([parent])
1705 if request is not None and has_flattened_params:
1706 raise ValueError(
1707 "If the `request` argument is set, then none of "
1708 "the individual field arguments should be set."
1709 )
1711 request = firestore.ListCollectionIdsRequest(request)
1713 # If we have keyword arguments corresponding to fields on the
1714 # request, apply these.
1715 if parent is not None:
1716 request.parent = parent
1718 # Wrap the RPC method; this adds retry and timeout information,
1719 # and friendly error handling.
1720 rpc = gapic_v1.method_async.wrap_method(
1721 self._client._transport.list_collection_ids,
1722 default_retry=retries.AsyncRetry(
1723 initial=0.1,
1724 maximum=60.0,
1725 multiplier=1.3,
1726 predicate=retries.if_exception_type(
1727 core_exceptions.DeadlineExceeded,
1728 core_exceptions.InternalServerError,
1729 core_exceptions.ResourceExhausted,
1730 core_exceptions.ServiceUnavailable,
1731 ),
1732 deadline=60.0,
1733 ),
1734 default_timeout=60.0,
1735 client_info=DEFAULT_CLIENT_INFO,
1736 )
1738 # Certain fields should be provided within the metadata header;
1739 # add these here.
1740 metadata = tuple(metadata) + (
1741 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1742 )
1744 # Send the request.
1745 response = await rpc(
1746 request,
1747 retry=retry,
1748 timeout=timeout,
1749 metadata=metadata,
1750 )
1752 # This method is paged; wrap the response in a pager, which provides
1753 # an `__aiter__` convenience method.
1754 response = pagers.ListCollectionIdsAsyncPager(
1755 method=rpc,
1756 request=request,
1757 response=response,
1758 metadata=metadata,
1759 )
1761 # Done; return the response.
1762 return response
1764 async def batch_write(
1765 self,
1766 request: Optional[Union[firestore.BatchWriteRequest, dict]] = None,
1767 *,
1768 retry: OptionalRetry = gapic_v1.method.DEFAULT,
1769 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1770 metadata: Sequence[Tuple[str, str]] = (),
1771 ) -> firestore.BatchWriteResponse:
1772 r"""Applies a batch of write operations.
1774 The BatchWrite method does not apply the write operations
1775 atomically and can apply them out of order. Method does not
1776 allow more than one write per document. Each write succeeds or
1777 fails independently. See the
1778 [BatchWriteResponse][google.firestore.v1.BatchWriteResponse] for
1779 the success status of each write.
1781 If you require an atomically applied set of writes, use
1782 [Commit][google.firestore.v1.Firestore.Commit] instead.
1784 .. code-block:: python
1786 # This snippet has been automatically generated and should be regarded as a
1787 # code template only.
1788 # It will require modifications to work:
1789 # - It may require correct/in-range values for request initialization.
1790 # - It may require specifying regional endpoints when creating the service
1791 # client as shown in:
1792 # https://googleapis.dev/python/google-api-core/latest/client_options.html
1793 from google.cloud import firestore_v1
1795 async def sample_batch_write():
1796 # Create a client
1797 client = firestore_v1.FirestoreAsyncClient()
1799 # Initialize request argument(s)
1800 request = firestore_v1.BatchWriteRequest(
1801 database="database_value",
1802 )
1804 # Make the request
1805 response = await client.batch_write(request=request)
1807 # Handle the response
1808 print(response)
1810 Args:
1811 request (Optional[Union[google.cloud.firestore_v1.types.BatchWriteRequest, dict]]):
1812 The request object. The request for
1813 [Firestore.BatchWrite][google.firestore.v1.Firestore.BatchWrite].
1814 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1815 should be retried.
1816 timeout (float): The timeout for this request.
1817 metadata (Sequence[Tuple[str, str]]): Strings which should be
1818 sent along with the request as metadata.
1820 Returns:
1821 google.cloud.firestore_v1.types.BatchWriteResponse:
1822 The response from
1823 [Firestore.BatchWrite][google.firestore.v1.Firestore.BatchWrite].
1825 """
1826 # Create or coerce a protobuf request object.
1827 request = firestore.BatchWriteRequest(request)
1829 # Wrap the RPC method; this adds retry and timeout information,
1830 # and friendly error handling.
1831 rpc = gapic_v1.method_async.wrap_method(
1832 self._client._transport.batch_write,
1833 default_retry=retries.AsyncRetry(
1834 initial=0.1,
1835 maximum=60.0,
1836 multiplier=1.3,
1837 predicate=retries.if_exception_type(
1838 core_exceptions.Aborted,
1839 core_exceptions.ResourceExhausted,
1840 core_exceptions.ServiceUnavailable,
1841 ),
1842 deadline=60.0,
1843 ),
1844 default_timeout=60.0,
1845 client_info=DEFAULT_CLIENT_INFO,
1846 )
1848 # Certain fields should be provided within the metadata header;
1849 # add these here.
1850 metadata = tuple(metadata) + (
1851 gapic_v1.routing_header.to_grpc_metadata((("database", request.database),)),
1852 )
1854 # Send the request.
1855 response = await rpc(
1856 request,
1857 retry=retry,
1858 timeout=timeout,
1859 metadata=metadata,
1860 )
1862 # Done; return the response.
1863 return response
1865 async def create_document(
1866 self,
1867 request: Optional[Union[firestore.CreateDocumentRequest, dict]] = None,
1868 *,
1869 retry: OptionalRetry = gapic_v1.method.DEFAULT,
1870 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1871 metadata: Sequence[Tuple[str, str]] = (),
1872 ) -> document.Document:
1873 r"""Creates a new document.
1875 .. code-block:: python
1877 # This snippet has been automatically generated and should be regarded as a
1878 # code template only.
1879 # It will require modifications to work:
1880 # - It may require correct/in-range values for request initialization.
1881 # - It may require specifying regional endpoints when creating the service
1882 # client as shown in:
1883 # https://googleapis.dev/python/google-api-core/latest/client_options.html
1884 from google.cloud import firestore_v1
1886 async def sample_create_document():
1887 # Create a client
1888 client = firestore_v1.FirestoreAsyncClient()
1890 # Initialize request argument(s)
1891 request = firestore_v1.CreateDocumentRequest(
1892 parent="parent_value",
1893 collection_id="collection_id_value",
1894 )
1896 # Make the request
1897 response = await client.create_document(request=request)
1899 # Handle the response
1900 print(response)
1902 Args:
1903 request (Optional[Union[google.cloud.firestore_v1.types.CreateDocumentRequest, dict]]):
1904 The request object. The request for
1905 [Firestore.CreateDocument][google.firestore.v1.Firestore.CreateDocument].
1906 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1907 should be retried.
1908 timeout (float): The timeout for this request.
1909 metadata (Sequence[Tuple[str, str]]): Strings which should be
1910 sent along with the request as metadata.
1912 Returns:
1913 google.cloud.firestore_v1.types.Document:
1914 A Firestore document.
1916 Must not exceed 1 MiB - 4 bytes.
1918 """
1919 # Create or coerce a protobuf request object.
1920 request = firestore.CreateDocumentRequest(request)
1922 # Wrap the RPC method; this adds retry and timeout information,
1923 # and friendly error handling.
1924 rpc = gapic_v1.method_async.wrap_method(
1925 self._client._transport.create_document,
1926 default_retry=retries.AsyncRetry(
1927 initial=0.1,
1928 maximum=60.0,
1929 multiplier=1.3,
1930 predicate=retries.if_exception_type(
1931 core_exceptions.ResourceExhausted,
1932 core_exceptions.ServiceUnavailable,
1933 ),
1934 deadline=60.0,
1935 ),
1936 default_timeout=60.0,
1937 client_info=DEFAULT_CLIENT_INFO,
1938 )
1940 # Certain fields should be provided within the metadata header;
1941 # add these here.
1942 metadata = tuple(metadata) + (
1943 gapic_v1.routing_header.to_grpc_metadata(
1944 (
1945 ("parent", request.parent),
1946 ("collection_id", request.collection_id),
1947 )
1948 ),
1949 )
1951 # Send the request.
1952 response = await rpc(
1953 request,
1954 retry=retry,
1955 timeout=timeout,
1956 metadata=metadata,
1957 )
1959 # Done; return the response.
1960 return response
1962 async def list_operations(
1963 self,
1964 request: Optional[operations_pb2.ListOperationsRequest] = None,
1965 *,
1966 retry: OptionalRetry = gapic_v1.method.DEFAULT,
1967 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1968 metadata: Sequence[Tuple[str, str]] = (),
1969 ) -> operations_pb2.ListOperationsResponse:
1970 r"""Lists operations that match the specified filter in the request.
1972 Args:
1973 request (:class:`~.operations_pb2.ListOperationsRequest`):
1974 The request object. Request message for
1975 `ListOperations` method.
1976 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
1977 if any, should be retried.
1978 timeout (float): The timeout for this request.
1979 metadata (Sequence[Tuple[str, str]]): Strings which should be
1980 sent along with the request as metadata.
1981 Returns:
1982 ~.operations_pb2.ListOperationsResponse:
1983 Response message for ``ListOperations`` method.
1984 """
1985 # Create or coerce a protobuf request object.
1986 # The request isn't a proto-plus wrapped type,
1987 # so it must be constructed via keyword expansion.
1988 if isinstance(request, dict):
1989 request = operations_pb2.ListOperationsRequest(**request)
1991 # Wrap the RPC method; this adds retry and timeout information,
1992 # and friendly error handling.
1993 rpc = gapic_v1.method_async.wrap_method(
1994 self._client._transport.list_operations,
1995 default_timeout=None,
1996 client_info=DEFAULT_CLIENT_INFO,
1997 )
1999 # Certain fields should be provided within the metadata header;
2000 # add these here.
2001 metadata = tuple(metadata) + (
2002 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2003 )
2005 # Send the request.
2006 response = await rpc(
2007 request,
2008 retry=retry,
2009 timeout=timeout,
2010 metadata=metadata,
2011 )
2013 # Done; return the response.
2014 return response
2016 async def get_operation(
2017 self,
2018 request: Optional[operations_pb2.GetOperationRequest] = None,
2019 *,
2020 retry: OptionalRetry = gapic_v1.method.DEFAULT,
2021 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2022 metadata: Sequence[Tuple[str, str]] = (),
2023 ) -> operations_pb2.Operation:
2024 r"""Gets the latest state of a long-running operation.
2026 Args:
2027 request (:class:`~.operations_pb2.GetOperationRequest`):
2028 The request object. Request message for
2029 `GetOperation` method.
2030 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
2031 if any, should be retried.
2032 timeout (float): The timeout for this request.
2033 metadata (Sequence[Tuple[str, str]]): Strings which should be
2034 sent along with the request as metadata.
2035 Returns:
2036 ~.operations_pb2.Operation:
2037 An ``Operation`` object.
2038 """
2039 # Create or coerce a protobuf request object.
2040 # The request isn't a proto-plus wrapped type,
2041 # so it must be constructed via keyword expansion.
2042 if isinstance(request, dict):
2043 request = operations_pb2.GetOperationRequest(**request)
2045 # Wrap the RPC method; this adds retry and timeout information,
2046 # and friendly error handling.
2047 rpc = gapic_v1.method_async.wrap_method(
2048 self._client._transport.get_operation,
2049 default_timeout=None,
2050 client_info=DEFAULT_CLIENT_INFO,
2051 )
2053 # Certain fields should be provided within the metadata header;
2054 # add these here.
2055 metadata = tuple(metadata) + (
2056 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2057 )
2059 # Send the request.
2060 response = await rpc(
2061 request,
2062 retry=retry,
2063 timeout=timeout,
2064 metadata=metadata,
2065 )
2067 # Done; return the response.
2068 return response
2070 async def delete_operation(
2071 self,
2072 request: Optional[operations_pb2.DeleteOperationRequest] = None,
2073 *,
2074 retry: OptionalRetry = gapic_v1.method.DEFAULT,
2075 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2076 metadata: Sequence[Tuple[str, str]] = (),
2077 ) -> None:
2078 r"""Deletes a long-running operation.
2080 This method indicates that the client is no longer interested
2081 in the operation result. It does not cancel the operation.
2082 If the server doesn't support this method, it returns
2083 `google.rpc.Code.UNIMPLEMENTED`.
2085 Args:
2086 request (:class:`~.operations_pb2.DeleteOperationRequest`):
2087 The request object. Request message for
2088 `DeleteOperation` method.
2089 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
2090 if any, should be retried.
2091 timeout (float): The timeout for this request.
2092 metadata (Sequence[Tuple[str, str]]): Strings which should be
2093 sent along with the request as metadata.
2094 Returns:
2095 None
2096 """
2097 # Create or coerce a protobuf request object.
2098 # The request isn't a proto-plus wrapped type,
2099 # so it must be constructed via keyword expansion.
2100 if isinstance(request, dict):
2101 request = operations_pb2.DeleteOperationRequest(**request)
2103 # Wrap the RPC method; this adds retry and timeout information,
2104 # and friendly error handling.
2105 rpc = gapic_v1.method_async.wrap_method(
2106 self._client._transport.delete_operation,
2107 default_timeout=None,
2108 client_info=DEFAULT_CLIENT_INFO,
2109 )
2111 # Certain fields should be provided within the metadata header;
2112 # add these here.
2113 metadata = tuple(metadata) + (
2114 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2115 )
2117 # Send the request.
2118 await rpc(
2119 request,
2120 retry=retry,
2121 timeout=timeout,
2122 metadata=metadata,
2123 )
2125 async def cancel_operation(
2126 self,
2127 request: Optional[operations_pb2.CancelOperationRequest] = None,
2128 *,
2129 retry: OptionalRetry = gapic_v1.method.DEFAULT,
2130 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2131 metadata: Sequence[Tuple[str, str]] = (),
2132 ) -> None:
2133 r"""Starts asynchronous cancellation on a long-running operation.
2135 The server makes a best effort to cancel the operation, but success
2136 is not guaranteed. If the server doesn't support this method, it returns
2137 `google.rpc.Code.UNIMPLEMENTED`.
2139 Args:
2140 request (:class:`~.operations_pb2.CancelOperationRequest`):
2141 The request object. Request message for
2142 `CancelOperation` method.
2143 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
2144 if any, should be retried.
2145 timeout (float): The timeout for this request.
2146 metadata (Sequence[Tuple[str, str]]): Strings which should be
2147 sent along with the request as metadata.
2148 Returns:
2149 None
2150 """
2151 # Create or coerce a protobuf request object.
2152 # The request isn't a proto-plus wrapped type,
2153 # so it must be constructed via keyword expansion.
2154 if isinstance(request, dict):
2155 request = operations_pb2.CancelOperationRequest(**request)
2157 # Wrap the RPC method; this adds retry and timeout information,
2158 # and friendly error handling.
2159 rpc = gapic_v1.method_async.wrap_method(
2160 self._client._transport.cancel_operation,
2161 default_timeout=None,
2162 client_info=DEFAULT_CLIENT_INFO,
2163 )
2165 # Certain fields should be provided within the metadata header;
2166 # add these here.
2167 metadata = tuple(metadata) + (
2168 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2169 )
2171 # Send the request.
2172 await rpc(
2173 request,
2174 retry=retry,
2175 timeout=timeout,
2176 metadata=metadata,
2177 )
2179 async def __aenter__(self) -> "FirestoreAsyncClient":
2180 return self
2182 async def __aexit__(self, exc_type, exc, tb):
2183 await self.transport.close()
2186DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
2187 gapic_version=package_version.__version__
2188)
2191__all__ = ("FirestoreAsyncClient",)