Google Cloud Bigtable C++ Client 2.13.0
A C++ Client Library for Google Cloud Bigtable
Loading...
Searching...
No Matches
table_resource.h
1// Copyright 2022 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// 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_RESOURCE_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_TABLE_RESOURCE_H
17
18#include "google/cloud/bigtable/instance_resource.h"
19#include "google/cloud/bigtable/version.h"
20#include "google/cloud/status_or.h"
21#include <iosfwd>
22#include <string>
23
24namespace google {
25namespace cloud {
26namespace bigtable {
27GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
28
29/**
30 * This class identifies a Cloud Bigtable Table.
31 *
32 * Bigtable stores data in massively scalable tables, each of which is a sorted
33 * key/value map. A Cloud Bigtable table is identified by the instance it is
34 * contained in and its `table_id`.
35 *
36 * @note This class makes no effort to validate the components of the
37 * table name. It is the application's responsibility to provide valid
38 * project, instance, and table ids. Passing invalid values will not be
39 * checked until the table name is used in a RPC to Bigtable.
40 *
41 * @see https://cloud.google.com/bigtable/docs/overview for an overview of the
42 * Cloud Bigtable data model.
43 */
44class TableResource {
45 public:
46 /**
47 * Constructs a TableResource object identified by the given @p instance and
48 * @p table_id.
49 */
50 TableResource(InstanceResource instance, std::string table_id);
51
52 /**
53 * Constructs a TableResource object identified by the given IDs.
54 *
55 * This is equivalent to first constructing an `InstanceResource` from the
56 * given @p project_id and @p instance_id arguments and then calling the
57 * `TableResource(InstanceResource, std::string)` constructor.
58 */
59 TableResource(std::string project_id, std::string instance_id,
60 std::string table_id);
61
62 /// Returns the `InstanceResource` containing this table.
63 InstanceResource const& instance() const { return instance_; }
64
65 /// Returns the Table ID.
66 std::string const& table_id() const { return table_id_; }
67
68 /**
69 * Returns the fully qualified table name as a string of the form:
70 * "projects/<project-id>/instances/<instance-id>/tables/<table-id>"
71 */
72 std::string FullName() const;
73
74 /// @name Equality operators
75 ///@{
76 friend bool operator==(TableResource const& a, TableResource const& b);
77 friend bool operator!=(TableResource const& a, TableResource const& b);
78 ///@}
79
80 /// Output the `FullName()` format.
81 friend std::ostream& operator<<(std::ostream&, TableResource const&);
82
83 private:
84 InstanceResource instance_;
85 std::string table_id_;
86};
87
88/**
89 * Constructs a `TableResource` from the given @p full_name.
90 * Returns a non-OK Status if `full_name` is improperly formed.
91 */
92StatusOr<TableResource> MakeTableResource(std::string const& full_name);
93
94GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
95} // namespace bigtable
96} // namespace cloud
97} // namespace google
98
99#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_TABLE_RESOURCE_H
This class identifies a Cloud Bigtable Instance.
Definition: instance_resource.h:45
This class identifies a Cloud Bigtable Table.
Definition: table_resource.h:44
friend bool operator==(TableResource const &a, TableResource const &b)
TableResource(std::string project_id, std::string instance_id, std::string table_id)
Constructs a TableResource object identified by the given IDs.
std::string const & table_id() const
Returns the Table ID.
Definition: table_resource.h:66
std::string FullName() const
Returns the fully qualified table name as a string of the form: "projects/<project-id>/instances/<ins...
friend bool operator!=(TableResource const &a, TableResource const &b)
TableResource(InstanceResource instance, std::string table_id)
Constructs a TableResource object identified by the given instance and table_id.
InstanceResource const & instance() const
Returns the InstanceResource containing this table.
Definition: table_resource.h:63
Contains all the Cloud Bigtable C++ client APIs.
Definition: admin_client.h:28
StatusOr< TableResource > MakeTableResource(std::string const &full_name)
Constructs a TableResource from the given full_name.