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() -> 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 =
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    /// Common implementation for [crate::client::Maintenance] request builders.
52    #[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    /// The request builder for [Maintenance::summarize_maintenances][crate::client::Maintenance::summarize_maintenances] calls.
75    ///
76    /// # Example
77    /// ```
78    /// # use google_cloud_maintenance_api_v1::builder::maintenance::SummarizeMaintenances;
79    /// # async fn sample() -> gax::Result<()> {
80    /// use gax::paginator::ItemPaginator;
81    ///
82    /// let builder = prepare_request_builder();
83    /// let mut items = builder.by_item();
84    /// while let Some(result) = items.next().await {
85    ///   let item = result?;
86    /// }
87    /// # Ok(()) }
88    ///
89    /// fn prepare_request_builder() -> SummarizeMaintenances {
90    ///   # panic!();
91    ///   // ... details omitted ...
92    /// }
93    /// ```
94    #[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        /// Sets the full request, replacing any prior values.
105        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        /// Sets all the options, replacing any prior values.
114        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        /// Sends the request.
120        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        /// Streams each page in the collection.
128        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        /// Streams each item in the collection.
143        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        /// Sets the value of [parent][crate::model::SummarizeMaintenancesRequest::parent].
154        ///
155        /// This is a **required** field for requests.
156        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        /// Sets the value of [page_size][crate::model::SummarizeMaintenancesRequest::page_size].
162        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        /// Sets the value of [page_token][crate::model::SummarizeMaintenancesRequest::page_token].
168        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        /// Sets the value of [filter][crate::model::SummarizeMaintenancesRequest::filter].
174        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        /// Sets the value of [order_by][crate::model::SummarizeMaintenancesRequest::order_by].
180        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    /// The request builder for [Maintenance::list_resource_maintenances][crate::client::Maintenance::list_resource_maintenances] calls.
194    ///
195    /// # Example
196    /// ```
197    /// # use google_cloud_maintenance_api_v1::builder::maintenance::ListResourceMaintenances;
198    /// # async fn sample() -> gax::Result<()> {
199    /// use gax::paginator::ItemPaginator;
200    ///
201    /// let builder = prepare_request_builder();
202    /// let mut items = builder.by_item();
203    /// while let Some(result) = items.next().await {
204    ///   let item = result?;
205    /// }
206    /// # Ok(()) }
207    ///
208    /// fn prepare_request_builder() -> ListResourceMaintenances {
209    ///   # panic!();
210    ///   // ... details omitted ...
211    /// }
212    /// ```
213    #[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        /// Sets the full request, replacing any prior values.
226        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        /// Sets all the options, replacing any prior values.
235        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        /// Sends the request.
241        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        /// Streams each page in the collection.
249        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        /// Streams each item in the collection.
266        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        /// Sets the value of [parent][crate::model::ListResourceMaintenancesRequest::parent].
277        ///
278        /// This is a **required** field for requests.
279        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        /// Sets the value of [page_size][crate::model::ListResourceMaintenancesRequest::page_size].
285        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        /// Sets the value of [page_token][crate::model::ListResourceMaintenancesRequest::page_token].
291        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        /// Sets the value of [filter][crate::model::ListResourceMaintenancesRequest::filter].
297        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        /// Sets the value of [order_by][crate::model::ListResourceMaintenancesRequest::order_by].
303        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    /// The request builder for [Maintenance::get_resource_maintenance][crate::client::Maintenance::get_resource_maintenance] calls.
317    ///
318    /// # Example
319    /// ```
320    /// # use google_cloud_maintenance_api_v1::builder::maintenance::GetResourceMaintenance;
321    /// # async fn sample() -> gax::Result<()> {
322    ///
323    /// let builder = prepare_request_builder();
324    /// let response = builder.send().await?;
325    /// # Ok(()) }
326    ///
327    /// fn prepare_request_builder() -> GetResourceMaintenance {
328    ///   # panic!();
329    ///   // ... details omitted ...
330    /// }
331    /// ```
332    #[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        /// Sets the full request, replacing any prior values.
343        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        /// Sets all the options, replacing any prior values.
352        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        /// Sends the request.
358        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        /// Sets the value of [name][crate::model::GetResourceMaintenanceRequest::name].
366        ///
367        /// This is a **required** field for requests.
368        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    /// The request builder for [Maintenance::list_locations][crate::client::Maintenance::list_locations] calls.
382    ///
383    /// # Example
384    /// ```
385    /// # use google_cloud_maintenance_api_v1::builder::maintenance::ListLocations;
386    /// # async fn sample() -> gax::Result<()> {
387    /// use gax::paginator::ItemPaginator;
388    ///
389    /// let builder = prepare_request_builder();
390    /// let mut items = builder.by_item();
391    /// while let Some(result) = items.next().await {
392    ///   let item = result?;
393    /// }
394    /// # Ok(()) }
395    ///
396    /// fn prepare_request_builder() -> ListLocations {
397    ///   # panic!();
398    ///   // ... details omitted ...
399    /// }
400    /// ```
401    #[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        /// Sets the full request, replacing any prior values.
412        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        /// Sets all the options, replacing any prior values.
421        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        /// Sends the request.
427        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        /// Streams each page in the collection.
435        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        /// Streams each item in the collection.
450        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        /// Sets the value of [name][location::model::ListLocationsRequest::name].
459        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        /// Sets the value of [filter][location::model::ListLocationsRequest::filter].
465        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        /// Sets the value of [page_size][location::model::ListLocationsRequest::page_size].
471        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        /// Sets the value of [page_token][location::model::ListLocationsRequest::page_token].
477        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    /// The request builder for [Maintenance::get_location][crate::client::Maintenance::get_location] calls.
491    ///
492    /// # Example
493    /// ```
494    /// # use google_cloud_maintenance_api_v1::builder::maintenance::GetLocation;
495    /// # async fn sample() -> gax::Result<()> {
496    ///
497    /// let builder = prepare_request_builder();
498    /// let response = builder.send().await?;
499    /// # Ok(()) }
500    ///
501    /// fn prepare_request_builder() -> GetLocation {
502    ///   # panic!();
503    ///   // ... details omitted ...
504    /// }
505    /// ```
506    #[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        /// Sets the full request, replacing any prior values.
517        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        /// Sets all the options, replacing any prior values.
523        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        /// Sends the request.
529        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        /// Sets the value of [name][location::model::GetLocationRequest::name].
537        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}