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