Skip to content

Commit 204f2ae

Browse files
Google APIscopybara-github
authored andcommitted
feat: add DeleteDatabase API and delete protection
docs: update Database API description PiperOrigin-RevId: 591922567
1 parent f33842a commit 204f2ae

File tree

3 files changed

+85
-6
lines changed

3 files changed

+85
-6
lines changed

google/firestore/admin/v1/database.proto

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1";
3131
option ruby_package = "Google::Cloud::Firestore::Admin::V1";
3232

3333
// A Cloud Firestore Database.
34-
// Currently only one database is allowed per cloud project; this database
35-
// must have a `database_id` of '(default)'.
3634
message Database {
3735
option (google.api.resource) = {
3836
type: "firestore.googleapis.com/Database"
@@ -118,10 +116,36 @@ message Database {
118116
DISABLED = 2;
119117
}
120118

119+
// The delete protection state of the database.
120+
enum DeleteProtectionState {
121+
// The default value. Delete protection type is not specified
122+
DELETE_PROTECTION_STATE_UNSPECIFIED = 0;
123+
124+
// Delete protection is disabled
125+
DELETE_PROTECTION_DISABLED = 1;
126+
127+
// Delete protection is enabled
128+
DELETE_PROTECTION_ENABLED = 2;
129+
}
130+
121131
// The resource name of the Database.
122132
// Format: `projects/{project}/databases/{database}`
123133
string name = 1;
124134

135+
// Output only. The system-generated UUID4 for this Database.
136+
string uid = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
137+
138+
// Output only. The timestamp at which this database was created. Databases
139+
// created before 2016 do not populate create_time.
140+
google.protobuf.Timestamp create_time = 5
141+
[(google.api.field_behavior) = OUTPUT_ONLY];
142+
143+
// Output only. The timestamp at which this database was most recently
144+
// updated. Note this only includes updates to the database resource and not
145+
// data contained by the database.
146+
google.protobuf.Timestamp update_time = 6
147+
[(google.api.field_behavior) = OUTPUT_ONLY];
148+
125149
// The location of the database. Available locations are listed at
126150
// https://cloud.google.com/firestore/docs/locations.
127151
string location_id = 9;
@@ -173,6 +197,9 @@ message Database {
173197
// is the project_id (eg: foo instead of v~foo).
174198
string key_prefix = 20 [(google.api.field_behavior) = OUTPUT_ONLY];
175199

200+
// State of delete protection for the database.
201+
DeleteProtectionState delete_protection_state = 22;
202+
176203
// This checksum is computed by the server based on the value of other
177204
// fields, and may be sent on update and delete requests to ensure the
178205
// client has an up-to-date value before proceeding.

google/firestore/admin/v1/firestore_admin.proto

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ service FirestoreAdmin {
164164
// only supports listing fields that have been explicitly overridden. To issue
165165
// this query, call
166166
// [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
167-
// with the filter set to `indexConfig.usesAncestorConfig:false` .
167+
// with the filter set to `indexConfig.usesAncestorConfig:false or
168+
// `ttlConfig:*`.
168169
rpc ListFields(ListFieldsRequest) returns (ListFieldsResponse) {
169170
option (google.api.http) = {
170171
get: "/v1/{parent=projects/*/databases/*/collectionGroups/*}/fields"
@@ -257,6 +258,19 @@ service FirestoreAdmin {
257258
metadata_type: "UpdateDatabaseMetadata"
258259
};
259260
}
261+
262+
// Deletes a database.
263+
rpc DeleteDatabase(DeleteDatabaseRequest)
264+
returns (google.longrunning.Operation) {
265+
option (google.api.http) = {
266+
delete: "/v1/{name=projects/*/databases/*}"
267+
};
268+
option (google.api.method_signature) = "name";
269+
option (google.longrunning.operation_info) = {
270+
response_type: "Database"
271+
metadata_type: "DeleteDatabaseMetadata"
272+
};
273+
}
260274
}
261275

262276
// A request to list the Firestore Databases in all locations for a project.
@@ -289,7 +303,11 @@ message CreateDatabaseRequest {
289303
// Required. The ID to use for the database, which will become the final
290304
// component of the database's resource name.
291305
//
292-
// The value must be set to "(default)".
306+
// This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
307+
// with first character a letter and the last a letter or a number. Must not
308+
// be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
309+
//
310+
// "(default)" database id is also valid.
293311
string database_id = 3 [(google.api.field_behavior) = REQUIRED];
294312
}
295313

@@ -300,6 +318,17 @@ message CreateDatabaseMetadata {}
300318
message ListDatabasesResponse {
301319
// The databases in the project.
302320
repeated Database databases = 1;
321+
322+
// In the event that data about individual databases cannot be listed they
323+
// will be recorded here.
324+
//
325+
// An example entry might be: projects/some_project/locations/some_location
326+
// This can happen if the Cloud Region that the Database resides in is
327+
// currently unavailable. In this case we can't fetch all the details about
328+
// the database. You may be able to get a more detailed error message
329+
// (or possibly fetch the resource) by sending a 'Get' request for the
330+
// resource or a 'List' request for the specific location.
331+
repeated string unreachable = 3;
303332
}
304333

305334
// The request for
@@ -328,6 +357,27 @@ message UpdateDatabaseRequest {
328357
// Metadata related to the update database operation.
329358
message UpdateDatabaseMetadata {}
330359

360+
// The request for
361+
// [FirestoreAdmin.DeleteDatabase][google.firestore.admin.v1.FirestoreAdmin.DeleteDatabase].
362+
message DeleteDatabaseRequest {
363+
// Required. A name of the form
364+
// `projects/{project_id}/databases/{database_id}`
365+
string name = 1 [
366+
(google.api.field_behavior) = REQUIRED,
367+
(google.api.resource_reference) = {
368+
type: "firestore.googleapis.com/Database"
369+
}
370+
];
371+
372+
// The current etag of the Database.
373+
// If an etag is provided and does not match the current etag of the database,
374+
// deletion will be blocked and a FAILED_PRECONDITION error will be returned.
375+
string etag = 3;
376+
}
377+
378+
// Metadata related to the delete database operation.
379+
message DeleteDatabaseMetadata {}
380+
331381
// The request for
332382
// [FirestoreAdmin.CreateIndex][google.firestore.admin.v1.FirestoreAdmin.CreateIndex].
333383
message CreateIndexRequest {
@@ -488,7 +538,7 @@ message ExportDocumentsRequest {
488538
// generated based on the start time.
489539
string output_uri_prefix = 3;
490540

491-
// Unspecified means all namespaces. This is the preferred
541+
// An empty list represents all namespaces. This is the preferred
492542
// usage for databases that don't use namespaces.
493543
//
494544
// An empty string element represents the default namespace. This should be
@@ -529,7 +579,7 @@ message ImportDocumentsRequest {
529579
// [google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix][google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix].
530580
string input_uri_prefix = 3;
531581

532-
// Unspecified means all namespaces. This is the preferred
582+
// An empty list represents all namespaces. This is the preferred
533583
// usage for databases that don't use namespaces.
534584
//
535585
// An empty string element represents the default namespace. This should be

google/firestore/admin/v1/firestore_v1.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ apis:
99
- name: google.longrunning.Operations
1010

1111
types:
12+
- name: google.firestore.admin.v1.CreateDatabaseMetadata
13+
- name: google.firestore.admin.v1.DeleteDatabaseMetadata
1214
- name: google.firestore.admin.v1.ExportDocumentsMetadata
1315
- name: google.firestore.admin.v1.ExportDocumentsResponse
1416
- name: google.firestore.admin.v1.FieldOperationMetadata

0 commit comments

Comments
 (0)