Google Cloud IAM C++ Client 2.13.0
A C++ Client Library for Google Cloud IAM
Loading...
Searching...
No Matches
iam_policy_client.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// Generated by the Codegen C++ plugin.
16// If you make any local changes, they will be lost.
17// source: google/iam/v1/iam_policy.proto
18
19#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V1_IAM_POLICY_CLIENT_H
20#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V1_IAM_POLICY_CLIENT_H
21
22#include "google/cloud/iam/v1/iam_policy_connection.h"
23#include "google/cloud/future.h"
24#include "google/cloud/options.h"
25#include "google/cloud/polling_policy.h"
26#include "google/cloud/status_or.h"
27#include "google/cloud/version.h"
28#include <memory>
29
30namespace google {
31namespace cloud {
32namespace iam_v1 {
33GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
34
35///
36/// API Overview
37///
38///
39/// Manages Identity and Access Management (IAM) policies.
40///
41/// Any implementation of an API that offers access control features
42/// implements the google.iam.v1.IAMPolicy interface.
43///
44/// ## Data model
45///
46/// Access control is applied when a principal (user or service account), takes
47/// some action on a resource exposed by a service. Resources, identified by
48/// URI-like names, are the unit of access control specification. Service
49/// implementations can choose the granularity of access control and the
50/// supported permissions for their resources.
51/// For example one database service may allow access control to be
52/// specified only at the Table level, whereas another might allow access
53/// control to also be specified at the Column level.
54///
55/// ## Policy Structure
56///
57/// See google.iam.v1.Policy
58///
59/// This is intentionally not a CRUD style API because access control policies
60/// are created and deleted implicitly with the resources to which they are
61/// attached.
62///
63/// @par Equality
64///
65/// Instances of this class created via copy-construction or copy-assignment
66/// always compare equal. Instances created with equal
67/// `std::shared_ptr<*Connection>` objects compare equal. Objects that compare
68/// equal share the same underlying resources.
69///
70/// @par Performance
71///
72/// Creating a new instance of this class is a relatively expensive operation,
73/// new objects establish new connections to the service. In contrast,
74/// copy-construction, move-construction, and the corresponding assignment
75/// operations are relatively efficient as the copies share all underlying
76/// resources.
77///
78/// @par Thread Safety
79///
80/// Concurrent access to different instances of this class, even if they compare
81/// equal, is guaranteed to work. Two or more threads operating on the same
82/// instance of this class is not guaranteed to work. Since copy-construction
83/// and move-construction is a relatively efficient operation, consider using
84/// such a copy when using this class from multiple threads.
85///
86class IAMPolicyClient {
87 public:
88 explicit IAMPolicyClient(std::shared_ptr<IAMPolicyConnection> connection,
89 Options opts = {});
91
92 ///@{
93 /// @name Copy and move support
94 IAMPolicyClient(IAMPolicyClient const&) = default;
95 IAMPolicyClient& operator=(IAMPolicyClient const&) = default;
98 ///@}
99
100 ///@{
101 /// @name Equality
102 friend bool operator==(IAMPolicyClient const& a, IAMPolicyClient const& b) {
103 return a.connection_ == b.connection_;
104 }
105 friend bool operator!=(IAMPolicyClient const& a, IAMPolicyClient const& b) {
106 return !(a == b);
107 }
108 ///@}
109
110 // clang-format off
111 ///
112 /// Sets the access control policy on the specified resource. Replaces any
113 /// existing policy.
114 ///
115 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
116 ///
117 /// @param request Unary RPCs, such as the one wrapped by this
118 /// function, receive a single `request` proto message which includes all
119 /// the inputs for the RPC. In this case, the proto message is a
120 /// [google.iam.v1.SetIamPolicyRequest].
121 /// Proto messages are converted to C++ classes by Protobuf, using the
122 /// [Protobuf mapping rules].
123 /// @param opts Optional. Override the class-level options, such as retry and
124 /// backoff policies.
125 /// @return the result of the RPC. The response message type
126 /// ([google.iam.v1.Policy])
127 /// is mapped to a C++ class using the [Protobuf mapping rules].
128 /// If the request fails, the [`StatusOr`] contains the error details.
129 ///
130 /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/
131 /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator
132 /// [Long Running Operation]: https://google.aip.dev/151
133 /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string
134 /// [`future`]: @ref google::cloud::future
135 /// [`StatusOr`]: @ref google::cloud::StatusOr
136 /// [`Status`]: @ref google::cloud::Status
137 /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L98}
138 /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101}
139 ///
140 // clang-format on
141 StatusOr<google::iam::v1::Policy> SetIamPolicy(
142 google::iam::v1::SetIamPolicyRequest const& request, Options opts = {});
143
144 // clang-format off
145 ///
146 /// Gets the access control policy for a resource.
147 /// Returns an empty policy if the resource exists and does not have a policy
148 /// set.
149 ///
150 /// @param request Unary RPCs, such as the one wrapped by this
151 /// function, receive a single `request` proto message which includes all
152 /// the inputs for the RPC. In this case, the proto message is a
153 /// [google.iam.v1.GetIamPolicyRequest].
154 /// Proto messages are converted to C++ classes by Protobuf, using the
155 /// [Protobuf mapping rules].
156 /// @param opts Optional. Override the class-level options, such as retry and
157 /// backoff policies.
158 /// @return the result of the RPC. The response message type
159 /// ([google.iam.v1.Policy])
160 /// is mapped to a C++ class using the [Protobuf mapping rules].
161 /// If the request fails, the [`StatusOr`] contains the error details.
162 ///
163 /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/
164 /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator
165 /// [Long Running Operation]: https://google.aip.dev/151
166 /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string
167 /// [`future`]: @ref google::cloud::future
168 /// [`StatusOr`]: @ref google::cloud::StatusOr
169 /// [`Status`]: @ref google::cloud::Status
170 /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123}
171 /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L98}
172 ///
173 // clang-format on
174 StatusOr<google::iam::v1::Policy> GetIamPolicy(
175 google::iam::v1::GetIamPolicyRequest const& request, Options opts = {});
176
177 // clang-format off
178 ///
179 /// Returns permissions that a caller has on the specified resource.
180 /// If the resource does not exist, this will return an empty set of
181 /// permissions, not a `NOT_FOUND` error.
182 ///
183 /// Note: This operation is designed to be used for building permission-aware
184 /// UIs and command-line tools, not for authorization checking. This operation
185 /// may "fail open" without warning.
186 ///
187 /// @param request Unary RPCs, such as the one wrapped by this
188 /// function, receive a single `request` proto message which includes all
189 /// the inputs for the RPC. In this case, the proto message is a
190 /// [google.iam.v1.TestIamPermissionsRequest].
191 /// Proto messages are converted to C++ classes by Protobuf, using the
192 /// [Protobuf mapping rules].
193 /// @param opts Optional. Override the class-level options, such as retry and
194 /// backoff policies.
195 /// @return the result of the RPC. The response message type
196 /// ([google.iam.v1.TestIamPermissionsResponse])
197 /// is mapped to a C++ class using the [Protobuf mapping rules].
198 /// If the request fails, the [`StatusOr`] contains the error details.
199 ///
200 /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/
201 /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator
202 /// [Long Running Operation]: https://google.aip.dev/151
203 /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string
204 /// [`future`]: @ref google::cloud::future
205 /// [`StatusOr`]: @ref google::cloud::StatusOr
206 /// [`Status`]: @ref google::cloud::Status
207 /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136}
208 /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151}
209 ///
210 // clang-format on
211 StatusOr<google::iam::v1::TestIamPermissionsResponse> TestIamPermissions(
212 google::iam::v1::TestIamPermissionsRequest const& request,
213 Options opts = {});
214
215 private:
216 std::shared_ptr<IAMPolicyConnection> connection_;
217 Options options_;
218};
219
220GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
221} // namespace iam_v1
222} // namespace cloud
223} // namespace google
224
225#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V1_IAM_POLICY_CLIENT_H
API Overview.
Definition: iam_policy_client.h:86
IAMPolicyClient & operator=(IAMPolicyClient const &)=default
StatusOr< google::iam::v1::Policy > GetIamPolicy(google::iam::v1::GetIamPolicyRequest const &request, Options opts={})
Gets the access control policy for a resource.
IAMPolicyClient(IAMPolicyClient &&)=default
IAMPolicyClient(IAMPolicyClient const &)=default
IAMPolicyClient(std::shared_ptr< IAMPolicyConnection > connection, Options opts={})
StatusOr< google::iam::v1::Policy > SetIamPolicy(google::iam::v1::SetIamPolicyRequest const &request, Options opts={})
Sets the access control policy on the specified resource.
friend bool operator!=(IAMPolicyClient const &a, IAMPolicyClient const &b)
Definition: iam_policy_client.h:105
friend bool operator==(IAMPolicyClient const &a, IAMPolicyClient const &b)
Definition: iam_policy_client.h:102
IAMPolicyClient & operator=(IAMPolicyClient &&)=default
StatusOr< google::iam::v1::TestIamPermissionsResponse > TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const &request, Options opts={})
Returns permissions that a caller has on the specified resource.
The IAMPolicyConnection object for IAMPolicyClient.
Definition: iam_policy_connection.h:59
Definition: iam_policy_client.h:32