Skip to main content

google_cloud_maintenance_api_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 maintenance {
18    use crate::Result;
19
20    /// A builder for [Maintenance][crate::client::Maintenance].
21    ///
22    /// ```
23    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
24    /// # use google_cloud_maintenance_api_v1::*;
25    /// # use builder::maintenance::ClientBuilder;
26    /// # use client::Maintenance;
27    /// let builder : ClientBuilder = Maintenance::builder();
28    /// let client = builder
29    ///     .with_endpoint("https://maintenance.googleapis.com")
30    ///     .build().await?;
31    /// # Ok(()) }
32    /// ```
33    pub type ClientBuilder = crate::ClientBuilder<client::Factory, gaxi::options::Credentials>;
34
35    pub(crate) mod client {
36        use super::super::super::client::Maintenance;
37        pub struct Factory;
38        impl crate::ClientFactory for Factory {
39            type Client = Maintenance;
40            type Credentials = gaxi::options::Credentials;
41            async fn build(
42                self,
43                config: gaxi::options::ClientConfig,
44            ) -> crate::ClientBuilderResult<Self::Client> {
45                Self::Client::new(config).await
46            }
47        }
48    }
49
50    /// Common implementation for [crate::client::Maintenance] request builders.
51    #[derive(Clone, Debug)]
52    pub(crate) struct RequestBuilder<R: std::default::Default> {
53        stub: std::sync::Arc<dyn super::super::stub::dynamic::Maintenance>,
54        request: R,
55        options: crate::RequestOptions,
56    }
57
58    impl<R> RequestBuilder<R>
59    where
60        R: std::default::Default,
61    {
62        pub(crate) fn new(
63            stub: std::sync::Arc<dyn super::super::stub::dynamic::Maintenance>,
64        ) -> Self {
65            Self {
66                stub,
67                request: R::default(),
68                options: crate::RequestOptions::default(),
69            }
70        }
71    }
72
73    /// The request builder for [Maintenance::summarize_maintenances][crate::client::Maintenance::summarize_maintenances] calls.
74    ///
75    /// # Example
76    /// ```
77    /// # use google_cloud_maintenance_api_v1::builder::maintenance::SummarizeMaintenances;
78    /// # async fn sample() -> google_cloud_maintenance_api_v1::Result<()> {
79    /// use google_cloud_gax::paginator::ItemPaginator;
80    ///
81    /// let builder = prepare_request_builder();
82    /// let mut items = builder.by_item();
83    /// while let Some(result) = items.next().await {
84    ///   let item = result?;
85    /// }
86    /// # Ok(()) }
87    ///
88    /// fn prepare_request_builder() -> SummarizeMaintenances {
89    ///   # panic!();
90    ///   // ... details omitted ...
91    /// }
92    /// ```
93    #[derive(Clone, Debug)]
94    pub struct SummarizeMaintenances(RequestBuilder<crate::model::SummarizeMaintenancesRequest>);
95
96    impl SummarizeMaintenances {
97        pub(crate) fn new(
98            stub: std::sync::Arc<dyn super::super::stub::dynamic::Maintenance>,
99        ) -> Self {
100            Self(RequestBuilder::new(stub))
101        }
102
103        /// Sets the full request, replacing any prior values.
104        pub fn with_request<V: Into<crate::model::SummarizeMaintenancesRequest>>(
105            mut self,
106            v: V,
107        ) -> Self {
108            self.0.request = v.into();
109            self
110        }
111
112        /// Sets all the options, replacing any prior values.
113        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
114            self.0.options = v.into();
115            self
116        }
117
118        /// Sends the request.
119        pub async fn send(self) -> Result<crate::model::SummarizeMaintenancesResponse> {
120            (*self.0.stub)
121                .summarize_maintenances(self.0.request, self.0.options)
122                .await
123                .map(crate::Response::into_body)
124        }
125
126        /// Streams each page in the collection.
127        pub fn by_page(
128            self,
129        ) -> impl google_cloud_gax::paginator::Paginator<
130            crate::model::SummarizeMaintenancesResponse,
131            crate::Error,
132        > {
133            use std::clone::Clone;
134            let token = self.0.request.page_token.clone();
135            let execute = move |token: String| {
136                let mut builder = self.clone();
137                builder.0.request = builder.0.request.set_page_token(token);
138                builder.send()
139            };
140            google_cloud_gax::paginator::internal::new_paginator(token, execute)
141        }
142
143        /// Streams each item in the collection.
144        pub fn by_item(
145            self,
146        ) -> impl google_cloud_gax::paginator::ItemPaginator<
147            crate::model::SummarizeMaintenancesResponse,
148            crate::Error,
149        > {
150            use google_cloud_gax::paginator::Paginator;
151            self.by_page().items()
152        }
153
154        /// Sets the value of [parent][crate::model::SummarizeMaintenancesRequest::parent].
155        ///
156        /// This is a **required** field for requests.
157        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
158            self.0.request.parent = v.into();
159            self
160        }
161
162        /// Sets the value of [page_size][crate::model::SummarizeMaintenancesRequest::page_size].
163        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
164            self.0.request.page_size = v.into();
165            self
166        }
167
168        /// Sets the value of [page_token][crate::model::SummarizeMaintenancesRequest::page_token].
169        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
170            self.0.request.page_token = v.into();
171            self
172        }
173
174        /// Sets the value of [filter][crate::model::SummarizeMaintenancesRequest::filter].
175        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
176            self.0.request.filter = v.into();
177            self
178        }
179
180        /// Sets the value of [order_by][crate::model::SummarizeMaintenancesRequest::order_by].
181        pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
182            self.0.request.order_by = v.into();
183            self
184        }
185    }
186
187    #[doc(hidden)]
188    impl crate::RequestBuilder for SummarizeMaintenances {
189        fn request_options(&mut self) -> &mut crate::RequestOptions {
190            &mut self.0.options
191        }
192    }
193
194    /// The request builder for [Maintenance::list_resource_maintenances][crate::client::Maintenance::list_resource_maintenances] calls.
195    ///
196    /// # Example
197    /// ```
198    /// # use google_cloud_maintenance_api_v1::builder::maintenance::ListResourceMaintenances;
199    /// # async fn sample() -> google_cloud_maintenance_api_v1::Result<()> {
200    /// use google_cloud_gax::paginator::ItemPaginator;
201    ///
202    /// let builder = prepare_request_builder();
203    /// let mut items = builder.by_item();
204    /// while let Some(result) = items.next().await {
205    ///   let item = result?;
206    /// }
207    /// # Ok(()) }
208    ///
209    /// fn prepare_request_builder() -> ListResourceMaintenances {
210    ///   # panic!();
211    ///   // ... details omitted ...
212    /// }
213    /// ```
214    #[derive(Clone, Debug)]
215    pub struct ListResourceMaintenances(
216        RequestBuilder<crate::model::ListResourceMaintenancesRequest>,
217    );
218
219    impl ListResourceMaintenances {
220        pub(crate) fn new(
221            stub: std::sync::Arc<dyn super::super::stub::dynamic::Maintenance>,
222        ) -> Self {
223            Self(RequestBuilder::new(stub))
224        }
225
226        /// Sets the full request, replacing any prior values.
227        pub fn with_request<V: Into<crate::model::ListResourceMaintenancesRequest>>(
228            mut self,
229            v: V,
230        ) -> Self {
231            self.0.request = v.into();
232            self
233        }
234
235        /// Sets all the options, replacing any prior values.
236        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
237            self.0.options = v.into();
238            self
239        }
240
241        /// Sends the request.
242        pub async fn send(self) -> Result<crate::model::ListResourceMaintenancesResponse> {
243            (*self.0.stub)
244                .list_resource_maintenances(self.0.request, self.0.options)
245                .await
246                .map(crate::Response::into_body)
247        }
248
249        /// Streams each page in the collection.
250        pub fn by_page(
251            self,
252        ) -> impl google_cloud_gax::paginator::Paginator<
253            crate::model::ListResourceMaintenancesResponse,
254            crate::Error,
255        > {
256            use std::clone::Clone;
257            let token = self.0.request.page_token.clone();
258            let execute = move |token: String| {
259                let mut builder = self.clone();
260                builder.0.request = builder.0.request.set_page_token(token);
261                builder.send()
262            };
263            google_cloud_gax::paginator::internal::new_paginator(token, execute)
264        }
265
266        /// Streams each item in the collection.
267        pub fn by_item(
268            self,
269        ) -> impl google_cloud_gax::paginator::ItemPaginator<
270            crate::model::ListResourceMaintenancesResponse,
271            crate::Error,
272        > {
273            use google_cloud_gax::paginator::Paginator;
274            self.by_page().items()
275        }
276
277        /// Sets the value of [parent][crate::model::ListResourceMaintenancesRequest::parent].
278        ///
279        /// This is a **required** field for requests.
280        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
281            self.0.request.parent = v.into();
282            self
283        }
284
285        /// Sets the value of [page_size][crate::model::ListResourceMaintenancesRequest::page_size].
286        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
287            self.0.request.page_size = v.into();
288            self
289        }
290
291        /// Sets the value of [page_token][crate::model::ListResourceMaintenancesRequest::page_token].
292        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
293            self.0.request.page_token = v.into();
294            self
295        }
296
297        /// Sets the value of [filter][crate::model::ListResourceMaintenancesRequest::filter].
298        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
299            self.0.request.filter = v.into();
300            self
301        }
302
303        /// Sets the value of [order_by][crate::model::ListResourceMaintenancesRequest::order_by].
304        pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
305            self.0.request.order_by = v.into();
306            self
307        }
308    }
309
310    #[doc(hidden)]
311    impl crate::RequestBuilder for ListResourceMaintenances {
312        fn request_options(&mut self) -> &mut crate::RequestOptions {
313            &mut self.0.options
314        }
315    }
316
317    /// The request builder for [Maintenance::get_resource_maintenance][crate::client::Maintenance::get_resource_maintenance] calls.
318    ///
319    /// # Example
320    /// ```
321    /// # use google_cloud_maintenance_api_v1::builder::maintenance::GetResourceMaintenance;
322    /// # async fn sample() -> google_cloud_maintenance_api_v1::Result<()> {
323    ///
324    /// let builder = prepare_request_builder();
325    /// let response = builder.send().await?;
326    /// # Ok(()) }
327    ///
328    /// fn prepare_request_builder() -> GetResourceMaintenance {
329    ///   # panic!();
330    ///   // ... details omitted ...
331    /// }
332    /// ```
333    #[derive(Clone, Debug)]
334    pub struct GetResourceMaintenance(RequestBuilder<crate::model::GetResourceMaintenanceRequest>);
335
336    impl GetResourceMaintenance {
337        pub(crate) fn new(
338            stub: std::sync::Arc<dyn super::super::stub::dynamic::Maintenance>,
339        ) -> Self {
340            Self(RequestBuilder::new(stub))
341        }
342
343        /// Sets the full request, replacing any prior values.
344        pub fn with_request<V: Into<crate::model::GetResourceMaintenanceRequest>>(
345            mut self,
346            v: V,
347        ) -> Self {
348            self.0.request = v.into();
349            self
350        }
351
352        /// Sets all the options, replacing any prior values.
353        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
354            self.0.options = v.into();
355            self
356        }
357
358        /// Sends the request.
359        pub async fn send(self) -> Result<crate::model::ResourceMaintenance> {
360            (*self.0.stub)
361                .get_resource_maintenance(self.0.request, self.0.options)
362                .await
363                .map(crate::Response::into_body)
364        }
365
366        /// Sets the value of [name][crate::model::GetResourceMaintenanceRequest::name].
367        ///
368        /// This is a **required** field for requests.
369        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
370            self.0.request.name = v.into();
371            self
372        }
373    }
374
375    #[doc(hidden)]
376    impl crate::RequestBuilder for GetResourceMaintenance {
377        fn request_options(&mut self) -> &mut crate::RequestOptions {
378            &mut self.0.options
379        }
380    }
381
382    /// The request builder for [Maintenance::list_locations][crate::client::Maintenance::list_locations] calls.
383    ///
384    /// # Example
385    /// ```
386    /// # use google_cloud_maintenance_api_v1::builder::maintenance::ListLocations;
387    /// # async fn sample() -> google_cloud_maintenance_api_v1::Result<()> {
388    /// use google_cloud_gax::paginator::ItemPaginator;
389    ///
390    /// let builder = prepare_request_builder();
391    /// let mut items = builder.by_item();
392    /// while let Some(result) = items.next().await {
393    ///   let item = result?;
394    /// }
395    /// # Ok(()) }
396    ///
397    /// fn prepare_request_builder() -> ListLocations {
398    ///   # panic!();
399    ///   // ... details omitted ...
400    /// }
401    /// ```
402    #[derive(Clone, Debug)]
403    pub struct ListLocations(RequestBuilder<google_cloud_location::model::ListLocationsRequest>);
404
405    impl ListLocations {
406        pub(crate) fn new(
407            stub: std::sync::Arc<dyn super::super::stub::dynamic::Maintenance>,
408        ) -> Self {
409            Self(RequestBuilder::new(stub))
410        }
411
412        /// Sets the full request, replacing any prior values.
413        pub fn with_request<V: Into<google_cloud_location::model::ListLocationsRequest>>(
414            mut self,
415            v: V,
416        ) -> Self {
417            self.0.request = v.into();
418            self
419        }
420
421        /// Sets all the options, replacing any prior values.
422        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
423            self.0.options = v.into();
424            self
425        }
426
427        /// Sends the request.
428        pub async fn send(self) -> Result<google_cloud_location::model::ListLocationsResponse> {
429            (*self.0.stub)
430                .list_locations(self.0.request, self.0.options)
431                .await
432                .map(crate::Response::into_body)
433        }
434
435        /// Streams each page in the collection.
436        pub fn by_page(
437            self,
438        ) -> impl google_cloud_gax::paginator::Paginator<
439            google_cloud_location::model::ListLocationsResponse,
440            crate::Error,
441        > {
442            use std::clone::Clone;
443            let token = self.0.request.page_token.clone();
444            let execute = move |token: String| {
445                let mut builder = self.clone();
446                builder.0.request = builder.0.request.set_page_token(token);
447                builder.send()
448            };
449            google_cloud_gax::paginator::internal::new_paginator(token, execute)
450        }
451
452        /// Streams each item in the collection.
453        pub fn by_item(
454            self,
455        ) -> impl google_cloud_gax::paginator::ItemPaginator<
456            google_cloud_location::model::ListLocationsResponse,
457            crate::Error,
458        > {
459            use google_cloud_gax::paginator::Paginator;
460            self.by_page().items()
461        }
462
463        /// Sets the value of [name][google_cloud_location::model::ListLocationsRequest::name].
464        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
465            self.0.request.name = v.into();
466            self
467        }
468
469        /// Sets the value of [filter][google_cloud_location::model::ListLocationsRequest::filter].
470        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
471            self.0.request.filter = v.into();
472            self
473        }
474
475        /// Sets the value of [page_size][google_cloud_location::model::ListLocationsRequest::page_size].
476        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
477            self.0.request.page_size = v.into();
478            self
479        }
480
481        /// Sets the value of [page_token][google_cloud_location::model::ListLocationsRequest::page_token].
482        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
483            self.0.request.page_token = v.into();
484            self
485        }
486    }
487
488    #[doc(hidden)]
489    impl crate::RequestBuilder for ListLocations {
490        fn request_options(&mut self) -> &mut crate::RequestOptions {
491            &mut self.0.options
492        }
493    }
494
495    /// The request builder for [Maintenance::get_location][crate::client::Maintenance::get_location] calls.
496    ///
497    /// # Example
498    /// ```
499    /// # use google_cloud_maintenance_api_v1::builder::maintenance::GetLocation;
500    /// # async fn sample() -> google_cloud_maintenance_api_v1::Result<()> {
501    ///
502    /// let builder = prepare_request_builder();
503    /// let response = builder.send().await?;
504    /// # Ok(()) }
505    ///
506    /// fn prepare_request_builder() -> GetLocation {
507    ///   # panic!();
508    ///   // ... details omitted ...
509    /// }
510    /// ```
511    #[derive(Clone, Debug)]
512    pub struct GetLocation(RequestBuilder<google_cloud_location::model::GetLocationRequest>);
513
514    impl GetLocation {
515        pub(crate) fn new(
516            stub: std::sync::Arc<dyn super::super::stub::dynamic::Maintenance>,
517        ) -> Self {
518            Self(RequestBuilder::new(stub))
519        }
520
521        /// Sets the full request, replacing any prior values.
522        pub fn with_request<V: Into<google_cloud_location::model::GetLocationRequest>>(
523            mut self,
524            v: V,
525        ) -> Self {
526            self.0.request = v.into();
527            self
528        }
529
530        /// Sets all the options, replacing any prior values.
531        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
532            self.0.options = v.into();
533            self
534        }
535
536        /// Sends the request.
537        pub async fn send(self) -> Result<google_cloud_location::model::Location> {
538            (*self.0.stub)
539                .get_location(self.0.request, self.0.options)
540                .await
541                .map(crate::Response::into_body)
542        }
543
544        /// Sets the value of [name][google_cloud_location::model::GetLocationRequest::name].
545        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
546            self.0.request.name = v.into();
547            self
548        }
549    }
550
551    #[doc(hidden)]
552    impl crate::RequestBuilder for GetLocation {
553        fn request_options(&mut self) -> &mut crate::RequestOptions {
554            &mut self.0.options
555        }
556    }
557}