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