Skip to content

Commit 3a13bf9

Browse files
fix: allow protobuf 5.x (#919)
* feat: Expose the `FindNearest.distance_result_field` parameter feat: Expose the `FindNearest.distance_threshold` parameter PiperOrigin-RevId: 660557033 Source-Link: googleapis/googleapis@28685f7 Source-Link: googleapis/googleapis-gen@38f25b0 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMzhmMjViMGJjZjU0NjEzNzU4ZWQ1NWE2MzkwYmM4NGU0MDM2OGRjMiJ9 chore: Update gapic-generator-python to v1.18.4 PiperOrigin-RevId: 657207628 Source-Link: googleapis/googleapis@33fe71e Source-Link: googleapis/googleapis-gen@e02739d Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTAyNzM5ZDEyMmVkMTViZDVlZjU3NzFjNTdmMTJhODNkNDdhMWRkYSJ9 chore: Update gapic-generator-python to v1.18.3 PiperOrigin-RevId: 656040068 Source-Link: googleapis/googleapis@3f4e29a Source-Link: googleapis/googleapis-gen@b8feb21 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjhmZWIyMTA5ZGRlN2IwOTM4YzIyYzk5M2QwMDIyNTFhYzY3MTRkYyJ9 chore: Update gapic-generator-python to v1.18.3 PiperOrigin-RevId: 655567917 Source-Link: googleapis/googleapis@43aa65e Source-Link: googleapis/googleapis-gen@0e38378 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMGUzODM3ODc1MzA3NGMwZjY2ZmY2MzM0OGQ2ODY0OTI5ZTEwNGQ1YyJ9 chore: expose new experimental FindNearest distance params to the preview branch docs: minor documentation clarifications on FindNearest DistanceMeasure options PiperOrigin-RevId: 655267922 Source-Link: googleapis/googleapis@7858db4 Source-Link: googleapis/googleapis-gen@c075428 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYzA3NTQyODJlODA2MjU2NTk1OWI1MjM5MWJiM2FkZGI4NzAyNjdiOCJ9 feat(spanner): Add support for Cloud Spanner Scheduled Backups PiperOrigin-RevId: 649277844 Source-Link: googleapis/googleapis@fd7efa2 Source-Link: googleapis/googleapis-gen@50be251 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNTBiZTI1MTMyOWQ4ZGI1YjU1NTYyNmViZDQ4ODY3MjFmNTQ3ZDNjYyJ9 feat: add bulk delete api docs: update field api description PiperOrigin-RevId: 642337904 Source-Link: googleapis/googleapis@9aab32e Source-Link: googleapis/googleapis-gen@757cf9d Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNzU3Y2Y5ZDhlMmQxMzlkN2IyODcxY2UwMTNkNWUyZWRjNDAxNzZkMyJ9 chore: Update gapic-generator-python to v1.18.0 PiperOrigin-RevId: 638650618 Source-Link: googleapis/googleapis@6330f03 Source-Link: googleapis/googleapis-gen@44fa4f1 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDRmYTRmMTk3OWRjNDVjMTc3OGZkN2NhZjEzZjhlNjFjNmQxY2FlOCJ9 chore: Update gapic-generator-python to v1.17.1 PiperOrigin-RevId: 629071173 Source-Link: googleapis/googleapis@4afa392 Source-Link: googleapis/googleapis-gen@16dbbb4 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTZkYmJiNGQwNDU3ZGI1ZTYxYWM5Zjk5YjBkNTJhNDYxNTQ0NTVhYyJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: Update gapic-generator-python to v1.18.5 PiperOrigin-RevId: 661268868 Source-Link: googleapis/googleapis@f7d214c Source-Link: googleapis/googleapis-gen@79a8411 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNzlhODQxMWJiZGIyNWE5ODNmYTNhYWU4YzBlMTQzMjdkZjEyOWY5NCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent a0d2d7e commit 3a13bf9

File tree

24 files changed

+9448
-2877
lines changed

24 files changed

+9448
-2877
lines changed

google/cloud/firestore_admin_v1/gapic_metadata.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
"grpc": {
1111
"libraryClient": "FirestoreAdminClient",
1212
"rpcs": {
13+
"BulkDeleteDocuments": {
14+
"methods": [
15+
"bulk_delete_documents"
16+
]
17+
},
1318
"CreateBackupSchedule": {
1419
"methods": [
1520
"create_backup_schedule"
@@ -130,6 +135,11 @@
130135
"grpc-async": {
131136
"libraryClient": "FirestoreAdminAsyncClient",
132137
"rpcs": {
138+
"BulkDeleteDocuments": {
139+
"methods": [
140+
"bulk_delete_documents"
141+
]
142+
},
133143
"CreateBackupSchedule": {
134144
"methods": [
135145
"create_backup_schedule"
@@ -250,6 +260,11 @@
250260
"rest": {
251261
"libraryClient": "FirestoreAdminClient",
252262
"rpcs": {
263+
"BulkDeleteDocuments": {
264+
"methods": [
265+
"bulk_delete_documents"
266+
]
267+
},
253268
"CreateBackupSchedule": {
254269
"methods": [
255270
"create_backup_schedule"

google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py

Lines changed: 360 additions & 246 deletions
Large diffs are not rendered by default.

google/cloud/firestore_admin_v1/services/firestore_admin/client.py

Lines changed: 249 additions & 143 deletions
Large diffs are not rendered by default.

google/cloud/firestore_admin_v1/services/firestore_admin/pagers.py

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16+
from google.api_core import gapic_v1
17+
from google.api_core import retry as retries
18+
from google.api_core import retry_async as retries_async
1619
from typing import (
1720
Any,
1821
AsyncIterator,
@@ -22,8 +25,18 @@
2225
Tuple,
2326
Optional,
2427
Iterator,
28+
Union,
2529
)
2630

31+
try:
32+
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
33+
OptionalAsyncRetry = Union[
34+
retries_async.AsyncRetry, gapic_v1.method._MethodDefault, None
35+
]
36+
except AttributeError: # pragma: NO COVER
37+
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
38+
OptionalAsyncRetry = Union[retries_async.AsyncRetry, object, None] # type: ignore
39+
2740
from google.cloud.firestore_admin_v1.types import field
2841
from google.cloud.firestore_admin_v1.types import firestore_admin
2942
from google.cloud.firestore_admin_v1.types import index
@@ -53,6 +66,8 @@ def __init__(
5366
request: firestore_admin.ListIndexesRequest,
5467
response: firestore_admin.ListIndexesResponse,
5568
*,
69+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
70+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
5671
metadata: Sequence[Tuple[str, str]] = ()
5772
):
5873
"""Instantiate the pager.
@@ -64,12 +79,17 @@ def __init__(
6479
The initial request object.
6580
response (google.cloud.firestore_admin_v1.types.ListIndexesResponse):
6681
The initial response object.
82+
retry (google.api_core.retry.Retry): Designation of what errors,
83+
if any, should be retried.
84+
timeout (float): The timeout for this request.
6785
metadata (Sequence[Tuple[str, str]]): Strings which should be
6886
sent along with the request as metadata.
6987
"""
7088
self._method = method
7189
self._request = firestore_admin.ListIndexesRequest(request)
7290
self._response = response
91+
self._retry = retry
92+
self._timeout = timeout
7393
self._metadata = metadata
7494

7595
def __getattr__(self, name: str) -> Any:
@@ -80,7 +100,12 @@ def pages(self) -> Iterator[firestore_admin.ListIndexesResponse]:
80100
yield self._response
81101
while self._response.next_page_token:
82102
self._request.page_token = self._response.next_page_token
83-
self._response = self._method(self._request, metadata=self._metadata)
103+
self._response = self._method(
104+
self._request,
105+
retry=self._retry,
106+
timeout=self._timeout,
107+
metadata=self._metadata,
108+
)
84109
yield self._response
85110

86111
def __iter__(self) -> Iterator[index.Index]:
@@ -115,6 +140,8 @@ def __init__(
115140
request: firestore_admin.ListIndexesRequest,
116141
response: firestore_admin.ListIndexesResponse,
117142
*,
143+
retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,
144+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
118145
metadata: Sequence[Tuple[str, str]] = ()
119146
):
120147
"""Instantiates the pager.
@@ -126,12 +153,17 @@ def __init__(
126153
The initial request object.
127154
response (google.cloud.firestore_admin_v1.types.ListIndexesResponse):
128155
The initial response object.
156+
retry (google.api_core.retry.AsyncRetry): Designation of what errors,
157+
if any, should be retried.
158+
timeout (float): The timeout for this request.
129159
metadata (Sequence[Tuple[str, str]]): Strings which should be
130160
sent along with the request as metadata.
131161
"""
132162
self._method = method
133163
self._request = firestore_admin.ListIndexesRequest(request)
134164
self._response = response
165+
self._retry = retry
166+
self._timeout = timeout
135167
self._metadata = metadata
136168

137169
def __getattr__(self, name: str) -> Any:
@@ -142,7 +174,12 @@ async def pages(self) -> AsyncIterator[firestore_admin.ListIndexesResponse]:
142174
yield self._response
143175
while self._response.next_page_token:
144176
self._request.page_token = self._response.next_page_token
145-
self._response = await self._method(self._request, metadata=self._metadata)
177+
self._response = await self._method(
178+
self._request,
179+
retry=self._retry,
180+
timeout=self._timeout,
181+
metadata=self._metadata,
182+
)
146183
yield self._response
147184

148185
def __aiter__(self) -> AsyncIterator[index.Index]:
@@ -181,6 +218,8 @@ def __init__(
181218
request: firestore_admin.ListFieldsRequest,
182219
response: firestore_admin.ListFieldsResponse,
183220
*,
221+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
222+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
184223
metadata: Sequence[Tuple[str, str]] = ()
185224
):
186225
"""Instantiate the pager.
@@ -192,12 +231,17 @@ def __init__(
192231
The initial request object.
193232
response (google.cloud.firestore_admin_v1.types.ListFieldsResponse):
194233
The initial response object.
234+
retry (google.api_core.retry.Retry): Designation of what errors,
235+
if any, should be retried.
236+
timeout (float): The timeout for this request.
195237
metadata (Sequence[Tuple[str, str]]): Strings which should be
196238
sent along with the request as metadata.
197239
"""
198240
self._method = method
199241
self._request = firestore_admin.ListFieldsRequest(request)
200242
self._response = response
243+
self._retry = retry
244+
self._timeout = timeout
201245
self._metadata = metadata
202246

203247
def __getattr__(self, name: str) -> Any:
@@ -208,7 +252,12 @@ def pages(self) -> Iterator[firestore_admin.ListFieldsResponse]:
208252
yield self._response
209253
while self._response.next_page_token:
210254
self._request.page_token = self._response.next_page_token
211-
self._response = self._method(self._request, metadata=self._metadata)
255+
self._response = self._method(
256+
self._request,
257+
retry=self._retry,
258+
timeout=self._timeout,
259+
metadata=self._metadata,
260+
)
212261
yield self._response
213262

214263
def __iter__(self) -> Iterator[field.Field]:
@@ -243,6 +292,8 @@ def __init__(
243292
request: firestore_admin.ListFieldsRequest,
244293
response: firestore_admin.ListFieldsResponse,
245294
*,
295+
retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,
296+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
246297
metadata: Sequence[Tuple[str, str]] = ()
247298
):
248299
"""Instantiates the pager.
@@ -254,12 +305,17 @@ def __init__(
254305
The initial request object.
255306
response (google.cloud.firestore_admin_v1.types.ListFieldsResponse):
256307
The initial response object.
308+
retry (google.api_core.retry.AsyncRetry): Designation of what errors,
309+
if any, should be retried.
310+
timeout (float): The timeout for this request.
257311
metadata (Sequence[Tuple[str, str]]): Strings which should be
258312
sent along with the request as metadata.
259313
"""
260314
self._method = method
261315
self._request = firestore_admin.ListFieldsRequest(request)
262316
self._response = response
317+
self._retry = retry
318+
self._timeout = timeout
263319
self._metadata = metadata
264320

265321
def __getattr__(self, name: str) -> Any:
@@ -270,7 +326,12 @@ async def pages(self) -> AsyncIterator[firestore_admin.ListFieldsResponse]:
270326
yield self._response
271327
while self._response.next_page_token:
272328
self._request.page_token = self._response.next_page_token
273-
self._response = await self._method(self._request, metadata=self._metadata)
329+
self._response = await self._method(
330+
self._request,
331+
retry=self._retry,
332+
timeout=self._timeout,
333+
metadata=self._metadata,
334+
)
274335
yield self._response
275336

276337
def __aiter__(self) -> AsyncIterator[field.Field]:

google/cloud/firestore_admin_v1/services/firestore_admin/transports/base.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ def __init__(
9494

9595
# Save the scopes.
9696
self._scopes = scopes
97+
if not hasattr(self, "_ignore_credentials"):
98+
self._ignore_credentials: bool = False
9799

98100
# If no credentials are provided, then determine the appropriate
99101
# defaults.
@@ -106,7 +108,7 @@ def __init__(
106108
credentials, _ = google.auth.load_credentials_from_file(
107109
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
108110
)
109-
elif credentials is None:
111+
elif credentials is None and not self._ignore_credentials:
110112
credentials, _ = google.auth.default(
111113
**scopes_kwargs, quota_project_id=quota_project_id
112114
)
@@ -239,6 +241,11 @@ def _prep_wrapped_messages(self, client_info):
239241
default_timeout=60.0,
240242
client_info=client_info,
241243
),
244+
self.bulk_delete_documents: gapic_v1.method.wrap_method(
245+
self.bulk_delete_documents,
246+
default_timeout=60.0,
247+
client_info=client_info,
248+
),
242249
self.create_database: gapic_v1.method.wrap_method(
243250
self.create_database,
244251
default_timeout=None,
@@ -410,6 +417,15 @@ def import_documents(
410417
]:
411418
raise NotImplementedError()
412419

420+
@property
421+
def bulk_delete_documents(
422+
self,
423+
) -> Callable[
424+
[firestore_admin.BulkDeleteDocumentsRequest],
425+
Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
426+
]:
427+
raise NotImplementedError()
428+
413429
@property
414430
def create_database(
415431
self,

google/cloud/firestore_admin_v1/services/firestore_admin/transports/grpc.py

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def __init__(
8989
credentials: Optional[ga_credentials.Credentials] = None,
9090
credentials_file: Optional[str] = None,
9191
scopes: Optional[Sequence[str]] = None,
92-
channel: Optional[grpc.Channel] = None,
92+
channel: Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]] = None,
9393
api_mtls_endpoint: Optional[str] = None,
9494
client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
9595
ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
@@ -109,14 +109,17 @@ def __init__(
109109
credentials identify the application to the service; if none
110110
are specified, the client will attempt to ascertain the
111111
credentials from the environment.
112-
This argument is ignored if ``channel`` is provided.
112+
This argument is ignored if a ``channel`` instance is provided.
113113
credentials_file (Optional[str]): A file with credentials that can
114114
be loaded with :func:`google.auth.load_credentials_from_file`.
115-
This argument is ignored if ``channel`` is provided.
115+
This argument is ignored if a ``channel`` instance is provided.
116116
scopes (Optional(Sequence[str])): A list of scopes. This argument is
117-
ignored if ``channel`` is provided.
118-
channel (Optional[grpc.Channel]): A ``Channel`` instance through
119-
which to make calls.
117+
ignored if a ``channel`` instance is provided.
118+
channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]):
119+
A ``Channel`` instance through which to make calls, or a Callable
120+
that constructs and returns one. If set to None, ``self.create_channel``
121+
is used to create the channel. If a Callable is given, it will be called
122+
with the same arguments as used in ``self.create_channel``.
120123
api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
121124
If provided, it overrides the ``host`` argument and tries to create
122125
a mutual TLS channel with client SSL credentials from
@@ -126,11 +129,11 @@ def __init__(
126129
private key bytes, both in PEM format. It is ignored if
127130
``api_mtls_endpoint`` is None.
128131
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
129-
for the grpc channel. It is ignored if ``channel`` is provided.
132+
for the grpc channel. It is ignored if a ``channel`` instance is provided.
130133
client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
131134
A callback to provide client certificate bytes and private key bytes,
132135
both in PEM format. It is used to configure a mutual TLS channel. It is
133-
ignored if ``channel`` or ``ssl_channel_credentials`` is provided.
136+
ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
134137
quota_project_id (Optional[str]): An optional project to use for billing
135138
and quota.
136139
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
@@ -157,9 +160,10 @@ def __init__(
157160
if client_cert_source:
158161
warnings.warn("client_cert_source is deprecated", DeprecationWarning)
159162

160-
if channel:
163+
if isinstance(channel, grpc.Channel):
161164
# Ignore credentials if a channel was passed.
162-
credentials = False
165+
credentials = None
166+
self._ignore_credentials = True
163167
# If a channel was explicitly provided, set it.
164168
self._grpc_channel = channel
165169
self._ssl_channel_credentials = None
@@ -198,7 +202,9 @@ def __init__(
198202
)
199203

200204
if not self._grpc_channel:
201-
self._grpc_channel = type(self).create_channel(
205+
# initialize with the provided callable or the default channel
206+
channel_init = channel or type(self).create_channel
207+
self._grpc_channel = channel_init(
202208
self._host,
203209
# use the credentials which are saved
204210
credentials=self._credentials,
@@ -564,6 +570,43 @@ def import_documents(
564570
)
565571
return self._stubs["import_documents"]
566572

573+
@property
574+
def bulk_delete_documents(
575+
self,
576+
) -> Callable[
577+
[firestore_admin.BulkDeleteDocumentsRequest], operations_pb2.Operation
578+
]:
579+
r"""Return a callable for the bulk delete documents method over gRPC.
580+
581+
Bulk deletes a subset of documents from Google Cloud
582+
Firestore. Documents created or updated after the
583+
underlying system starts to process the request will not
584+
be deleted. The bulk delete occurs in the background and
585+
its progress can be monitored and managed via the
586+
Operation resource that is created.
587+
588+
For more details on bulk delete behavior, refer to:
589+
590+
https://cloud.google.com/firestore/docs/manage-data/bulk-delete
591+
592+
Returns:
593+
Callable[[~.BulkDeleteDocumentsRequest],
594+
~.Operation]:
595+
A function that, when called, will call the underlying RPC
596+
on the server.
597+
"""
598+
# Generate a "stub function" on-the-fly which will actually make
599+
# the request.
600+
# gRPC handles serialization and deserialization, so we just need
601+
# to pass in the functions for each.
602+
if "bulk_delete_documents" not in self._stubs:
603+
self._stubs["bulk_delete_documents"] = self.grpc_channel.unary_unary(
604+
"/google.firestore.admin.v1.FirestoreAdmin/BulkDeleteDocuments",
605+
request_serializer=firestore_admin.BulkDeleteDocumentsRequest.serialize,
606+
response_deserializer=operations_pb2.Operation.FromString,
607+
)
608+
return self._stubs["bulk_delete_documents"]
609+
567610
@property
568611
def create_database(
569612
self,
@@ -785,7 +828,7 @@ def restore_database(
785828
The new database must be in the same cloud region or
786829
multi-region location as the existing backup. This behaves
787830
similar to
788-
[FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.CreateDatabase]
831+
[FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase]
789832
except instead of creating a new empty database, a new database
790833
is created with the database type, index configuration, and
791834
documents from an existing backup.

0 commit comments

Comments
 (0)