Google Cloud Spanner C++ Client  1.32.0
A C++ Client Library for Google Cloud Spanner
database_admin_client.h
Go to the documentation of this file.
1 // Copyright 2021 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 // https://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 
15 // Generated by the Codegen C++ plugin.
16 // If you make any local changes, they will be lost.
17 // source: google/spanner/admin/database/v1/spanner_database_admin.proto
18 
19 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_ADMIN_DATABASE_ADMIN_CLIENT_H
20 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_ADMIN_DATABASE_ADMIN_CLIENT_H
21 
22 #include "google/cloud/spanner/admin/database_admin_connection.h"
23 #include "google/cloud/future.h"
24 #include "google/cloud/iam_updater.h"
25 #include "google/cloud/options.h"
26 #include "google/cloud/polling_policy.h"
27 #include "google/cloud/status_or.h"
28 #include "google/cloud/version.h"
29 #include <google/longrunning/operations.grpc.pb.h>
30 #include <memory>
31 
32 namespace google {
33 namespace cloud {
34 namespace spanner_admin {
35 inline namespace GOOGLE_CLOUD_CPP_GENERATED_NS {
36 
37 /**
38  * Cloud Spanner Database Admin API
39  *
40  * The Cloud Spanner Database Admin API can be used to create, drop, and
41  * list databases. It also enables updating the schema of pre-existing
42  * databases. It can be also used to create, delete and list backups for a
43  * database and to restore from an existing backup.
44  */
46  public:
47  explicit DatabaseAdminClient(
48  std::shared_ptr<DatabaseAdminConnection> connection);
50 
51  //@{
52  // @name Copy and move support
57  //@}
58 
59  //@{
60  // @name Equality
61  friend bool operator==(DatabaseAdminClient const& a,
62  DatabaseAdminClient const& b) {
63  return a.connection_ == b.connection_;
64  }
65  friend bool operator!=(DatabaseAdminClient const& a,
66  DatabaseAdminClient const& b) {
67  return !(a == b);
68  }
69  //@}
70 
71  /**
72  * Lists Cloud Spanner databases.
73  *
74  * @param parent Required. The instance whose databases should be listed.
75  * Values are of the form `projects/<project>/instances/<instance>`.
76  */
77  StreamRange<google::spanner::admin::database::v1::Database> ListDatabases(
78  std::string const& parent);
79 
80  /**
81  * Creates a new Cloud Spanner database and starts to prepare it for serving.
82  * The returned [long-running operation][google.longrunning.Operation] will
83  * have a name of the format `<database_name>/operations/<operation_id>` and
84  * can be used to track preparation of the database. The
85  * [metadata][google.longrunning.Operation.metadata] field type is
86  * [CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata].
87  * The [response][google.longrunning.Operation.response] field type is
88  * [Database][google.spanner.admin.database.v1.Database], if successful.
89  *
90  * @param parent Required. The name of the instance that will serve the new
91  * database. Values are of the form `projects/<project>/instances/<instance>`.
92  * @param create_statement Required. A `CREATE DATABASE` statement, which
93  * specifies the ID of the new database. The database ID must conform to the
94  * regular expression
95  * `[a-z][a-z0-9_\-]*[a-z0-9]` and be between 2 and 30 characters in length.
96  * If the database ID is a reserved word or if it contains a hyphen, the
97  * database ID must be enclosed in backticks (`` ` ``).
98  * @return
99  * [google::spanner::admin::database::v1::Database](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/spanner_database_admin.proto#L326)
100  */
101  future<StatusOr<google::spanner::admin::database::v1::Database>>
102  CreateDatabase(std::string const& parent,
103  std::string const& create_statement);
104 
105  /**
106  * Gets the state of a Cloud Spanner database.
107  *
108  * @param name Required. The name of the requested database. Values are of
109  * the form `projects/<project>/instances/<instance>/databases/<database>`.
110  * @return
111  * [google::spanner::admin::database::v1::Database](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/spanner_database_admin.proto#L326)
112  */
113  StatusOr<google::spanner::admin::database::v1::Database> GetDatabase(
114  std::string const& name);
115 
116  /**
117  * Updates the schema of a Cloud Spanner database by
118  * creating/altering/dropping tables, columns, indexes, etc. The returned
119  * [long-running operation][google.longrunning.Operation] will have a name of
120  * the format `<database_name>/operations/<operation_id>` and can be used to
121  * track execution of the schema change(s). The
122  * [metadata][google.longrunning.Operation.metadata] field type is
123  * [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata].
124  * The operation has no response.
125  *
126  * @param database Required. The database to update.
127  * @param statements Required. DDL statements to be applied to the database.
128  * @return
129  * [google::spanner::admin::database::v1::UpdateDatabaseDdlMetadata](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/spanner_database_admin.proto#L547)
130  */
131  future<
132  StatusOr<google::spanner::admin::database::v1::UpdateDatabaseDdlMetadata>>
133  UpdateDatabaseDdl(std::string const& database,
134  std::vector<std::string> const& statements);
135 
136  /**
137  * Drops (aka deletes) a Cloud Spanner database.
138  * Completed backups for the database will be retained according to their
139  * `expire_time`.
140  *
141  * @param database Required. The database to be dropped.
142  */
143  Status DropDatabase(std::string const& database);
144 
145  /**
146  * Returns the schema of a Cloud Spanner database as a list of formatted
147  * DDL statements. This method does not show pending schema updates, those may
148  * be queried using the [Operations][google.longrunning.Operations] API.
149  *
150  * @param database Required. The database whose schema we wish to get.
151  * Values are of the form
152  * `projects/<project>/instances/<instance>/databases/<database>`
153  * @return
154  * [google::spanner::admin::database::v1::GetDatabaseDdlResponse](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/spanner_database_admin.proto#L603)
155  */
156  StatusOr<google::spanner::admin::database::v1::GetDatabaseDdlResponse>
157  GetDatabaseDdl(std::string const& database);
158 
159  /**
160  * Sets the access control policy on a database or backup resource.
161  * Replaces any existing policy.
162  *
163  * Authorization requires `spanner.databases.setIamPolicy`
164  * permission on [resource][google.iam.v1.SetIamPolicyRequest.resource].
165  * For backups, authorization requires `spanner.backups.setIamPolicy`
166  * permission on [resource][google.iam.v1.SetIamPolicyRequest.resource].
167  *
168  * @param resource REQUIRED: The resource for which the policy is being
169  * specified. See the operation documentation for the appropriate value for
170  * this field.
171  * @param policy REQUIRED: The complete policy to be applied to the
172  * `resource`. The size of the policy is limited to a few 10s of KB. An empty
173  * policy is a valid policy but certain Cloud Platform services (such as
174  * Projects) might reject them.
175  * @return
176  * [google::iam::v1::Policy](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/iam/v1/policy.proto#L88)
177  */
178  StatusOr<google::iam::v1::Policy> SetIamPolicy(
179  std::string const& resource, google::iam::v1::Policy const& policy);
180 
181  /**
182  * Updates the IAM policy for @p resource using an optimistic concurrency
183  * control loop.
184  *
185  * The loop fetches the current policy for @p resource, and passes it to @p
186  * updater, which should return the new policy. This new policy should use the
187  * current etag so that the read-modify-write cycle can detect races and rerun
188  * the update when there is a mismatch. If the new policy does not have an
189  * etag, the existing policy will be blindly overwritten. If @p updater does
190  * not yield a policy, the control loop is terminated and kCancelled is
191  * returned.
192  *
193  * @param resource Required. The resource for which the policy is being
194  * specified. See the operation documentation for the appropriate value for
195  * this field.
196  * @param updater Required. Functor to map the current policy to a new one.
197  * @param options Optional. Options to control the loop. Expected options
198  * are:
199  * - `DatabaseAdminBackoffPolicyOption`
200  * @return google::iam::v1::Policy
201  */
202  StatusOr<google::iam::v1::Policy> SetIamPolicy(std::string const& resource,
203  IamUpdater const& updater,
204  Options options = {});
205 
206  /**
207  * Gets the access control policy for a database or backup resource.
208  * Returns an empty policy if a database or backup exists but does not have a
209  * policy set.
210  *
211  * Authorization requires `spanner.databases.getIamPolicy` permission on
212  * [resource][google.iam.v1.GetIamPolicyRequest.resource].
213  * For backups, authorization requires `spanner.backups.getIamPolicy`
214  * permission on [resource][google.iam.v1.GetIamPolicyRequest.resource].
215  *
216  * @param resource REQUIRED: The resource for which the policy is being
217  * requested. See the operation documentation for the appropriate value for
218  * this field.
219  * @return
220  * [google::iam::v1::Policy](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/iam/v1/policy.proto#L88)
221  */
222  StatusOr<google::iam::v1::Policy> GetIamPolicy(std::string const& resource);
223 
224  /**
225  * Returns permissions that the caller has on the specified database or backup
226  * resource.
227  *
228  * Attempting this RPC on a non-existent Cloud Spanner database will
229  * result in a NOT_FOUND error if the user has
230  * `spanner.databases.list` permission on the containing Cloud
231  * Spanner instance. Otherwise returns an empty set of permissions.
232  * Calling this method on a backup that does not exist will
233  * result in a NOT_FOUND error if the user has
234  * `spanner.backups.list` permission on the containing instance.
235  *
236  * @param resource REQUIRED: The resource for which the policy detail is
237  * being requested. See the operation documentation for the appropriate value
238  * for this field.
239  * @param permissions The set of permissions to check for the `resource`.
240  * Permissions with wildcards (such as '*' or 'storage.*') are not allowed.
241  * For more information see [IAM
242  * Overview](https://cloud.google.com/iam/docs/overview#permissions).
243  * @return
244  * [google::iam::v1::TestIamPermissionsResponse](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/iam/v1/iam_policy.proto#L141)
245  */
246  StatusOr<google::iam::v1::TestIamPermissionsResponse> TestIamPermissions(
247  std::string const& resource, std::vector<std::string> const& permissions);
248 
249  /**
250  * Starts creating a new Cloud Spanner Backup.
251  * The returned backup [long-running operation][google.longrunning.Operation]
252  * will have a name of the format
253  * `projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id>`
254  * and can be used to track creation of the backup. The
255  * [metadata][google.longrunning.Operation.metadata] field type is
256  * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata].
257  * The [response][google.longrunning.Operation.response] field type is
258  * [Backup][google.spanner.admin.database.v1.Backup], if successful.
259  * Cancelling the returned operation will stop the creation and delete the
260  * backup. There can be only one pending backup creation per database. Backup
261  * creation of different databases can run concurrently.
262  *
263  * @param parent Required. The name of the instance in which the backup will
264  * be created. This must be the same instance that contains the database the
265  * backup will be created from. The backup will be stored in the
266  * location(s) specified in the instance configuration of this
267  * instance. Values are of the form
268  * `projects/<project>/instances/<instance>`.
269  * @param backup Required. The backup to create.
270  * @param backup_id Required. The id of the backup to be created. The
271  * `backup_id` appended to `parent` forms the full backup name of the form
272  * `projects/<project>/instances/<instance>/backups/<backup_id>`.
273  * @return
274  * [google::spanner::admin::database::v1::Backup](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/backup.proto#L36)
275  */
276  future<StatusOr<google::spanner::admin::database::v1::Backup>> CreateBackup(
277  std::string const& parent,
278  google::spanner::admin::database::v1::Backup const& backup,
279  std::string const& backup_id);
280 
281  /**
282  * Gets metadata on a pending or completed
283  * [Backup][google.spanner.admin.database.v1.Backup].
284  *
285  * @param name Required. Name of the backup.
286  * Values are of the form
287  * `projects/<project>/instances/<instance>/backups/<backup>`.
288  * @return
289  * [google::spanner::admin::database::v1::Backup](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/backup.proto#L36)
290  */
291  StatusOr<google::spanner::admin::database::v1::Backup> GetBackup(
292  std::string const& name);
293 
294  /**
295  * Updates a pending or completed
296  * [Backup][google.spanner.admin.database.v1.Backup].
297  *
298  * @param backup Required. The backup to update. `backup.name`, and the
299  * fields to be updated as specified by `update_mask` are required. Other
300  * fields are ignored. Update is only supported for the following fields:
301  * * `backup.expire_time`.
302  * @param update_mask Required. A mask specifying which fields (e.g.
303  * `expire_time`) in the Backup resource should be updated. This mask is
304  * relative to the Backup resource, not to the request message. The field mask
305  * must always be specified; this prevents any future fields from being erased
306  * accidentally by clients that do not know about them.
307  * @return
308  * [google::spanner::admin::database::v1::Backup](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/backup.proto#L36)
309  */
310  StatusOr<google::spanner::admin::database::v1::Backup> UpdateBackup(
311  google::spanner::admin::database::v1::Backup const& backup,
312  google::protobuf::FieldMask const& update_mask);
313 
314  /**
315  * Deletes a pending or completed
316  * [Backup][google.spanner.admin.database.v1.Backup].
317  *
318  * @param name Required. Name of the backup to delete.
319  * Values are of the form
320  * `projects/<project>/instances/<instance>/backups/<backup>`.
321  */
322  Status DeleteBackup(std::string const& name);
323 
324  /**
325  * Lists completed and pending backups.
326  * Backups returned are ordered by `create_time` in descending order,
327  * starting from the most recent `create_time`.
328  *
329  * @param parent Required. The instance to list backups from. Values are of
330  * the form `projects/<project>/instances/<instance>`.
331  */
332  StreamRange<google::spanner::admin::database::v1::Backup> ListBackups(
333  std::string const& parent);
334 
335  /**
336  * Create a new database by restoring from a completed backup. The new
337  * database must be in the same project and in an instance with the same
338  * instance configuration as the instance containing
339  * the backup. The returned database [long-running
340  * operation][google.longrunning.Operation] has a name of the format
341  * `projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>`,
342  * and can be used to track the progress of the operation, and to cancel it.
343  * The [metadata][google.longrunning.Operation.metadata] field type is
344  * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata].
345  * The [response][google.longrunning.Operation.response] type
346  * is [Database][google.spanner.admin.database.v1.Database], if
347  * successful. Cancelling the returned operation will stop the restore and
348  * delete the database.
349  * There can be only one database being restored into an instance at a time.
350  * Once the restore operation completes, a new restore operation can be
351  * initiated, without waiting for the optimize operation associated with the
352  * first restore to complete.
353  *
354  * @param parent Required. The name of the instance in which to create the
355  * restored database. This instance must be in the same project and
356  * have the same instance configuration as the instance containing
357  * the source backup. Values are of the form
358  * `projects/<project>/instances/<instance>`.
359  * @param database_id Required. The id of the database to create and restore
360  * to. This database must not already exist. The `database_id` appended to
361  * `parent` forms the full database name of the form
362  * `projects/<project>/instances/<instance>/databases/<database_id>`.
363  * @param backup Name of the backup from which to restore. Values are of the
364  * form `projects/<project>/instances/<instance>/backups/<backup>`.
365  * @return
366  * [google::spanner::admin::database::v1::Database](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/spanner_database_admin.proto#L326)
367  */
368  future<StatusOr<google::spanner::admin::database::v1::Database>>
369  RestoreDatabase(std::string const& parent, std::string const& database_id,
370  std::string const& backup);
371 
372  /**
373  * Lists database [longrunning-operations][google.longrunning.Operation].
374  * A database operation has a name of the form
375  * `projects/<project>/instances/<instance>/databases/<database>/operations/<operation>`.
376  * The long-running operation
377  * [metadata][google.longrunning.Operation.metadata] field type
378  * `metadata.type_url` describes the type of the metadata. Operations returned
379  * include those that have completed/failed/canceled within the last 7 days,
380  * and pending operations.
381  *
382  * @param parent Required. The instance of the database operations.
383  * Values are of the form `projects/<project>/instances/<instance>`.
384  */
385  StreamRange<google::longrunning::Operation> ListDatabaseOperations(
386  std::string const& parent);
387 
388  /**
389  * Lists the backup [long-running operations][google.longrunning.Operation] in
390  * the given instance. A backup operation has a name of the form
391  * `projects/<project>/instances/<instance>/backups/<backup>/operations/<operation>`.
392  * The long-running operation
393  * [metadata][google.longrunning.Operation.metadata] field type
394  * `metadata.type_url` describes the type of the metadata. Operations returned
395  * include those that have completed/failed/canceled within the last 7 days,
396  * and pending operations. Operations returned are ordered by
397  * `operation.metadata.value.progress.start_time` in descending order starting
398  * from the most recently started operation.
399  *
400  * @param parent Required. The instance of the backup operations. Values are
401  * of the form `projects/<project>/instances/<instance>`.
402  */
403  StreamRange<google::longrunning::Operation> ListBackupOperations(
404  std::string const& parent);
405 
406  /**
407  * Lists Cloud Spanner databases.
408  *
409  * @param request
410  * [google::spanner::admin::database::v1::ListDatabasesRequest](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/spanner_database_admin.proto#L413)
411  */
412  StreamRange<google::spanner::admin::database::v1::Database> ListDatabases(
413  google::spanner::admin::database::v1::ListDatabasesRequest request);
414 
415  /**
416  * Creates a new Cloud Spanner database and starts to prepare it for serving.
417  * The returned [long-running operation][google.longrunning.Operation] will
418  * have a name of the format `<database_name>/operations/<operation_id>` and
419  * can be used to track preparation of the database. The
420  * [metadata][google.longrunning.Operation.metadata] field type is
421  * [CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata].
422  * The [response][google.longrunning.Operation.response] field type is
423  * [Database][google.spanner.admin.database.v1.Database], if successful.
424  *
425  * @param request
426  * [google::spanner::admin::database::v1::CreateDatabaseRequest](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/spanner_database_admin.proto#L445)
427  * @return
428  * [google::spanner::admin::database::v1::Database](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/spanner_database_admin.proto#L326)
429  */
430  future<StatusOr<google::spanner::admin::database::v1::Database>>
432  google::spanner::admin::database::v1::CreateDatabaseRequest const&
433  request);
434 
435  /**
436  * Gets the state of a Cloud Spanner database.
437  *
438  * @param request
439  * [google::spanner::admin::database::v1::GetDatabaseRequest](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/spanner_database_admin.proto#L484)
440  * @return
441  * [google::spanner::admin::database::v1::Database](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/spanner_database_admin.proto#L326)
442  */
443  StatusOr<google::spanner::admin::database::v1::Database> GetDatabase(
444  google::spanner::admin::database::v1::GetDatabaseRequest const& request);
445 
446  /**
447  * Updates the schema of a Cloud Spanner database by
448  * creating/altering/dropping tables, columns, indexes, etc. The returned
449  * [long-running operation][google.longrunning.Operation] will have a name of
450  * the format `<database_name>/operations/<operation_id>` and can be used to
451  * track execution of the schema change(s). The
452  * [metadata][google.longrunning.Operation.metadata] field type is
453  * [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata].
454  * The operation has no response.
455  *
456  * @param request
457  * [google::spanner::admin::database::v1::UpdateDatabaseDdlRequest](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/spanner_database_admin.proto#L511)
458  * @return
459  * [google::spanner::admin::database::v1::UpdateDatabaseDdlMetadata](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/spanner_database_admin.proto#L547)
460  */
461  future<
462  StatusOr<google::spanner::admin::database::v1::UpdateDatabaseDdlMetadata>>
464  google::spanner::admin::database::v1::UpdateDatabaseDdlRequest const&
465  request);
466 
467  /**
468  * Drops (aka deletes) a Cloud Spanner database.
469  * Completed backups for the database will be retained according to their
470  * `expire_time`.
471  *
472  * @param request
473  * [google::spanner::admin::database::v1::DropDatabaseRequest](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/spanner_database_admin.proto#L579)
474  */
476  google::spanner::admin::database::v1::DropDatabaseRequest const& request);
477 
478  /**
479  * Returns the schema of a Cloud Spanner database as a list of formatted
480  * DDL statements. This method does not show pending schema updates, those may
481  * be queried using the [Operations][google.longrunning.Operations] API.
482  *
483  * @param request
484  * [google::spanner::admin::database::v1::GetDatabaseDdlRequest](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/spanner_database_admin.proto#L590)
485  * @return
486  * [google::spanner::admin::database::v1::GetDatabaseDdlResponse](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/spanner_database_admin.proto#L603)
487  */
488  StatusOr<google::spanner::admin::database::v1::GetDatabaseDdlResponse>
490  google::spanner::admin::database::v1::GetDatabaseDdlRequest const&
491  request);
492 
493  /**
494  * Sets the access control policy on a database or backup resource.
495  * Replaces any existing policy.
496  *
497  * Authorization requires `spanner.databases.setIamPolicy`
498  * permission on [resource][google.iam.v1.SetIamPolicyRequest.resource].
499  * For backups, authorization requires `spanner.backups.setIamPolicy`
500  * permission on [resource][google.iam.v1.SetIamPolicyRequest.resource].
501  *
502  * @param request
503  * [google::iam::v1::SetIamPolicyRequest](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/iam/v1/iam_policy.proto#L98)
504  * @return
505  * [google::iam::v1::Policy](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/iam/v1/policy.proto#L88)
506  */
507  StatusOr<google::iam::v1::Policy> SetIamPolicy(
508  google::iam::v1::SetIamPolicyRequest const& request);
509 
510  /**
511  * Gets the access control policy for a database or backup resource.
512  * Returns an empty policy if a database or backup exists but does not have a
513  * policy set.
514  *
515  * Authorization requires `spanner.databases.getIamPolicy` permission on
516  * [resource][google.iam.v1.GetIamPolicyRequest.resource].
517  * For backups, authorization requires `spanner.backups.getIamPolicy`
518  * permission on [resource][google.iam.v1.GetIamPolicyRequest.resource].
519  *
520  * @param request
521  * [google::iam::v1::GetIamPolicyRequest](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/iam/v1/iam_policy.proto#L113)
522  * @return
523  * [google::iam::v1::Policy](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/iam/v1/policy.proto#L88)
524  */
525  StatusOr<google::iam::v1::Policy> GetIamPolicy(
526  google::iam::v1::GetIamPolicyRequest const& request);
527 
528  /**
529  * Returns permissions that the caller has on the specified database or backup
530  * resource.
531  *
532  * Attempting this RPC on a non-existent Cloud Spanner database will
533  * result in a NOT_FOUND error if the user has
534  * `spanner.databases.list` permission on the containing Cloud
535  * Spanner instance. Otherwise returns an empty set of permissions.
536  * Calling this method on a backup that does not exist will
537  * result in a NOT_FOUND error if the user has
538  * `spanner.backups.list` permission on the containing instance.
539  *
540  * @param request
541  * [google::iam::v1::TestIamPermissionsRequest](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/iam/v1/iam_policy.proto#L126)
542  * @return
543  * [google::iam::v1::TestIamPermissionsResponse](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/iam/v1/iam_policy.proto#L141)
544  */
545  StatusOr<google::iam::v1::TestIamPermissionsResponse> TestIamPermissions(
546  google::iam::v1::TestIamPermissionsRequest const& request);
547 
548  /**
549  * Starts creating a new Cloud Spanner Backup.
550  * The returned backup [long-running operation][google.longrunning.Operation]
551  * will have a name of the format
552  * `projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id>`
553  * and can be used to track creation of the backup. The
554  * [metadata][google.longrunning.Operation.metadata] field type is
555  * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata].
556  * The [response][google.longrunning.Operation.response] field type is
557  * [Backup][google.spanner.admin.database.v1.Backup], if successful.
558  * Cancelling the returned operation will stop the creation and delete the
559  * backup. There can be only one pending backup creation per database. Backup
560  * creation of different databases can run concurrently.
561  *
562  * @param request
563  * [google::spanner::admin::database::v1::CreateBackupRequest](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/backup.proto#L123)
564  * @return
565  * [google::spanner::admin::database::v1::Backup](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/backup.proto#L36)
566  */
567  future<StatusOr<google::spanner::admin::database::v1::Backup>> CreateBackup(
568  google::spanner::admin::database::v1::CreateBackupRequest const& request);
569 
570  /**
571  * Gets metadata on a pending or completed
572  * [Backup][google.spanner.admin.database.v1.Backup].
573  *
574  * @param request
575  * [google::spanner::admin::database::v1::GetBackupRequest](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/backup.proto#L202)
576  * @return
577  * [google::spanner::admin::database::v1::Backup](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/backup.proto#L36)
578  */
579  StatusOr<google::spanner::admin::database::v1::Backup> GetBackup(
580  google::spanner::admin::database::v1::GetBackupRequest const& request);
581 
582  /**
583  * Updates a pending or completed
584  * [Backup][google.spanner.admin.database.v1.Backup].
585  *
586  * @param request
587  * [google::spanner::admin::database::v1::UpdateBackupRequest](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/backup.proto#L186)
588  * @return
589  * [google::spanner::admin::database::v1::Backup](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/backup.proto#L36)
590  */
591  StatusOr<google::spanner::admin::database::v1::Backup> UpdateBackup(
592  google::spanner::admin::database::v1::UpdateBackupRequest const& request);
593 
594  /**
595  * Deletes a pending or completed
596  * [Backup][google.spanner.admin.database.v1.Backup].
597  *
598  * @param request
599  * [google::spanner::admin::database::v1::DeleteBackupRequest](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/backup.proto#L215)
600  */
602  google::spanner::admin::database::v1::DeleteBackupRequest const& request);
603 
604  /**
605  * Lists completed and pending backups.
606  * Backups returned are ordered by `create_time` in descending order,
607  * starting from the most recent `create_time`.
608  *
609  * @param request
610  * [google::spanner::admin::database::v1::ListBackupsRequest](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/backup.proto#L228)
611  */
612  StreamRange<google::spanner::admin::database::v1::Backup> ListBackups(
613  google::spanner::admin::database::v1::ListBackupsRequest request);
614 
615  /**
616  * Create a new database by restoring from a completed backup. The new
617  * database must be in the same project and in an instance with the same
618  * instance configuration as the instance containing
619  * the backup. The returned database [long-running
620  * operation][google.longrunning.Operation] has a name of the format
621  * `projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>`,
622  * and can be used to track the progress of the operation, and to cancel it.
623  * The [metadata][google.longrunning.Operation.metadata] field type is
624  * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata].
625  * The [response][google.longrunning.Operation.response] type
626  * is [Database][google.spanner.admin.database.v1.Database], if
627  * successful. Cancelling the returned operation will stop the restore and
628  * delete the database.
629  * There can be only one database being restored into an instance at a time.
630  * Once the restore operation completes, a new restore operation can be
631  * initiated, without waiting for the optimize operation associated with the
632  * first restore to complete.
633  *
634  * @param request
635  * [google::spanner::admin::database::v1::RestoreDatabaseRequest](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/spanner_database_admin.proto#L692)
636  * @return
637  * [google::spanner::admin::database::v1::Database](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/spanner_database_admin.proto#L326)
638  */
639  future<StatusOr<google::spanner::admin::database::v1::Database>>
641  google::spanner::admin::database::v1::RestoreDatabaseRequest const&
642  request);
643 
644  /**
645  * Lists database [longrunning-operations][google.longrunning.Operation].
646  * A database operation has a name of the form
647  * `projects/<project>/instances/<instance>/databases/<database>/operations/<operation>`.
648  * The long-running operation
649  * [metadata][google.longrunning.Operation.metadata] field type
650  * `metadata.type_url` describes the type of the metadata. Operations returned
651  * include those that have completed/failed/canceled within the last 7 days,
652  * and pending operations.
653  *
654  * @param request
655  * [google::spanner::admin::database::v1::ListDatabaseOperationsRequest](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/spanner_database_admin.proto#L611)
656  */
657  StreamRange<google::longrunning::Operation> ListDatabaseOperations(
658  google::spanner::admin::database::v1::ListDatabaseOperationsRequest
659  request);
660 
661  /**
662  * Lists the backup [long-running operations][google.longrunning.Operation] in
663  * the given instance. A backup operation has a name of the form
664  * `projects/<project>/instances/<instance>/backups/<backup>/operations/<operation>`.
665  * The long-running operation
666  * [metadata][google.longrunning.Operation.metadata] field type
667  * `metadata.type_url` describes the type of the metadata. Operations returned
668  * include those that have completed/failed/canceled within the last 7 days,
669  * and pending operations. Operations returned are ordered by
670  * `operation.metadata.value.progress.start_time` in descending order starting
671  * from the most recently started operation.
672  *
673  * @param request
674  * [google::spanner::admin::database::v1::ListBackupOperationsRequest](https://github.com/googleapis/googleapis/blob/ed739492993c4a99629b6430affdd6c0fb59d435/google/spanner/admin/database/v1/backup.proto#L300)
675  */
676  StreamRange<google::longrunning::Operation> ListBackupOperations(
677  google::spanner::admin::database::v1::ListBackupOperationsRequest
678  request);
679 
680  private:
681  std::shared_ptr<DatabaseAdminConnection> connection_;
682 };
683 
684 } // namespace GOOGLE_CLOUD_CPP_GENERATED_NS
685 } // namespace spanner_admin
686 } // namespace cloud
687 } // namespace google
688 
689 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_ADMIN_DATABASE_ADMIN_CLIENT_H