Skip to content

Commit

Permalink
Merge branch 'main' into renovate/all
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sanche committed Aug 9, 2024
2 parents 6a86ca6 + 3a13bf9 commit 30ad0aa
Show file tree
Hide file tree
Showing 24 changed files with 9,448 additions and 2,877 deletions.
15 changes: 15 additions & 0 deletions google/cloud/firestore_admin_v1/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
"grpc": {
"libraryClient": "FirestoreAdminClient",
"rpcs": {
"BulkDeleteDocuments": {
"methods": [
"bulk_delete_documents"
]
},
"CreateBackupSchedule": {
"methods": [
"create_backup_schedule"
Expand Down Expand Up @@ -130,6 +135,11 @@
"grpc-async": {
"libraryClient": "FirestoreAdminAsyncClient",
"rpcs": {
"BulkDeleteDocuments": {
"methods": [
"bulk_delete_documents"
]
},
"CreateBackupSchedule": {
"methods": [
"create_backup_schedule"
Expand Down Expand Up @@ -250,6 +260,11 @@
"rest": {
"libraryClient": "FirestoreAdminClient",
"rpcs": {
"BulkDeleteDocuments": {
"methods": [
"bulk_delete_documents"
]
},
"CreateBackupSchedule": {
"methods": [
"create_backup_schedule"
Expand Down
606 changes: 360 additions & 246 deletions google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py

Large diffs are not rendered by default.

392 changes: 249 additions & 143 deletions google/cloud/firestore_admin_v1/services/firestore_admin/client.py

Large diffs are not rendered by default.

69 changes: 65 additions & 4 deletions google/cloud/firestore_admin_v1/services/firestore_admin/pagers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from google.api_core import gapic_v1
from google.api_core import retry as retries
from google.api_core import retry_async as retries_async
from typing import (
Any,
AsyncIterator,
Expand All @@ -22,8 +25,18 @@
Tuple,
Optional,
Iterator,
Union,
)

try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
OptionalAsyncRetry = Union[
retries_async.AsyncRetry, gapic_v1.method._MethodDefault, None
]
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
OptionalAsyncRetry = Union[retries_async.AsyncRetry, object, None] # type: ignore

from google.cloud.firestore_admin_v1.types import field
from google.cloud.firestore_admin_v1.types import firestore_admin
from google.cloud.firestore_admin_v1.types import index
Expand Down Expand Up @@ -53,6 +66,8 @@ def __init__(
request: firestore_admin.ListIndexesRequest,
response: firestore_admin.ListIndexesResponse,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = ()
):
"""Instantiate the pager.
Expand All @@ -64,12 +79,17 @@ def __init__(
The initial request object.
response (google.cloud.firestore_admin_v1.types.ListIndexesResponse):
The initial response object.
retry (google.api_core.retry.Retry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
"""
self._method = method
self._request = firestore_admin.ListIndexesRequest(request)
self._response = response
self._retry = retry
self._timeout = timeout
self._metadata = metadata

def __getattr__(self, name: str) -> Any:
Expand All @@ -80,7 +100,12 @@ def pages(self) -> Iterator[firestore_admin.ListIndexesResponse]:
yield self._response
while self._response.next_page_token:
self._request.page_token = self._response.next_page_token
self._response = self._method(self._request, metadata=self._metadata)
self._response = self._method(
self._request,
retry=self._retry,
timeout=self._timeout,
metadata=self._metadata,
)
yield self._response

def __iter__(self) -> Iterator[index.Index]:
Expand Down Expand Up @@ -115,6 +140,8 @@ def __init__(
request: firestore_admin.ListIndexesRequest,
response: firestore_admin.ListIndexesResponse,
*,
retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = ()
):
"""Instantiates the pager.
Expand All @@ -126,12 +153,17 @@ def __init__(
The initial request object.
response (google.cloud.firestore_admin_v1.types.ListIndexesResponse):
The initial response object.
retry (google.api_core.retry.AsyncRetry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
"""
self._method = method
self._request = firestore_admin.ListIndexesRequest(request)
self._response = response
self._retry = retry
self._timeout = timeout
self._metadata = metadata

def __getattr__(self, name: str) -> Any:
Expand All @@ -142,7 +174,12 @@ async def pages(self) -> AsyncIterator[firestore_admin.ListIndexesResponse]:
yield self._response
while self._response.next_page_token:
self._request.page_token = self._response.next_page_token
self._response = await self._method(self._request, metadata=self._metadata)
self._response = await self._method(
self._request,
retry=self._retry,
timeout=self._timeout,
metadata=self._metadata,
)
yield self._response

def __aiter__(self) -> AsyncIterator[index.Index]:
Expand Down Expand Up @@ -181,6 +218,8 @@ def __init__(
request: firestore_admin.ListFieldsRequest,
response: firestore_admin.ListFieldsResponse,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = ()
):
"""Instantiate the pager.
Expand All @@ -192,12 +231,17 @@ def __init__(
The initial request object.
response (google.cloud.firestore_admin_v1.types.ListFieldsResponse):
The initial response object.
retry (google.api_core.retry.Retry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
"""
self._method = method
self._request = firestore_admin.ListFieldsRequest(request)
self._response = response
self._retry = retry
self._timeout = timeout
self._metadata = metadata

def __getattr__(self, name: str) -> Any:
Expand All @@ -208,7 +252,12 @@ def pages(self) -> Iterator[firestore_admin.ListFieldsResponse]:
yield self._response
while self._response.next_page_token:
self._request.page_token = self._response.next_page_token
self._response = self._method(self._request, metadata=self._metadata)
self._response = self._method(
self._request,
retry=self._retry,
timeout=self._timeout,
metadata=self._metadata,
)
yield self._response

def __iter__(self) -> Iterator[field.Field]:
Expand Down Expand Up @@ -243,6 +292,8 @@ def __init__(
request: firestore_admin.ListFieldsRequest,
response: firestore_admin.ListFieldsResponse,
*,
retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = ()
):
"""Instantiates the pager.
Expand All @@ -254,12 +305,17 @@ def __init__(
The initial request object.
response (google.cloud.firestore_admin_v1.types.ListFieldsResponse):
The initial response object.
retry (google.api_core.retry.AsyncRetry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
"""
self._method = method
self._request = firestore_admin.ListFieldsRequest(request)
self._response = response
self._retry = retry
self._timeout = timeout
self._metadata = metadata

def __getattr__(self, name: str) -> Any:
Expand All @@ -270,7 +326,12 @@ async def pages(self) -> AsyncIterator[firestore_admin.ListFieldsResponse]:
yield self._response
while self._response.next_page_token:
self._request.page_token = self._response.next_page_token
self._response = await self._method(self._request, metadata=self._metadata)
self._response = await self._method(
self._request,
retry=self._retry,
timeout=self._timeout,
metadata=self._metadata,
)
yield self._response

def __aiter__(self) -> AsyncIterator[field.Field]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def __init__(

# Save the scopes.
self._scopes = scopes
if not hasattr(self, "_ignore_credentials"):
self._ignore_credentials: bool = False

# If no credentials are provided, then determine the appropriate
# defaults.
Expand All @@ -106,7 +108,7 @@ def __init__(
credentials, _ = google.auth.load_credentials_from_file(
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
)
elif credentials is None:
elif credentials is None and not self._ignore_credentials:
credentials, _ = google.auth.default(
**scopes_kwargs, quota_project_id=quota_project_id
)
Expand Down Expand Up @@ -239,6 +241,11 @@ def _prep_wrapped_messages(self, client_info):
default_timeout=60.0,
client_info=client_info,
),
self.bulk_delete_documents: gapic_v1.method.wrap_method(
self.bulk_delete_documents,
default_timeout=60.0,
client_info=client_info,
),
self.create_database: gapic_v1.method.wrap_method(
self.create_database,
default_timeout=None,
Expand Down Expand Up @@ -410,6 +417,15 @@ def import_documents(
]:
raise NotImplementedError()

@property
def bulk_delete_documents(
self,
) -> Callable[
[firestore_admin.BulkDeleteDocumentsRequest],
Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
]:
raise NotImplementedError()

@property
def create_database(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init__(
credentials: Optional[ga_credentials.Credentials] = None,
credentials_file: Optional[str] = None,
scopes: Optional[Sequence[str]] = None,
channel: Optional[grpc.Channel] = None,
channel: Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]] = None,
api_mtls_endpoint: Optional[str] = None,
client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
Expand All @@ -109,14 +109,17 @@ def __init__(
credentials identify the application to the service; if none
are specified, the client will attempt to ascertain the
credentials from the environment.
This argument is ignored if ``channel`` is provided.
This argument is ignored if a ``channel`` instance is provided.
credentials_file (Optional[str]): A file with credentials that can
be loaded with :func:`google.auth.load_credentials_from_file`.
This argument is ignored if ``channel`` is provided.
This argument is ignored if a ``channel`` instance is provided.
scopes (Optional(Sequence[str])): A list of scopes. This argument is
ignored if ``channel`` is provided.
channel (Optional[grpc.Channel]): A ``Channel`` instance through
which to make calls.
ignored if a ``channel`` instance is provided.
channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]):
A ``Channel`` instance through which to make calls, or a Callable
that constructs and returns one. If set to None, ``self.create_channel``
is used to create the channel. If a Callable is given, it will be called
with the same arguments as used in ``self.create_channel``.
api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
If provided, it overrides the ``host`` argument and tries to create
a mutual TLS channel with client SSL credentials from
Expand All @@ -126,11 +129,11 @@ def __init__(
private key bytes, both in PEM format. It is ignored if
``api_mtls_endpoint`` is None.
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
for the grpc channel. It is ignored if ``channel`` is provided.
for the grpc channel. It is ignored if a ``channel`` instance is provided.
client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
A callback to provide client certificate bytes and private key bytes,
both in PEM format. It is used to configure a mutual TLS channel. It is
ignored if ``channel`` or ``ssl_channel_credentials`` is provided.
ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
quota_project_id (Optional[str]): An optional project to use for billing
and quota.
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
Expand All @@ -157,9 +160,10 @@ def __init__(
if client_cert_source:
warnings.warn("client_cert_source is deprecated", DeprecationWarning)

if channel:
if isinstance(channel, grpc.Channel):
# Ignore credentials if a channel was passed.
credentials = False
credentials = None
self._ignore_credentials = True
# If a channel was explicitly provided, set it.
self._grpc_channel = channel
self._ssl_channel_credentials = None
Expand Down Expand Up @@ -198,7 +202,9 @@ def __init__(
)

if not self._grpc_channel:
self._grpc_channel = type(self).create_channel(
# initialize with the provided callable or the default channel
channel_init = channel or type(self).create_channel
self._grpc_channel = channel_init(
self._host,
# use the credentials which are saved
credentials=self._credentials,
Expand Down Expand Up @@ -564,6 +570,43 @@ def import_documents(
)
return self._stubs["import_documents"]

@property
def bulk_delete_documents(
self,
) -> Callable[
[firestore_admin.BulkDeleteDocumentsRequest], operations_pb2.Operation
]:
r"""Return a callable for the bulk delete documents method over gRPC.
Bulk deletes a subset of documents from Google Cloud
Firestore. Documents created or updated after the
underlying system starts to process the request will not
be deleted. The bulk delete occurs in the background and
its progress can be monitored and managed via the
Operation resource that is created.
For more details on bulk delete behavior, refer to:
https://cloud.google.com/firestore/docs/manage-data/bulk-delete
Returns:
Callable[[~.BulkDeleteDocumentsRequest],
~.Operation]:
A function that, when called, will call the underlying RPC
on the server.
"""
# Generate a "stub function" on-the-fly which will actually make
# the request.
# gRPC handles serialization and deserialization, so we just need
# to pass in the functions for each.
if "bulk_delete_documents" not in self._stubs:
self._stubs["bulk_delete_documents"] = self.grpc_channel.unary_unary(
"/google.firestore.admin.v1.FirestoreAdmin/BulkDeleteDocuments",
request_serializer=firestore_admin.BulkDeleteDocumentsRequest.serialize,
response_deserializer=operations_pb2.Operation.FromString,
)
return self._stubs["bulk_delete_documents"]

@property
def create_database(
self,
Expand Down Expand Up @@ -785,7 +828,7 @@ def restore_database(
The new database must be in the same cloud region or
multi-region location as the existing backup. This behaves
similar to
[FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.CreateDatabase]
[FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase]
except instead of creating a new empty database, a new database
is created with the database type, index configuration, and
documents from an existing backup.
Expand Down
Loading

0 comments on commit 30ad0aa

Please sign in to comment.