google_cloud_maintenance_api_v1/
builder.rs1pub mod maintenance {
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::Maintenance;
38 pub struct Factory;
39 impl gax::client_builder::internal::ClientFactory for Factory {
40 type Client = Maintenance;
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::Maintenance>,
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::Maintenance>,
65 ) -> Self {
66 Self {
67 stub,
68 request: R::default(),
69 options: gax::options::RequestOptions::default(),
70 }
71 }
72 }
73
74 #[derive(Clone, Debug)]
95 pub struct SummarizeMaintenances(RequestBuilder<crate::model::SummarizeMaintenancesRequest>);
96
97 impl SummarizeMaintenances {
98 pub(crate) fn new(
99 stub: std::sync::Arc<dyn super::super::stub::dynamic::Maintenance>,
100 ) -> Self {
101 Self(RequestBuilder::new(stub))
102 }
103
104 pub fn with_request<V: Into<crate::model::SummarizeMaintenancesRequest>>(
106 mut self,
107 v: V,
108 ) -> Self {
109 self.0.request = v.into();
110 self
111 }
112
113 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
115 self.0.options = v.into();
116 self
117 }
118
119 pub async fn send(self) -> Result<crate::model::SummarizeMaintenancesResponse> {
121 (*self.0.stub)
122 .summarize_maintenances(self.0.request, self.0.options)
123 .await
124 .map(gax::response::Response::into_body)
125 }
126
127 pub fn by_page(
129 self,
130 ) -> impl gax::paginator::Paginator<crate::model::SummarizeMaintenancesResponse, gax::error::Error>
131 {
132 use std::clone::Clone;
133 let token = self.0.request.page_token.clone();
134 let execute = move |token: String| {
135 let mut builder = self.clone();
136 builder.0.request = builder.0.request.set_page_token(token);
137 builder.send()
138 };
139 gax::paginator::internal::new_paginator(token, execute)
140 }
141
142 pub fn by_item(
144 self,
145 ) -> impl gax::paginator::ItemPaginator<
146 crate::model::SummarizeMaintenancesResponse,
147 gax::error::Error,
148 > {
149 use gax::paginator::Paginator;
150 self.by_page().items()
151 }
152
153 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
157 self.0.request.parent = v.into();
158 self
159 }
160
161 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
163 self.0.request.page_size = v.into();
164 self
165 }
166
167 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
169 self.0.request.page_token = v.into();
170 self
171 }
172
173 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
175 self.0.request.filter = v.into();
176 self
177 }
178
179 pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
181 self.0.request.order_by = v.into();
182 self
183 }
184 }
185
186 #[doc(hidden)]
187 impl gax::options::internal::RequestBuilder for SummarizeMaintenances {
188 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
189 &mut self.0.options
190 }
191 }
192
193 #[derive(Clone, Debug)]
214 pub struct ListResourceMaintenances(
215 RequestBuilder<crate::model::ListResourceMaintenancesRequest>,
216 );
217
218 impl ListResourceMaintenances {
219 pub(crate) fn new(
220 stub: std::sync::Arc<dyn super::super::stub::dynamic::Maintenance>,
221 ) -> Self {
222 Self(RequestBuilder::new(stub))
223 }
224
225 pub fn with_request<V: Into<crate::model::ListResourceMaintenancesRequest>>(
227 mut self,
228 v: V,
229 ) -> Self {
230 self.0.request = v.into();
231 self
232 }
233
234 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
236 self.0.options = v.into();
237 self
238 }
239
240 pub async fn send(self) -> Result<crate::model::ListResourceMaintenancesResponse> {
242 (*self.0.stub)
243 .list_resource_maintenances(self.0.request, self.0.options)
244 .await
245 .map(gax::response::Response::into_body)
246 }
247
248 pub fn by_page(
250 self,
251 ) -> impl gax::paginator::Paginator<
252 crate::model::ListResourceMaintenancesResponse,
253 gax::error::Error,
254 > {
255 use std::clone::Clone;
256 let token = self.0.request.page_token.clone();
257 let execute = move |token: String| {
258 let mut builder = self.clone();
259 builder.0.request = builder.0.request.set_page_token(token);
260 builder.send()
261 };
262 gax::paginator::internal::new_paginator(token, execute)
263 }
264
265 pub fn by_item(
267 self,
268 ) -> impl gax::paginator::ItemPaginator<
269 crate::model::ListResourceMaintenancesResponse,
270 gax::error::Error,
271 > {
272 use gax::paginator::Paginator;
273 self.by_page().items()
274 }
275
276 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
280 self.0.request.parent = v.into();
281 self
282 }
283
284 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
286 self.0.request.page_size = v.into();
287 self
288 }
289
290 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
292 self.0.request.page_token = v.into();
293 self
294 }
295
296 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
298 self.0.request.filter = v.into();
299 self
300 }
301
302 pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
304 self.0.request.order_by = v.into();
305 self
306 }
307 }
308
309 #[doc(hidden)]
310 impl gax::options::internal::RequestBuilder for ListResourceMaintenances {
311 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
312 &mut self.0.options
313 }
314 }
315
316 #[derive(Clone, Debug)]
333 pub struct GetResourceMaintenance(RequestBuilder<crate::model::GetResourceMaintenanceRequest>);
334
335 impl GetResourceMaintenance {
336 pub(crate) fn new(
337 stub: std::sync::Arc<dyn super::super::stub::dynamic::Maintenance>,
338 ) -> Self {
339 Self(RequestBuilder::new(stub))
340 }
341
342 pub fn with_request<V: Into<crate::model::GetResourceMaintenanceRequest>>(
344 mut self,
345 v: V,
346 ) -> Self {
347 self.0.request = v.into();
348 self
349 }
350
351 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
353 self.0.options = v.into();
354 self
355 }
356
357 pub async fn send(self) -> Result<crate::model::ResourceMaintenance> {
359 (*self.0.stub)
360 .get_resource_maintenance(self.0.request, self.0.options)
361 .await
362 .map(gax::response::Response::into_body)
363 }
364
365 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
369 self.0.request.name = v.into();
370 self
371 }
372 }
373
374 #[doc(hidden)]
375 impl gax::options::internal::RequestBuilder for GetResourceMaintenance {
376 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
377 &mut self.0.options
378 }
379 }
380
381 #[derive(Clone, Debug)]
402 pub struct ListLocations(RequestBuilder<location::model::ListLocationsRequest>);
403
404 impl ListLocations {
405 pub(crate) fn new(
406 stub: std::sync::Arc<dyn super::super::stub::dynamic::Maintenance>,
407 ) -> Self {
408 Self(RequestBuilder::new(stub))
409 }
410
411 pub fn with_request<V: Into<location::model::ListLocationsRequest>>(
413 mut self,
414 v: V,
415 ) -> Self {
416 self.0.request = v.into();
417 self
418 }
419
420 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
422 self.0.options = v.into();
423 self
424 }
425
426 pub async fn send(self) -> Result<location::model::ListLocationsResponse> {
428 (*self.0.stub)
429 .list_locations(self.0.request, self.0.options)
430 .await
431 .map(gax::response::Response::into_body)
432 }
433
434 pub fn by_page(
436 self,
437 ) -> impl gax::paginator::Paginator<location::model::ListLocationsResponse, gax::error::Error>
438 {
439 use std::clone::Clone;
440 let token = self.0.request.page_token.clone();
441 let execute = move |token: String| {
442 let mut builder = self.clone();
443 builder.0.request = builder.0.request.set_page_token(token);
444 builder.send()
445 };
446 gax::paginator::internal::new_paginator(token, execute)
447 }
448
449 pub fn by_item(
451 self,
452 ) -> impl gax::paginator::ItemPaginator<location::model::ListLocationsResponse, gax::error::Error>
453 {
454 use gax::paginator::Paginator;
455 self.by_page().items()
456 }
457
458 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
460 self.0.request.name = v.into();
461 self
462 }
463
464 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
466 self.0.request.filter = v.into();
467 self
468 }
469
470 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
472 self.0.request.page_size = v.into();
473 self
474 }
475
476 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
478 self.0.request.page_token = v.into();
479 self
480 }
481 }
482
483 #[doc(hidden)]
484 impl gax::options::internal::RequestBuilder for ListLocations {
485 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
486 &mut self.0.options
487 }
488 }
489
490 #[derive(Clone, Debug)]
507 pub struct GetLocation(RequestBuilder<location::model::GetLocationRequest>);
508
509 impl GetLocation {
510 pub(crate) fn new(
511 stub: std::sync::Arc<dyn super::super::stub::dynamic::Maintenance>,
512 ) -> Self {
513 Self(RequestBuilder::new(stub))
514 }
515
516 pub fn with_request<V: Into<location::model::GetLocationRequest>>(mut self, v: V) -> Self {
518 self.0.request = v.into();
519 self
520 }
521
522 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
524 self.0.options = v.into();
525 self
526 }
527
528 pub async fn send(self) -> Result<location::model::Location> {
530 (*self.0.stub)
531 .get_location(self.0.request, self.0.options)
532 .await
533 .map(gax::response::Response::into_body)
534 }
535
536 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
538 self.0.request.name = v.into();
539 self
540 }
541 }
542
543 #[doc(hidden)]
544 impl gax::options::internal::RequestBuilder for GetLocation {
545 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
546 &mut self.0.options
547 }
548 }
549}