google_cloud_api_servicecontrol_v1/builder.rs
1// Copyright 2025 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// Code generated by sidekick. DO NOT EDIT.
16
17pub mod quota_controller {
18 use crate::Result;
19
20 /// A builder for [QuotaController][crate::client::QuotaController].
21 ///
22 /// ```
23 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
24 /// # use google_cloud_api_servicecontrol_v1::*;
25 /// # use builder::quota_controller::ClientBuilder;
26 /// # use client::QuotaController;
27 /// let builder : ClientBuilder = QuotaController::builder();
28 /// let client = builder
29 /// .with_endpoint("https://servicecontrol.googleapis.com")
30 /// .build().await?;
31 /// # Ok(()) }
32 /// ```
33 pub type ClientBuilder = crate::ClientBuilder<client::Factory, gaxi::options::Credentials>;
34
35 pub(crate) mod client {
36 use super::super::super::client::QuotaController;
37 pub struct Factory;
38 impl crate::ClientFactory for Factory {
39 type Client = QuotaController;
40 type Credentials = gaxi::options::Credentials;
41 async fn build(
42 self,
43 config: gaxi::options::ClientConfig,
44 ) -> crate::ClientBuilderResult<Self::Client> {
45 Self::Client::new(config).await
46 }
47 }
48 }
49
50 /// Common implementation for [crate::client::QuotaController] request builders.
51 #[derive(Clone, Debug)]
52 pub(crate) struct RequestBuilder<R: std::default::Default> {
53 stub: std::sync::Arc<dyn super::super::stub::dynamic::QuotaController>,
54 request: R,
55 options: crate::RequestOptions,
56 }
57
58 impl<R> RequestBuilder<R>
59 where
60 R: std::default::Default,
61 {
62 pub(crate) fn new(
63 stub: std::sync::Arc<dyn super::super::stub::dynamic::QuotaController>,
64 ) -> Self {
65 Self {
66 stub,
67 request: R::default(),
68 options: crate::RequestOptions::default(),
69 }
70 }
71 }
72
73 /// The request builder for [QuotaController::allocate_quota][crate::client::QuotaController::allocate_quota] calls.
74 ///
75 /// # Example
76 /// ```
77 /// # use google_cloud_api_servicecontrol_v1::builder::quota_controller::AllocateQuota;
78 /// # async fn sample() -> google_cloud_api_servicecontrol_v1::Result<()> {
79 ///
80 /// let builder = prepare_request_builder();
81 /// let response = builder.send().await?;
82 /// # Ok(()) }
83 ///
84 /// fn prepare_request_builder() -> AllocateQuota {
85 /// # panic!();
86 /// // ... details omitted ...
87 /// }
88 /// ```
89 #[derive(Clone, Debug)]
90 pub struct AllocateQuota(RequestBuilder<crate::model::AllocateQuotaRequest>);
91
92 impl AllocateQuota {
93 pub(crate) fn new(
94 stub: std::sync::Arc<dyn super::super::stub::dynamic::QuotaController>,
95 ) -> Self {
96 Self(RequestBuilder::new(stub))
97 }
98
99 /// Sets the full request, replacing any prior values.
100 pub fn with_request<V: Into<crate::model::AllocateQuotaRequest>>(mut self, v: V) -> Self {
101 self.0.request = v.into();
102 self
103 }
104
105 /// Sets all the options, replacing any prior values.
106 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
107 self.0.options = v.into();
108 self
109 }
110
111 /// Sends the request.
112 pub async fn send(self) -> Result<crate::model::AllocateQuotaResponse> {
113 (*self.0.stub)
114 .allocate_quota(self.0.request, self.0.options)
115 .await
116 .map(crate::Response::into_body)
117 }
118
119 /// Sets the value of [service_name][crate::model::AllocateQuotaRequest::service_name].
120 pub fn set_service_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
121 self.0.request.service_name = v.into();
122 self
123 }
124
125 /// Sets the value of [allocate_operation][crate::model::AllocateQuotaRequest::allocate_operation].
126 pub fn set_allocate_operation<T>(mut self, v: T) -> Self
127 where
128 T: std::convert::Into<crate::model::QuotaOperation>,
129 {
130 self.0.request.allocate_operation = std::option::Option::Some(v.into());
131 self
132 }
133
134 /// Sets or clears the value of [allocate_operation][crate::model::AllocateQuotaRequest::allocate_operation].
135 pub fn set_or_clear_allocate_operation<T>(mut self, v: std::option::Option<T>) -> Self
136 where
137 T: std::convert::Into<crate::model::QuotaOperation>,
138 {
139 self.0.request.allocate_operation = v.map(|x| x.into());
140 self
141 }
142
143 /// Sets the value of [service_config_id][crate::model::AllocateQuotaRequest::service_config_id].
144 pub fn set_service_config_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
145 self.0.request.service_config_id = v.into();
146 self
147 }
148 }
149
150 #[doc(hidden)]
151 impl crate::RequestBuilder for AllocateQuota {
152 fn request_options(&mut self) -> &mut crate::RequestOptions {
153 &mut self.0.options
154 }
155 }
156}
157
158pub mod service_controller {
159 use crate::Result;
160
161 /// A builder for [ServiceController][crate::client::ServiceController].
162 ///
163 /// ```
164 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
165 /// # use google_cloud_api_servicecontrol_v1::*;
166 /// # use builder::service_controller::ClientBuilder;
167 /// # use client::ServiceController;
168 /// let builder : ClientBuilder = ServiceController::builder();
169 /// let client = builder
170 /// .with_endpoint("https://servicecontrol.googleapis.com")
171 /// .build().await?;
172 /// # Ok(()) }
173 /// ```
174 pub type ClientBuilder = crate::ClientBuilder<client::Factory, gaxi::options::Credentials>;
175
176 pub(crate) mod client {
177 use super::super::super::client::ServiceController;
178 pub struct Factory;
179 impl crate::ClientFactory for Factory {
180 type Client = ServiceController;
181 type Credentials = gaxi::options::Credentials;
182 async fn build(
183 self,
184 config: gaxi::options::ClientConfig,
185 ) -> crate::ClientBuilderResult<Self::Client> {
186 Self::Client::new(config).await
187 }
188 }
189 }
190
191 /// Common implementation for [crate::client::ServiceController] request builders.
192 #[derive(Clone, Debug)]
193 pub(crate) struct RequestBuilder<R: std::default::Default> {
194 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceController>,
195 request: R,
196 options: crate::RequestOptions,
197 }
198
199 impl<R> RequestBuilder<R>
200 where
201 R: std::default::Default,
202 {
203 pub(crate) fn new(
204 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceController>,
205 ) -> Self {
206 Self {
207 stub,
208 request: R::default(),
209 options: crate::RequestOptions::default(),
210 }
211 }
212 }
213
214 /// The request builder for [ServiceController::check][crate::client::ServiceController::check] calls.
215 ///
216 /// # Example
217 /// ```
218 /// # use google_cloud_api_servicecontrol_v1::builder::service_controller::Check;
219 /// # async fn sample() -> google_cloud_api_servicecontrol_v1::Result<()> {
220 ///
221 /// let builder = prepare_request_builder();
222 /// let response = builder.send().await?;
223 /// # Ok(()) }
224 ///
225 /// fn prepare_request_builder() -> Check {
226 /// # panic!();
227 /// // ... details omitted ...
228 /// }
229 /// ```
230 #[derive(Clone, Debug)]
231 pub struct Check(RequestBuilder<crate::model::CheckRequest>);
232
233 impl Check {
234 pub(crate) fn new(
235 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceController>,
236 ) -> Self {
237 Self(RequestBuilder::new(stub))
238 }
239
240 /// Sets the full request, replacing any prior values.
241 pub fn with_request<V: Into<crate::model::CheckRequest>>(mut self, v: V) -> Self {
242 self.0.request = v.into();
243 self
244 }
245
246 /// Sets all the options, replacing any prior values.
247 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
248 self.0.options = v.into();
249 self
250 }
251
252 /// Sends the request.
253 pub async fn send(self) -> Result<crate::model::CheckResponse> {
254 (*self.0.stub)
255 .check(self.0.request, self.0.options)
256 .await
257 .map(crate::Response::into_body)
258 }
259
260 /// Sets the value of [service_name][crate::model::CheckRequest::service_name].
261 pub fn set_service_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
262 self.0.request.service_name = v.into();
263 self
264 }
265
266 /// Sets the value of [operation][crate::model::CheckRequest::operation].
267 pub fn set_operation<T>(mut self, v: T) -> Self
268 where
269 T: std::convert::Into<crate::model::Operation>,
270 {
271 self.0.request.operation = std::option::Option::Some(v.into());
272 self
273 }
274
275 /// Sets or clears the value of [operation][crate::model::CheckRequest::operation].
276 pub fn set_or_clear_operation<T>(mut self, v: std::option::Option<T>) -> Self
277 where
278 T: std::convert::Into<crate::model::Operation>,
279 {
280 self.0.request.operation = v.map(|x| x.into());
281 self
282 }
283
284 /// Sets the value of [service_config_id][crate::model::CheckRequest::service_config_id].
285 pub fn set_service_config_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
286 self.0.request.service_config_id = v.into();
287 self
288 }
289 }
290
291 #[doc(hidden)]
292 impl crate::RequestBuilder for Check {
293 fn request_options(&mut self) -> &mut crate::RequestOptions {
294 &mut self.0.options
295 }
296 }
297
298 /// The request builder for [ServiceController::report][crate::client::ServiceController::report] calls.
299 ///
300 /// # Example
301 /// ```
302 /// # use google_cloud_api_servicecontrol_v1::builder::service_controller::Report;
303 /// # async fn sample() -> google_cloud_api_servicecontrol_v1::Result<()> {
304 ///
305 /// let builder = prepare_request_builder();
306 /// let response = builder.send().await?;
307 /// # Ok(()) }
308 ///
309 /// fn prepare_request_builder() -> Report {
310 /// # panic!();
311 /// // ... details omitted ...
312 /// }
313 /// ```
314 #[derive(Clone, Debug)]
315 pub struct Report(RequestBuilder<crate::model::ReportRequest>);
316
317 impl Report {
318 pub(crate) fn new(
319 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceController>,
320 ) -> Self {
321 Self(RequestBuilder::new(stub))
322 }
323
324 /// Sets the full request, replacing any prior values.
325 pub fn with_request<V: Into<crate::model::ReportRequest>>(mut self, v: V) -> Self {
326 self.0.request = v.into();
327 self
328 }
329
330 /// Sets all the options, replacing any prior values.
331 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
332 self.0.options = v.into();
333 self
334 }
335
336 /// Sends the request.
337 pub async fn send(self) -> Result<crate::model::ReportResponse> {
338 (*self.0.stub)
339 .report(self.0.request, self.0.options)
340 .await
341 .map(crate::Response::into_body)
342 }
343
344 /// Sets the value of [service_name][crate::model::ReportRequest::service_name].
345 pub fn set_service_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
346 self.0.request.service_name = v.into();
347 self
348 }
349
350 /// Sets the value of [operations][crate::model::ReportRequest::operations].
351 pub fn set_operations<T, V>(mut self, v: T) -> Self
352 where
353 T: std::iter::IntoIterator<Item = V>,
354 V: std::convert::Into<crate::model::Operation>,
355 {
356 use std::iter::Iterator;
357 self.0.request.operations = v.into_iter().map(|i| i.into()).collect();
358 self
359 }
360
361 /// Sets the value of [service_config_id][crate::model::ReportRequest::service_config_id].
362 pub fn set_service_config_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
363 self.0.request.service_config_id = v.into();
364 self
365 }
366 }
367
368 #[doc(hidden)]
369 impl crate::RequestBuilder for Report {
370 fn request_options(&mut self) -> &mut crate::RequestOptions {
371 &mut self.0.options
372 }
373 }
374}