spanner_database_admin.proto 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930
  1. // Copyright 2022 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.spanner.admin.database.v1;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/api/resource.proto";
  20. import "google/iam/v1/iam_policy.proto";
  21. import "google/iam/v1/policy.proto";
  22. import "google/longrunning/operations.proto";
  23. import "google/protobuf/empty.proto";
  24. import "google/protobuf/timestamp.proto";
  25. import "google/spanner/admin/database/v1/backup.proto";
  26. import "google/spanner/admin/database/v1/common.proto";
  27. option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1";
  28. option go_package = "google.golang.org/genproto/googleapis/spanner/admin/database/v1;database";
  29. option java_multiple_files = true;
  30. option java_outer_classname = "SpannerDatabaseAdminProto";
  31. option java_package = "com.google.spanner.admin.database.v1";
  32. option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Database\\V1";
  33. option ruby_package = "Google::Cloud::Spanner::Admin::Database::V1";
  34. option (google.api.resource_definition) = {
  35. type: "spanner.googleapis.com/Instance"
  36. pattern: "projects/{project}/instances/{instance}"
  37. };
  38. // Cloud Spanner Database Admin API
  39. //
  40. // The Cloud Spanner Database Admin API can be used to:
  41. // * create, drop, and list databases
  42. // * update the schema of pre-existing databases
  43. // * create, delete and list backups for a database
  44. // * restore a database from an existing backup
  45. service DatabaseAdmin {
  46. option (google.api.default_host) = "spanner.googleapis.com";
  47. option (google.api.oauth_scopes) =
  48. "https://www.googleapis.com/auth/cloud-platform,"
  49. "https://www.googleapis.com/auth/spanner.admin";
  50. // Lists Cloud Spanner databases.
  51. rpc ListDatabases(ListDatabasesRequest) returns (ListDatabasesResponse) {
  52. option (google.api.http) = {
  53. get: "/v1/{parent=projects/*/instances/*}/databases"
  54. };
  55. option (google.api.method_signature) = "parent";
  56. }
  57. // Creates a new Cloud Spanner database and starts to prepare it for serving.
  58. // The returned [long-running operation][google.longrunning.Operation] will
  59. // have a name of the format `<database_name>/operations/<operation_id>` and
  60. // can be used to track preparation of the database. The
  61. // [metadata][google.longrunning.Operation.metadata] field type is
  62. // [CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata]. The
  63. // [response][google.longrunning.Operation.response] field type is
  64. // [Database][google.spanner.admin.database.v1.Database], if successful.
  65. rpc CreateDatabase(CreateDatabaseRequest) returns (google.longrunning.Operation) {
  66. option (google.api.http) = {
  67. post: "/v1/{parent=projects/*/instances/*}/databases"
  68. body: "*"
  69. };
  70. option (google.api.method_signature) = "parent,create_statement";
  71. option (google.longrunning.operation_info) = {
  72. response_type: "google.spanner.admin.database.v1.Database"
  73. metadata_type: "google.spanner.admin.database.v1.CreateDatabaseMetadata"
  74. };
  75. }
  76. // Gets the state of a Cloud Spanner database.
  77. rpc GetDatabase(GetDatabaseRequest) returns (Database) {
  78. option (google.api.http) = {
  79. get: "/v1/{name=projects/*/instances/*/databases/*}"
  80. };
  81. option (google.api.method_signature) = "name";
  82. }
  83. // Updates the schema of a Cloud Spanner database by
  84. // creating/altering/dropping tables, columns, indexes, etc. The returned
  85. // [long-running operation][google.longrunning.Operation] will have a name of
  86. // the format `<database_name>/operations/<operation_id>` and can be used to
  87. // track execution of the schema change(s). The
  88. // [metadata][google.longrunning.Operation.metadata] field type is
  89. // [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. The operation has no response.
  90. rpc UpdateDatabaseDdl(UpdateDatabaseDdlRequest) returns (google.longrunning.Operation) {
  91. option (google.api.http) = {
  92. patch: "/v1/{database=projects/*/instances/*/databases/*}/ddl"
  93. body: "*"
  94. };
  95. option (google.api.method_signature) = "database,statements";
  96. option (google.longrunning.operation_info) = {
  97. response_type: "google.protobuf.Empty"
  98. metadata_type: "google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata"
  99. };
  100. }
  101. // Drops (aka deletes) a Cloud Spanner database.
  102. // Completed backups for the database will be retained according to their
  103. // `expire_time`.
  104. // Note: Cloud Spanner might continue to accept requests for a few seconds
  105. // after the database has been deleted.
  106. rpc DropDatabase(DropDatabaseRequest) returns (google.protobuf.Empty) {
  107. option (google.api.http) = {
  108. delete: "/v1/{database=projects/*/instances/*/databases/*}"
  109. };
  110. option (google.api.method_signature) = "database";
  111. }
  112. // Returns the schema of a Cloud Spanner database as a list of formatted
  113. // DDL statements. This method does not show pending schema updates, those may
  114. // be queried using the [Operations][google.longrunning.Operations] API.
  115. rpc GetDatabaseDdl(GetDatabaseDdlRequest) returns (GetDatabaseDdlResponse) {
  116. option (google.api.http) = {
  117. get: "/v1/{database=projects/*/instances/*/databases/*}/ddl"
  118. };
  119. option (google.api.method_signature) = "database";
  120. }
  121. // Sets the access control policy on a database or backup resource.
  122. // Replaces any existing policy.
  123. //
  124. // Authorization requires `spanner.databases.setIamPolicy`
  125. // permission on [resource][google.iam.v1.SetIamPolicyRequest.resource].
  126. // For backups, authorization requires `spanner.backups.setIamPolicy`
  127. // permission on [resource][google.iam.v1.SetIamPolicyRequest.resource].
  128. rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) {
  129. option (google.api.http) = {
  130. post: "/v1/{resource=projects/*/instances/*/databases/*}:setIamPolicy"
  131. body: "*"
  132. additional_bindings {
  133. post: "/v1/{resource=projects/*/instances/*/backups/*}:setIamPolicy"
  134. body: "*"
  135. }
  136. };
  137. option (google.api.method_signature) = "resource,policy";
  138. }
  139. // Gets the access control policy for a database or backup resource.
  140. // Returns an empty policy if a database or backup exists but does not have a
  141. // policy set.
  142. //
  143. // Authorization requires `spanner.databases.getIamPolicy` permission on
  144. // [resource][google.iam.v1.GetIamPolicyRequest.resource].
  145. // For backups, authorization requires `spanner.backups.getIamPolicy`
  146. // permission on [resource][google.iam.v1.GetIamPolicyRequest.resource].
  147. rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) {
  148. option (google.api.http) = {
  149. post: "/v1/{resource=projects/*/instances/*/databases/*}:getIamPolicy"
  150. body: "*"
  151. additional_bindings {
  152. post: "/v1/{resource=projects/*/instances/*/backups/*}:getIamPolicy"
  153. body: "*"
  154. }
  155. };
  156. option (google.api.method_signature) = "resource";
  157. }
  158. // Returns permissions that the caller has on the specified database or backup
  159. // resource.
  160. //
  161. // Attempting this RPC on a non-existent Cloud Spanner database will
  162. // result in a NOT_FOUND error if the user has
  163. // `spanner.databases.list` permission on the containing Cloud
  164. // Spanner instance. Otherwise returns an empty set of permissions.
  165. // Calling this method on a backup that does not exist will
  166. // result in a NOT_FOUND error if the user has
  167. // `spanner.backups.list` permission on the containing instance.
  168. rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) {
  169. option (google.api.http) = {
  170. post: "/v1/{resource=projects/*/instances/*/databases/*}:testIamPermissions"
  171. body: "*"
  172. additional_bindings {
  173. post: "/v1/{resource=projects/*/instances/*/backups/*}:testIamPermissions"
  174. body: "*"
  175. }
  176. additional_bindings {
  177. post: "/v1/{resource=projects/*/instances/*/databases/*/databaseRoles/*}:testIamPermissions"
  178. body: "*"
  179. }
  180. };
  181. option (google.api.method_signature) = "resource,permissions";
  182. }
  183. // Starts creating a new Cloud Spanner Backup.
  184. // The returned backup [long-running operation][google.longrunning.Operation]
  185. // will have a name of the format
  186. // `projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id>`
  187. // and can be used to track creation of the backup. The
  188. // [metadata][google.longrunning.Operation.metadata] field type is
  189. // [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. The
  190. // [response][google.longrunning.Operation.response] field type is
  191. // [Backup][google.spanner.admin.database.v1.Backup], if successful. Cancelling the returned operation will stop the
  192. // creation and delete the backup.
  193. // There can be only one pending backup creation per database. Backup creation
  194. // of different databases can run concurrently.
  195. rpc CreateBackup(CreateBackupRequest) returns (google.longrunning.Operation) {
  196. option (google.api.http) = {
  197. post: "/v1/{parent=projects/*/instances/*}/backups"
  198. body: "backup"
  199. };
  200. option (google.api.method_signature) = "parent,backup,backup_id";
  201. option (google.longrunning.operation_info) = {
  202. response_type: "google.spanner.admin.database.v1.Backup"
  203. metadata_type: "google.spanner.admin.database.v1.CreateBackupMetadata"
  204. };
  205. }
  206. // Starts copying a Cloud Spanner Backup.
  207. // The returned backup [long-running operation][google.longrunning.Operation]
  208. // will have a name of the format
  209. // `projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id>`
  210. // and can be used to track copying of the backup. The operation is associated
  211. // with the destination backup.
  212. // The [metadata][google.longrunning.Operation.metadata] field type is
  213. // [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata].
  214. // The [response][google.longrunning.Operation.response] field type is
  215. // [Backup][google.spanner.admin.database.v1.Backup], if successful. Cancelling the returned operation will stop the
  216. // copying and delete the backup.
  217. // Concurrent CopyBackup requests can run on the same source backup.
  218. rpc CopyBackup(CopyBackupRequest) returns (google.longrunning.Operation) {
  219. option (google.api.http) = {
  220. post: "/v1/{parent=projects/*/instances/*}/backups:copy"
  221. body: "*"
  222. };
  223. option (google.api.method_signature) = "parent,backup_id,source_backup,expire_time";
  224. option (google.longrunning.operation_info) = {
  225. response_type: "google.spanner.admin.database.v1.Backup"
  226. metadata_type: "google.spanner.admin.database.v1.CopyBackupMetadata"
  227. };
  228. }
  229. // Gets metadata on a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
  230. rpc GetBackup(GetBackupRequest) returns (Backup) {
  231. option (google.api.http) = {
  232. get: "/v1/{name=projects/*/instances/*/backups/*}"
  233. };
  234. option (google.api.method_signature) = "name";
  235. }
  236. // Updates a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
  237. rpc UpdateBackup(UpdateBackupRequest) returns (Backup) {
  238. option (google.api.http) = {
  239. patch: "/v1/{backup.name=projects/*/instances/*/backups/*}"
  240. body: "backup"
  241. };
  242. option (google.api.method_signature) = "backup,update_mask";
  243. }
  244. // Deletes a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
  245. rpc DeleteBackup(DeleteBackupRequest) returns (google.protobuf.Empty) {
  246. option (google.api.http) = {
  247. delete: "/v1/{name=projects/*/instances/*/backups/*}"
  248. };
  249. option (google.api.method_signature) = "name";
  250. }
  251. // Lists completed and pending backups.
  252. // Backups returned are ordered by `create_time` in descending order,
  253. // starting from the most recent `create_time`.
  254. rpc ListBackups(ListBackupsRequest) returns (ListBackupsResponse) {
  255. option (google.api.http) = {
  256. get: "/v1/{parent=projects/*/instances/*}/backups"
  257. };
  258. option (google.api.method_signature) = "parent";
  259. }
  260. // Create a new database by restoring from a completed backup. The new
  261. // database must be in the same project and in an instance with the same
  262. // instance configuration as the instance containing
  263. // the backup. The returned database [long-running
  264. // operation][google.longrunning.Operation] has a name of the format
  265. // `projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>`,
  266. // and can be used to track the progress of the operation, and to cancel it.
  267. // The [metadata][google.longrunning.Operation.metadata] field type is
  268. // [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata].
  269. // The [response][google.longrunning.Operation.response] type
  270. // is [Database][google.spanner.admin.database.v1.Database], if
  271. // successful. Cancelling the returned operation will stop the restore and
  272. // delete the database.
  273. // There can be only one database being restored into an instance at a time.
  274. // Once the restore operation completes, a new restore operation can be
  275. // initiated, without waiting for the optimize operation associated with the
  276. // first restore to complete.
  277. rpc RestoreDatabase(RestoreDatabaseRequest) returns (google.longrunning.Operation) {
  278. option (google.api.http) = {
  279. post: "/v1/{parent=projects/*/instances/*}/databases:restore"
  280. body: "*"
  281. };
  282. option (google.api.method_signature) = "parent,database_id,backup";
  283. option (google.longrunning.operation_info) = {
  284. response_type: "google.spanner.admin.database.v1.Database"
  285. metadata_type: "google.spanner.admin.database.v1.RestoreDatabaseMetadata"
  286. };
  287. }
  288. // Lists database [longrunning-operations][google.longrunning.Operation].
  289. // A database operation has a name of the form
  290. // `projects/<project>/instances/<instance>/databases/<database>/operations/<operation>`.
  291. // The long-running operation
  292. // [metadata][google.longrunning.Operation.metadata] field type
  293. // `metadata.type_url` describes the type of the metadata. Operations returned
  294. // include those that have completed/failed/canceled within the last 7 days,
  295. // and pending operations.
  296. rpc ListDatabaseOperations(ListDatabaseOperationsRequest) returns (ListDatabaseOperationsResponse) {
  297. option (google.api.http) = {
  298. get: "/v1/{parent=projects/*/instances/*}/databaseOperations"
  299. };
  300. option (google.api.method_signature) = "parent";
  301. }
  302. // Lists the backup [long-running operations][google.longrunning.Operation] in
  303. // the given instance. A backup operation has a name of the form
  304. // `projects/<project>/instances/<instance>/backups/<backup>/operations/<operation>`.
  305. // The long-running operation
  306. // [metadata][google.longrunning.Operation.metadata] field type
  307. // `metadata.type_url` describes the type of the metadata. Operations returned
  308. // include those that have completed/failed/canceled within the last 7 days,
  309. // and pending operations. Operations returned are ordered by
  310. // `operation.metadata.value.progress.start_time` in descending order starting
  311. // from the most recently started operation.
  312. rpc ListBackupOperations(ListBackupOperationsRequest) returns (ListBackupOperationsResponse) {
  313. option (google.api.http) = {
  314. get: "/v1/{parent=projects/*/instances/*}/backupOperations"
  315. };
  316. option (google.api.method_signature) = "parent";
  317. }
  318. // Lists Cloud Spanner database roles.
  319. rpc ListDatabaseRoles(ListDatabaseRolesRequest) returns (ListDatabaseRolesResponse) {
  320. option (google.api.http) = {
  321. get: "/v1/{parent=projects/*/instances/*/databases/*}/databaseRoles"
  322. };
  323. option (google.api.method_signature) = "parent";
  324. }
  325. }
  326. // Information about the database restore.
  327. message RestoreInfo {
  328. // The type of the restore source.
  329. RestoreSourceType source_type = 1;
  330. // Information about the source used to restore the database.
  331. oneof source_info {
  332. // Information about the backup used to restore the database. The backup
  333. // may no longer exist.
  334. BackupInfo backup_info = 2;
  335. }
  336. }
  337. // A Cloud Spanner database.
  338. message Database {
  339. option (google.api.resource) = {
  340. type: "spanner.googleapis.com/Database"
  341. pattern: "projects/{project}/instances/{instance}/databases/{database}"
  342. };
  343. // Indicates the current state of the database.
  344. enum State {
  345. // Not specified.
  346. STATE_UNSPECIFIED = 0;
  347. // The database is still being created. Operations on the database may fail
  348. // with `FAILED_PRECONDITION` in this state.
  349. CREATING = 1;
  350. // The database is fully created and ready for use.
  351. READY = 2;
  352. // The database is fully created and ready for use, but is still
  353. // being optimized for performance and cannot handle full load.
  354. //
  355. // In this state, the database still references the backup
  356. // it was restore from, preventing the backup
  357. // from being deleted. When optimizations are complete, the full performance
  358. // of the database will be restored, and the database will transition to
  359. // `READY` state.
  360. READY_OPTIMIZING = 3;
  361. }
  362. // Required. The name of the database. Values are of the form
  363. // `projects/<project>/instances/<instance>/databases/<database>`,
  364. // where `<database>` is as specified in the `CREATE DATABASE`
  365. // statement. This name can be passed to other API methods to
  366. // identify the database.
  367. string name = 1 [(google.api.field_behavior) = REQUIRED];
  368. // Output only. The current database state.
  369. State state = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
  370. // Output only. If exists, the time at which the database creation started.
  371. google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
  372. // Output only. Applicable only for restored databases. Contains information
  373. // about the restore source.
  374. RestoreInfo restore_info = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
  375. // Output only. For databases that are using customer managed encryption, this
  376. // field contains the encryption configuration for the database.
  377. // For databases that are using Google default or other types of encryption,
  378. // this field is empty.
  379. EncryptionConfig encryption_config = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
  380. // Output only. For databases that are using customer managed encryption, this
  381. // field contains the encryption information for the database, such as
  382. // encryption state and the Cloud KMS key versions that are in use.
  383. //
  384. // For databases that are using Google default or other types of encryption,
  385. // this field is empty.
  386. //
  387. // This field is propagated lazily from the backend. There might be a delay
  388. // from when a key version is being used and when it appears in this field.
  389. repeated EncryptionInfo encryption_info = 8 [(google.api.field_behavior) = OUTPUT_ONLY];
  390. // Output only. The period in which Cloud Spanner retains all versions of data
  391. // for the database. This is the same as the value of version_retention_period
  392. // database option set using
  393. // [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl]. Defaults to 1 hour,
  394. // if not set.
  395. string version_retention_period = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
  396. // Output only. Earliest timestamp at which older versions of the data can be
  397. // read. This value is continuously updated by Cloud Spanner and becomes stale
  398. // the moment it is queried. If you are using this value to recover data, make
  399. // sure to account for the time from the moment when the value is queried to
  400. // the moment when you initiate the recovery.
  401. google.protobuf.Timestamp earliest_version_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
  402. // Output only. The read-write region which contains the database's leader
  403. // replicas.
  404. //
  405. // This is the same as the value of default_leader
  406. // database option set using DatabaseAdmin.CreateDatabase or
  407. // DatabaseAdmin.UpdateDatabaseDdl. If not explicitly set, this is empty.
  408. string default_leader = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
  409. // Output only. The dialect of the Cloud Spanner Database.
  410. DatabaseDialect database_dialect = 10 [(google.api.field_behavior) = OUTPUT_ONLY];
  411. }
  412. // The request for [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases].
  413. message ListDatabasesRequest {
  414. // Required. The instance whose databases should be listed.
  415. // Values are of the form `projects/<project>/instances/<instance>`.
  416. string parent = 1 [
  417. (google.api.field_behavior) = REQUIRED,
  418. (google.api.resource_reference) = {
  419. type: "spanner.googleapis.com/Instance"
  420. }
  421. ];
  422. // Number of databases to be returned in the response. If 0 or less,
  423. // defaults to the server's maximum allowed page size.
  424. int32 page_size = 3;
  425. // If non-empty, `page_token` should contain a
  426. // [next_page_token][google.spanner.admin.database.v1.ListDatabasesResponse.next_page_token] from a
  427. // previous [ListDatabasesResponse][google.spanner.admin.database.v1.ListDatabasesResponse].
  428. string page_token = 4;
  429. }
  430. // The response for [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases].
  431. message ListDatabasesResponse {
  432. // Databases that matched the request.
  433. repeated Database databases = 1;
  434. // `next_page_token` can be sent in a subsequent
  435. // [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases] call to fetch more
  436. // of the matching databases.
  437. string next_page_token = 2;
  438. }
  439. // The request for [CreateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase].
  440. message CreateDatabaseRequest {
  441. // Required. The name of the instance that will serve the new database.
  442. // Values are of the form `projects/<project>/instances/<instance>`.
  443. string parent = 1 [
  444. (google.api.field_behavior) = REQUIRED,
  445. (google.api.resource_reference) = {
  446. type: "spanner.googleapis.com/Instance"
  447. }
  448. ];
  449. // Required. A `CREATE DATABASE` statement, which specifies the ID of the
  450. // new database. The database ID must conform to the regular expression
  451. // `[a-z][a-z0-9_\-]*[a-z0-9]` and be between 2 and 30 characters in length.
  452. // If the database ID is a reserved word or if it contains a hyphen, the
  453. // database ID must be enclosed in backticks (`` ` ``).
  454. string create_statement = 2 [(google.api.field_behavior) = REQUIRED];
  455. // Optional. A list of DDL statements to run inside the newly created
  456. // database. Statements can create tables, indexes, etc. These
  457. // statements execute atomically with the creation of the database:
  458. // if there is an error in any statement, the database is not created.
  459. repeated string extra_statements = 3 [(google.api.field_behavior) = OPTIONAL];
  460. // Optional. The encryption configuration for the database. If this field is not
  461. // specified, Cloud Spanner will encrypt/decrypt all data at rest using
  462. // Google default encryption.
  463. EncryptionConfig encryption_config = 4 [(google.api.field_behavior) = OPTIONAL];
  464. // Optional. The dialect of the Cloud Spanner Database.
  465. DatabaseDialect database_dialect = 5 [(google.api.field_behavior) = OPTIONAL];
  466. }
  467. // Metadata type for the operation returned by
  468. // [CreateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase].
  469. message CreateDatabaseMetadata {
  470. // The database being created.
  471. string database = 1 [(google.api.resource_reference) = {
  472. type: "spanner.googleapis.com/Database"
  473. }];
  474. }
  475. // The request for [GetDatabase][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabase].
  476. message GetDatabaseRequest {
  477. // Required. The name of the requested database. Values are of the form
  478. // `projects/<project>/instances/<instance>/databases/<database>`.
  479. string name = 1 [
  480. (google.api.field_behavior) = REQUIRED,
  481. (google.api.resource_reference) = {
  482. type: "spanner.googleapis.com/Database"
  483. }
  484. ];
  485. }
  486. // Enqueues the given DDL statements to be applied, in order but not
  487. // necessarily all at once, to the database schema at some point (or
  488. // points) in the future. The server checks that the statements
  489. // are executable (syntactically valid, name tables that exist, etc.)
  490. // before enqueueing them, but they may still fail upon
  491. // later execution (e.g., if a statement from another batch of
  492. // statements is applied first and it conflicts in some way, or if
  493. // there is some data-related problem like a `NULL` value in a column to
  494. // which `NOT NULL` would be added). If a statement fails, all
  495. // subsequent statements in the batch are automatically cancelled.
  496. //
  497. // Each batch of statements is assigned a name which can be used with
  498. // the [Operations][google.longrunning.Operations] API to monitor
  499. // progress. See the
  500. // [operation_id][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.operation_id] field for more
  501. // details.
  502. message UpdateDatabaseDdlRequest {
  503. // Required. The database to update.
  504. string database = 1 [
  505. (google.api.field_behavior) = REQUIRED,
  506. (google.api.resource_reference) = {
  507. type: "spanner.googleapis.com/Database"
  508. }
  509. ];
  510. // Required. DDL statements to be applied to the database.
  511. repeated string statements = 2 [(google.api.field_behavior) = REQUIRED];
  512. // If empty, the new update request is assigned an
  513. // automatically-generated operation ID. Otherwise, `operation_id`
  514. // is used to construct the name of the resulting
  515. // [Operation][google.longrunning.Operation].
  516. //
  517. // Specifying an explicit operation ID simplifies determining
  518. // whether the statements were executed in the event that the
  519. // [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] call is replayed,
  520. // or the return value is otherwise lost: the [database][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.database] and
  521. // `operation_id` fields can be combined to form the
  522. // [name][google.longrunning.Operation.name] of the resulting
  523. // [longrunning.Operation][google.longrunning.Operation]: `<database>/operations/<operation_id>`.
  524. //
  525. // `operation_id` should be unique within the database, and must be
  526. // a valid identifier: `[a-z][a-z0-9_]*`. Note that
  527. // automatically-generated operation IDs always begin with an
  528. // underscore. If the named operation already exists,
  529. // [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] returns
  530. // `ALREADY_EXISTS`.
  531. string operation_id = 3;
  532. }
  533. // Metadata type for the operation returned by
  534. // [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl].
  535. message UpdateDatabaseDdlMetadata {
  536. // The database being modified.
  537. string database = 1 [(google.api.resource_reference) = {
  538. type: "spanner.googleapis.com/Database"
  539. }];
  540. // For an update this list contains all the statements. For an
  541. // individual statement, this list contains only that statement.
  542. repeated string statements = 2;
  543. // Reports the commit timestamps of all statements that have
  544. // succeeded so far, where `commit_timestamps[i]` is the commit
  545. // timestamp for the statement `statements[i]`.
  546. repeated google.protobuf.Timestamp commit_timestamps = 3;
  547. // Output only. When true, indicates that the operation is throttled e.g
  548. // due to resource constraints. When resources become available the operation
  549. // will resume and this field will be false again.
  550. bool throttled = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
  551. // The progress of the
  552. // [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] operations.
  553. // Currently, only index creation statements will have a continuously
  554. // updating progress.
  555. // For non-index creation statements, `progress[i]` will have start time
  556. // and end time populated with commit timestamp of operation,
  557. // as well as a progress of 100% once the operation has completed.
  558. // `progress[i]` is the operation progress for `statements[i]`.
  559. repeated OperationProgress progress = 5;
  560. }
  561. // The request for [DropDatabase][google.spanner.admin.database.v1.DatabaseAdmin.DropDatabase].
  562. message DropDatabaseRequest {
  563. // Required. The database to be dropped.
  564. string database = 1 [
  565. (google.api.field_behavior) = REQUIRED,
  566. (google.api.resource_reference) = {
  567. type: "spanner.googleapis.com/Database"
  568. }
  569. ];
  570. }
  571. // The request for [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl].
  572. message GetDatabaseDdlRequest {
  573. // Required. The database whose schema we wish to get.
  574. // Values are of the form
  575. // `projects/<project>/instances/<instance>/databases/<database>`
  576. string database = 1 [
  577. (google.api.field_behavior) = REQUIRED,
  578. (google.api.resource_reference) = {
  579. type: "spanner.googleapis.com/Database"
  580. }
  581. ];
  582. }
  583. // The response for [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl].
  584. message GetDatabaseDdlResponse {
  585. // A list of formatted DDL statements defining the schema of the database
  586. // specified in the request.
  587. repeated string statements = 1;
  588. }
  589. // The request for
  590. // [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations].
  591. message ListDatabaseOperationsRequest {
  592. // Required. The instance of the database operations.
  593. // Values are of the form `projects/<project>/instances/<instance>`.
  594. string parent = 1 [
  595. (google.api.field_behavior) = REQUIRED,
  596. (google.api.resource_reference) = {
  597. type: "spanner.googleapis.com/Instance"
  598. }
  599. ];
  600. // An expression that filters the list of returned operations.
  601. //
  602. // A filter expression consists of a field name, a
  603. // comparison operator, and a value for filtering.
  604. // The value must be a string, a number, or a boolean. The comparison operator
  605. // must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
  606. // Colon `:` is the contains operator. Filter rules are not case sensitive.
  607. //
  608. // The following fields in the [Operation][google.longrunning.Operation]
  609. // are eligible for filtering:
  610. //
  611. // * `name` - The name of the long-running operation
  612. // * `done` - False if the operation is in progress, else true.
  613. // * `metadata.@type` - the type of metadata. For example, the type string
  614. // for [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata] is
  615. // `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`.
  616. // * `metadata.<field_name>` - any field in metadata.value.
  617. // `metadata.@type` must be specified first, if filtering on metadata
  618. // fields.
  619. // * `error` - Error associated with the long-running operation.
  620. // * `response.@type` - the type of response.
  621. // * `response.<field_name>` - any field in response.value.
  622. //
  623. // You can combine multiple expressions by enclosing each expression in
  624. // parentheses. By default, expressions are combined with AND logic. However,
  625. // you can specify AND, OR, and NOT logic explicitly.
  626. //
  627. // Here are a few examples:
  628. //
  629. // * `done:true` - The operation is complete.
  630. // * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` \
  631. // `(metadata.source_type:BACKUP) AND` \
  632. // `(metadata.backup_info.backup:backup_howl) AND` \
  633. // `(metadata.name:restored_howl) AND` \
  634. // `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \
  635. // `(error:*)` - Return operations where:
  636. // * The operation's metadata type is [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata].
  637. // * The database is restored from a backup.
  638. // * The backup name contains "backup_howl".
  639. // * The restored database's name contains "restored_howl".
  640. // * The operation started before 2018-03-28T14:50:00Z.
  641. // * The operation resulted in an error.
  642. string filter = 2;
  643. // Number of operations to be returned in the response. If 0 or
  644. // less, defaults to the server's maximum allowed page size.
  645. int32 page_size = 3;
  646. // If non-empty, `page_token` should contain a
  647. // [next_page_token][google.spanner.admin.database.v1.ListDatabaseOperationsResponse.next_page_token]
  648. // from a previous [ListDatabaseOperationsResponse][google.spanner.admin.database.v1.ListDatabaseOperationsResponse] to the
  649. // same `parent` and with the same `filter`.
  650. string page_token = 4;
  651. }
  652. // The response for
  653. // [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations].
  654. message ListDatabaseOperationsResponse {
  655. // The list of matching database [long-running
  656. // operations][google.longrunning.Operation]. Each operation's name will be
  657. // prefixed by the database's name. The operation's
  658. // [metadata][google.longrunning.Operation.metadata] field type
  659. // `metadata.type_url` describes the type of the metadata.
  660. repeated google.longrunning.Operation operations = 1;
  661. // `next_page_token` can be sent in a subsequent
  662. // [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations]
  663. // call to fetch more of the matching metadata.
  664. string next_page_token = 2;
  665. }
  666. // The request for
  667. // [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase].
  668. message RestoreDatabaseRequest {
  669. // Required. The name of the instance in which to create the
  670. // restored database. This instance must be in the same project and
  671. // have the same instance configuration as the instance containing
  672. // the source backup. Values are of the form
  673. // `projects/<project>/instances/<instance>`.
  674. string parent = 1 [
  675. (google.api.field_behavior) = REQUIRED,
  676. (google.api.resource_reference) = {
  677. type: "spanner.googleapis.com/Instance"
  678. }
  679. ];
  680. // Required. The id of the database to create and restore to. This
  681. // database must not already exist. The `database_id` appended to
  682. // `parent` forms the full database name of the form
  683. // `projects/<project>/instances/<instance>/databases/<database_id>`.
  684. string database_id = 2 [(google.api.field_behavior) = REQUIRED];
  685. // Required. The source from which to restore.
  686. oneof source {
  687. // Name of the backup from which to restore. Values are of the form
  688. // `projects/<project>/instances/<instance>/backups/<backup>`.
  689. string backup = 3 [(google.api.resource_reference) = {
  690. type: "spanner.googleapis.com/Backup"
  691. }];
  692. }
  693. // Optional. An encryption configuration describing the encryption type and key
  694. // resources in Cloud KMS used to encrypt/decrypt the database to restore to.
  695. // If this field is not specified, the restored database will use
  696. // the same encryption configuration as the backup by default, namely
  697. // [encryption_type][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.encryption_type] =
  698. // `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`.
  699. RestoreDatabaseEncryptionConfig encryption_config = 4 [(google.api.field_behavior) = OPTIONAL];
  700. }
  701. // Encryption configuration for the restored database.
  702. message RestoreDatabaseEncryptionConfig {
  703. // Encryption types for the database to be restored.
  704. enum EncryptionType {
  705. // Unspecified. Do not use.
  706. ENCRYPTION_TYPE_UNSPECIFIED = 0;
  707. // This is the default option when
  708. // [encryption_config][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig] is not specified.
  709. USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION = 1;
  710. // Use Google default encryption.
  711. GOOGLE_DEFAULT_ENCRYPTION = 2;
  712. // Use customer managed encryption. If specified, `kms_key_name` must
  713. // must contain a valid Cloud KMS key.
  714. CUSTOMER_MANAGED_ENCRYPTION = 3;
  715. }
  716. // Required. The encryption type of the restored database.
  717. EncryptionType encryption_type = 1 [(google.api.field_behavior) = REQUIRED];
  718. // Optional. The Cloud KMS key that will be used to encrypt/decrypt the restored
  719. // database. This field should be set only when
  720. // [encryption_type][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.encryption_type] is
  721. // `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form
  722. // `projects/<project>/locations/<location>/keyRings/<key_ring>/cryptoKeys/<kms_key_name>`.
  723. string kms_key_name = 2 [
  724. (google.api.field_behavior) = OPTIONAL,
  725. (google.api.resource_reference) = {
  726. type: "cloudkms.googleapis.com/CryptoKey"
  727. }
  728. ];
  729. }
  730. // Metadata type for the long-running operation returned by
  731. // [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase].
  732. message RestoreDatabaseMetadata {
  733. // Name of the database being created and restored to.
  734. string name = 1 [(google.api.resource_reference) = {
  735. type: "spanner.googleapis.com/Database"
  736. }];
  737. // The type of the restore source.
  738. RestoreSourceType source_type = 2;
  739. // Information about the source used to restore the database, as specified by
  740. // `source` in [RestoreDatabaseRequest][google.spanner.admin.database.v1.RestoreDatabaseRequest].
  741. oneof source_info {
  742. // Information about the backup used to restore the database.
  743. BackupInfo backup_info = 3;
  744. }
  745. // The progress of the
  746. // [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase]
  747. // operation.
  748. OperationProgress progress = 4;
  749. // The time at which cancellation of this operation was received.
  750. // [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
  751. // starts asynchronous cancellation on a long-running operation. The server
  752. // makes a best effort to cancel the operation, but success is not guaranteed.
  753. // Clients can use
  754. // [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
  755. // other methods to check whether the cancellation succeeded or whether the
  756. // operation completed despite cancellation. On successful cancellation,
  757. // the operation is not deleted; instead, it becomes an operation with
  758. // an [Operation.error][google.longrunning.Operation.error] value with a
  759. // [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`.
  760. google.protobuf.Timestamp cancel_time = 5;
  761. // If exists, the name of the long-running operation that will be used to
  762. // track the post-restore optimization process to optimize the performance of
  763. // the restored database, and remove the dependency on the restore source.
  764. // The name is of the form
  765. // `projects/<project>/instances/<instance>/databases/<database>/operations/<operation>`
  766. // where the <database> is the name of database being created and restored to.
  767. // The metadata type of the long-running operation is
  768. // [OptimizeRestoredDatabaseMetadata][google.spanner.admin.database.v1.OptimizeRestoredDatabaseMetadata]. This long-running operation will be
  769. // automatically created by the system after the RestoreDatabase long-running
  770. // operation completes successfully. This operation will not be created if the
  771. // restore was not successful.
  772. string optimize_database_operation_name = 6;
  773. }
  774. // Metadata type for the long-running operation used to track the progress
  775. // of optimizations performed on a newly restored database. This long-running
  776. // operation is automatically created by the system after the successful
  777. // completion of a database restore, and cannot be cancelled.
  778. message OptimizeRestoredDatabaseMetadata {
  779. // Name of the restored database being optimized.
  780. string name = 1 [(google.api.resource_reference) = {
  781. type: "spanner.googleapis.com/Database"
  782. }];
  783. // The progress of the post-restore optimizations.
  784. OperationProgress progress = 2;
  785. }
  786. // Indicates the type of the restore source.
  787. enum RestoreSourceType {
  788. // No restore associated.
  789. TYPE_UNSPECIFIED = 0;
  790. // A backup was used as the source of the restore.
  791. BACKUP = 1;
  792. }
  793. // A Cloud Spanner database role.
  794. message DatabaseRole {
  795. option (google.api.resource) = {
  796. type: "spanner.googleapis.com/DatabaseRole"
  797. pattern: "projects/{project}/instances/{instance}/databases/{database}/databaseRoles/{role}"
  798. };
  799. // Required. The name of the database role. Values are of the form
  800. // `projects/<project>/instances/<instance>/databases/<database>/databaseRoles/
  801. // {role}`, where `<role>` is as specified in the `CREATE ROLE`
  802. // DDL statement. This name can be passed to Get/Set IAMPolicy methods to
  803. // identify the database role.
  804. string name = 1 [(google.api.field_behavior) = REQUIRED];
  805. }
  806. // The request for [ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles].
  807. message ListDatabaseRolesRequest {
  808. // Required. The database whose roles should be listed.
  809. // Values are of the form
  810. // `projects/<project>/instances/<instance>/databases/<database>/databaseRoles`.
  811. string parent = 1 [
  812. (google.api.field_behavior) = REQUIRED,
  813. (google.api.resource_reference) = {
  814. type: "spanner.googleapis.com/Database"
  815. }
  816. ];
  817. // Number of database roles to be returned in the response. If 0 or less,
  818. // defaults to the server's maximum allowed page size.
  819. int32 page_size = 2;
  820. // If non-empty, `page_token` should contain a
  821. // [next_page_token][google.spanner.admin.database.v1.ListDatabaseRolesResponse.next_page_token] from a
  822. // previous [ListDatabaseRolesResponse][google.spanner.admin.database.v1.ListDatabaseRolesResponse].
  823. string page_token = 3;
  824. }
  825. // The response for [ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles].
  826. message ListDatabaseRolesResponse {
  827. // Database roles that matched the request.
  828. repeated DatabaseRole database_roles = 1;
  829. // `next_page_token` can be sent in a subsequent
  830. // [ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles]
  831. // call to fetch more of the matching roles.
  832. string next_page_token = 2;
  833. }