Google Cloud Bigtable C++ Client  2.1.0
A C++ Client Library for Google Cloud Bigtable
admin_client.h
Go to the documentation of this file.
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_ADMIN_CLIENT_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_ADMIN_CLIENT_H
17 
18 #include "google/cloud/bigtable/admin/bigtable_table_admin_connection.h"
19 #include "google/cloud/bigtable/client_options.h"
20 #include "google/cloud/bigtable/internal/admin_client_params.h"
21 #include "google/cloud/bigtable/version.h"
22 #include "google/cloud/options.h"
23 #include <memory>
24 #include <string>
25 
26 namespace google {
27 namespace cloud {
28 namespace bigtable {
30 
31 /**
32  * Creates a `bigtable_admin::BigtableTableAdminConnection` and a
33  * `CompletionQueue` for `bigtable::TableAdmin` to use.
34  *
35  * This class is used to initiate a connection to the Cloud Bigtable Table
36  * Admin service. It is maintained only for backwards compatibility.
37  *
38  * @note Please prefer using `bigtable_admin::BigtableTableAdminConnection` to
39  * configure `bigtable_admin::BigtableTableAdminClient`, instead of using
40  * this class to configure `bigtable::TableAdmin`.
41  */
42 class AdminClient final {
43  public:
44  /// The project id that this AdminClient works on.
45  std::string const& project() { return project_; };
46 
47  private:
48  friend class TableAdmin;
49  friend std::shared_ptr<AdminClient> MakeAdminClient(std::string, Options);
50 
51  AdminClient(std::string project, bigtable_internal::AdminClientParams params)
52  : project_(std::move(project)),
53  cq_(params.options.get<GrpcCompletionQueueOption>()),
54  background_threads_(std::move(params.background_threads)),
56  std::move(params.options))) {}
57 
58  std::string project_;
59  CompletionQueue cq_;
60  std::shared_ptr<BackgroundThreads> background_threads_;
61  std::shared_ptr<bigtable_admin::BigtableTableAdminConnection> connection_;
62 };
63 
64 /// Create a new table admin client configured via @p options.
65 std::shared_ptr<AdminClient> MakeAdminClient(std::string project,
66  Options options = {});
67 
68 /**
69  * Create a new table admin client configured via @p options.
70  *
71  * @deprecated use the `MakeAdminClient` method which accepts
72  * `google::cloud::Options` instead.
73  */
74 GOOGLE_CLOUD_CPP_DEPRECATED("use `MakeAdminClient` instead")
75 std::shared_ptr<AdminClient> CreateDefaultAdminClient(std::string project,
76  ClientOptions options);
77 
79 } // namespace bigtable
80 } // namespace cloud
81 } // namespace google
82 
83 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_ADMIN_CLIENT_H