15#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_TABLE_ADMIN_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_TABLE_ADMIN_H
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"
42namespace bigtable_internal {
43GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
44class TableAdminTester;
45GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
48GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
150
151
152
153
154
156 TableAdmin(std::shared_ptr<AdminClient> client, std::string instance_id)
157 : connection_(client->connection_),
159 background_threads_(client->background_threads_),
161 instance_id_(std::move(instance_id)),
162 instance_name_(InstanceName()),
170 bigtable_internal::MakeTableAdminOptions(
171 retry_prototype_, backoff_prototype_, polling_prototype_),
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200 template <
typename... Policies>
202 TableAdmin(std::shared_ptr<AdminClient> client, std::string instance_id,
203 Policies&&... policies)
204 : connection_(client->connection_),
206 background_threads_(client->background_threads_),
208 instance_id_(std::move(instance_id)),
209 instance_name_(InstanceName()),
216 ChangePolicies(std::forward<Policies>(policies)...);
218 bigtable_internal::MakeTableAdminOptions(
219 retry_prototype_, backoff_prototype_, polling_prototype_),
227 return a.connection_ == b.connection_ &&
228 a.instance_name_ == b.instance_name_;
236 using TableView = ::
google::bigtable::admin::v2::Table::View;
239 google::bigtable::admin::v2::Table::ENCRYPTION_VIEW;
241 static auto constexpr FULL =
242 google::bigtable::admin::v2::Table::FULL;
245 google::bigtable::admin::v2::Table::NAME_ONLY;
249 google::bigtable::admin::v2::Table::REPLICATION_VIEW;
252 google::bigtable::admin::v2::Table::SCHEMA_VIEW;
255 google::bigtable::admin::v2::Table::VIEW_UNSPECIFIED;
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_; }
263
264
265
267 std::string instance_id)
const {
269 table.project_id_ = std::move(project_id);
270 table.instance_id_ = std::move(instance_id);
271 table.instance_name_ = table.InstanceName();
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
322 ::
google::bigtable::admin::v2::Table::View view);
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
349 std::string
const& table_id, TableView view =
SCHEMA_VIEW);
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
397 std::string table_id,
398 std::chrono::system_clock::time_point expire_time)
405 std::string instance_name)
const;
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
459 std::string
const& cluster_id, std::string
const& backup_id);
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
480 std::chrono::system_clock::time_point expire_time)
486 std::string
const& instance_name)
const;
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
539 std::string
const& backup_id);
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
560
561
564
565
566
567
568
569
570
571
572
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
650 std::string
const& instance_name)
const;
653 absl::optional<std::string>
filter;
654 absl::optional<std::string>
order_by;
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
699 std::string backup_id)
706 std::string
const& instance_name)
const;
714
715
716
717
718
719
720
721
722
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
786 std::string
const& table_id,
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
809 std::string row_key_prefix);
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
851 std::string
const& consistency_token);
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
873 std::string
const& table_id, std::string
const& consistency_token);
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
934 std::string
const& backup_id);
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
962 std::string
const& table_id,
google::iam::v1::Policy
const& iam_policy);
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
991 std::string
const& cluster_id, std::string
const& backup_id,
992 google::iam::v1::Policy
const& iam_policy);
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1015 std::string
const& table_id, std::vector<std::string>
const& permissions);
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1039 std::string
const& cluster_id, std::string
const& backup_id,
1040 std::vector<std::string>
const& permissions);
1043 std::string
TableName(std::string
const& table_id)
const {
1049 std::string
ClusterName(std::string
const& cluster_id)
const {
1055 std::string
BackupName(std::string
const& cluster_id,
1056 std::string
const& backup_id)
const {
1058 cluster_id
, backup_id
);
1062 friend class bigtable_internal::TableAdminTester;
1064 explicit TableAdmin(
1066 CompletionQueue cq, std::string project_id, std::string instance_id)
1067 : connection_(std::move(connection)),
1069 project_id_(std::move(project_id)),
1070 instance_id_(std::move(instance_id)),
1071 instance_name_(InstanceName()),
1079 bigtable_internal::MakeTableAdminOptions(
1080 retry_prototype_, backoff_prototype_, polling_prototype_),
1090 backoff_prototype_ = policy
.clone();
1094 polling_prototype_ = policy
.clone();
1097 template <
typename Policy,
typename... Policies>
1098 void ChangePolicies(Policy&& policy, Policies&&... policies) {
1099 ChangePolicy(policy);
1100 ChangePolicies(std::forward<Policies>(policies)...);
1102 void ChangePolicies() {}
1106 std::string InstanceName()
const;
1108 StatusOr<
google::iam::v1::Policy> GetIamPolicyImpl(std::string resource);
1110 StatusOr<
google::iam::v1::Policy> SetIamPolicyImpl(
1111 std::string resource,
google::iam::v1::Policy
const& iam_policy);
1113 StatusOr<std::vector<std::string>> TestIamPermissionsImpl(
1114 std::string resource, std::vector<std::string>
const& permissions);
1117 CompletionQueue cq_;
1119 std::string project_id_;
1120 std::string instance_id_;
1121 std::string instance_name_;
1132GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
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 ¶ms)
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 ¶ms)
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 ¶ms)
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 ¶ms)
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
CreateBackupParams()=default
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
std::string table_id
Definition: table_admin.h:724
std::string backup_name
Definition: table_admin.h:725
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
RestoreTableParams()=default
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()=default
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