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