Publish `Backup` APIs and protos.

PiperOrigin-RevId: 300246038
pull/592/head
Google APIs 5 years ago committed by Copybara-Service
parent eced64c3f1
commit 309b899ca1
  1. 4
      google/spanner/admin/database/v1/BUILD.bazel
  2. 363
      google/spanner/admin/database/v1/backup.proto
  3. 43
      google/spanner/admin/database/v1/common.proto
  4. 32
      google/spanner/admin/database/v1/spanner_admin_database_grpc_service_config.json
  5. 364
      google/spanner/admin/database/v1/spanner_database_admin.proto

@ -12,6 +12,8 @@ load("@com_google_googleapis_imports//:imports.bzl", "proto_library_with_info")
proto_library(
name = "database_proto",
srcs = [
"backup.proto",
"common.proto",
"spanner_database_admin.proto",
],
deps = [
@ -23,6 +25,7 @@ proto_library(
"//google/iam/v1:policy_proto",
"//google/longrunning:operations_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:field_mask_proto",
"@com_google_protobuf//:timestamp_proto",
],
)
@ -174,6 +177,7 @@ moved_proto_library(
"//google/iam/v1:policy_proto",
"//google/longrunning:operations_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:field_mask_proto",
"@com_google_protobuf//:timestamp_proto",
],
)

@ -0,0 +1,363 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.spanner.admin.database.v1;
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";
import "google/spanner/admin/database/v1/common.proto";
import "google/api/annotations.proto";
option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1";
option go_package = "google.golang.org/genproto/googleapis/spanner/admin/database/v1;database";
option java_multiple_files = true;
option java_outer_classname = "BackupProto";
option java_package = "com.google.spanner.admin.database.v1";
option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Database\\V1";
// A backup of a Cloud Spanner database.
message Backup {
option (google.api.resource) = {
type: "spanner.googleapis.com/Backup"
pattern: "projects/{project}/instances/{instance}/backups/{backup}"
};
// Indicates the current state of the backup.
enum State {
// Not specified.
STATE_UNSPECIFIED = 0;
// The pending backup is still being created. Operations on the
// backup may fail with `FAILED_PRECONDITION` in this state.
CREATING = 1;
// The backup is complete and ready for use.
READY = 2;
}
// Required for the [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] operation.
// Name of the database from which this backup was
// created. This needs to be in the same instance as the backup.
// Values are of the form
// `projects/<project>/instances/<instance>/databases/<database>`.
string database = 2;
// Required for the [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]
// operation. The expiration time of the backup, with microseconds
// granularity that must be at least 6 hours and at most 366 days
// from the time the CreateBackup request is processed. Once the `expire_time`
// has passed, the backup is eligible to be automatically deleted by Cloud
// Spanner to free the resources used by the backup.
google.protobuf.Timestamp expire_time = 3;
// Output only for the [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] operation.
// Required for the [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup] operation.
//
// A globally unique identifier for the backup which cannot be
// changed. Values are of the form
// `projects/<project>/instances/<instance>/backups/[a-z][a-z0-9_\-]*[a-z0-9]`
// The final segment of the name must be between 2 and 60 characters
// in length.
//
// The backup is stored in the location(s) specified in the instance
// configuration of the instance containing the backup, identified
// by the prefix of the backup name of the form
// `projects/<project>/instances/<instance>`.
string name = 1;
// Output only. The backup will contain an externally consistent
// copy of the database at the timestamp specified by
// `create_time`. `create_time` is approximately the time the
// [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] request is received.
google.protobuf.Timestamp create_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
// Output only. Size of the backup in bytes.
int64 size_bytes = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
// Output only. The current state of the backup.
State state = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
// Output only. The names of the restored databases that reference the backup.
// The database names are of
// the form `projects/<project>/instances/<instance>/databases/<database>`.
// Referencing databases may exist in different instances. The existence of
// any referencing database prevents the backup from being deleted. When a
// restored database from the backup enters the `READY` state, the reference
// to the backup is removed.
repeated string referencing_databases = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
}
// The request for [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup].
message CreateBackupRequest {
// Required. The name of the instance in which the backup will be
// created. This must be the same instance that contains the database the
// backup will be created from. The backup will be stored in the
// location(s) specified in the instance configuration of this
// instance. Values are of the form
// `projects/<project>/instances/<instance>`.
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "spanner.googleapis.com/Instance"
}
];
// Required. The id of the backup to be created. The `backup_id` appended to
// `parent` forms the full backup name of the form
// `projects/<project>/instances/<instance>/backups/<backup_id>`.
string backup_id = 2 [(google.api.field_behavior) = REQUIRED];
// Required. The backup to create.
Backup backup = 3 [(google.api.field_behavior) = REQUIRED];
}
// Metadata type for the operation returned by
// [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup].
message CreateBackupMetadata {
// The name of the backup being created.
string name = 1;
// The name of the database the backup is created from.
string database = 2;
// The progress of the
// [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] operation.
OperationProgress progress = 3;
// The time at which cancellation of this operation was received.
// [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
// starts asynchronous cancellation on a long-running operation. The server
// makes a best effort to cancel the operation, but success is not guaranteed.
// Clients can use
// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
// other methods to check whether the cancellation succeeded or whether the
// operation completed despite cancellation. On successful cancellation,
// the operation is not deleted; instead, it becomes an operation with
// an [Operation.error][] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1,
// corresponding to `Code.CANCELLED`.
google.protobuf.Timestamp cancel_time = 4;
}
// The request for [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup].
message UpdateBackupRequest {
// Required. The backup to update. `backup.name`, and the fields to be updated
// as specified by `update_mask` are required. Other fields are ignored.
// Update is only supported for the following fields:
// * `backup.expire_time`.
Backup backup = 1 [(google.api.field_behavior) = REQUIRED];
// Required. A mask specifying which fields (e.g. `expire_time`) in the
// Backup resource should be updated. This mask is relative to the Backup
// resource, not to the request message. The field mask must always be
// specified; this prevents any future fields from being erased accidentally
// by clients that do not know about them.
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
}
// The request for [GetBackup][google.spanner.admin.database.v1.DatabaseAdmin.GetBackup].
message GetBackupRequest {
// Required. Name of the backup.
// Values are of the form
// `projects/<project>/instances/<instance>/backups/<backup>`.
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "spanner.googleapis.com/Backup"
}
];
}
// The request for [DeleteBackup][google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackup].
message DeleteBackupRequest {
// Required. Name of the backup to delete.
// Values are of the form
// `projects/<project>/instances/<instance>/backups/<backup>`.
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "spanner.googleapis.com/Backup"
}
];
}
// The request for [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups].
message ListBackupsRequest {
// Required. The instance to list backups from. Values are of the
// form `projects/<project>/instances/<instance>`.
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "spanner.googleapis.com/Instance"
}
];
// An expression that filters the list of returned backups.
//
// A filter expression consists of a field name, a comparison operator, and a
// value for filtering.
// The value must be a string, a number, or a boolean. The comparison operator
// must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
// Colon `:` is the contains operator. Filter rules are not case sensitive.
//
// The following fields in the [Backup][google.spanner.admin.database.v1.Backup] are eligible for filtering:
//
// * `name`
// * `database`
// * `state`
// * `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
// * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
// * `size_bytes`
//
// You can combine multiple expressions by enclosing each expression in
// parentheses. By default, expressions are combined with AND logic, but
// you can specify AND, OR, and NOT logic explicitly.
//
// Here are a few examples:
//
// * `name:Howl` - The backup's name contains the string "howl".
// * `database:prod`
// - The database's name contains the string "prod".
// * `state:CREATING` - The backup is pending creation.
// * `state:READY` - The backup is fully created and ready for use.
// * `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")`
// - The backup name contains the string "howl" and `create_time`
// of the backup is before 2018-03-28T14:50:00Z.
// * `expire_time < \"2018-03-28T14:50:00Z\"`
// - The backup `expire_time` is before 2018-03-28T14:50:00Z.
// * `size_bytes > 10000000000` - The backup's size is greater than 10GB
string filter = 2;
// Number of backups to be returned in the response. If 0 or
// less, defaults to the server's maximum allowed page size.
int32 page_size = 3;
// If non-empty, `page_token` should contain a
// [next_page_token][google.spanner.admin.database.v1.ListBackupsResponse.next_page_token] from a
// previous [ListBackupsResponse][google.spanner.admin.database.v1.ListBackupsResponse] to the same `parent` and with the same
// `filter`.
string page_token = 4;
}
// The response for [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups].
message ListBackupsResponse {
// The list of matching backups. Backups returned are ordered by `create_time`
// in descending order, starting from the most recent `create_time`.
repeated Backup backups = 1;
// `next_page_token` can be sent in a subsequent
// [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups] call to fetch more
// of the matching backups.
string next_page_token = 2;
}
// The request for
// [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations].
message ListBackupOperationsRequest {
// Required. The instance of the backup operations. Values are of
// the form `projects/<project>/instances/<instance>`.
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "spanner.googleapis.com/Instance"
}
];
// An expression that filters the list of returned backup operations.
//
// A filter expression consists of a field name, a
// comparison operator, and a value for filtering.
// The value must be a string, a number, or a boolean. The comparison operator
// must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
// Colon `:` is the contains operator. Filter rules are not case sensitive.
//
// The following fields in the [operation][google.longrunning.Operation]
// are eligible for filtering:
//
// * `name` - The name of the long-running operation
// * `done` - False if the operation is in progress, else true.
// * `metadata.@type` - the type of metadata. For example, the type string
// for [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata] is
// `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`.
// * `metadata.<field_name>` - any field in metadata.value.
// * `error` - Error associated with the long-running operation.
// * `response.@type` - the type of response.
// * `response.<field_name>` - any field in response.value.
//
// You can combine multiple expressions by enclosing each expression in
// parentheses. By default, expressions are combined with AND logic, but
// you can specify AND, OR, and NOT logic explicitly.
//
// Here are a few examples:
//
// * `done:true` - The operation is complete.
// * `metadata.database:prod` - The database the backup was taken from has
// a name containing the string "prod".
// * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` <br/>
// `(metadata.name:howl) AND` <br/>
// `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` <br/>
// `(error:*)` - Returns operations where:
// * The operation's metadata type is [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata].
// * The backup name contains the string "howl".
// * The operation started before 2018-03-28T14:50:00Z.
// * The operation resulted in an error.
string filter = 2;
// Number of operations to be returned in the response. If 0 or
// less, defaults to the server's maximum allowed page size.
int32 page_size = 3;
// If non-empty, `page_token` should contain a
// [next_page_token][google.spanner.admin.database.v1.ListBackupOperationsResponse.next_page_token]
// from a previous [ListBackupOperationsResponse][google.spanner.admin.database.v1.ListBackupOperationsResponse] to the
// same `parent` and with the same `filter`.
string page_token = 4;
}
// The response for
// [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations].
message ListBackupOperationsResponse {
// The list of matching backup [long-running
// operations][google.longrunning.Operation]. Each operation's name will be
// prefixed by the backup's name and the operation's
// [metadata][google.longrunning.Operation.metadata] will be of type
// [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. Operations returned include those that are
// pending or have completed/failed/canceled within the last 7 days.
// Operations returned are ordered by
// `operation.metadata.value.progress.start_time` in descending order starting
// from the most recently started operation.
repeated google.longrunning.Operation operations = 1;
// `next_page_token` can be sent in a subsequent
// [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations]
// call to fetch more of the matching metadata.
string next_page_token = 2;
}
// Information about a backup.
message BackupInfo {
// Name of the backup.
string backup = 1;
// The backup contains an externally consistent copy of `source_database` at
// the timestamp specified by `create_time`.
google.protobuf.Timestamp create_time = 2;
// Name of the database the backup was created from.
string source_database = 3;
}

@ -0,0 +1,43 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.spanner.admin.database.v1;
import "google/api/field_behavior.proto";
import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";
option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1";
option go_package = "google.golang.org/genproto/googleapis/spanner/admin/database/v1;database";
option java_multiple_files = true;
option java_outer_classname = "CommonProto";
option java_package = "com.google.spanner.admin.database.v1";
option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Database\\V1";
// Encapsulates progress related information for a Cloud Spanner long
// running operation.
message OperationProgress {
// Percent completion of the operation.
// Values are between 0 and 100 inclusive.
int32 progress_percent = 1;
// Time the request was received.
google.protobuf.Timestamp start_time = 2;
// If set, the time at which this operation failed or was completed
// successfully.
google.protobuf.Timestamp end_time = 3;
}

@ -25,6 +25,34 @@
{
"service": "google.spanner.admin.database.v1.DatabaseAdmin",
"method": "GetIamPolicy"
},
{
"service": "google.spanner.admin.database.v1.DatabaseAdmin",
"method": "GetBackup"
},
{
"service": "google.spanner.admin.database.v1.DatabaseAdmin",
"method": "UpdateBackup"
},
{
"service": "google.spanner.admin.database.v1.DatabaseAdmin",
"method": "DeleteBackup"
},
{
"service": "google.spanner.admin.database.v1.DatabaseAdmin",
"method": "ListBackups"
},
{
"service": "google.spanner.admin.database.v1.DatabaseAdmin",
"method": "RestoreDatabase"
},
{
"service": "google.spanner.admin.database.v1.DatabaseAdmin",
"method": "ListDatabaseOperations"
},
{
"service": "google.spanner.admin.database.v1.DatabaseAdmin",
"method": "ListBackupOperations"
}
],
"timeout": "3600s",
@ -51,6 +79,10 @@
{
"service": "google.spanner.admin.database.v1.DatabaseAdmin",
"method": "TestIamPermissions"
},
{
"service": "google.spanner.admin.database.v1.DatabaseAdmin",
"method": "CreateBackup"
}
],
"timeout": "3600s"

@ -25,6 +25,8 @@ import "google/iam/v1/policy.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
import "google/spanner/admin/database/v1/backup.proto";
import "google/spanner/admin/database/v1/common.proto";
option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1";
option go_package = "google.golang.org/genproto/googleapis/spanner/admin/database/v1;database";
@ -41,7 +43,8 @@ option (google.api.resource_definition) = {
//
// The Cloud Spanner Database Admin API can be used to create, drop, and
// list databases. It also enables updating the schema of pre-existing
// databases.
// databases. It can be also used to create, delete and list backups for a
// database and to restore from an existing backup.
service DatabaseAdmin {
option (google.api.default_host) = "spanner.googleapis.com";
option (google.api.oauth_scopes) =
@ -104,6 +107,8 @@ service DatabaseAdmin {
}
// Drops (aka deletes) a Cloud Spanner database.
// Completed backups for the database will be retained according to their
// `expire_time`.
rpc DropDatabase(DropDatabaseRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
delete: "/v1/{database=projects/*/instances/*/databases/*}"
@ -121,11 +126,13 @@ service DatabaseAdmin {
option (google.api.method_signature) = "database";
}
// Sets the access control policy on a database resource.
// Sets the access control policy on a database or backup resource.
// Replaces any existing policy.
//
// Authorization requires `spanner.databases.setIamPolicy`
// permission on [resource][google.iam.v1.SetIamPolicyRequest.resource].
// For backups, authorization requires `spanner.backups.setIamPolicy`
// permission on [resource][google.iam.v1.SetIamPolicyRequest.resource].
rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) {
option (google.api.http) = {
post: "/v1/{resource=projects/*/instances/*/databases/*}:setIamPolicy"
@ -138,12 +145,14 @@ service DatabaseAdmin {
option (google.api.method_signature) = "resource,policy";
}
// Gets the access control policy for a database resource.
// Returns an empty policy if a database exists but does
// not have a policy set.
// Gets the access control policy for a database or backup resource.
// Returns an empty policy if a database or backup exists but does not have a
// policy set.
//
// Authorization requires `spanner.databases.getIamPolicy` permission on
// [resource][google.iam.v1.GetIamPolicyRequest.resource].
// For backups, authorization requires `spanner.backups.getIamPolicy`
// permission on [resource][google.iam.v1.GetIamPolicyRequest.resource].
rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) {
option (google.api.http) = {
post: "/v1/{resource=projects/*/instances/*/databases/*}:getIamPolicy"
@ -156,12 +165,16 @@ service DatabaseAdmin {
option (google.api.method_signature) = "resource";
}
// Returns permissions that the caller has on the specified database resource.
// Returns permissions that the caller has on the specified database or backup
// resource.
//
// Attempting this RPC on a non-existent Cloud Spanner database will
// result in a NOT_FOUND error if the user has
// `spanner.databases.list` permission on the containing Cloud
// Spanner instance. Otherwise returns an empty set of permissions.
// Calling this method on a backup that does not exist will
// result in a NOT_FOUND error if the user has
// `spanner.backups.list` permission on the containing instance.
rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) {
option (google.api.http) = {
post: "/v1/{resource=projects/*/instances/*/databases/*}:testIamPermissions"
@ -173,6 +186,139 @@ service DatabaseAdmin {
};
option (google.api.method_signature) = "resource,permissions";
}
// Starts creating a new Cloud Spanner Backup.
// The returned backup [long-running operation][google.longrunning.Operation]
// will have a name of the format
// `projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id>`
// and can be used to track creation of the backup. The
// [metadata][google.longrunning.Operation.metadata] field type is
// [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. The
// [response][google.longrunning.Operation.response] field type is
// [Backup][google.spanner.admin.database.v1.Backup], if successful. Cancelling the returned operation will stop the
// creation and delete the backup.
// There can be only one pending backup creation per database. Backup creation
// of different databases can run concurrently.
rpc CreateBackup(CreateBackupRequest) returns (google.longrunning.Operation) {
option (google.api.http) = {
post: "/v1/{parent=projects/*/instances/*}/backups"
body: "backup"
};
option (google.api.method_signature) = "parent,backup,backup_id";
option (google.longrunning.operation_info) = {
response_type: "Backup"
metadata_type: "google.spanner.admin.database.v1.CreateBackupMetadata"
};
}
// Gets metadata on a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
rpc GetBackup(GetBackupRequest) returns (Backup) {
option (google.api.http) = {
get: "/v1/{name=projects/*/instances/*/backups/*}"
};
option (google.api.method_signature) = "name";
}
// Updates a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
rpc UpdateBackup(UpdateBackupRequest) returns (Backup) {
option (google.api.http) = {
patch: "/v1/{backup.name=projects/*/instances/*/backups/*}"
body: "backup"
};
option (google.api.method_signature) = "backup,update_mask";
}
// Deletes a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
rpc DeleteBackup(DeleteBackupRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
delete: "/v1/{name=projects/*/instances/*/backups/*}"
};
option (google.api.method_signature) = "name";
}
// Lists completed and pending backups.
// Backups returned are ordered by `create_time` in descending order,
// starting from the most recent `create_time`.
rpc ListBackups(ListBackupsRequest) returns (ListBackupsResponse) {
option (google.api.http) = {
get: "/v1/{parent=projects/*/instances/*}/backups"
};
option (google.api.method_signature) = "parent";
}
// Create a new database by restoring from a completed backup. The new
// database must be in the same project and in an instance with the same
// instance configuration as the instance containing
// the backup. The returned database [long-running
// operation][google.longrunning.Operation] has a name of the format
// `projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>`,
// and can be used to track the progress of the operation, and to cancel it.
// The [metadata][google.longrunning.Operation.metadata] field type is
// [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata].
// The [response][google.longrunning.Operation.response] type
// is [Database][google.spanner.admin.database.v1.Database], if
// successful. Cancelling the returned operation will stop the restore and
// delete the database.
// There can be only one database being restored into an instance at a time.
// Once the restore operation completes, a new restore operation can be
// initiated, without waiting for the optimize operation associated with the
// first restore to complete.
rpc RestoreDatabase(RestoreDatabaseRequest) returns (google.longrunning.Operation) {
option (google.api.http) = {
post: "/v1/{parent=projects/*/instances/*}/databases:restore"
body: "*"
};
option (google.api.method_signature) = "parent,database_id,backup";
option (google.longrunning.operation_info) = {
response_type: "google.spanner.admin.database.v1.Database"
metadata_type: "google.spanner.admin.database.v1.RestoreDatabaseMetadata"
};
}
// Lists database [longrunning-operations][google.longrunning.Operation].
// A database operation has a name of the form
// `projects/<project>/instances/<instance>/databases/<database>/operations/<operation>`.
// The long-running operation
// [metadata][google.longrunning.Operation.metadata] field type
// `metadata.type_url` describes the type of the metadata. Operations returned
// include those that have completed/failed/canceled within the last 7 days,
// and pending operations.
rpc ListDatabaseOperations(ListDatabaseOperationsRequest) returns (ListDatabaseOperationsResponse) {
option (google.api.http) = {
get: "/v1/{parent=projects/*/instances/*}/databaseOperations"
};
option (google.api.method_signature) = "parent";
}
// Lists the backup [long-running operations][google.longrunning.Operation] in
// the given instance. A backup operation has a name of the form
// `projects/<project>/instances/<instance>/backups/<backup>/operations/<operation>`.
// The long-running operation
// [metadata][google.longrunning.Operation.metadata] field type
// `metadata.type_url` describes the type of the metadata. Operations returned
// include those that have completed/failed/canceled within the last 7 days,
// and pending operations. Operations returned are ordered by
// `operation.metadata.value.progress.start_time` in descending order starting
// from the most recently started operation.
rpc ListBackupOperations(ListBackupOperationsRequest) returns (ListBackupOperationsResponse) {
option (google.api.http) = {
get: "/v1/{parent=projects/*/instances/*}/backupOperations"
};
option (google.api.method_signature) = "parent";
}
}
// Information about the database restore.
message RestoreInfo {
// The type of the restore source.
RestoreSourceType source_type = 1;
// Information about the source used to restore the database.
oneof source_info {
// Information about the backup used to restore the database. The backup
// may no longer exist.
BackupInfo backup_info = 2;
}
}
// A Cloud Spanner database.
@ -193,6 +339,16 @@ message Database {
// The database is fully created and ready for use.
READY = 2;
// The database is fully created and ready for use, but is still
// being optimized for performance and cannot handle full load.
//
// In this state, the database still references the backup
// it was restore from, preventing the backup
// from being deleted. When optimizations are complete, the full performance
// of the database will be restored, and the database will transition to
// `READY` state.
READY_OPTIMIZING = 3;
}
// Required. The name of the database. Values are of the form
@ -200,10 +356,17 @@ message Database {
// where `<database>` is as specified in the `CREATE DATABASE`
// statement. This name can be passed to other API methods to
// identify the database.
string name = 1;
string name = 1 [(google.api.field_behavior) = REQUIRED];
// Output only. The current database state.
State state = 2;
State state = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
// Output only. If exists, the time at which the database creation started.
google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
// Output only. Applicable only for restored databases. Contains information
// about the restore source.
RestoreInfo restore_info = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
}
// The request for [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases].
@ -256,11 +419,11 @@ message CreateDatabaseRequest {
// database ID must be enclosed in backticks (`` ` ``).
string create_statement = 2 [(google.api.field_behavior) = REQUIRED];
// An optional list of DDL statements to run inside the newly created
// Optional. A list of DDL statements to run inside the newly created
// database. Statements can create tables, indexes, etc. These
// statements execute atomically with the creation of the database:
// if there is an error in any statement, the database is not created.
repeated string extra_statements = 3;
repeated string extra_statements = 3 [(google.api.field_behavior) = OPTIONAL];
}
// Metadata type for the operation returned by
@ -380,3 +543,184 @@ message GetDatabaseDdlResponse {
// specified in the request.
repeated string statements = 1;
}
// The request for
// [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations].
message ListDatabaseOperationsRequest {
// Required. The instance of the database operations.
// Values are of the form `projects/<project>/instances/<instance>`.
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "spanner.googleapis.com/Instance"
}
];
// An expression that filters the list of returned operations.
//
// A filter expression consists of a field name, a
// comparison operator, and a value for filtering.
// The value must be a string, a number, or a boolean. The comparison operator
// must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
// Colon `:` is the contains operator. Filter rules are not case sensitive.
//
// The following fields in the [Operation][google.longrunning.Operation]
// are eligible for filtering:
//
// * `name` - The name of the long-running operation
// * `done` - False if the operation is in progress, else true.
// * `metadata.@type` - the type of metadata. For example, the type string
// for [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata] is
// `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`.
// * `metadata.<field_name>` - any field in metadata.value.
// * `error` - Error associated with the long-running operation.
// * `response.@type` - the type of response.
// * `response.<field_name>` - any field in response.value.
//
// You can combine multiple expressions by enclosing each expression in
// parentheses. By default, expressions are combined with AND logic. However,
// you can specify AND, OR, and NOT logic explicitly.
//
// Here are a few examples:
//
// * `done:true` - The operation is complete.
// * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` <br/>
// `(metadata.source_type:BACKUP) AND` <br/>
// `(metadata.backup_info.backup:backup_howl) AND` <br/>
// `(metadata.name:restored_howl) AND` <br/>
// `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` <br/>
// `(error:*)` - Return operations where:
// * The operation's metadata type is [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata].
// * The database is restored from a backup.
// * The backup name contains "backup_howl".
// * The restored database's name contains "restored_howl".
// * The operation started before 2018-03-28T14:50:00Z.
// * The operation resulted in an error.
string filter = 2;
// Number of operations to be returned in the response. If 0 or
// less, defaults to the server's maximum allowed page size.
int32 page_size = 3;
// If non-empty, `page_token` should contain a
// [next_page_token][google.spanner.admin.database.v1.ListDatabaseOperationsResponse.next_page_token]
// from a previous [ListDatabaseOperationsResponse][google.spanner.admin.database.v1.ListDatabaseOperationsResponse] to the
// same `parent` and with the same `filter`.
string page_token = 4;
}
// The response for
// [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations].
message ListDatabaseOperationsResponse {
// The list of matching database [long-running
// operations][google.longrunning.Operation]. Each operation's name will be
// prefixed by the database's name. The operation's
// [metadata][google.longrunning.Operation.metadata] field type
// `metadata.type_url` describes the type of the metadata.
repeated google.longrunning.Operation operations = 1;
// `next_page_token` can be sent in a subsequent
// [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations]
// call to fetch more of the matching metadata.
string next_page_token = 2;
}
// The request for
// [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase].
message RestoreDatabaseRequest {
// Required. The name of the instance in which to create the
// restored database. This instance must be in the same project and
// have the same instance configuration as the instance containing
// the source backup. Values are of the form
// `projects/<project>/instances/<instance>`.
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "spanner.googleapis.com/Instance"
}
];
// Required. The id of the database to create and restore to. This
// database must not already exist. The `database_id` appended to
// `parent` forms the full database name of the form
// `projects/<project>/instances/<instance>/databases/<database_id>`.
string database_id = 2 [(google.api.field_behavior) = REQUIRED];
// Required. The source from which to restore.
oneof source {
// Name of the backup from which to restore. Values are of the form
// `projects/<project>/instances/<instance>/backups/<backup>`.
string backup = 3 [(google.api.resource_reference) = {
type: "spanner.googleapis.com/Backup"
}];
}
}
// Metadata type for the long-running operation returned by
// [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase].
message RestoreDatabaseMetadata {
// Name of the database being created and restored to.
string name = 1;
// The type of the restore source.
RestoreSourceType source_type = 2;
// Information about the source used to restore the database, as specified by
// `source` in [RestoreDatabaseRequest][google.spanner.admin.database.v1.RestoreDatabaseRequest].
oneof source_info {
// Information about the backup used to restore the database.
BackupInfo backup_info = 3;
}
// The progress of the
// [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase]
// operation.
OperationProgress progress = 4;
// The time at which cancellation of this operation was received.
// [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
// starts asynchronous cancellation on a long-running operation. The server
// makes a best effort to cancel the operation, but success is not guaranteed.
// Clients can use
// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
// other methods to check whether the cancellation succeeded or whether the
// operation completed despite cancellation. On successful cancellation,
// the operation is not deleted; instead, it becomes an operation with
// an [Operation.error][google.longrunning.Operation.error] value with a
// [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`.
google.protobuf.Timestamp cancel_time = 5;
// If exists, the name of the long-running operation that will be used to
// track the post-restore optimization process to optimize the performance of
// the restored database, and remove the dependency on the restore source.
// The name is of the form
// `projects/<project>/instances/<instance>/databases/<database>/operations/<operation>`
// where the <database> is the name of database being created and restored to.
// The metadata type of the long-running operation is
// [OptimizeRestoredDatabaseMetadata][google.spanner.admin.database.v1.OptimizeRestoredDatabaseMetadata]. This long-running operation will be
// automatically created by the system after the RestoreDatabase long-running
// operation completes successfully. This operation will not be created if the
// restore was not successful.
string optimize_database_operation_name = 6;
}
// Metadata type for the long-running operation used to track the progress
// of optimizations performed on a newly restored database. This long-running
// operation is automatically created by the system after the successful
// completion of a database restore, and cannot be cancelled.
message OptimizeRestoredDatabaseMetadata {
// Name of the restored database being optimized.
string name = 1;
// The progress of the post-restore optimizations.
OperationProgress progress = 2;
}
// Indicates the type of the restore source.
enum RestoreSourceType {
// No restore associated.
TYPE_UNSPECIFIED = 0;
// A backup was used as the source of the restore.
BACKUP = 1;
}

Loading…
Cancel
Save