Skip to content

Commit 9aab32e

Browse files
Google APIscopybara-github
authored andcommitted
feat: add bulk delete api
docs: update field api description PiperOrigin-RevId: 642337904
1 parent 04abdaa commit 9aab32e

7 files changed

Lines changed: 129 additions & 33 deletions

File tree

google/firestore/admin/v1/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,6 @@ load(
358358

359359
csharp_proto_library(
360360
name = "admin_csharp_proto",
361-
extra_opts = [],
362361
deps = [":admin_proto"],
363362
)
364363

google/firestore/admin/v1/field.proto

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ message Field {
4949
// When false, the `Field`'s index configuration is defined explicitly.
5050
bool uses_ancestor_config = 2;
5151

52-
// Output only. Specifies the resource name of the `Field` from which this field's
53-
// index configuration is set (when `uses_ancestor_config` is true),
52+
// Output only. Specifies the resource name of the `Field` from which this
53+
// field's index configuration is set (when `uses_ancestor_config` is true),
5454
// or from which it *would* be set if this field had no index configuration
5555
// (when `uses_ancestor_config` is false).
5656
string ancestor_field = 3;
@@ -65,9 +65,12 @@ message Field {
6565

6666
// The TTL (time-to-live) configuration for documents that have this `Field`
6767
// set.
68+
//
6869
// Storing a timestamp value into a TTL-enabled field will be treated as
69-
// the document's absolute expiration time. Using any other data type or
70-
// leaving the field absent will disable the TTL for the individual document.
70+
// the document's absolute expiration time. Timestamp values in the past
71+
// indicate that the document is eligible for immediate expiration. Using any
72+
// other data type or leaving the field absent will disable expiration for the
73+
// individual document.
7174
message TtlConfig {
7275
// The state of applying the TTL configuration to all documents.
7376
enum State {
@@ -95,26 +98,24 @@ message Field {
9598
State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
9699
}
97100

98-
// Required. A field name of the form
101+
// Required. A field name of the form:
99102
// `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
100103
//
101-
// A field path may be a simple field name, e.g. `address` or a path to fields
102-
// within map_value , e.g. `address.city`,
104+
// A field path can be a simple field name, e.g. `address` or a path to fields
105+
// within `map_value` , e.g. `address.city`,
103106
// or a special field path. The only valid special field is `*`, which
104107
// represents any field.
105108
//
106-
// Field paths may be quoted using ` (backtick). The only character that needs
107-
// to be escaped within a quoted field path is the backtick character itself,
108-
// escaped using a backslash. Special characters in field paths that
109+
// Field paths can be quoted using `` ` `` (backtick). The only character that
110+
// must be escaped within a quoted field path is the backtick character
111+
// itself, escaped using a backslash. Special characters in field paths that
109112
// must be quoted include: `*`, `.`,
110-
// ``` (backtick), `[`, `]`, as well as any ascii symbolic characters.
113+
// `` ` `` (backtick), `[`, `]`, as well as any ascii symbolic characters.
111114
//
112115
// Examples:
113-
// (Note: Comments here are written in markdown syntax, so there is an
114-
// additional layer of backticks to represent a code block)
115-
// `\`address.city\`` represents a field named `address.city`, not the map key
116-
// `city` in the field `address`.
117-
// `\`*\`` represents a field named `*`, not any field.
116+
// `` `address.city` `` represents a field named `address.city`, not the map
117+
// key `city` in the field `address`. `` `*` `` represents a field named `*`,
118+
// not any field.
118119
//
119120
// A special `Field` contains the default indexing settings for all fields.
120121
// This field's resource name is:

google/firestore/admin/v1/firestore_admin.proto

Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,27 @@ service FirestoreAdmin {
217217
};
218218
}
219219

220+
// Bulk deletes a subset of documents from Google Cloud Firestore.
221+
// Documents created or updated after the underlying system starts to process
222+
// the request will not be deleted. The bulk delete occurs in the background
223+
// and its progress can be monitored and managed via the Operation resource
224+
// that is created.
225+
//
226+
// For more details on bulk delete behavior, refer to:
227+
// https://cloud.google.com/firestore/docs/manage-data/bulk-delete
228+
rpc BulkDeleteDocuments(BulkDeleteDocumentsRequest)
229+
returns (google.longrunning.Operation) {
230+
option (google.api.http) = {
231+
post: "/v1/{name=projects/*/databases/*}:bulkDeleteDocuments"
232+
body: "*"
233+
};
234+
option (google.api.method_signature) = "name";
235+
option (google.longrunning.operation_info) = {
236+
response_type: "BulkDeleteDocumentsResponse"
237+
metadata_type: "BulkDeleteDocumentsMetadata"
238+
};
239+
}
240+
220241
// Create a database.
221242
rpc CreateDatabase(CreateDatabaseRequest)
222243
returns (google.longrunning.Operation) {
@@ -302,7 +323,7 @@ service FirestoreAdmin {
302323
//
303324
// The new database must be in the same cloud region or multi-region location
304325
// as the existing backup. This behaves similar to
305-
// [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.CreateDatabase]
326+
// [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase]
306327
// except instead of creating a new empty database, a new database is created
307328
// with the database type, index configuration, and documents from an existing
308329
// backup.
@@ -386,6 +407,9 @@ message ListDatabasesRequest {
386407
child_type: "firestore.googleapis.com/Database"
387408
}
388409
];
410+
411+
// If true, also returns deleted resources.
412+
bool show_deleted = 4;
389413
}
390414

391415
// The request for
@@ -670,7 +694,8 @@ message ListFieldsRequest {
670694
// only supports listing fields that have been explicitly overridden. To issue
671695
// this query, call
672696
// [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
673-
// with a filter that includes `indexConfig.usesAncestorConfig:false` .
697+
// with a filter that includes `indexConfig.usesAncestorConfig:false` or
698+
// `ttlConfig:*`.
674699
string filter = 2;
675700

676701
// The number of results to return.
@@ -705,7 +730,8 @@ message ExportDocumentsRequest {
705730
}
706731
];
707732

708-
// Which collection ids to export. Unspecified means all collections.
733+
// Which collection ids to export. Unspecified means all collections. Each
734+
// collection id in this list must be unique.
709735
repeated string collection_ids = 2;
710736

711737
// The output URI. Currently only supports Google Cloud Storage URIs of the
@@ -749,7 +775,7 @@ message ImportDocumentsRequest {
749775
];
750776

751777
// Which collection ids to import. Unspecified means all collections included
752-
// in the import.
778+
// in the import. Each collection id in this list must be unique.
753779
repeated string collection_ids = 2;
754780

755781
// Location of the exported files.
@@ -768,6 +794,49 @@ message ImportDocumentsRequest {
768794
repeated string namespace_ids = 4;
769795
}
770796

797+
// The request for
798+
// [FirestoreAdmin.BulkDeleteDocuments][google.firestore.admin.v1.FirestoreAdmin.BulkDeleteDocuments].
799+
//
800+
// When both collection_ids and namespace_ids are set, only documents satisfying
801+
// both conditions will be deleted.
802+
//
803+
// Requests with namespace_ids and collection_ids both empty will be rejected.
804+
// Please use
805+
// [FirestoreAdmin.DeleteDatabase][google.firestore.admin.v1.FirestoreAdmin.DeleteDatabase]
806+
// instead.
807+
message BulkDeleteDocumentsRequest {
808+
// Required. Database to operate. Should be of the form:
809+
// `projects/{project_id}/databases/{database_id}`.
810+
string name = 1 [
811+
(google.api.field_behavior) = REQUIRED,
812+
(google.api.resource_reference) = {
813+
type: "firestore.googleapis.com/Database"
814+
}
815+
];
816+
817+
// Optional. IDs of the collection groups to delete. Unspecified means all
818+
// collection groups.
819+
//
820+
// Each collection group in this list must be unique.
821+
repeated string collection_ids = 2 [(google.api.field_behavior) = OPTIONAL];
822+
823+
// Optional. Namespaces to delete.
824+
//
825+
// An empty list means all namespaces. This is the recommended
826+
// usage for databases that don't use namespaces.
827+
//
828+
// An empty string element represents the default namespace. This should be
829+
// used if the database has data in non-default namespaces, but doesn't want
830+
// to delete from them.
831+
//
832+
// Each namespace in this list must be unique.
833+
repeated string namespace_ids = 3 [(google.api.field_behavior) = OPTIONAL];
834+
}
835+
836+
// The response for
837+
// [FirestoreAdmin.BulkDeleteDocuments][google.firestore.admin.v1.FirestoreAdmin.BulkDeleteDocuments].
838+
message BulkDeleteDocumentsResponse {}
839+
771840
// The request for
772841
// [FirestoreAdmin.GetBackup][google.firestore.admin.v1.FirestoreAdmin.GetBackup].
773842
message GetBackupRequest {

google/firestore/admin/v1/firestore_admin_grpc_service_config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
{
5454
"service": "google.firestore.admin.v1.FirestoreAdmin",
5555
"method": "UpdateField"
56+
},
57+
{
58+
"service": "google.firestore.admin.v1.FirestoreAdmin",
59+
"method": "BulkDeleteDocuments"
5660
}
5761
],
5862
"timeout": "60s"

google/firestore/admin/v1/firestore_v1.yaml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ apis:
99
- name: google.longrunning.Operations
1010

1111
types:
12+
- name: google.firestore.admin.v1.BulkDeleteDocumentsMetadata
1213
- name: google.firestore.admin.v1.CreateDatabaseMetadata
1314
- name: google.firestore.admin.v1.DeleteDatabaseMetadata
1415
- name: google.firestore.admin.v1.ExportDocumentsMetadata
@@ -31,17 +32,6 @@ documentation:
3132
- selector: google.cloud.location.Locations.ListLocations
3233
description: Lists information about the supported locations for this service.
3334

34-
backend:
35-
rules:
36-
- selector: google.cloud.location.Locations.GetLocation
37-
deadline: 295.0
38-
- selector: google.cloud.location.Locations.ListLocations
39-
deadline: 295.0
40-
- selector: 'google.firestore.admin.v1.FirestoreAdmin.*'
41-
deadline: 295.0
42-
- selector: 'google.longrunning.Operations.*'
43-
deadline: 295.0
44-
4535
http:
4636
rules:
4737
- selector: google.longrunning.Operations.CancelOperation

google/firestore/admin/v1/index.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ message Index {
126126
// Indicates that this field supports operations on `array_value`s.
127127
ArrayConfig array_config = 3;
128128

129-
// Indicates that this field supports nearest neighbors and distance
129+
// Indicates that this field supports nearest neighbor and distance
130130
// operations on vector.
131131
VectorConfig vector_config = 4;
132132
}

google/firestore/admin/v1/operation.proto

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,39 @@ message ImportDocumentsMetadata {
191191
repeated string namespace_ids = 8;
192192
}
193193

194+
// Metadata for [google.longrunning.Operation][google.longrunning.Operation]
195+
// results from
196+
// [FirestoreAdmin.BulkDeleteDocuments][google.firestore.admin.v1.FirestoreAdmin.BulkDeleteDocuments].
197+
message BulkDeleteDocumentsMetadata {
198+
// The time this operation started.
199+
google.protobuf.Timestamp start_time = 1;
200+
201+
// The time this operation completed. Will be unset if operation still in
202+
// progress.
203+
google.protobuf.Timestamp end_time = 2;
204+
205+
// The state of the operation.
206+
OperationState operation_state = 3;
207+
208+
// The progress, in documents, of this operation.
209+
Progress progress_documents = 4;
210+
211+
// The progress, in bytes, of this operation.
212+
Progress progress_bytes = 5;
213+
214+
// The ids of the collection groups that are being deleted.
215+
repeated string collection_ids = 6;
216+
217+
// Which namespace ids are being deleted.
218+
repeated string namespace_ids = 7;
219+
220+
// The timestamp that corresponds to the version of the database that is being
221+
// read to get the list of documents to delete. This time can also be used as
222+
// the timestamp of PITR in case of disaster recovery (subject to PITR window
223+
// limit).
224+
google.protobuf.Timestamp snapshot_time = 8;
225+
}
226+
194227
// Returned in the [google.longrunning.Operation][google.longrunning.Operation]
195228
// response field.
196229
message ExportDocumentsResponse {

0 commit comments

Comments
 (0)