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 /// # tokio_test::block_on(async {
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 /// # gax::client_builder::Result::<()>::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 /// ```no_run
78 /// # use google_cloud_maintenance_api_v1::builder;
79 /// use builder::maintenance::SummarizeMaintenances;
80 /// # tokio_test::block_on(async {
81 /// use gax::paginator::ItemPaginator;
82 ///
83 /// let builder = prepare_request_builder();
84 /// let mut items = builder.by_item();
85 /// while let Some(result) = items.next().await {
86 /// let item = result?;
87 /// }
88 /// # gax::Result::<()>::Ok(()) });
89 ///
90 /// fn prepare_request_builder() -> SummarizeMaintenances {
91 /// # panic!();
92 /// // ... details omitted ...
93 /// }
94 /// ```
95 #[derive(Clone, Debug)]
96 pub struct SummarizeMaintenances(RequestBuilder<crate::model::SummarizeMaintenancesRequest>);
97
98 impl SummarizeMaintenances {
99 pub(crate) fn new(
100 stub: std::sync::Arc<dyn super::super::stub::dynamic::Maintenance>,
101 ) -> Self {
102 Self(RequestBuilder::new(stub))
103 }
104
105 /// Sets the full request, replacing any prior values.
106 pub fn with_request<V: Into<crate::model::SummarizeMaintenancesRequest>>(
107 mut self,
108 v: V,
109 ) -> Self {
110 self.0.request = v.into();
111 self
112 }
113
114 /// Sets all the options, replacing any prior values.
115 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
116 self.0.options = v.into();
117 self
118 }
119
120 /// Sends the request.
121 pub async fn send(self) -> Result<crate::model::SummarizeMaintenancesResponse> {
122 (*self.0.stub)
123 .summarize_maintenances(self.0.request, self.0.options)
124 .await
125 .map(gax::response::Response::into_body)
126 }
127
128 /// Streams each page in the collection.
129 pub fn by_page(
130 self,
131 ) -> impl gax::paginator::Paginator<crate::model::SummarizeMaintenancesResponse, gax::error::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 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 gax::paginator::ItemPaginator<
147 crate::model::SummarizeMaintenancesResponse,
148 gax::error::Error,
149 > {
150 use 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 gax::options::internal::RequestBuilder for SummarizeMaintenances {
189 fn request_options(&mut self) -> &mut gax::options::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 /// ```no_run
198 /// # use google_cloud_maintenance_api_v1::builder;
199 /// use builder::maintenance::ListResourceMaintenances;
200 /// # tokio_test::block_on(async {
201 /// use gax::paginator::ItemPaginator;
202 ///
203 /// let builder = prepare_request_builder();
204 /// let mut items = builder.by_item();
205 /// while let Some(result) = items.next().await {
206 /// let item = result?;
207 /// }
208 /// # gax::Result::<()>::Ok(()) });
209 ///
210 /// fn prepare_request_builder() -> ListResourceMaintenances {
211 /// # panic!();
212 /// // ... details omitted ...
213 /// }
214 /// ```
215 #[derive(Clone, Debug)]
216 pub struct ListResourceMaintenances(
217 RequestBuilder<crate::model::ListResourceMaintenancesRequest>,
218 );
219
220 impl ListResourceMaintenances {
221 pub(crate) fn new(
222 stub: std::sync::Arc<dyn super::super::stub::dynamic::Maintenance>,
223 ) -> Self {
224 Self(RequestBuilder::new(stub))
225 }
226
227 /// Sets the full request, replacing any prior values.
228 pub fn with_request<V: Into<crate::model::ListResourceMaintenancesRequest>>(
229 mut self,
230 v: V,
231 ) -> Self {
232 self.0.request = v.into();
233 self
234 }
235
236 /// Sets all the options, replacing any prior values.
237 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
238 self.0.options = v.into();
239 self
240 }
241
242 /// Sends the request.
243 pub async fn send(self) -> Result<crate::model::ListResourceMaintenancesResponse> {
244 (*self.0.stub)
245 .list_resource_maintenances(self.0.request, self.0.options)
246 .await
247 .map(gax::response::Response::into_body)
248 }
249
250 /// Streams each page in the collection.
251 pub fn by_page(
252 self,
253 ) -> impl gax::paginator::Paginator<
254 crate::model::ListResourceMaintenancesResponse,
255 gax::error::Error,
256 > {
257 use std::clone::Clone;
258 let token = self.0.request.page_token.clone();
259 let execute = move |token: String| {
260 let mut builder = self.clone();
261 builder.0.request = builder.0.request.set_page_token(token);
262 builder.send()
263 };
264 gax::paginator::internal::new_paginator(token, execute)
265 }
266
267 /// Streams each item in the collection.
268 pub fn by_item(
269 self,
270 ) -> impl gax::paginator::ItemPaginator<
271 crate::model::ListResourceMaintenancesResponse,
272 gax::error::Error,
273 > {
274 use gax::paginator::Paginator;
275 self.by_page().items()
276 }
277
278 /// Sets the value of [parent][crate::model::ListResourceMaintenancesRequest::parent].
279 ///
280 /// This is a **required** field for requests.
281 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
282 self.0.request.parent = v.into();
283 self
284 }
285
286 /// Sets the value of [page_size][crate::model::ListResourceMaintenancesRequest::page_size].
287 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
288 self.0.request.page_size = v.into();
289 self
290 }
291
292 /// Sets the value of [page_token][crate::model::ListResourceMaintenancesRequest::page_token].
293 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
294 self.0.request.page_token = v.into();
295 self
296 }
297
298 /// Sets the value of [filter][crate::model::ListResourceMaintenancesRequest::filter].
299 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
300 self.0.request.filter = v.into();
301 self
302 }
303
304 /// Sets the value of [order_by][crate::model::ListResourceMaintenancesRequest::order_by].
305 pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
306 self.0.request.order_by = v.into();
307 self
308 }
309 }
310
311 #[doc(hidden)]
312 impl gax::options::internal::RequestBuilder for ListResourceMaintenances {
313 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
314 &mut self.0.options
315 }
316 }
317
318 /// The request builder for [Maintenance::get_resource_maintenance][crate::client::Maintenance::get_resource_maintenance] calls.
319 ///
320 /// # Example
321 /// ```no_run
322 /// # use google_cloud_maintenance_api_v1::builder;
323 /// use builder::maintenance::GetResourceMaintenance;
324 /// # tokio_test::block_on(async {
325 ///
326 /// let builder = prepare_request_builder();
327 /// let response = builder.send().await?;
328 /// # gax::Result::<()>::Ok(()) });
329 ///
330 /// fn prepare_request_builder() -> GetResourceMaintenance {
331 /// # panic!();
332 /// // ... details omitted ...
333 /// }
334 /// ```
335 #[derive(Clone, Debug)]
336 pub struct GetResourceMaintenance(RequestBuilder<crate::model::GetResourceMaintenanceRequest>);
337
338 impl GetResourceMaintenance {
339 pub(crate) fn new(
340 stub: std::sync::Arc<dyn super::super::stub::dynamic::Maintenance>,
341 ) -> Self {
342 Self(RequestBuilder::new(stub))
343 }
344
345 /// Sets the full request, replacing any prior values.
346 pub fn with_request<V: Into<crate::model::GetResourceMaintenanceRequest>>(
347 mut self,
348 v: V,
349 ) -> Self {
350 self.0.request = v.into();
351 self
352 }
353
354 /// Sets all the options, replacing any prior values.
355 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
356 self.0.options = v.into();
357 self
358 }
359
360 /// Sends the request.
361 pub async fn send(self) -> Result<crate::model::ResourceMaintenance> {
362 (*self.0.stub)
363 .get_resource_maintenance(self.0.request, self.0.options)
364 .await
365 .map(gax::response::Response::into_body)
366 }
367
368 /// Sets the value of [name][crate::model::GetResourceMaintenanceRequest::name].
369 ///
370 /// This is a **required** field for requests.
371 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
372 self.0.request.name = v.into();
373 self
374 }
375 }
376
377 #[doc(hidden)]
378 impl gax::options::internal::RequestBuilder for GetResourceMaintenance {
379 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
380 &mut self.0.options
381 }
382 }
383
384 /// The request builder for [Maintenance::list_locations][crate::client::Maintenance::list_locations] calls.
385 ///
386 /// # Example
387 /// ```no_run
388 /// # use google_cloud_maintenance_api_v1::builder;
389 /// use builder::maintenance::ListLocations;
390 /// # tokio_test::block_on(async {
391 /// use gax::paginator::ItemPaginator;
392 ///
393 /// let builder = prepare_request_builder();
394 /// let mut items = builder.by_item();
395 /// while let Some(result) = items.next().await {
396 /// let item = result?;
397 /// }
398 /// # gax::Result::<()>::Ok(()) });
399 ///
400 /// fn prepare_request_builder() -> ListLocations {
401 /// # panic!();
402 /// // ... details omitted ...
403 /// }
404 /// ```
405 #[derive(Clone, Debug)]
406 pub struct ListLocations(RequestBuilder<location::model::ListLocationsRequest>);
407
408 impl ListLocations {
409 pub(crate) fn new(
410 stub: std::sync::Arc<dyn super::super::stub::dynamic::Maintenance>,
411 ) -> Self {
412 Self(RequestBuilder::new(stub))
413 }
414
415 /// Sets the full request, replacing any prior values.
416 pub fn with_request<V: Into<location::model::ListLocationsRequest>>(
417 mut self,
418 v: V,
419 ) -> Self {
420 self.0.request = v.into();
421 self
422 }
423
424 /// Sets all the options, replacing any prior values.
425 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
426 self.0.options = v.into();
427 self
428 }
429
430 /// Sends the request.
431 pub async fn send(self) -> Result<location::model::ListLocationsResponse> {
432 (*self.0.stub)
433 .list_locations(self.0.request, self.0.options)
434 .await
435 .map(gax::response::Response::into_body)
436 }
437
438 /// Streams each page in the collection.
439 pub fn by_page(
440 self,
441 ) -> impl gax::paginator::Paginator<location::model::ListLocationsResponse, gax::error::Error>
442 {
443 use std::clone::Clone;
444 let token = self.0.request.page_token.clone();
445 let execute = move |token: String| {
446 let mut builder = self.clone();
447 builder.0.request = builder.0.request.set_page_token(token);
448 builder.send()
449 };
450 gax::paginator::internal::new_paginator(token, execute)
451 }
452
453 /// Streams each item in the collection.
454 pub fn by_item(
455 self,
456 ) -> impl gax::paginator::ItemPaginator<location::model::ListLocationsResponse, gax::error::Error>
457 {
458 use gax::paginator::Paginator;
459 self.by_page().items()
460 }
461
462 /// Sets the value of [name][location::model::ListLocationsRequest::name].
463 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
464 self.0.request.name = v.into();
465 self
466 }
467
468 /// Sets the value of [filter][location::model::ListLocationsRequest::filter].
469 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
470 self.0.request.filter = v.into();
471 self
472 }
473
474 /// Sets the value of [page_size][location::model::ListLocationsRequest::page_size].
475 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
476 self.0.request.page_size = v.into();
477 self
478 }
479
480 /// Sets the value of [page_token][location::model::ListLocationsRequest::page_token].
481 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
482 self.0.request.page_token = v.into();
483 self
484 }
485 }
486
487 #[doc(hidden)]
488 impl gax::options::internal::RequestBuilder for ListLocations {
489 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
490 &mut self.0.options
491 }
492 }
493
494 /// The request builder for [Maintenance::get_location][crate::client::Maintenance::get_location] calls.
495 ///
496 /// # Example
497 /// ```no_run
498 /// # use google_cloud_maintenance_api_v1::builder;
499 /// use builder::maintenance::GetLocation;
500 /// # tokio_test::block_on(async {
501 ///
502 /// let builder = prepare_request_builder();
503 /// let response = builder.send().await?;
504 /// # gax::Result::<()>::Ok(()) });
505 ///
506 /// fn prepare_request_builder() -> GetLocation {
507 /// # panic!();
508 /// // ... details omitted ...
509 /// }
510 /// ```
511 #[derive(Clone, Debug)]
512 pub struct GetLocation(RequestBuilder<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<location::model::GetLocationRequest>>(mut self, v: V) -> Self {
523 self.0.request = v.into();
524 self
525 }
526
527 /// Sets all the options, replacing any prior values.
528 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
529 self.0.options = v.into();
530 self
531 }
532
533 /// Sends the request.
534 pub async fn send(self) -> Result<location::model::Location> {
535 (*self.0.stub)
536 .get_location(self.0.request, self.0.options)
537 .await
538 .map(gax::response::Response::into_body)
539 }
540
541 /// Sets the value of [name][location::model::GetLocationRequest::name].
542 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
543 self.0.request.name = v.into();
544 self
545 }
546 }
547
548 #[doc(hidden)]
549 impl gax::options::internal::RequestBuilder for GetLocation {
550 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
551 &mut self.0.options
552 }
553 }
554}