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)]
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 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 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 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 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 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 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 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 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 #[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 #[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 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 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 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 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 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 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 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 #[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 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 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 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 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 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 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}