Google Cloud Bigtable C++ Client 2.13.0
A C++ Client Library for Google Cloud Bigtable
Loading...
Searching...
No Matches
instance_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_INSTANCE_RESOURCE_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INSTANCE_RESOURCE_H
17
18#include "google/cloud/bigtable/version.h"
19#include "google/cloud/project.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 Instance.
31 *
32 * To use Cloud Bigtable, you create instances, which contain clusters that your
33 * applications can connect to. Each cluster contains nodes, the compute units
34 * that manage your data and perform maintenance tasks. A Cloud Bigtable
35 * instance is identified by its `project_id` and `instance_id`.
36 *
37 * @note This class makes no effort to validate the components of the
38 * instance name. It is the application's responsibility to provide valid
39 * project, and instance ids. Passing invalid values will not be checked
40 * until the instance name is used in an RPC to Bigtable.
41 *
42 * @see https://cloud.google.com/bigtable/docs/instances-clusters-nodes for an
43 * overview of Cloud Bigtable instances, clusters, and nodes.
44 */
45class InstanceResource {
46 public:
47 /**
48 * Constructs an InstanceResource object identified by the given @p project
49 * and @p instance_id.
50 */
51 InstanceResource(Project project, std::string instance_id);
52
53 /// Returns the `Project` containing this instance.
54 Project const& project() const { return project_; }
55 std::string const& project_id() const { return project_.project_id(); }
56
57 /// Returns the Instance ID.
58 std::string const& instance_id() const { return instance_id_; }
59
60 /**
61 * Returns the fully qualified instance name as a string of the form:
62 * "projects/<project-id>/instances/<instance-id>"
63 */
64 std::string FullName() const;
65
66 /// @name Equality operators
67 ///@{
68 friend bool operator==(InstanceResource const& a, InstanceResource const& b);
69 friend bool operator!=(InstanceResource const& a, InstanceResource const& b);
70 ///@}
71
72 /// Output the `FullName()` format.
73 friend std::ostream& operator<<(std::ostream&, InstanceResource const&);
74
75 private:
76 Project project_;
77 std::string instance_id_;
78};
79
80/**
81 * Constructs an `InstanceResource` from the given @p full_name.
82 * Returns a non-OK Status if `full_name` is improperly formed.
83 */
84StatusOr<InstanceResource> MakeInstanceResource(std::string const& full_name);
85
86GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
87} // namespace bigtable
88} // namespace cloud
89} // namespace google
90
91#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INSTANCE_RESOURCE_H
std::string const & project_id() const
This class identifies a Cloud Bigtable Instance.
Definition: instance_resource.h:45
friend bool operator==(InstanceResource const &a, InstanceResource const &b)
std::string FullName() const
Returns the fully qualified instance name as a string of the form: "projects/<project-id>/instances/<...
friend bool operator!=(InstanceResource const &a, InstanceResource const &b)
InstanceResource(Project project, std::string instance_id)
Constructs an InstanceResource object identified by the given project and instance_id.
Project const & project() const
Returns the Project containing this instance.
Definition: instance_resource.h:54
std::string const & instance_id() const
Returns the Instance ID.
Definition: instance_resource.h:58
std::string const & project_id() const
Definition: instance_resource.h:55
Contains all the Cloud Bigtable C++ client APIs.
Definition: admin_client.h:28
StatusOr< InstanceResource > MakeInstanceResource(std::string const &full_name)
Constructs an InstanceResource from the given full_name.