Google Cloud Bigtable C++ Client 2.13.0
A C++ Client Library for Google Cloud Bigtable
Loading...
Searching...
No Matches
table_admin.h
1// Copyright 2017 Google Inc.
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#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_TABLE_ADMIN_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_TABLE_ADMIN_H
17
18#include "google/cloud/bigtable/admin/bigtable_table_admin_connection.h"
19#include "google/cloud/bigtable/admin_client.h"
20#include "google/cloud/bigtable/column_family.h"
21#include "google/cloud/bigtable/completion_queue.h"
22#include "google/cloud/bigtable/iam_policy.h"
23#include "google/cloud/bigtable/internal/convert_policies.h"
24#include "google/cloud/bigtable/metadata_update_policy.h"
25#include "google/cloud/bigtable/polling_policy.h"
26#include "google/cloud/bigtable/resource_names.h"
27#include "google/cloud/bigtable/table_config.h"
28#include "google/cloud/bigtable/version.h"
29#include "google/cloud/future.h"
30#include "google/cloud/grpc_error_delegate.h"
31#include "google/cloud/options.h"
32#include "google/cloud/status_or.h"
33#include "absl/types/optional.h"
34#include <chrono>
35#include <future>
36#include <memory>
37#include <string>
38#include <vector>
39
40namespace google {
41namespace cloud {
42namespace bigtable_internal {
43GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
44class TableAdminTester;
45GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
46} // namespace bigtable_internal
47namespace bigtable {
48GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
49/// The result of checking replication against a given token.
50enum class Consistency {
51 /// Some of the mutations created before the consistency token have not been
52 /// received by all the table replicas.
54 /// All mutations created before the consistency token have been received by
55 /// all the table replicas.
57};
58
59/**
60 * Implements the API to administer tables in a Cloud Bigtable instance.
61 *
62 * @par Thread-safety
63 * Instances of this class created via copy-construction or copy-assignment
64 * share the underlying pool of connections. Access to these copies via multiple
65 * threads is guaranteed to work. Two threads operating concurrently on the same
66 * instance of this class is not guaranteed to work.
67 *
68 * @par Cost
69 * Creating a new object of type `TableAdmin` is comparable to creating a few
70 * objects of type `std::string` or a few objects of type
71 * `std::shared_ptr<int>`. The class represents a shallow handle to a remote
72 * object.
73 *
74 * @par Error Handling
75 * This class uses `StatusOr<T>` to report errors. When an operation fails to
76 * perform its work the returned `StatusOr<T>` contains the error details. If
77 * the `ok()` member function in the `StatusOr<T>` returns `true` then it
78 * contains the expected result. Operations that do not return a value simply
79 * return a `google::cloud::Status` indicating success or the details of the
80 * error Please consult the [`StatusOr<T>`
81 * documentation](#google::cloud::StatusOr) for more details.
82 *
83 * @code
84 * namespace cbt = google::cloud::bigtable;
85 * namespace btadmin = google::bigtable::admin::v2;
86 * cbt::TableAdmin admin = ...;
87 * google::cloud::StatusOr<btadmin::Table> metadata = admin.GetTable(...);
88 *
89 * if (!metadata) {
90 * std::cerr << "Error fetching table metadata\n";
91 * return;
92 * }
93 *
94 * // Use "metadata" as a smart pointer here, e.g.:
95 * std::cout << "The full table name is " << table->name() << " the table has "
96 * << table->column_families_size() << " column families\n";
97 * @endcode
98 *
99 * In addition, the @ref index "main page" contains examples using `StatusOr<T>`
100 * to handle errors.
101 *
102 * @par Retry, Backoff, and Idempotency Policies
103 * The library automatically retries requests that fail with transient errors,
104 * and uses [truncated exponential backoff][backoff-link] to backoff between
105 * retries. The default policies are to continue retrying for up to 10 minutes.
106 * On each transient failure the backoff period is doubled, starting with an
107 * initial backoff of 100 milliseconds. The backoff period growth is truncated
108 * at 60 seconds. The default idempotency policy is to only retry idempotent
109 * operations. Note that most operations that change state are **not**
110 * idempotent.
111 *
112 * The application can override these policies when constructing objects of this
113 * class. The documentation for the constructors show examples of this in
114 * action.
115 *
116 * [backoff-link]: https://cloud.google.com/storage/docs/exponential-backoff
117 *
118 * @par Equality
119 * `TableAdmin` objects will compare equal iff they were created with the
120 * same `DataClient` and target the same Instance resource. Note that
121 * `TableAdmin` objects can compare equal with different retry/backoff/polling
122 * policies.
123 *
124 * @see https://cloud.google.com/bigtable/ for an overview of Cloud Bigtable.
125 *
126 * @see https://cloud.google.com/bigtable/docs/overview for an overview of the
127 * Cloud Bigtable data model.
128 *
129 * @see https://cloud.google.com/bigtable/docs/instances-clusters-nodes for an
130 * introduction of the main APIs into Cloud Bigtable.
131 *
132 * @see https://cloud.google.com/bigtable/docs/reference/service-apis-overview
133 * for an overview of the underlying Cloud Bigtable API.
134 *
135 * @see #google::cloud::StatusOr for a description of the error reporting class
136 * used by this library.
137 *
138 * @see `LimitedTimeRetryPolicy` and `LimitedErrorCountRetryPolicy` for
139 * alternative retry policies.
140 *
141 * @see `ExponentialBackoffPolicy` to configure different parameters for the
142 * exponential backoff policy.
143 *
144 * @see `SafeIdempotentMutationPolicy` and `AlwaysRetryMutationPolicy` for
145 * alternative idempotency policies.
146 */
147class TableAdmin {
148 public:
149 /**
150 * @param client the interface to create grpc stubs, report errors, etc.
151 * @param instance_id the id of the instance, e.g., "my-instance", the full
152 * name (e.g. '/projects/my-project/instances/my-instance') is built using
153 * the project id in the @p client parameter.
154 */
155 // NOLINTNEXTLINE(performance-unnecessary-value-param)
156 TableAdmin(std::shared_ptr<AdminClient> client, std::string instance_id)
157 : connection_(client->connection_),
158 cq_(client->cq_),
159 background_threads_(client->background_threads_),
160 project_id_(client->project()),
161 instance_id_(std::move(instance_id)),
162 instance_name_(InstanceName()),
163 retry_prototype_(
164 DefaultRPCRetryPolicy(internal::kBigtableTableAdminLimits)),
165 backoff_prototype_(
166 DefaultRPCBackoffPolicy(internal::kBigtableTableAdminLimits)),
167 polling_prototype_(
168 DefaultPollingPolicy(internal::kBigtableTableAdminLimits)),
169 options_(google::cloud::internal::MergeOptions(
170 bigtable_internal::MakeTableAdminOptions(
171 retry_prototype_, backoff_prototype_, polling_prototype_),
172 connection_->options())) {}
173
174 /**
175 * Create a new TableAdmin using explicit policies to handle RPC errors.
176 *
177 * @param client the interface to create grpc stubs, report errors, etc.
178 * @param instance_id the id of the instance, e.g., "my-instance", the full
179 * name (e.g. '/projects/my-project/instances/my-instance') is built using
180 * the project id in the @p client parameter.
181 * @param policies the set of policy overrides for this object.
182 * @tparam Policies the types of the policies to override, the types must
183 * derive from one of the following types:
184 * - `RPCBackoffPolicy` how to backoff from a failed RPC. Currently only
185 * `ExponentialBackoffPolicy` is implemented. You can also create your
186 * own policies that backoff using a different algorithm.
187 * - `RPCRetryPolicy` for how long to retry failed RPCs. Use
188 * `LimitedErrorCountRetryPolicy` to limit the number of failures
189 * allowed. Use `LimitedTimeRetryPolicy` to bound the time for any
190 * request. You can also create your own policies that combine time and
191 * error counts.
192 * - `PollingPolicy` for how long will the class wait for
193 * `google.longrunning.Operation` to complete. This class combines both
194 * the backoff policy for checking long running operations and the
195 * retry policy.
196 *
197 * @see GenericPollingPolicy, ExponentialBackoffPolicy,
198 * LimitedErrorCountRetryPolicy, LimitedTimeRetryPolicy.
199 */
200 template <typename... Policies>
201 // NOLINTNEXTLINE(performance-unnecessary-value-param)
202 TableAdmin(std::shared_ptr<AdminClient> client, std::string instance_id,
203 Policies&&... policies)
204 : connection_(client->connection_),
205 cq_(client->cq_),
206 background_threads_(client->background_threads_),
207 project_id_(client->project()),
208 instance_id_(std::move(instance_id)),
209 instance_name_(InstanceName()),
210 retry_prototype_(
211 DefaultRPCRetryPolicy(internal::kBigtableTableAdminLimits)),
212 backoff_prototype_(
213 DefaultRPCBackoffPolicy(internal::kBigtableTableAdminLimits)),
214 polling_prototype_(
215 DefaultPollingPolicy(internal::kBigtableTableAdminLimits)) {
216 ChangePolicies(std::forward<Policies>(policies)...);
217 options_ = google::cloud::internal::MergeOptions(
218 bigtable_internal::MakeTableAdminOptions(
219 retry_prototype_, backoff_prototype_, polling_prototype_),
220 connection_->options());
221 }
222
223 TableAdmin(TableAdmin const&) = default;
224 TableAdmin& operator=(TableAdmin const&) = default;
225
226 friend bool operator==(TableAdmin const& a, TableAdmin const& b) noexcept {
227 return a.connection_ == b.connection_ &&
228 a.instance_name_ == b.instance_name_;
229 }
230 friend bool operator!=(TableAdmin const& a, TableAdmin const& b) noexcept {
231 return !(a == b);
232 }
233
234 ///@{
235 /// @name Convenience shorthands for the schema views.
236 using TableView = ::google::bigtable::admin::v2::Table::View;
237 /// Only populate 'name' and fields related to the table's encryption state.
238 static auto constexpr ENCRYPTION_VIEW = // NOLINT(readability-identifier-naming)
239 google::bigtable::admin::v2::Table::ENCRYPTION_VIEW;
240 /// Populate all the fields in the response.
241 static auto constexpr FULL = // NOLINT(readability-identifier-naming)
242 google::bigtable::admin::v2::Table::FULL;
243 /// Populate only the name in the responses.
244 static auto constexpr NAME_ONLY = // NOLINT(readability-identifier-naming)
245 google::bigtable::admin::v2::Table::NAME_ONLY;
246 /// Populate only the name and the fields related to the table replication
247 /// state.
248 static auto constexpr REPLICATION_VIEW = // NOLINT(readability-identifier-naming)
249 google::bigtable::admin::v2::Table::REPLICATION_VIEW;
250 /// Populate only the name and the fields related to the table schema.
251 static auto constexpr SCHEMA_VIEW = // NOLINT(readability-identifier-naming)
252 google::bigtable::admin::v2::Table::SCHEMA_VIEW;
253 /// Use the default view as defined for each function.
254 static auto constexpr VIEW_UNSPECIFIED = // NOLINT(readability-identifier-naming)
255 google::bigtable::admin::v2::Table::VIEW_UNSPECIFIED;
256 ///@}
257
258 std::string const& project() const { return project_id_; }
259 std::string const& instance_id() const { return instance_id_; }
260 std::string const& instance_name() const { return instance_name_; }
261
262 /**
263 * Returns a TableAdmin that reuses the connection and configuration of this
264 * TableAdmin, but with a different resource name.
265 */
266 TableAdmin WithNewTarget(std::string project_id,
267 std::string instance_id) const {
268 auto table = *this;
269 table.project_id_ = std::move(project_id);
270 table.instance_id_ = std::move(instance_id);
271 table.instance_name_ = table.InstanceName();
272 return table;
273 }
274
275 /**
276 * Create a new table in the instance.
277 *
278 * @param table_id the name of the table relative to the instance managed by
279 * this object. The full table name is
280 * `projects/<PROJECT_ID>/instances/<INSTANCE_ID>/tables/<table_id>`
281 * where PROJECT_ID is obtained from the associated AdminClient and
282 * INSTANCE_ID is the instance_id() of this object.
283 * @param config the initial schema for the table.
284 * @return the attributes of the newly created table. Notice that the server
285 * only populates the table_name() field at this time.
286 *
287 * @par Idempotency
288 * This operation is always treated as non-idempotent.
289 *
290 * @par Thread-safety
291 * Two threads concurrently calling this member function on the same instance
292 * of this class are **not** guaranteed to work. Consider copying the object
293 * and using different copies in each thread.
294 *
295 * @par Example
296 * @snippet table_admin_snippets.cc create table
297 */
298 StatusOr<::google::bigtable::admin::v2::Table> CreateTable(
299 std::string table_id, TableConfig config);
300
301 /**
302 * Return all the tables in the instance.
303 *
304 * @param view define what information about the tables is retrieved.
305 * - `VIEW_UNSPECIFIED`: equivalent to `VIEW_SCHEMA`.
306 * - `NAME`: return only the name of the table.
307 * - `VIEW_SCHEMA`: return the name and the schema.
308 * - `FULL`: return all the information about the table.
309 *
310 * @par Idempotency
311 * This operation is read-only and therefore it is always idempotent.
312 *
313 * @par Thread-safety
314 * Two threads concurrently calling this member function on the same instance
315 * of this class are **not** guaranteed to work. Consider copying the object
316 * and using different copies in each thread.
317 *
318 * @par Example
319 * @snippet table_admin_snippets.cc list tables
320 */
321 StatusOr<std::vector<::google::bigtable::admin::v2::Table>> ListTables(
322 ::google::bigtable::admin::v2::Table::View view);
323
324 /**
325 * Get information about a single table.
326 *
327 * @param table_id the id of the table within the instance associated with
328 * this object. The full name of the table is
329 * `this->instance_name() + "/tables/" + table_id`
330 * @param view describes how much information to get about the name.
331 * - VIEW_UNSPECIFIED: equivalent to VIEW_SCHEMA.
332 * - NAME: return only the name of the table.
333 * - VIEW_SCHEMA: return the name and the schema.
334 * - FULL: return all the information about the table.
335 * @return the information about the table or status.
336 *
337 * @par Idempotency
338 * This operation is read-only and therefore it is always idempotent.
339 *
340 * @par Thread-safety
341 * Two threads concurrently calling this member function on the same instance
342 * of this class are **not** guaranteed to work. Consider copying the object
343 * and using different copies in each thread.
344 *
345 * @par Example
346 * @snippet table_admin_snippets.cc get table
347 */
348 StatusOr<::google::bigtable::admin::v2::Table> GetTable(
349 std::string const& table_id, TableView view = SCHEMA_VIEW);
350
351 /**
352 * Delete a table.
353 *
354 * @param table_id the id of the table within the instance associated with
355 * this object. The full name of the table is
356 * `this->instance_name() + "/tables/" + table_id`
357 *
358 * @return status of the operation.
359 *
360 * @par Idempotency
361 * This operation is always treated as non-idempotent.
362 *
363 * @par Thread-safety
364 * Two threads concurrently calling this member function on the same instance
365 * of this class are **not** guaranteed to work. Consider copying the object
366 * and using different copies in each thread.
367 *
368 * @par Example
369 * @snippet table_admin_snippets.cc delete table
370 */
371 Status DeleteTable(std::string const& table_id);
372
373 /**
374 * Parameters for `CreateBackup`.
375 *
376 * @param cluster_id the name of the cluster relative to the instance managed
377 * by the `TableAdmin` object. The full cluster name is
378 * `projects/<PROJECT_ID>/instances/<INSTANCE_ID>/clusters/<cluster_id>`
379 * where PROJECT_ID is obtained from the associated AdminClient and
380 * INSTANCE_ID is the instance_id() of the `TableAdmin` object.
381 * @param backup_id the name of the backup relative to the cluster specified.
382 * The full backup name is
383 * `projects/<PROJECT_ID>/instances/<INSTANCE_ID>/clusters/<CLUSTER_ID>/backups/<backup_id>`
384 * where PROJECT_ID is obtained from the associated AdminClient,
385 * INSTANCE_ID is the instance_id() of the `TableAdmin` object, and
386 * CLUSTER_ID is the cluster_id specified for this object.
387 * @param table_id the id of the table within the instance to be backed up.
388 * The full name of the table is
389 * `projects/<PROJECT_ID>/instances/<INSTANCE_ID>/tables/<table_id>`
390 * where PROJECT_ID is obtained from the associated AdminClient and
391 * INSTANCE_ID is the instance_id() of the `TableAdmin` object.
392 * @param expire_time the date and time when the created backup will expire.
393 */
394 struct CreateBackupParams {
395 CreateBackupParams() = default;
396 CreateBackupParams(std::string cluster_id, std::string backup_id,
397 std::string table_id,
398 std::chrono::system_clock::time_point expire_time)
399 : cluster_id(std::move(cluster_id)),
400 backup_id(std::move(backup_id)),
401 table_name(std::move(table_id)),
402 expire_time(std::move(expire_time)) {}
403
404 google::bigtable::admin::v2::CreateBackupRequest AsProto(
405 std::string instance_name) const;
406
407 std::string cluster_id;
408 std::string backup_id;
409 std::string table_name;
410 std::chrono::system_clock::time_point expire_time;
411 };
412
413 /**
414 * Create a new backup of a table in the instance.
415 *
416 * @param params instance of `CreateBackupParams`.
417 *
418 * @par Idempotency
419 * This operation is always treated as non-idempotent.
420 *
421 * @par Thread-safety
422 * Two threads concurrently calling this member function on the same instance
423 * of this class are **not** guaranteed to work. Consider copying the object
424 * and using different copies in each thread.
425 *
426 * @par Example
427 * @snippet bigtable_table_admin_backup_snippets.cc create backup
428 */
429 StatusOr<google::bigtable::admin::v2::Backup> CreateBackup(
430 CreateBackupParams const& params);
431
432 /**
433 * Get information about a single backup.
434 *
435 * @param cluster_id the name of the cluster relative to the instance managed
436 * by the `TableAdmin` object. The full cluster name is
437 * `projects/<PROJECT_ID>/instances/<INSTANCE_ID>/clusters/<cluster_id>`
438 * where PROJECT_ID is obtained from the associated AdminClient and
439 * INSTANCE_ID is the instance_id() of the `TableAdmin` object.
440 * @param backup_id the name of the backup relative to the cluster specified.
441 * The full backup name is
442 * `projects/<PROJECT_ID>/instances/<INSTANCE_ID>/clusters/<CLUSTER_ID>/backups/<backup_id>`
443 * where PROJECT_ID is obtained from the associated AdminClient,
444 * INSTANCE_ID is the instance_id() of the `TableAdmin` object, and
445 * CLUSTER_ID is the cluster_id previously specified.
446 *
447 * @par Idempotency
448 * This operation is read-only and therefore it is always idempotent.
449 *
450 * @par Thread-safety
451 * Two threads concurrently calling this member function on the same instance
452 * of this class are **not** guaranteed to work. Consider copying the object
453 * and using different copies in each thread.
454 *
455 * @par Example
456 * @snippet bigtable_table_admin_backup_snippets.cc get backup
457 */
458 StatusOr<google::bigtable::admin::v2::Backup> GetBackup(
459 std::string const& cluster_id, std::string const& backup_id);
460
461 /**
462 * Parameters for `UpdateBackup`.
463 *
464 * @param cluster_id the name of the cluster relative to the instance managed
465 * by the `TableAdmin` object. The full cluster name is
466 * `projects/<PROJECT_ID>/instances/<INSTANCE_ID>/clusters/<cluster_id>`
467 * where PROJECT_ID is obtained from the associated AdminClient and
468 * INSTANCE_ID is the instance_id() of the `TableAdmin` object.
469 * @param backup_id the name of the backup relative to the cluster specified.
470 * The full backup name is
471 * `projects/<PROJECT_ID>/instances/<INSTANCE_ID>/clusters/<CLUSTER_ID>/backups/<backup_id>`
472 * where PROJECT_ID is obtained from the associated AdminClient,
473 * INSTANCE_ID is the instance_id() of the `TableAdmin` object, and
474 * CLUSTER_ID is the cluster_id specified for this object.
475 * @param expire_time the date and time when the created backup will expire.
476 */
477 struct UpdateBackupParams {
478 UpdateBackupParams() = default;
479 UpdateBackupParams(std::string cluster_id, std::string backup_id,
480 std::chrono::system_clock::time_point expire_time)
481 : cluster_id(std::move(cluster_id)),
482 backup_name(std::move(backup_id)),
483 expire_time(std::move(expire_time)) {}
484
485 google::bigtable::admin::v2::UpdateBackupRequest AsProto(
486 std::string const& instance_name) const;
487
488 std::string cluster_id;
489 std::string backup_name;
490 std::chrono::system_clock::time_point expire_time;
491 };
492
493 /**
494 * Updates a backup of a table in the instance.
495 *
496 * @param params instance of `UpdateBackupParams`.
497 *
498 * @par Idempotency
499 * This operation is always treated as non-idempotent.
500 *
501 * @par Thread-safety
502 * Two threads concurrently calling this member function on the same instance
503 * of this class are **not** guaranteed to work. Consider copying the object
504 * and using different copies in each thread.
505 *
506 * @par Example
507 * @snippet bigtable_table_admin_backup_snippets.cc update backup
508 */
509 StatusOr<google::bigtable::admin::v2::Backup> UpdateBackup(
510 UpdateBackupParams const& params);
511
512 /**
513 * Delete a backup.
514 *
515 * @param cluster_id the name of the cluster relative to the instance managed
516 * by the `TableAdmin` object. The full cluster name is
517 * `projects/<PROJECT_ID>/instances/<INSTANCE_ID>/clusters/<cluster_id>`
518 * where PROJECT_ID is obtained from the associated AdminClient and
519 * INSTANCE_ID is the instance_id() of the `TableAdmin` object.
520 * @param backup_id the name of the backup relative to the cluster specified.
521 * The full backup name is
522 * `projects/<PROJECT_ID>/instances/<INSTANCE_ID>/clusters/<CLUSTER_ID>/backups/<backup_id>`
523 * where PROJECT_ID is obtained from the associated AdminClient,
524 * INSTANCE_ID is the instance_id() of the `TableAdmin` object, and
525 * CLUSTER_ID is the cluster_id previously specified.
526 *
527 * @par Idempotency
528 * This operation is always treated as non-idempotent.
529 *
530 * @par Thread-safety
531 * Two threads concurrently calling this member function on the same instance
532 * of this class are **not** guaranteed to work. Consider copying the object
533 * and using different copies in each thread.
534 *
535 * @par Example
536 * @snippet bigtable_table_admin_backup_snippets.cc delete backup
537 */
538 Status DeleteBackup(std::string const& cluster_id,
539 std::string const& backup_id);
540
541 /**
542 * Delete a backup.
543 *
544 * @param backup typically returned by a call to `GetBackup` or `ListBackups`.
545 *
546 * @par Idempotency
547 * This operation is always treated as non-idempotent.
548 *
549 * @par Thread-safety
550 * Two threads concurrently calling this member function on the same instance
551 * of this class are **not** guaranteed to work. Consider copying the object
552 * and using different copies in each thread.
553 *
554 * @par Example
555 * @snippet bigtable_table_admin_backup_snippets.cc delete backup
556 */
557 Status DeleteBackup(google::bigtable::admin::v2::Backup const& backup);
558
559 /**
560 * Parameters for `ListBackups`.
561 */
562 struct ListBackupsParams {
563 /**
564 * Sets the cluster_id.
565 *
566 * @param c the name of the cluster relative to the instance
567 * managed by the `TableAdmin` object. If no cluster_id is specified,
568 * the all backups in all clusters are listed. The full cluster name is
569 * `projects/<PROJECT_ID>/instances/<INSTANCE_ID>/clusters/<cluster_id>`
570 * where PROJECT_ID is obtained from the associated AdminClient and
571 * INSTANCE_ID is the instance_id() of the `TableAdmin` object.
572 */
573 ListBackupsParams& set_cluster(std::string c) {
574 this->cluster_id = std::move(c);
575 return *this;
576 }
577
578 /**
579 * Sets the filtering expression.
580 *
581 * @param f expression that filters backups listed in the response.
582 * The expression must specify the field name, a comparison operator,
583 * and the value that you want to use for filtering. The value must be a
584 * string, a number, or a boolean. The comparison operator must be
585 * <, >, <=, >=, !=, =, or :. Colon ‘:’ represents a HAS operator which
586 * is roughly synonymous with equality. Filter rules are case
587 * insensitive.
588 *
589 * The fields eligible for filtering are:
590 * * `name`
591 * * `table`
592 * * `state`
593 * * `start_time` (and values are of the format
594 * `YYYY-MM-DDTHH:MM:SSZ`)
595 * * `end_time` (and values are of the format `YYYY-MM-DDTHH:MM:SSZ`)
596 * * `expire_time` (and values are of the format
597 * `YYYY-MM-DDTHH:MM:SSZ`)
598 * * `size_bytes`
599 *
600 * To filter on multiple expressions, provide each separate expression
601 * within parentheses. By default, each expression is an AND expression.
602 * However, you can include AND, OR, and NOT expressions explicitly.
603 *
604 * Some examples of using filters are:
605 * * `name:"exact"` --> The backup's name is the string "exact".
606 * * `name:howl` --> The backup's name contains the string "howl".
607 * * `table:prod` --> The table's name contains the string "prod".
608 * * `state:CREATING` --> The backup is pending creation.
609 * * `state:READY` --> The backup is fully created and ready for use.
610 * * `(name:howl) AND (start_time < "2018-03-28T14:50:00Z")`
611 * --> The backup name contains the string "howl" and start_time
612 * of the backup is before `2018-03-28T14:50:00Z`.
613 * * `size_bytes > 10000000000` --> The backup's size is greater than
614 * 10GB
615 */
616 ListBackupsParams& set_filter(std::string f) {
617 this->filter = std::move(f);
618 return *this;
619 }
620
621 /**
622 * Sets the ordering expression.
623 *
624 * @param o expression for specifying the sort order of the results
625 * of the request. The string value should specify only one field in
626 * `google::bigtable::admin::v2::Backup`.
627 * The following field names are supported:
628 * * name
629 * * table
630 * * expire_time
631 * * start_time
632 * * end_time
633 * * size_bytes
634 * * state
635 *
636 * For example, "start_time". The default sorting order is ascending.
637 * Append the " desc" suffix to the field name to sort descending, e.g.
638 * "start_time desc". Redundant space characters in the syntax are
639 * insignificant.
640 *
641 * If order_by is empty, results will be sorted by `start_time` in
642 * descending order starting from the most recently created backup.
643 */
644 ListBackupsParams& set_order_by(std::string o) {
645 this->order_by = std::move(o);
646 return *this;
647 }
648
649 google::bigtable::admin::v2::ListBackupsRequest AsProto(
650 std::string const& instance_name) const;
651
652 absl::optional<std::string> cluster_id;
653 absl::optional<std::string> filter;
654 absl::optional<std::string> order_by;
655 };
656
657 /**
658 * Retrieves a list of backups.
659 *
660 * @param params instance of `ListBackupsParams`.
661 *
662 * @par Idempotency
663 * This operation is read-only and therefore it is always idempotent.
664 *
665 * @par Thread-safety
666 * Two threads concurrently calling this member function on the same instance
667 * of this class are **not** guaranteed to work. Consider copying the object
668 * and using different copies in each thread.
669 *
670 * @par Example
671 * @snippet bigtable_table_admin_backup_snippets.cc list backups
672 */
673 StatusOr<std::vector<google::bigtable::admin::v2::Backup>> ListBackups(
674 ListBackupsParams const& params);
675
676 /**
677 * Parameters for `RestoreTable`.
678 *
679 * @param table_id the name of the table relative to the instance managed by
680 * this object. The full table name is
681 * `projects/<PROJECT_ID>/instances/<INSTANCE_ID>/tables/<table_id>`
682 * where PROJECT_ID is obtained from the associated AdminClient and
683 * INSTANCE_ID is the instance_id() of this object.
684 * @param cluster_id the name of the cluster relative to the instance managed
685 * by the `TableAdmin` object. The full cluster name is
686 * `projects/<PROJECT_ID>/instances/<INSTANCE_ID>/clusters/<cluster_id>`
687 * where PROJECT_ID is obtained from the associated AdminClient and
688 * INSTANCE_ID is the instance_id() of the `TableAdmin` object.
689 * @param backup_id the name of the backup relative to the cluster specified.
690 * The full backup name is
691 * `projects/<PROJECT_ID>/instances/<INSTANCE_ID>/clusters/<CLUSTER_ID>/backups/<backup_id>`
692 * where PROJECT_ID is obtained from the associated AdminClient,
693 * INSTANCE_ID is the instance_id() of the `TableAdmin` object, and
694 * CLUSTER_ID is the cluster_id previously specified.
695 */
696 struct RestoreTableParams {
697 RestoreTableParams() = default;
698 RestoreTableParams(std::string table_id, std::string cluster_id,
699 std::string backup_id)
700 : table_id(std::move(table_id)),
701 cluster_id(std::move(cluster_id)),
702 backup_id(std::move(backup_id)) {}
703
704 /// @deprecated covert the parameters to a proto.
705 google::bigtable::admin::v2::RestoreTableRequest AsProto(
706 std::string const& instance_name) const;
707
708 std::string table_id;
709 std::string cluster_id;
710 std::string backup_id;
711 };
712
713 /**
714 * Parameters for `RestoreTable`.
715 *
716 * @param table_id the name of the table relative to the instance managed by
717 * this object. The full table name is
718 * `projects/<PROJECT_ID>/instances/<INSTANCE_ID>/tables/<table_id>`
719 * where PROJECT_ID is obtained from the associated AdminClient and
720 * INSTANCE_ID is the instance_id() of this object.
721 * @param backup_name the full name of the backup used to restore @p table_id.
722 */
724 std::string table_id;
725 std::string backup_name;
726 };
727
728 /**
729 * Restore a backup into a new table in the instance.
730 *
731 * @param params instance of `RestoreTableParams`.
732 *
733 * @par Idempotency
734 * This operation is always treated as non-idempotent.
735 *
736 * @par Thread-safety
737 * Two threads concurrently calling this member function on the same instance
738 * of this class are **not** guaranteed to work. Consider copying the object
739 * and using different copies in each thread.
740 *
741 * @par Example
742 * @snippet bigtable_table_admin_backup_snippets.cc restore table
743 */
744 StatusOr<google::bigtable::admin::v2::Table> RestoreTable(
745 RestoreTableParams const& params);
746
747 /**
748 * Restore a backup into a new table in the instance.
749 *
750 * @param params instance of `RestoreTableFromInstanceParams`.
751 *
752 * @par Idempotency
753 * This operation is always treated as non-idempotent.
754 *
755 * @par Thread-safety
756 * Two threads concurrently calling this member function on the same instance
757 * of this class are **not** guaranteed to work. Consider copying the object
758 * and using different copies in each thread.
759 *
760 * @par Example
761 * @snippet bigtable_table_admin_backup_snippets.cc restore2
762 */
763 StatusOr<google::bigtable::admin::v2::Table> RestoreTable(
765
766 /**
767 * Modify the schema for an existing table.
768 *
769 * @param table_id the id of the table within the instance associated with
770 * this object. The full name of the table is
771 * `this->instance_name() + "/tables/" + table_id`
772 * @param modifications the list of modifications to the schema.
773 *
774 * @par Idempotency
775 * This operation is always treated as non-idempotent.
776 *
777 * @par Thread-safety
778 * Two threads concurrently calling this member function on the same instance
779 * of this class are **not** guaranteed to work. Consider copying the object
780 * and using different copies in each thread.
781 *
782 * @par Example
783 * @snippet table_admin_snippets.cc modify table
784 */
785 StatusOr<::google::bigtable::admin::v2::Table> ModifyColumnFamilies(
786 std::string const& table_id,
787 std::vector<ColumnFamilyModification> modifications);
788
789 /**
790 * Delete all the rows that start with a given prefix.
791 *
792 * @param table_id the id of the table within the instance associated with
793 * this object. The full name of the table is
794 * `this->instance_name() + "/tables/" + table_id`
795 * @param row_key_prefix drop any rows that start with this prefix.
796 *
797 * @par Idempotency
798 * This operation is always treated as non-idempotent.
799 *
800 * @par Thread-safety
801 * Two threads concurrently calling this member function on the same instance
802 * of this class are **not** guaranteed to work. Consider copying the object
803 * and using different copies in each thread.
804 *
805 * @par Example
806 * @snippet table_admin_snippets.cc drop rows by prefix
807 */
808 Status DropRowsByPrefix(std::string const& table_id,
809 std::string row_key_prefix);
810
811 /**
812 * Generates consistency token for a table.
813 *
814 * @param table_id the id of the table for which we want to generate
815 * consistency token.
816 * @return the consistency token for table.
817 *
818 * @par Idempotency
819 * This operation is read-only and therefore it is always idempotent.
820 *
821 * @par Thread-safety
822 * Two threads concurrently calling this member function on the same instance
823 * of this class are **not** guaranteed to work. Consider copying the object
824 * and using different copies in each thread.
825 *
826 * @par Example
827 * @snippet table_admin_snippets.cc generate consistency token
828 */
829 StatusOr<std::string> GenerateConsistencyToken(std::string const& table_id);
830
831 /**
832 * Checks consistency of a table.
833 *
834 * @param table_id the id of the table for which we want to check
835 * consistency.
836 * @param consistency_token the consistency token of the table.
837 * @return the consistency status for the table.
838 *
839 * @par Idempotency
840 * This operation is read-only and therefore it is always idempotent.
841 *
842 * @par Thread-safety
843 * Two threads concurrently calling this member function on the same instance
844 * of this class are **not** guaranteed to work. Consider copying the object
845 * and using different copies in each thread.
846 *
847 * @par Example
848 * @snippet table_admin_snippets.cc check consistency
849 */
850 StatusOr<Consistency> CheckConsistency(std::string const& table_id,
851 std::string const& consistency_token);
852
853 /**
854 * Checks consistency of a table with multiple calls using a separate thread
855 *
856 * @param table_id the id of the table for which we want to check
857 * consistency.
858 * @param consistency_token the consistency token of the table.
859 * @return the consistency status for the table.
860 *
861 * @par Idempotency
862 * This operation is read-only and therefore it is always idempotent.
863 *
864 * @par Thread-safety
865 * Two threads concurrently calling this member function on the same instance
866 * of this class are **not** guaranteed to work. Consider copying the object
867 * and using different copies in each thread.
868 *
869 * @par Example
870 * @snippet table_admin_snippets.cc wait for consistency check
871 */
873 std::string const& table_id, std::string const& consistency_token);
874
875 /**
876 * Delete all the rows in a table.
877 *
878 * @param table_id the id of the table within the instance associated with
879 * this object. The full name of the table is
880 * `this->instance_name() + "/tables/" + table_id`
881 *
882 * @par Idempotency
883 * This operation is always treated as non-idempotent.
884 *
885 * @par Thread-safety
886 * Two threads concurrently calling this member function on the same instance
887 * of this class are **not** guaranteed to work. Consider copying the object
888 * and using different copies in each thread.
889 *
890 * @par Example
891 * @snippet table_admin_snippets.cc drop all rows
892 */
893 Status DropAllRows(std::string const& table_id);
894
895 /**
896 * Gets the policy for @p table_id.
897 *
898 * @param table_id the table to query.
899 * @return google::iam::v1::Policy the full IAM policy for the table.
900 *
901 * @par Idempotency
902 * This operation is read-only and therefore it is always idempotent.
903 *
904 * @par Thread-safety
905 * Two threads concurrently calling this member function on the same instance
906 * of this class are **not** guaranteed to work. Consider copying the object
907 * and using different copies in each thread.
908 *
909 * @par Example
910 * @snippet table_admin_iam_policy_snippets.cc get iam policy
911 */
912 StatusOr<google::iam::v1::Policy> GetIamPolicy(std::string const& table_id);
913
914 /**
915 * Gets the policy for @p backup_id.
916 *
917 * @param cluster_id the associated cluster that contains backup.
918 *
919 * @param backup_id the backup to query.
920 * @return google::iam::v1::Policy the full IAM policy for the backup.
921 *
922 * @par Idempotency
923 * This operation is read-only and therefore it is always idempotent.
924 *
925 * @par Thread-safety
926 * Two threads concurrently calling this member function on the same instance
927 * of this class are **not** guaranteed to work. Consider copying the object
928 * and using different copies in each thread.
929 *
930 * @par Example
931 * @snippet bigtable_table_admin_backup_snippets.cc get backup iam policy
932 */
933 StatusOr<google::iam::v1::Policy> GetIamPolicy(std::string const& cluster_id,
934 std::string const& backup_id);
935
936 /**
937 * Sets the IAM policy for a table.
938 *
939 * This is the preferred way to overload `IamBindings`. This is more closely
940 * coupled to the underlying protocol, enable more actions and is more likely
941 * to tolerate future protocol changes.
942 *
943 * @param table_id which table to set the IAM policy for.
944 * @param iam_policy google::iam::v1::Policy object containing role and
945 * members.
946 * @return google::iam::v1::Policy the current IAM policy for the table.
947 *
948 * @warning ETags are currently not used by Cloud Bigtable.
949 *
950 * @par Idempotency
951 * This operation is always treated as non-idempotent.
952 *
953 * @par Thread-safety
954 * Two threads concurrently calling this member function on the same instance
955 * of this class are **not** guaranteed to work. Consider copying the object
956 * and using different copies in each thread.
957 *
958 * @par Example
959 * @snippet table_admin_iam_policy_snippets.cc set iam policy
960 */
961 StatusOr<google::iam::v1::Policy> SetIamPolicy(
962 std::string const& table_id, google::iam::v1::Policy const& iam_policy);
963
964 /**
965 * Sets the IAM policy for a backup.
966 *
967 * This is the preferred way to overload `IamBindings`. This is more closely
968 * coupled to the underlying protocol, enable more actions and is more likely
969 * to tolerate future protocol changes.
970 *
971 * @param cluster_id which is the cluster containing the backup.
972 * @param backup_id which backup to set the IAM policy for.
973 * @param iam_policy google::iam::v1::Policy object containing role and
974 * members.
975 * @return google::iam::v1::Policy the current IAM policy for the table.
976 *
977 * @warning ETags are currently not used by Cloud Bigtable.
978 *
979 * @par Idempotency
980 * This operation is always treated as non-idempotent.
981 *
982 * @par Thread-safety
983 * Two threads concurrently calling this member function on the same instance
984 * of this class are **not** guaranteed to work. Consider copying the object
985 * and using different copies in each thread.
986 *
987 * @par Example
988 * @snippet bigtable_table_admin_backup_snippets.cc set backup iam policy
989 */
990 StatusOr<google::iam::v1::Policy> SetIamPolicy(
991 std::string const& cluster_id, std::string const& backup_id,
992 google::iam::v1::Policy const& iam_policy);
993
994 /**
995 * Returns a permission set that the caller has on the specified table.
996 *
997 * @param table_id the ID of the table to query.
998 * @param permissions set of permissions to check for the resource.
999 *
1000 * @par Idempotency
1001 * This operation is read-only and therefore it is always idempotent.
1002 *
1003 * @par Thread-safety
1004 * Two threads concurrently calling this member function on the same instance
1005 * of this class are **not** guaranteed to work. Consider copying the object
1006 * and using different copies in each thread.
1007 *
1008 * @par Example
1009 * @snippet table_admin_iam_policy_snippets.cc test iam permissions
1010 *
1011 * @see https://cloud.google.com/bigtable/docs/access-control for a list of
1012 * valid permissions on Google Cloud Bigtable.
1013 */
1014 StatusOr<std::vector<std::string>> TestIamPermissions(
1015 std::string const& table_id, std::vector<std::string> const& permissions);
1016
1017 /**
1018 * Returns a permission set that the caller has on the specified backup.
1019 *
1020 * @param cluster_id the ID of the cluster that contains the backup.
1021 * @param backup_id the ID of the backup to query.
1022 * @param permissions set of permissions to check for the resource.
1023 *
1024 * @par Idempotency
1025 * This operation is read-only and therefore it is always idempotent.
1026 *
1027 * @par Thread-safety
1028 * Two threads concurrently calling this member function on the same instance
1029 * of this class are **not** guaranteed to work. Consider copying the object
1030 * and using different copies in each thread.
1031 *
1032 * @par Example
1033 * @snippet table_admin_iam_policy_snippets.cc test iam permissions
1034 *
1035 * @see https://cloud.google.com/bigtable/docs/access-control for a list of
1036 * valid permissions on Google Cloud Bigtable.
1037 */
1038 StatusOr<std::vector<std::string>> TestIamPermissions(
1039 std::string const& cluster_id, std::string const& backup_id,
1040 std::vector<std::string> const& permissions);
1041
1042 /// Return the fully qualified name of a table in this object's instance.
1043 std::string TableName(std::string const& table_id) const {
1044 return google::cloud::bigtable::TableName(project_id_, instance_id_,
1045 table_id);
1046 }
1047
1048 /// Return the fully qualified name of a Cluster.
1049 std::string ClusterName(std::string const& cluster_id) const {
1050 return google::cloud::bigtable::ClusterName(project_id_, instance_id_,
1051 cluster_id);
1052 }
1053
1054 /// Return the fully qualified name of a Backup.
1055 std::string BackupName(std::string const& cluster_id,
1056 std::string const& backup_id) const {
1057 return google::cloud::bigtable::BackupName(project_id_, instance_id_,
1058 cluster_id, backup_id);
1059 }
1060
1061 private:
1062 friend class bigtable_internal::TableAdminTester;
1063
1064 explicit TableAdmin(
1065 std::shared_ptr<bigtable_admin::BigtableTableAdminConnection> connection,
1066 CompletionQueue cq, std::string project_id, std::string instance_id)
1067 : connection_(std::move(connection)),
1068 cq_(std::move(cq)),
1069 project_id_(std::move(project_id)),
1070 instance_id_(std::move(instance_id)),
1071 instance_name_(InstanceName()),
1072 retry_prototype_(
1073 DefaultRPCRetryPolicy(internal::kBigtableTableAdminLimits)),
1074 backoff_prototype_(
1075 DefaultRPCBackoffPolicy(internal::kBigtableTableAdminLimits)),
1076 polling_prototype_(
1077 DefaultPollingPolicy(internal::kBigtableTableAdminLimits)),
1078 options_(google::cloud::internal::MergeOptions(
1079 bigtable_internal::MakeTableAdminOptions(
1080 retry_prototype_, backoff_prototype_, polling_prototype_),
1081 connection_->options())) {}
1082
1083 ///@{
1084 /// @name Helper functions to implement constructors with changed policies.
1085 void ChangePolicy(RPCRetryPolicy const& policy) {
1086 retry_prototype_ = policy.clone();
1087 }
1088
1089 void ChangePolicy(RPCBackoffPolicy const& policy) {
1090 backoff_prototype_ = policy.clone();
1091 }
1092
1093 void ChangePolicy(PollingPolicy const& policy) {
1094 polling_prototype_ = policy.clone();
1095 }
1096
1097 template <typename Policy, typename... Policies>
1098 void ChangePolicies(Policy&& policy, Policies&&... policies) {
1099 ChangePolicy(policy);
1100 ChangePolicies(std::forward<Policies>(policies)...);
1101 }
1102 void ChangePolicies() {}
1103 ///@}
1104
1105 /// Compute the fully qualified instance name.
1106 std::string InstanceName() const;
1107
1108 StatusOr<google::iam::v1::Policy> GetIamPolicyImpl(std::string resource);
1109
1110 StatusOr<google::iam::v1::Policy> SetIamPolicyImpl(
1111 std::string resource, google::iam::v1::Policy const& iam_policy);
1112
1113 StatusOr<std::vector<std::string>> TestIamPermissionsImpl(
1114 std::string resource, std::vector<std::string> const& permissions);
1115
1116 std::shared_ptr<bigtable_admin::BigtableTableAdminConnection> connection_;
1117 CompletionQueue cq_;
1118 std::shared_ptr<BackgroundThreads> background_threads_;
1119 std::string project_id_;
1120 std::string instance_id_;
1121 std::string instance_name_;
1122 ///@{
1123 /// These prototypes are only used as temporary storage during construction of
1124 /// the class, where they are consolidated as common policies in `options_`.
1125 std::shared_ptr<RPCRetryPolicy> retry_prototype_;
1126 std::shared_ptr<RPCBackoffPolicy> backoff_prototype_;
1127 std::shared_ptr<PollingPolicy> polling_prototype_;
1128 ///@}
1129 Options options_;
1130};
1131
1132GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
1133} // namespace bigtable
1134} // namespace cloud
1135} // namespace google
1136
1137#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_TABLE_ADMIN_H
Options & operator=(Options &&)=default
std::string const & project()
The project id that this AdminClient works on.
Definition: admin_client.h:45
Define the interfaces to create column family modifications.
Definition: column_family.h:178
Define the interface for providing asynchronous repetitive call rules.
Definition: polling_policy.h:34
virtual std::unique_ptr< PollingPolicy > clone() const =0
Return a new copy of this object.
Define the interface for controlling how the Bigtable client backsoff from failed RPC operations.
Definition: rpc_backoff_policy.h:44
virtual std::unique_ptr< RPCBackoffPolicy > clone() const =0
Return a new copy of this object.
Define the interface for controlling how the Bigtable client retries RPC operations.
Definition: rpc_retry_policy.h:78
virtual std::unique_ptr< RPCRetryPolicy > clone() const =0
Return a new copy of this object.
Implements the API to administer tables in a Cloud Bigtable instance.
Definition: table_admin.h:147
StatusOr<::google::bigtable::admin::v2::Table > CreateTable(std::string table_id, TableConfig config)
Create a new table in the instance.
std::string BackupName(std::string const &cluster_id, std::string const &backup_id) const
Return the fully qualified name of a Backup.
Definition: table_admin.h:1055
TableAdmin & operator=(TableAdmin const &)=default
Status DeleteTable(std::string const &table_id)
Delete a table.
std::string TableName(std::string const &table_id) const
Return the fully qualified name of a table in this object's instance.
Definition: table_admin.h:1043
friend bool operator!=(TableAdmin const &a, TableAdmin const &b) noexcept
Definition: table_admin.h:230
static auto constexpr REPLICATION_VIEW
Populate only the name and the fields related to the table replication state.
Definition: table_admin.h:248
StatusOr< google::bigtable::admin::v2::Backup > CreateBackup(CreateBackupParams const &params)
Create a new backup of a table in the instance.
StatusOr< Consistency > CheckConsistency(std::string const &table_id, std::string const &consistency_token)
Checks consistency of a table.
TableAdmin(std::shared_ptr< AdminClient > client, std::string instance_id, Policies &&... policies)
Create a new TableAdmin using explicit policies to handle RPC errors.
Definition: table_admin.h:202
Status DropRowsByPrefix(std::string const &table_id, std::string row_key_prefix)
Delete all the rows that start with a given prefix.
StatusOr< google::iam::v1::Policy > GetIamPolicy(std::string const &cluster_id, std::string const &backup_id)
Gets the policy for backup_id.
static auto constexpr NAME_ONLY
Populate only the name in the responses.
Definition: table_admin.h:244
StatusOr< google::iam::v1::Policy > GetIamPolicy(std::string const &table_id)
Gets the policy for table_id.
Status DeleteBackup(std::string const &cluster_id, std::string const &backup_id)
Delete a backup.
std::string const & instance_id() const
Definition: table_admin.h:259
Status DeleteBackup(google::bigtable::admin::v2::Backup const &backup)
Delete a backup.
friend bool operator==(TableAdmin const &a, TableAdmin const &b) noexcept
Definition: table_admin.h:226
static auto constexpr SCHEMA_VIEW
Populate only the name and the fields related to the table schema.
Definition: table_admin.h:251
StatusOr< std::vector< std::string > > TestIamPermissions(std::string const &cluster_id, std::string const &backup_id, std::vector< std::string > const &permissions)
Returns a permission set that the caller has on the specified backup.
StatusOr< std::vector< std::string > > TestIamPermissions(std::string const &table_id, std::vector< std::string > const &permissions)
Returns a permission set that the caller has on the specified table.
std::string const & instance_name() const
Definition: table_admin.h:260
StatusOr< google::bigtable::admin::v2::Backup > UpdateBackup(UpdateBackupParams const &params)
Updates a backup of a table in the instance.
static auto constexpr VIEW_UNSPECIFIED
Use the default view as defined for each function.
Definition: table_admin.h:254
std::string const & project() const
Definition: table_admin.h:258
StatusOr<::google::bigtable::admin::v2::Table > GetTable(std::string const &table_id, TableView view=SCHEMA_VIEW)
Get information about a single table.
StatusOr< google::iam::v1::Policy > SetIamPolicy(std::string const &table_id, google::iam::v1::Policy const &iam_policy)
Sets the IAM policy for a table.
StatusOr< std::string > GenerateConsistencyToken(std::string const &table_id)
Generates consistency token for a table.
Status DropAllRows(std::string const &table_id)
Delete all the rows in a table.
StatusOr< google::bigtable::admin::v2::Table > RestoreTable(RestoreTableParams const &params)
Restore a backup into a new table in the instance.
std::string ClusterName(std::string const &cluster_id) const
Return the fully qualified name of a Cluster.
Definition: table_admin.h:1049
TableAdmin WithNewTarget(std::string project_id, std::string instance_id) const
Returns a TableAdmin that reuses the connection and configuration of this TableAdmin,...
Definition: table_admin.h:266
static auto constexpr FULL
Populate all the fields in the response.
Definition: table_admin.h:241
StatusOr<::google::bigtable::admin::v2::Table > ModifyColumnFamilies(std::string const &table_id, std::vector< ColumnFamilyModification > modifications)
Modify the schema for an existing table.
StatusOr< google::bigtable::admin::v2::Backup > GetBackup(std::string const &cluster_id, std::string const &backup_id)
Get information about a single backup.
static auto constexpr ENCRYPTION_VIEW
Only populate 'name' and fields related to the table's encryption state.
Definition: table_admin.h:238
google::cloud::future< StatusOr< Consistency > > WaitForConsistency(std::string const &table_id, std::string const &consistency_token)
Checks consistency of a table with multiple calls using a separate thread.
StatusOr< google::iam::v1::Policy > SetIamPolicy(std::string const &cluster_id, std::string const &backup_id, google::iam::v1::Policy const &iam_policy)
Sets the IAM policy for a backup.
TableAdmin(TableAdmin const &)=default
TableAdmin(std::shared_ptr< AdminClient > client, std::string instance_id)
Definition: table_admin.h:156
StatusOr< google::bigtable::admin::v2::Table > RestoreTable(RestoreTableFromInstanceParams params)
Restore a backup into a new table in the instance.
StatusOr< std::vector<::google::bigtable::admin::v2::Table > > ListTables(::google::bigtable::admin::v2::Table::View view)
Return all the tables in the instance.
StatusOr< std::vector< google::bigtable::admin::v2::Backup > > ListBackups(ListBackupsParams const &params)
Retrieves a list of backups.
Specify the initial schema for a new table.
Definition: table_config.h:30
The BigtableTableAdminConnection object for BigtableTableAdminClient.
Definition: bigtable_table_admin_connection.h:64
virtual Options options()
Definition: bigtable_table_admin_connection.h:68
friend friend class future
Definition: bigtable_instance_admin_client.h:35
Contains all the Cloud Bigtable C++ client APIs.
Definition: admin_client.h:28
Consistency
The result of checking replication against a given token.
Definition: table_admin.h:50
@ kConsistent
All mutations created before the consistency token have been received by all the table replicas.
@ kInconsistent
Some of the mutations created before the consistency token have not been received by all the table re...
std::string TableName(std::string const &project_id, std::string const &instance_id, std::string const &table_id)
std::unique_ptr< RPCBackoffPolicy > DefaultRPCBackoffPolicy(internal::RPCPolicyParameters defaults)
Return an instance of the default RPCBackoffPolicy.
std::string ClusterName(std::string const &project_id, std::string const &instance_id, std::string const &cluster_id)
std::unique_ptr< RPCRetryPolicy > DefaultRPCRetryPolicy(internal::RPCPolicyParameters defaults)
Return an instance of the default RPCRetryPolicy.
std::unique_ptr< PollingPolicy > DefaultPollingPolicy(internal::RPCPolicyParameters defaults)
std::string BackupName(std::string const &project_id, std::string const &instance_id, std::string const &cluster_id, std::string const &backup_id)
Parameters for CreateBackup.
Definition: table_admin.h:394
std::chrono::system_clock::time_point expire_time
Definition: table_admin.h:410
google::bigtable::admin::v2::CreateBackupRequest AsProto(std::string instance_name) const
std::string cluster_id
Definition: table_admin.h:407
CreateBackupParams(std::string cluster_id, std::string backup_id, std::string table_id, std::chrono::system_clock::time_point expire_time)
Definition: table_admin.h:396
std::string backup_id
Definition: table_admin.h:408
std::string table_name
Definition: table_admin.h:409
Parameters for ListBackups.
Definition: table_admin.h:562
ListBackupsParams & set_filter(std::string f)
Sets the filtering expression.
Definition: table_admin.h:616
absl::optional< std::string > cluster_id
Definition: table_admin.h:652
google::bigtable::admin::v2::ListBackupsRequest AsProto(std::string const &instance_name) const
ListBackupsParams & set_order_by(std::string o)
Sets the ordering expression.
Definition: table_admin.h:644
ListBackupsParams & set_cluster(std::string c)
Sets the cluster_id.
Definition: table_admin.h:573
absl::optional< std::string > order_by
Definition: table_admin.h:654
absl::optional< std::string > filter
Definition: table_admin.h:653
Parameters for RestoreTable.
Definition: table_admin.h:723
Parameters for RestoreTable.
Definition: table_admin.h:696
google::bigtable::admin::v2::RestoreTableRequest AsProto(std::string const &instance_name) const
RestoreTableParams(std::string table_id, std::string cluster_id, std::string backup_id)
Definition: table_admin.h:698
std::string table_id
Definition: table_admin.h:708
std::string cluster_id
Definition: table_admin.h:709
std::string backup_id
Definition: table_admin.h:710
Parameters for UpdateBackup.
Definition: table_admin.h:477
std::string cluster_id
Definition: table_admin.h:488
std::string backup_name
Definition: table_admin.h:489
UpdateBackupParams(std::string cluster_id, std::string backup_id, std::chrono::system_clock::time_point expire_time)
Definition: table_admin.h:479
std::chrono::system_clock::time_point expire_time
Definition: table_admin.h:490
google::bigtable::admin::v2::UpdateBackupRequest AsProto(std::string const &instance_name) const