Resource Settings API C++ Client 2.13.0
A C++ Client Library for the Resource Settings API
Loading...
Searching...
No Matches
resource_settings_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/cloud/resourcesettings/v1/resource_settings.proto
18
19#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_RESOURCESETTINGS_V1_RESOURCE_SETTINGS_CLIENT_H
20#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_RESOURCESETTINGS_V1_RESOURCE_SETTINGS_CLIENT_H
21
22#include "google/cloud/resourcesettings/v1/resource_settings_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 resourcesettings_v1 {
33GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
34
35///
36/// An interface to interact with resource settings and setting values
37/// throughout the resource hierarchy.
38///
39/// Services may surface a number of settings for users to control how their
40/// resources behave. Values of settings applied on a given Cloud resource are
41/// evaluated hierarchically and inherited by all descendants of that resource.
42///
43/// For all requests, returns a `google.rpc.Status` with
44/// `google.rpc.Code.PERMISSION_DENIED` if the IAM check fails or the `parent`
45/// resource is not in a Cloud Organization.
46/// For all requests, returns a `google.rpc.Status` with
47/// `google.rpc.Code.INVALID_ARGUMENT` if the request is malformed.
48///
49/// @par Equality
50///
51/// Instances of this class created via copy-construction or copy-assignment
52/// always compare equal. Instances created with equal
53/// `std::shared_ptr<*Connection>` objects compare equal. Objects that compare
54/// equal share the same underlying resources.
55///
56/// @par Performance
57///
58/// Creating a new instance of this class is a relatively expensive operation,
59/// new objects establish new connections to the service. In contrast,
60/// copy-construction, move-construction, and the corresponding assignment
61/// operations are relatively efficient as the copies share all underlying
62/// resources.
63///
64/// @par Thread Safety
65///
66/// Concurrent access to different instances of this class, even if they compare
67/// equal, is guaranteed to work. Two or more threads operating on the same
68/// instance of this class is not guaranteed to work. Since copy-construction
69/// and move-construction is a relatively efficient operation, consider using
70/// such a copy when using this class from multiple threads.
71///
73 public:
75 std::shared_ptr<ResourceSettingsServiceConnection> connection,
76 Options opts = {});
78
79 ///@{
80 /// @name Copy and move support
83 ResourceSettingsServiceClient const&) = default;
86 default;
87 ///@}
88
89 ///@{
90 /// @name Equality
91 friend bool operator==(ResourceSettingsServiceClient const& a,
93 return a.connection_ == b.connection_;
94 }
95 friend bool operator!=(ResourceSettingsServiceClient const& a,
97 return !(a == b);
98 }
99 ///@}
100
101 // clang-format off
102 ///
103 /// Lists all the settings that are available on the Cloud resource `parent`.
104 ///
105 /// @param parent Required. The Cloud resource that parents the setting. Must be in one of the
106 /// following forms:
107 /// @n
108 /// * `projects/{project_number}`
109 /// * `projects/{project_id}`
110 /// * `folders/{folder_id}`
111 /// * `organizations/{organization_id}`
112 /// @param opts Optional. Override the class-level options, such as retry and
113 /// backoff policies.
114 /// @return a [StreamRange](@ref google::cloud::StreamRange)
115 /// to iterate of the results. See the documentation of this type for
116 /// details. In brief, this class has `begin()` and `end()` member
117 /// functions returning a iterator class meeting the
118 /// [input iterator requirements]. The value type for this iterator is a
119 /// [`StatusOr`] as the iteration may fail even after some values are
120 /// retrieved successfully, for example, if there is a network disconnect.
121 /// An empty set of results does not indicate an error, it indicates
122 /// that there are no resources meeting the request criteria.
123 /// On a successful iteration the `StatusOr<T>` contains elements of type
124 /// [google.cloud.resourcesettings.v1.Setting], or rather,
125 /// the C++ class generated by Protobuf from that type. Please consult the
126 /// Protobuf documentation for details on the [Protobuf mapping rules].
127 ///
128 /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/
129 /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator
130 /// [Long Running Operation]: https://google.aip.dev/151
131 /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string
132 /// [`future`]: @ref google::cloud::future
133 /// [`StatusOr`]: @ref google::cloud::StatusOr
134 /// [`Status`]: @ref google::cloud::Status
135 /// [google.cloud.resourcesettings.v1.ListSettingsRequest]: @googleapis_reference_link{google/cloud/resourcesettings/v1/resource_settings.proto#L238}
136 /// [google.cloud.resourcesettings.v1.Setting]: @googleapis_reference_link{google/cloud/resourcesettings/v1/resource_settings.proto#L115}
137 ///
138 // clang-format on
139 StreamRange<google::cloud::resourcesettings::v1::Setting> ListSettings(
140 std::string const& parent, Options opts = {});
141
142 // clang-format off
143 ///
144 /// Lists all the settings that are available on the Cloud resource `parent`.
145 ///
146 /// @param request Unary RPCs, such as the one wrapped by this
147 /// function, receive a single `request` proto message which includes all
148 /// the inputs for the RPC. In this case, the proto message is a
149 /// [google.cloud.resourcesettings.v1.ListSettingsRequest].
150 /// Proto messages are converted to C++ classes by Protobuf, using the
151 /// [Protobuf mapping rules].
152 /// @param opts Optional. Override the class-level options, such as retry and
153 /// backoff policies.
154 /// @return a [StreamRange](@ref google::cloud::StreamRange)
155 /// to iterate of the results. See the documentation of this type for
156 /// details. In brief, this class has `begin()` and `end()` member
157 /// functions returning a iterator class meeting the
158 /// [input iterator requirements]. The value type for this iterator is a
159 /// [`StatusOr`] as the iteration may fail even after some values are
160 /// retrieved successfully, for example, if there is a network disconnect.
161 /// An empty set of results does not indicate an error, it indicates
162 /// that there are no resources meeting the request criteria.
163 /// On a successful iteration the `StatusOr<T>` contains elements of type
164 /// [google.cloud.resourcesettings.v1.Setting], or rather,
165 /// the C++ class generated by Protobuf from that type. Please consult the
166 /// Protobuf documentation for details on the [Protobuf mapping rules].
167 ///
168 /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/
169 /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator
170 /// [Long Running Operation]: https://google.aip.dev/151
171 /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string
172 /// [`future`]: @ref google::cloud::future
173 /// [`StatusOr`]: @ref google::cloud::StatusOr
174 /// [`Status`]: @ref google::cloud::Status
175 /// [google.cloud.resourcesettings.v1.ListSettingsRequest]: @googleapis_reference_link{google/cloud/resourcesettings/v1/resource_settings.proto#L238}
176 /// [google.cloud.resourcesettings.v1.Setting]: @googleapis_reference_link{google/cloud/resourcesettings/v1/resource_settings.proto#L115}
177 ///
178 // clang-format on
179 StreamRange<google::cloud::resourcesettings::v1::Setting> ListSettings(
180 google::cloud::resourcesettings::v1::ListSettingsRequest request,
181 Options opts = {});
182
183 // clang-format off
184 ///
185 /// Gets a setting.
186 ///
187 /// Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
188 /// setting does not exist.
189 ///
190 /// @param name Required. The name of the setting to get. See [Setting][google.cloud.resourcesettings.v1.Setting] for naming
191 /// requirements.
192 /// @param opts Optional. Override the class-level options, such as retry and
193 /// backoff policies.
194 /// @return the result of the RPC. The response message type
195 /// ([google.cloud.resourcesettings.v1.Setting])
196 /// is mapped to a C++ class using the [Protobuf mapping rules].
197 /// If the request fails, the [`StatusOr`] contains the error details.
198 ///
199 /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/
200 /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator
201 /// [Long Running Operation]: https://google.aip.dev/151
202 /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string
203 /// [`future`]: @ref google::cloud::future
204 /// [`StatusOr`]: @ref google::cloud::StatusOr
205 /// [`Status`]: @ref google::cloud::Status
206 /// [google.cloud.resourcesettings.v1.GetSettingRequest]: @googleapis_reference_link{google/cloud/resourcesettings/v1/resource_settings.proto#L273}
207 /// [google.cloud.resourcesettings.v1.Setting]: @googleapis_reference_link{google/cloud/resourcesettings/v1/resource_settings.proto#L115}
208 ///
209 // clang-format on
210 StatusOr<google::cloud::resourcesettings::v1::Setting> GetSetting(
211 std::string const& name, Options opts = {});
212
213 // clang-format off
214 ///
215 /// Gets a setting.
216 ///
217 /// Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
218 /// setting does not exist.
219 ///
220 /// @param request Unary RPCs, such as the one wrapped by this
221 /// function, receive a single `request` proto message which includes all
222 /// the inputs for the RPC. In this case, the proto message is a
223 /// [google.cloud.resourcesettings.v1.GetSettingRequest].
224 /// Proto messages are converted to C++ classes by Protobuf, using the
225 /// [Protobuf mapping rules].
226 /// @param opts Optional. Override the class-level options, such as retry and
227 /// backoff policies.
228 /// @return the result of the RPC. The response message type
229 /// ([google.cloud.resourcesettings.v1.Setting])
230 /// is mapped to a C++ class using the [Protobuf mapping rules].
231 /// If the request fails, the [`StatusOr`] contains the error details.
232 ///
233 /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/
234 /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator
235 /// [Long Running Operation]: https://google.aip.dev/151
236 /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string
237 /// [`future`]: @ref google::cloud::future
238 /// [`StatusOr`]: @ref google::cloud::StatusOr
239 /// [`Status`]: @ref google::cloud::Status
240 /// [google.cloud.resourcesettings.v1.GetSettingRequest]: @googleapis_reference_link{google/cloud/resourcesettings/v1/resource_settings.proto#L273}
241 /// [google.cloud.resourcesettings.v1.Setting]: @googleapis_reference_link{google/cloud/resourcesettings/v1/resource_settings.proto#L115}
242 ///
243 // clang-format on
244 StatusOr<google::cloud::resourcesettings::v1::Setting> GetSetting(
245 google::cloud::resourcesettings::v1::GetSettingRequest const& request,
246 Options opts = {});
247
248 // clang-format off
249 ///
250 /// Updates a setting.
251 ///
252 /// Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
253 /// setting does not exist.
254 /// Returns a `google.rpc.Status` with `google.rpc.Code.FAILED_PRECONDITION` if
255 /// the setting is flagged as read only.
256 /// Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag
257 /// supplied in the request does not match the persisted etag of the setting
258 /// value.
259 ///
260 /// On success, the response will contain only `name`, `local_value` and
261 /// `etag`. The `metadata` and `effective_value` cannot be updated through
262 /// this API.
263 ///
264 /// Note: the supplied setting will perform a full overwrite of the
265 /// `local_value` field.
266 ///
267 /// @param request Unary RPCs, such as the one wrapped by this
268 /// function, receive a single `request` proto message which includes all
269 /// the inputs for the RPC. In this case, the proto message is a
270 /// [google.cloud.resourcesettings.v1.UpdateSettingRequest].
271 /// Proto messages are converted to C++ classes by Protobuf, using the
272 /// [Protobuf mapping rules].
273 /// @param opts Optional. Override the class-level options, such as retry and
274 /// backoff policies.
275 /// @return the result of the RPC. The response message type
276 /// ([google.cloud.resourcesettings.v1.Setting])
277 /// is mapped to a C++ class using the [Protobuf mapping rules].
278 /// If the request fails, the [`StatusOr`] contains the error details.
279 ///
280 /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/
281 /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator
282 /// [Long Running Operation]: https://google.aip.dev/151
283 /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string
284 /// [`future`]: @ref google::cloud::future
285 /// [`StatusOr`]: @ref google::cloud::StatusOr
286 /// [`Status`]: @ref google::cloud::Status
287 /// [google.cloud.resourcesettings.v1.Setting]: @googleapis_reference_link{google/cloud/resourcesettings/v1/resource_settings.proto#L115}
288 /// [google.cloud.resourcesettings.v1.UpdateSettingRequest]: @googleapis_reference_link{google/cloud/resourcesettings/v1/resource_settings.proto#L288}
289 ///
290 // clang-format on
291 StatusOr<google::cloud::resourcesettings::v1::Setting> UpdateSetting(
292 google::cloud::resourcesettings::v1::UpdateSettingRequest const& request,
293 Options opts = {});
294
295 private:
296 std::shared_ptr<ResourceSettingsServiceConnection> connection_;
297 Options options_;
298};
299
300GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
301} // namespace resourcesettings_v1
302} // namespace cloud
303} // namespace google
304
305#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_RESOURCESETTINGS_V1_RESOURCE_SETTINGS_CLIENT_H
An interface to interact with resource settings and setting values throughout the resource hierarchy.
Definition: resource_settings_client.h:72
ResourceSettingsServiceClient & operator=(ResourceSettingsServiceClient const &)=default
friend bool operator==(ResourceSettingsServiceClient const &a, ResourceSettingsServiceClient const &b)
Definition: resource_settings_client.h:91
ResourceSettingsServiceClient & operator=(ResourceSettingsServiceClient &&)=default
StatusOr< google::cloud::resourcesettings::v1::Setting > GetSetting(google::cloud::resourcesettings::v1::GetSettingRequest const &request, Options opts={})
Gets a setting.
StreamRange< google::cloud::resourcesettings::v1::Setting > ListSettings(google::cloud::resourcesettings::v1::ListSettingsRequest request, Options opts={})
Lists all the settings that are available on the Cloud resource parent.
StatusOr< google::cloud::resourcesettings::v1::Setting > GetSetting(std::string const &name, Options opts={})
Gets a setting.
ResourceSettingsServiceClient(ResourceSettingsServiceClient &&)=default
StreamRange< google::cloud::resourcesettings::v1::Setting > ListSettings(std::string const &parent, Options opts={})
Lists all the settings that are available on the Cloud resource parent.
friend bool operator!=(ResourceSettingsServiceClient const &a, ResourceSettingsServiceClient const &b)
Definition: resource_settings_client.h:95
ResourceSettingsServiceClient(ResourceSettingsServiceClient const &)=default
ResourceSettingsServiceClient(std::shared_ptr< ResourceSettingsServiceConnection > connection, Options opts={})
StatusOr< google::cloud::resourcesettings::v1::Setting > UpdateSetting(google::cloud::resourcesettings::v1::UpdateSettingRequest const &request, Options opts={})
Updates a setting.
The ResourceSettingsServiceConnection object for ResourceSettingsServiceClient.
Definition: resource_settings_connection.h:63
Definition: resource_settings_client.h:32
Definition: resource_settings_client.h:30