1- // Copyright 2022 Google LLC
1+ // Copyright 2023 Google LLC
22//
33// Licensed under the Apache License, Version 2.0 (the "License");
44// you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ import "google/iam/v1/iam_policy.proto";
2424import "google/iam/v1/policy.proto" ;
2525import "google/longrunning/operations.proto" ;
2626import "google/protobuf/empty.proto" ;
27+ import "google/protobuf/field_mask.proto" ;
2728import "google/protobuf/timestamp.proto" ;
2829import "google/spanner/admin/database/v1/backup.proto" ;
2930import "google/spanner/admin/database/v1/common.proto" ;
@@ -89,6 +90,55 @@ service DatabaseAdmin {
8990 option (google.api.method_signature ) = "name" ;
9091 }
9192
93+ // Updates a Cloud Spanner database. The returned
94+ // [long-running operation][google.longrunning.Operation] can be used to track
95+ // the progress of updating the database. If the named database does not
96+ // exist, returns `NOT_FOUND`.
97+ //
98+ // While the operation is pending:
99+ //
100+ // * The database's
101+ // [reconciling][google.spanner.admin.database.v1.Database.reconciling]
102+ // field is set to true.
103+ // * Cancelling the operation is best-effort. If the cancellation succeeds,
104+ // the operation metadata's
105+ // [cancel_time][google.spanner.admin.database.v1.UpdateDatabaseMetadata.cancel_time]
106+ // is set, the updates are reverted, and the operation terminates with a
107+ // `CANCELLED` status.
108+ // * New UpdateDatabase requests will return a `FAILED_PRECONDITION` error
109+ // until the pending operation is done (returns successfully or with
110+ // error).
111+ // * Reading the database via the API continues to give the pre-request
112+ // values.
113+ //
114+ // Upon completion of the returned operation:
115+ //
116+ // * The new values are in effect and readable via the API.
117+ // * The database's
118+ // [reconciling][google.spanner.admin.database.v1.Database.reconciling]
119+ // field becomes false.
120+ //
121+ // The returned [long-running operation][google.longrunning.Operation] will
122+ // have a name of the format
123+ // `projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>`
124+ // and can be used to track the database modification. The
125+ // [metadata][google.longrunning.Operation.metadata] field type is
126+ // [UpdateDatabaseMetadata][google.spanner.admin.database.v1.UpdateDatabaseMetadata].
127+ // The [response][google.longrunning.Operation.response] field type is
128+ // [Database][google.spanner.admin.database.v1.Database], if successful.
129+ rpc UpdateDatabase (UpdateDatabaseRequest )
130+ returns (google .longrunning .Operation ) {
131+ option (google.api.http ) = {
132+ patch : "/v1/{database.name=projects/*/instances/*/databases/*}"
133+ body : "database"
134+ };
135+ option (google.api.method_signature ) = "database,update_mask" ;
136+ option (google.longrunning.operation_info ) = {
137+ response_type : "Database"
138+ metadata_type : "UpdateDatabaseMetadata"
139+ };
140+ }
141+
92142 // Updates the schema of a Cloud Spanner database by
93143 // creating/altering/dropping tables, columns, indexes, etc. The returned
94144 // [long-running operation][google.longrunning.Operation] will have a name of
@@ -449,6 +499,14 @@ message Database {
449499
450500 // Output only. The dialect of the Cloud Spanner Database.
451501 DatabaseDialect database_dialect = 10 [(google.api.field_behavior ) = OUTPUT_ONLY ];
502+
503+ // Whether drop protection is enabled for this database. Defaults to false,
504+ // if not set.
505+ bool enable_drop_protection = 11 ;
506+
507+ // Output only. If true, the database is being updated. If false, there are no
508+ // ongoing update operations for the database.
509+ bool reconciling = 12 [(google.api.field_behavior ) = OUTPUT_ONLY ];
452510}
453511
454512// The request for [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases].
@@ -537,6 +595,37 @@ message GetDatabaseRequest {
537595 ];
538596}
539597
598+ // The request for
599+ // [UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase].
600+ message UpdateDatabaseRequest {
601+ // Required. The database to update.
602+ // The `name` field of the database is of the form
603+ // `projects/<project>/instances/<instance>/databases/<database>`.
604+ Database database = 1 [(google.api.field_behavior ) = REQUIRED ];
605+
606+ // Required. The list of fields to update. Currently, only
607+ // `enable_drop_protection` field can be updated.
608+ google.protobuf.FieldMask update_mask = 2
609+ [(google.api.field_behavior ) = REQUIRED ];
610+ }
611+
612+ // Metadata type for the operation returned by
613+ // [UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase].
614+ message UpdateDatabaseMetadata {
615+ // The request for
616+ // [UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase].
617+ UpdateDatabaseRequest request = 1 ;
618+
619+ // The progress of the
620+ // [UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase]
621+ // operation.
622+ OperationProgress progress = 2 ;
623+
624+ // The time at which this operation was cancelled. If set, this operation is
625+ // in the process of undoing itself (which is best-effort).
626+ google.protobuf.Timestamp cancel_time = 3 ;
627+ }
628+
540629// Enqueues the given DDL statements to be applied, in order but not
541630// necessarily all at once, to the database schema at some point (or
542631// points) in the future. The server checks that the statements
0 commit comments