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