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
17/// Request and client builders for [Maintenance][crate::client::Maintenance].
18pub mod maintenance {
19 use crate::Result;
20
21 /// A builder for [Maintenance][crate::client::Maintenance].
22 ///
23 /// ```
24 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
25 /// # use google_cloud_maintenance_api_v1::*;
26 /// # use builder::maintenance::ClientBuilder;
27 /// # use client::Maintenance;
28 /// let builder : ClientBuilder = Maintenance::builder();
29 /// let client = builder
30 /// .with_endpoint("https://maintenance.googleapis.com")
31 /// .build().await?;
32 /// # Ok(()) }
33 /// ```
34 pub type ClientBuilder = crate::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 crate::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 ) -> crate::ClientBuilderResult<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: crate::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: crate::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() -> google_cloud_maintenance_api_v1::Result<()> {
80 /// use google_cloud_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<crate::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(crate::Response::into_body)
125 }
126
127 /// Streams each page in the collection.
128 pub fn by_page(
129 self,
130 ) -> impl google_cloud_gax::paginator::Paginator<
131 crate::model::SummarizeMaintenancesResponse,
132 crate::Error,
133 > {
134 use std::clone::Clone;
135 let token = self.0.request.page_token.clone();
136 let execute = move |token: String| {
137 let mut builder = self.clone();
138 builder.0.request = builder.0.request.set_page_token(token);
139 builder.send()
140 };
141 google_cloud_gax::paginator::internal::new_paginator(token, execute)
142 }
143
144 /// Streams each item in the collection.
145 pub fn by_item(
146 self,
147 ) -> impl google_cloud_gax::paginator::ItemPaginator<
148 crate::model::SummarizeMaintenancesResponse,
149 crate::Error,
150 > {
151 use google_cloud_gax::paginator::Paginator;
152 self.by_page().items()
153 }
154
155 /// Sets the value of [parent][crate::model::SummarizeMaintenancesRequest::parent].
156 ///
157 /// This is a **required** field for requests.
158 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
159 self.0.request.parent = v.into();
160 self
161 }
162
163 /// Sets the value of [page_size][crate::model::SummarizeMaintenancesRequest::page_size].
164 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
165 self.0.request.page_size = v.into();
166 self
167 }
168
169 /// Sets the value of [page_token][crate::model::SummarizeMaintenancesRequest::page_token].
170 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
171 self.0.request.page_token = v.into();
172 self
173 }
174
175 /// Sets the value of [filter][crate::model::SummarizeMaintenancesRequest::filter].
176 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
177 self.0.request.filter = v.into();
178 self
179 }
180
181 /// Sets the value of [order_by][crate::model::SummarizeMaintenancesRequest::order_by].
182 pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
183 self.0.request.order_by = v.into();
184 self
185 }
186 }
187
188 #[doc(hidden)]
189 impl crate::RequestBuilder for SummarizeMaintenances {
190 fn request_options(&mut self) -> &mut crate::RequestOptions {
191 &mut self.0.options
192 }
193 }
194
195 /// The request builder for [Maintenance::list_resource_maintenances][crate::client::Maintenance::list_resource_maintenances] calls.
196 ///
197 /// # Example
198 /// ```
199 /// # use google_cloud_maintenance_api_v1::builder::maintenance::ListResourceMaintenances;
200 /// # async fn sample() -> google_cloud_maintenance_api_v1::Result<()> {
201 /// use google_cloud_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 /// # 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<crate::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(crate::Response::into_body)
248 }
249
250 /// Streams each page in the collection.
251 pub fn by_page(
252 self,
253 ) -> impl google_cloud_gax::paginator::Paginator<
254 crate::model::ListResourceMaintenancesResponse,
255 crate::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 google_cloud_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 google_cloud_gax::paginator::ItemPaginator<
271 crate::model::ListResourceMaintenancesResponse,
272 crate::Error,
273 > {
274 use google_cloud_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 crate::RequestBuilder for ListResourceMaintenances {
313 fn request_options(&mut self) -> &mut crate::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 /// ```
322 /// # use google_cloud_maintenance_api_v1::builder::maintenance::GetResourceMaintenance;
323 /// # async fn sample() -> google_cloud_maintenance_api_v1::Result<()> {
324 ///
325 /// let builder = prepare_request_builder();
326 /// let response = builder.send().await?;
327 /// # Ok(()) }
328 ///
329 /// fn prepare_request_builder() -> GetResourceMaintenance {
330 /// # panic!();
331 /// // ... details omitted ...
332 /// }
333 /// ```
334 #[derive(Clone, Debug)]
335 pub struct GetResourceMaintenance(RequestBuilder<crate::model::GetResourceMaintenanceRequest>);
336
337 impl GetResourceMaintenance {
338 pub(crate) fn new(
339 stub: std::sync::Arc<dyn super::super::stub::dynamic::Maintenance>,
340 ) -> Self {
341 Self(RequestBuilder::new(stub))
342 }
343
344 /// Sets the full request, replacing any prior values.
345 pub fn with_request<V: Into<crate::model::GetResourceMaintenanceRequest>>(
346 mut self,
347 v: V,
348 ) -> Self {
349 self.0.request = v.into();
350 self
351 }
352
353 /// Sets all the options, replacing any prior values.
354 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
355 self.0.options = v.into();
356 self
357 }
358
359 /// Sends the request.
360 pub async fn send(self) -> Result<crate::model::ResourceMaintenance> {
361 (*self.0.stub)
362 .get_resource_maintenance(self.0.request, self.0.options)
363 .await
364 .map(crate::Response::into_body)
365 }
366
367 /// Sets the value of [name][crate::model::GetResourceMaintenanceRequest::name].
368 ///
369 /// This is a **required** field for requests.
370 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
371 self.0.request.name = v.into();
372 self
373 }
374 }
375
376 #[doc(hidden)]
377 impl crate::RequestBuilder for GetResourceMaintenance {
378 fn request_options(&mut self) -> &mut crate::RequestOptions {
379 &mut self.0.options
380 }
381 }
382
383 /// The request builder for [Maintenance::list_locations][crate::client::Maintenance::list_locations] calls.
384 ///
385 /// # Example
386 /// ```
387 /// # use google_cloud_maintenance_api_v1::builder::maintenance::ListLocations;
388 /// # async fn sample() -> google_cloud_maintenance_api_v1::Result<()> {
389 /// use google_cloud_gax::paginator::ItemPaginator;
390 ///
391 /// let builder = prepare_request_builder();
392 /// let mut items = builder.by_item();
393 /// while let Some(result) = items.next().await {
394 /// let item = result?;
395 /// }
396 /// # Ok(()) }
397 ///
398 /// fn prepare_request_builder() -> ListLocations {
399 /// # panic!();
400 /// // ... details omitted ...
401 /// }
402 /// ```
403 #[derive(Clone, Debug)]
404 pub struct ListLocations(RequestBuilder<google_cloud_location::model::ListLocationsRequest>);
405
406 impl ListLocations {
407 pub(crate) fn new(
408 stub: std::sync::Arc<dyn super::super::stub::dynamic::Maintenance>,
409 ) -> Self {
410 Self(RequestBuilder::new(stub))
411 }
412
413 /// Sets the full request, replacing any prior values.
414 pub fn with_request<V: Into<google_cloud_location::model::ListLocationsRequest>>(
415 mut self,
416 v: V,
417 ) -> Self {
418 self.0.request = v.into();
419 self
420 }
421
422 /// Sets all the options, replacing any prior values.
423 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
424 self.0.options = v.into();
425 self
426 }
427
428 /// Sends the request.
429 pub async fn send(self) -> Result<google_cloud_location::model::ListLocationsResponse> {
430 (*self.0.stub)
431 .list_locations(self.0.request, self.0.options)
432 .await
433 .map(crate::Response::into_body)
434 }
435
436 /// Streams each page in the collection.
437 pub fn by_page(
438 self,
439 ) -> impl google_cloud_gax::paginator::Paginator<
440 google_cloud_location::model::ListLocationsResponse,
441 crate::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 google_cloud_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 google_cloud_gax::paginator::ItemPaginator<
457 google_cloud_location::model::ListLocationsResponse,
458 crate::Error,
459 > {
460 use google_cloud_gax::paginator::Paginator;
461 self.by_page().items()
462 }
463
464 /// Sets the value of [name][google_cloud_location::model::ListLocationsRequest::name].
465 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
466 self.0.request.name = v.into();
467 self
468 }
469
470 /// Sets the value of [filter][google_cloud_location::model::ListLocationsRequest::filter].
471 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
472 self.0.request.filter = v.into();
473 self
474 }
475
476 /// Sets the value of [page_size][google_cloud_location::model::ListLocationsRequest::page_size].
477 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
478 self.0.request.page_size = v.into();
479 self
480 }
481
482 /// Sets the value of [page_token][google_cloud_location::model::ListLocationsRequest::page_token].
483 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
484 self.0.request.page_token = v.into();
485 self
486 }
487 }
488
489 #[doc(hidden)]
490 impl crate::RequestBuilder for ListLocations {
491 fn request_options(&mut self) -> &mut crate::RequestOptions {
492 &mut self.0.options
493 }
494 }
495
496 /// The request builder for [Maintenance::get_location][crate::client::Maintenance::get_location] calls.
497 ///
498 /// # Example
499 /// ```
500 /// # use google_cloud_maintenance_api_v1::builder::maintenance::GetLocation;
501 /// # async fn sample() -> google_cloud_maintenance_api_v1::Result<()> {
502 ///
503 /// let builder = prepare_request_builder();
504 /// let response = builder.send().await?;
505 /// # Ok(()) }
506 ///
507 /// fn prepare_request_builder() -> GetLocation {
508 /// # panic!();
509 /// // ... details omitted ...
510 /// }
511 /// ```
512 #[derive(Clone, Debug)]
513 pub struct GetLocation(RequestBuilder<google_cloud_location::model::GetLocationRequest>);
514
515 impl GetLocation {
516 pub(crate) fn new(
517 stub: std::sync::Arc<dyn super::super::stub::dynamic::Maintenance>,
518 ) -> Self {
519 Self(RequestBuilder::new(stub))
520 }
521
522 /// Sets the full request, replacing any prior values.
523 pub fn with_request<V: Into<google_cloud_location::model::GetLocationRequest>>(
524 mut self,
525 v: V,
526 ) -> Self {
527 self.0.request = v.into();
528 self
529 }
530
531 /// Sets all the options, replacing any prior values.
532 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
533 self.0.options = v.into();
534 self
535 }
536
537 /// Sends the request.
538 pub async fn send(self) -> Result<google_cloud_location::model::Location> {
539 (*self.0.stub)
540 .get_location(self.0.request, self.0.options)
541 .await
542 .map(crate::Response::into_body)
543 }
544
545 /// Sets the value of [name][google_cloud_location::model::GetLocationRequest::name].
546 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
547 self.0.request.name = v.into();
548 self
549 }
550 }
551
552 #[doc(hidden)]
553 impl crate::RequestBuilder for GetLocation {
554 fn request_options(&mut self) -> &mut crate::RequestOptions {
555 &mut self.0.options
556 }
557 }
558}