Skip to content

Commit

Permalink
feat: Add support for UpdateDatabase in Cloud Spanner (#1848)
Browse files Browse the repository at this point in the history
* feat: Add support for UpdateDatabase in Cloud Spanner

PiperOrigin-RevId: 531423380

Source-Link: googleapis/googleapis@3e054d1

Source-Link: googleapis/googleapis-gen@e347738
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTM0NzczODQ4Mzc0M2U4ZTg2NmNhYzcyMmRiMGU5NDI1MzU2ZmM4MCJ9

* 🦉 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>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] committed May 12, 2023
1 parent fe677af commit dd9d505
Show file tree
Hide file tree
Showing 7 changed files with 1,382 additions and 1 deletion.
@@ -1,4 +1,4 @@
// Copyright 2022 Google LLC
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -24,6 +24,7 @@ import "google/iam/v1/iam_policy.proto";
import "google/iam/v1/policy.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";
import "google/spanner/admin/database/v1/backup.proto";
import "google/spanner/admin/database/v1/common.proto";
Expand Down Expand Up @@ -89,6 +90,55 @@ service DatabaseAdmin {
option (google.api.method_signature) = "name";
}

// Updates a Cloud Spanner database. The returned
// [long-running operation][google.longrunning.Operation] can be used to track
// the progress of updating the database. If the named database does not
// exist, returns `NOT_FOUND`.
//
// While the operation is pending:
//
// * The database's
// [reconciling][google.spanner.admin.database.v1.Database.reconciling]
// field is set to true.
// * Cancelling the operation is best-effort. If the cancellation succeeds,
// the operation metadata's
// [cancel_time][google.spanner.admin.database.v1.UpdateDatabaseMetadata.cancel_time]
// is set, the updates are reverted, and the operation terminates with a
// `CANCELLED` status.
// * New UpdateDatabase requests will return a `FAILED_PRECONDITION` error
// until the pending operation is done (returns successfully or with
// error).
// * Reading the database via the API continues to give the pre-request
// values.
//
// Upon completion of the returned operation:
//
// * The new values are in effect and readable via the API.
// * The database's
// [reconciling][google.spanner.admin.database.v1.Database.reconciling]
// field becomes false.
//
// The returned [long-running operation][google.longrunning.Operation] will
// have a name of the format
// `projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>`
// and can be used to track the database modification. The
// [metadata][google.longrunning.Operation.metadata] field type is
// [UpdateDatabaseMetadata][google.spanner.admin.database.v1.UpdateDatabaseMetadata].
// The [response][google.longrunning.Operation.response] field type is
// [Database][google.spanner.admin.database.v1.Database], if successful.
rpc UpdateDatabase(UpdateDatabaseRequest)
returns (google.longrunning.Operation) {
option (google.api.http) = {
patch: "/v1/{database.name=projects/*/instances/*/databases/*}"
body: "database"
};
option (google.api.method_signature) = "database,update_mask";
option (google.longrunning.operation_info) = {
response_type: "Database"
metadata_type: "UpdateDatabaseMetadata"
};
}

// Updates the schema of a Cloud Spanner database by
// creating/altering/dropping tables, columns, indexes, etc. The returned
// [long-running operation][google.longrunning.Operation] will have a name of
Expand Down Expand Up @@ -449,6 +499,14 @@ message Database {

// Output only. The dialect of the Cloud Spanner Database.
DatabaseDialect database_dialect = 10 [(google.api.field_behavior) = OUTPUT_ONLY];

// Whether drop protection is enabled for this database. Defaults to false,
// if not set.
bool enable_drop_protection = 11;

// Output only. If true, the database is being updated. If false, there are no
// ongoing update operations for the database.
bool reconciling = 12 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// The request for [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases].
Expand Down Expand Up @@ -537,6 +595,37 @@ message GetDatabaseRequest {
];
}

// The request for
// [UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase].
message UpdateDatabaseRequest {
// Required. The database to update.
// The `name` field of the database is of the form
// `projects/<project>/instances/<instance>/databases/<database>`.
Database database = 1 [(google.api.field_behavior) = REQUIRED];

// Required. The list of fields to update. Currently, only
// `enable_drop_protection` field can be updated.
google.protobuf.FieldMask update_mask = 2
[(google.api.field_behavior) = REQUIRED];
}

// Metadata type for the operation returned by
// [UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase].
message UpdateDatabaseMetadata {
// The request for
// [UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase].
UpdateDatabaseRequest request = 1;

// The progress of the
// [UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase]
// operation.
OperationProgress progress = 2;

// The time at which this operation was cancelled. If set, this operation is
// in the process of undoing itself (which is best-effort).
google.protobuf.Timestamp cancel_time = 3;
}

// Enqueues the given DDL statements to be applied, in order but not
// necessarily all at once, to the database schema at some point (or
// points) in the future. The server checks that the statements
Expand Down

0 comments on commit dd9d505

Please sign in to comment.