google_cloud_api_servicecontrol_v1/
builder.rs1pub mod quota_controller {
18 use crate::Result;
19
20 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 #[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 #[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 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 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 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 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 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 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 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 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 #[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 #[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 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 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 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 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 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 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 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 #[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 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 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 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 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 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 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}