Skip to main content

google_cloud_api_serviceusage_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 [ServiceUsage][crate::client::ServiceUsage].
18pub mod service_usage {
19    use crate::Result;
20
21    /// A builder for [ServiceUsage][crate::client::ServiceUsage].
22    ///
23    /// ```
24    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
25    /// # use google_cloud_api_serviceusage_v1::*;
26    /// # use builder::service_usage::ClientBuilder;
27    /// # use client::ServiceUsage;
28    /// let builder : ClientBuilder = ServiceUsage::builder();
29    /// let client = builder
30    ///     .with_endpoint("https://serviceusage.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::ServiceUsage;
38        pub struct Factory;
39        impl crate::ClientFactory for Factory {
40            type Client = ServiceUsage;
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::ServiceUsage] 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::ServiceUsage>,
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::ServiceUsage>,
65        ) -> Self {
66            Self {
67                stub,
68                request: R::default(),
69                options: crate::RequestOptions::default(),
70            }
71        }
72    }
73
74    /// The request builder for [ServiceUsage::enable_service][crate::client::ServiceUsage::enable_service] calls.
75    ///
76    /// # Example
77    /// ```
78    /// # use google_cloud_api_serviceusage_v1::builder::service_usage::EnableService;
79    /// # async fn sample() -> google_cloud_api_serviceusage_v1::Result<()> {
80    /// use google_cloud_lro::Poller;
81    ///
82    /// let builder = prepare_request_builder();
83    /// let response = builder.poller().until_done().await?;
84    /// # Ok(()) }
85    ///
86    /// fn prepare_request_builder() -> EnableService {
87    ///   # panic!();
88    ///   // ... details omitted ...
89    /// }
90    /// ```
91    #[derive(Clone, Debug)]
92    pub struct EnableService(RequestBuilder<crate::model::EnableServiceRequest>);
93
94    impl EnableService {
95        pub(crate) fn new(
96            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
97        ) -> Self {
98            Self(RequestBuilder::new(stub))
99        }
100
101        /// Sets the full request, replacing any prior values.
102        pub fn with_request<V: Into<crate::model::EnableServiceRequest>>(mut self, v: V) -> Self {
103            self.0.request = v.into();
104            self
105        }
106
107        /// Sets all the options, replacing any prior values.
108        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
109            self.0.options = v.into();
110            self
111        }
112
113        /// Sends the request.
114        ///
115        /// # Long running operations
116        ///
117        /// This starts, but does not poll, a longrunning operation. More information
118        /// on [enable_service][crate::client::ServiceUsage::enable_service].
119        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
120            (*self.0.stub)
121                .enable_service(self.0.request, self.0.options)
122                .await
123                .map(crate::Response::into_body)
124        }
125
126        /// Creates a [Poller][google_cloud_lro::Poller] to work with `enable_service`.
127        pub fn poller(
128            self,
129        ) -> impl google_cloud_lro::Poller<
130            crate::model::EnableServiceResponse,
131            crate::model::OperationMetadata,
132        > {
133            type Operation = google_cloud_lro::internal::Operation<
134                crate::model::EnableServiceResponse,
135                crate::model::OperationMetadata,
136            >;
137            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
138            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
139            let mut poller_options = self.0.stub.get_poller_options(&self.0.options);
140            if let Some(ref mut details) = poller_options.tracing {
141                details.method_name = "google_cloud_api_serviceusage_v1::client::ServiceUsage::enable_service::until_done";
142            }
143
144            let stub = self.0.stub.clone();
145            let mut options = self.0.options.clone();
146            options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
147            let query = move |name| {
148                let stub = stub.clone();
149                let options = options.clone();
150                async {
151                    let op = GetOperation::new(stub)
152                        .set_name(name)
153                        .with_options(options)
154                        .send()
155                        .await?;
156                    Ok(Operation::new(op))
157                }
158            };
159
160            let start = move || async {
161                let op = self.send().await?;
162                Ok(Operation::new(op))
163            };
164
165            use google_cloud_lro::internal::PollerExt;
166            {
167                google_cloud_lro::internal::new_poller(
168                    polling_error_policy,
169                    polling_backoff_policy,
170                    start,
171                    query,
172                )
173            }
174            .with_options(poller_options)
175        }
176
177        /// Sets the value of [name][crate::model::EnableServiceRequest::name].
178        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
179            self.0.request.name = v.into();
180            self
181        }
182    }
183
184    #[doc(hidden)]
185    impl crate::RequestBuilder for EnableService {
186        fn request_options(&mut self) -> &mut crate::RequestOptions {
187            &mut self.0.options
188        }
189    }
190
191    /// The request builder for [ServiceUsage::disable_service][crate::client::ServiceUsage::disable_service] calls.
192    ///
193    /// # Example
194    /// ```
195    /// # use google_cloud_api_serviceusage_v1::builder::service_usage::DisableService;
196    /// # async fn sample() -> google_cloud_api_serviceusage_v1::Result<()> {
197    /// use google_cloud_lro::Poller;
198    ///
199    /// let builder = prepare_request_builder();
200    /// let response = builder.poller().until_done().await?;
201    /// # Ok(()) }
202    ///
203    /// fn prepare_request_builder() -> DisableService {
204    ///   # panic!();
205    ///   // ... details omitted ...
206    /// }
207    /// ```
208    #[derive(Clone, Debug)]
209    pub struct DisableService(RequestBuilder<crate::model::DisableServiceRequest>);
210
211    impl DisableService {
212        pub(crate) fn new(
213            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
214        ) -> Self {
215            Self(RequestBuilder::new(stub))
216        }
217
218        /// Sets the full request, replacing any prior values.
219        pub fn with_request<V: Into<crate::model::DisableServiceRequest>>(mut self, v: V) -> Self {
220            self.0.request = v.into();
221            self
222        }
223
224        /// Sets all the options, replacing any prior values.
225        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
226            self.0.options = v.into();
227            self
228        }
229
230        /// Sends the request.
231        ///
232        /// # Long running operations
233        ///
234        /// This starts, but does not poll, a longrunning operation. More information
235        /// on [disable_service][crate::client::ServiceUsage::disable_service].
236        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
237            (*self.0.stub)
238                .disable_service(self.0.request, self.0.options)
239                .await
240                .map(crate::Response::into_body)
241        }
242
243        /// Creates a [Poller][google_cloud_lro::Poller] to work with `disable_service`.
244        pub fn poller(
245            self,
246        ) -> impl google_cloud_lro::Poller<
247            crate::model::DisableServiceResponse,
248            crate::model::OperationMetadata,
249        > {
250            type Operation = google_cloud_lro::internal::Operation<
251                crate::model::DisableServiceResponse,
252                crate::model::OperationMetadata,
253            >;
254            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
255            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
256            let mut poller_options = self.0.stub.get_poller_options(&self.0.options);
257            if let Some(ref mut details) = poller_options.tracing {
258                details.method_name = "google_cloud_api_serviceusage_v1::client::ServiceUsage::disable_service::until_done";
259            }
260
261            let stub = self.0.stub.clone();
262            let mut options = self.0.options.clone();
263            options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
264            let query = move |name| {
265                let stub = stub.clone();
266                let options = options.clone();
267                async {
268                    let op = GetOperation::new(stub)
269                        .set_name(name)
270                        .with_options(options)
271                        .send()
272                        .await?;
273                    Ok(Operation::new(op))
274                }
275            };
276
277            let start = move || async {
278                let op = self.send().await?;
279                Ok(Operation::new(op))
280            };
281
282            use google_cloud_lro::internal::PollerExt;
283            {
284                google_cloud_lro::internal::new_poller(
285                    polling_error_policy,
286                    polling_backoff_policy,
287                    start,
288                    query,
289                )
290            }
291            .with_options(poller_options)
292        }
293
294        /// Sets the value of [name][crate::model::DisableServiceRequest::name].
295        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
296            self.0.request.name = v.into();
297            self
298        }
299
300        /// Sets the value of [disable_dependent_services][crate::model::DisableServiceRequest::disable_dependent_services].
301        pub fn set_disable_dependent_services<T: Into<bool>>(mut self, v: T) -> Self {
302            self.0.request.disable_dependent_services = v.into();
303            self
304        }
305
306        /// Sets the value of [check_if_service_has_usage][crate::model::DisableServiceRequest::check_if_service_has_usage].
307        pub fn set_check_if_service_has_usage<
308            T: Into<crate::model::disable_service_request::CheckIfServiceHasUsage>,
309        >(
310            mut self,
311            v: T,
312        ) -> Self {
313            self.0.request.check_if_service_has_usage = v.into();
314            self
315        }
316    }
317
318    #[doc(hidden)]
319    impl crate::RequestBuilder for DisableService {
320        fn request_options(&mut self) -> &mut crate::RequestOptions {
321            &mut self.0.options
322        }
323    }
324
325    /// The request builder for [ServiceUsage::get_service][crate::client::ServiceUsage::get_service] calls.
326    ///
327    /// # Example
328    /// ```
329    /// # use google_cloud_api_serviceusage_v1::builder::service_usage::GetService;
330    /// # async fn sample() -> google_cloud_api_serviceusage_v1::Result<()> {
331    ///
332    /// let builder = prepare_request_builder();
333    /// let response = builder.send().await?;
334    /// # Ok(()) }
335    ///
336    /// fn prepare_request_builder() -> GetService {
337    ///   # panic!();
338    ///   // ... details omitted ...
339    /// }
340    /// ```
341    #[derive(Clone, Debug)]
342    pub struct GetService(RequestBuilder<crate::model::GetServiceRequest>);
343
344    impl GetService {
345        pub(crate) fn new(
346            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
347        ) -> Self {
348            Self(RequestBuilder::new(stub))
349        }
350
351        /// Sets the full request, replacing any prior values.
352        pub fn with_request<V: Into<crate::model::GetServiceRequest>>(mut self, v: V) -> Self {
353            self.0.request = v.into();
354            self
355        }
356
357        /// Sets all the options, replacing any prior values.
358        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
359            self.0.options = v.into();
360            self
361        }
362
363        /// Sends the request.
364        pub async fn send(self) -> Result<crate::model::Service> {
365            (*self.0.stub)
366                .get_service(self.0.request, self.0.options)
367                .await
368                .map(crate::Response::into_body)
369        }
370
371        /// Sets the value of [name][crate::model::GetServiceRequest::name].
372        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
373            self.0.request.name = v.into();
374            self
375        }
376    }
377
378    #[doc(hidden)]
379    impl crate::RequestBuilder for GetService {
380        fn request_options(&mut self) -> &mut crate::RequestOptions {
381            &mut self.0.options
382        }
383    }
384
385    /// The request builder for [ServiceUsage::list_services][crate::client::ServiceUsage::list_services] calls.
386    ///
387    /// # Example
388    /// ```
389    /// # use google_cloud_api_serviceusage_v1::builder::service_usage::ListServices;
390    /// # async fn sample() -> google_cloud_api_serviceusage_v1::Result<()> {
391    /// use google_cloud_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    /// # Ok(()) }
399    ///
400    /// fn prepare_request_builder() -> ListServices {
401    ///   # panic!();
402    ///   // ... details omitted ...
403    /// }
404    /// ```
405    #[derive(Clone, Debug)]
406    pub struct ListServices(RequestBuilder<crate::model::ListServicesRequest>);
407
408    impl ListServices {
409        pub(crate) fn new(
410            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
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<crate::model::ListServicesRequest>>(mut self, v: V) -> 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<crate::model::ListServicesResponse> {
429            (*self.0.stub)
430                .list_services(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<crate::model::ListServicesResponse, crate::Error>
439        {
440            use std::clone::Clone;
441            let token = self.0.request.page_token.clone();
442            let execute = move |token: String| {
443                let mut builder = self.clone();
444                builder.0.request = builder.0.request.set_page_token(token);
445                builder.send()
446            };
447            google_cloud_gax::paginator::internal::new_paginator(token, execute)
448        }
449
450        /// Streams each item in the collection.
451        pub fn by_item(
452            self,
453        ) -> impl google_cloud_gax::paginator::ItemPaginator<
454            crate::model::ListServicesResponse,
455            crate::Error,
456        > {
457            use google_cloud_gax::paginator::Paginator;
458            self.by_page().items()
459        }
460
461        /// Sets the value of [parent][crate::model::ListServicesRequest::parent].
462        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
463            self.0.request.parent = v.into();
464            self
465        }
466
467        /// Sets the value of [page_size][crate::model::ListServicesRequest::page_size].
468        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
469            self.0.request.page_size = v.into();
470            self
471        }
472
473        /// Sets the value of [page_token][crate::model::ListServicesRequest::page_token].
474        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
475            self.0.request.page_token = v.into();
476            self
477        }
478
479        /// Sets the value of [filter][crate::model::ListServicesRequest::filter].
480        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
481            self.0.request.filter = v.into();
482            self
483        }
484    }
485
486    #[doc(hidden)]
487    impl crate::RequestBuilder for ListServices {
488        fn request_options(&mut self) -> &mut crate::RequestOptions {
489            &mut self.0.options
490        }
491    }
492
493    /// The request builder for [ServiceUsage::batch_enable_services][crate::client::ServiceUsage::batch_enable_services] calls.
494    ///
495    /// # Example
496    /// ```
497    /// # use google_cloud_api_serviceusage_v1::builder::service_usage::BatchEnableServices;
498    /// # async fn sample() -> google_cloud_api_serviceusage_v1::Result<()> {
499    /// use google_cloud_lro::Poller;
500    ///
501    /// let builder = prepare_request_builder();
502    /// let response = builder.poller().until_done().await?;
503    /// # Ok(()) }
504    ///
505    /// fn prepare_request_builder() -> BatchEnableServices {
506    ///   # panic!();
507    ///   // ... details omitted ...
508    /// }
509    /// ```
510    #[derive(Clone, Debug)]
511    pub struct BatchEnableServices(RequestBuilder<crate::model::BatchEnableServicesRequest>);
512
513    impl BatchEnableServices {
514        pub(crate) fn new(
515            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
516        ) -> Self {
517            Self(RequestBuilder::new(stub))
518        }
519
520        /// Sets the full request, replacing any prior values.
521        pub fn with_request<V: Into<crate::model::BatchEnableServicesRequest>>(
522            mut self,
523            v: V,
524        ) -> Self {
525            self.0.request = v.into();
526            self
527        }
528
529        /// Sets all the options, replacing any prior values.
530        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
531            self.0.options = v.into();
532            self
533        }
534
535        /// Sends the request.
536        ///
537        /// # Long running operations
538        ///
539        /// This starts, but does not poll, a longrunning operation. More information
540        /// on [batch_enable_services][crate::client::ServiceUsage::batch_enable_services].
541        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
542            (*self.0.stub)
543                .batch_enable_services(self.0.request, self.0.options)
544                .await
545                .map(crate::Response::into_body)
546        }
547
548        /// Creates a [Poller][google_cloud_lro::Poller] to work with `batch_enable_services`.
549        pub fn poller(
550            self,
551        ) -> impl google_cloud_lro::Poller<
552            crate::model::BatchEnableServicesResponse,
553            crate::model::OperationMetadata,
554        > {
555            type Operation = google_cloud_lro::internal::Operation<
556                crate::model::BatchEnableServicesResponse,
557                crate::model::OperationMetadata,
558            >;
559            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
560            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
561            let mut poller_options = self.0.stub.get_poller_options(&self.0.options);
562            if let Some(ref mut details) = poller_options.tracing {
563                details.method_name = "google_cloud_api_serviceusage_v1::client::ServiceUsage::batch_enable_services::until_done";
564            }
565
566            let stub = self.0.stub.clone();
567            let mut options = self.0.options.clone();
568            options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
569            let query = move |name| {
570                let stub = stub.clone();
571                let options = options.clone();
572                async {
573                    let op = GetOperation::new(stub)
574                        .set_name(name)
575                        .with_options(options)
576                        .send()
577                        .await?;
578                    Ok(Operation::new(op))
579                }
580            };
581
582            let start = move || async {
583                let op = self.send().await?;
584                Ok(Operation::new(op))
585            };
586
587            use google_cloud_lro::internal::PollerExt;
588            {
589                google_cloud_lro::internal::new_poller(
590                    polling_error_policy,
591                    polling_backoff_policy,
592                    start,
593                    query,
594                )
595            }
596            .with_options(poller_options)
597        }
598
599        /// Sets the value of [parent][crate::model::BatchEnableServicesRequest::parent].
600        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
601            self.0.request.parent = v.into();
602            self
603        }
604
605        /// Sets the value of [service_ids][crate::model::BatchEnableServicesRequest::service_ids].
606        pub fn set_service_ids<T, V>(mut self, v: T) -> Self
607        where
608            T: std::iter::IntoIterator<Item = V>,
609            V: std::convert::Into<std::string::String>,
610        {
611            use std::iter::Iterator;
612            self.0.request.service_ids = v.into_iter().map(|i| i.into()).collect();
613            self
614        }
615    }
616
617    #[doc(hidden)]
618    impl crate::RequestBuilder for BatchEnableServices {
619        fn request_options(&mut self) -> &mut crate::RequestOptions {
620            &mut self.0.options
621        }
622    }
623
624    /// The request builder for [ServiceUsage::batch_get_services][crate::client::ServiceUsage::batch_get_services] calls.
625    ///
626    /// # Example
627    /// ```
628    /// # use google_cloud_api_serviceusage_v1::builder::service_usage::BatchGetServices;
629    /// # async fn sample() -> google_cloud_api_serviceusage_v1::Result<()> {
630    ///
631    /// let builder = prepare_request_builder();
632    /// let response = builder.send().await?;
633    /// # Ok(()) }
634    ///
635    /// fn prepare_request_builder() -> BatchGetServices {
636    ///   # panic!();
637    ///   // ... details omitted ...
638    /// }
639    /// ```
640    #[derive(Clone, Debug)]
641    pub struct BatchGetServices(RequestBuilder<crate::model::BatchGetServicesRequest>);
642
643    impl BatchGetServices {
644        pub(crate) fn new(
645            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
646        ) -> Self {
647            Self(RequestBuilder::new(stub))
648        }
649
650        /// Sets the full request, replacing any prior values.
651        pub fn with_request<V: Into<crate::model::BatchGetServicesRequest>>(
652            mut self,
653            v: V,
654        ) -> Self {
655            self.0.request = v.into();
656            self
657        }
658
659        /// Sets all the options, replacing any prior values.
660        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
661            self.0.options = v.into();
662            self
663        }
664
665        /// Sends the request.
666        pub async fn send(self) -> Result<crate::model::BatchGetServicesResponse> {
667            (*self.0.stub)
668                .batch_get_services(self.0.request, self.0.options)
669                .await
670                .map(crate::Response::into_body)
671        }
672
673        /// Sets the value of [parent][crate::model::BatchGetServicesRequest::parent].
674        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
675            self.0.request.parent = v.into();
676            self
677        }
678
679        /// Sets the value of [names][crate::model::BatchGetServicesRequest::names].
680        pub fn set_names<T, V>(mut self, v: T) -> Self
681        where
682            T: std::iter::IntoIterator<Item = V>,
683            V: std::convert::Into<std::string::String>,
684        {
685            use std::iter::Iterator;
686            self.0.request.names = v.into_iter().map(|i| i.into()).collect();
687            self
688        }
689    }
690
691    #[doc(hidden)]
692    impl crate::RequestBuilder for BatchGetServices {
693        fn request_options(&mut self) -> &mut crate::RequestOptions {
694            &mut self.0.options
695        }
696    }
697
698    /// The request builder for [ServiceUsage::list_operations][crate::client::ServiceUsage::list_operations] calls.
699    ///
700    /// # Example
701    /// ```
702    /// # use google_cloud_api_serviceusage_v1::builder::service_usage::ListOperations;
703    /// # async fn sample() -> google_cloud_api_serviceusage_v1::Result<()> {
704    /// use google_cloud_gax::paginator::ItemPaginator;
705    ///
706    /// let builder = prepare_request_builder();
707    /// let mut items = builder.by_item();
708    /// while let Some(result) = items.next().await {
709    ///   let item = result?;
710    /// }
711    /// # Ok(()) }
712    ///
713    /// fn prepare_request_builder() -> ListOperations {
714    ///   # panic!();
715    ///   // ... details omitted ...
716    /// }
717    /// ```
718    #[derive(Clone, Debug)]
719    pub struct ListOperations(
720        RequestBuilder<google_cloud_longrunning::model::ListOperationsRequest>,
721    );
722
723    impl ListOperations {
724        pub(crate) fn new(
725            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
726        ) -> Self {
727            Self(RequestBuilder::new(stub))
728        }
729
730        /// Sets the full request, replacing any prior values.
731        pub fn with_request<V: Into<google_cloud_longrunning::model::ListOperationsRequest>>(
732            mut self,
733            v: V,
734        ) -> Self {
735            self.0.request = v.into();
736            self
737        }
738
739        /// Sets all the options, replacing any prior values.
740        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
741            self.0.options = v.into();
742            self
743        }
744
745        /// Sends the request.
746        pub async fn send(self) -> Result<google_cloud_longrunning::model::ListOperationsResponse> {
747            (*self.0.stub)
748                .list_operations(self.0.request, self.0.options)
749                .await
750                .map(crate::Response::into_body)
751        }
752
753        /// Streams each page in the collection.
754        pub fn by_page(
755            self,
756        ) -> impl google_cloud_gax::paginator::Paginator<
757            google_cloud_longrunning::model::ListOperationsResponse,
758            crate::Error,
759        > {
760            use std::clone::Clone;
761            let token = self.0.request.page_token.clone();
762            let execute = move |token: String| {
763                let mut builder = self.clone();
764                builder.0.request = builder.0.request.set_page_token(token);
765                builder.send()
766            };
767            google_cloud_gax::paginator::internal::new_paginator(token, execute)
768        }
769
770        /// Streams each item in the collection.
771        pub fn by_item(
772            self,
773        ) -> impl google_cloud_gax::paginator::ItemPaginator<
774            google_cloud_longrunning::model::ListOperationsResponse,
775            crate::Error,
776        > {
777            use google_cloud_gax::paginator::Paginator;
778            self.by_page().items()
779        }
780
781        /// Sets the value of [name][google_cloud_longrunning::model::ListOperationsRequest::name].
782        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
783            self.0.request.name = v.into();
784            self
785        }
786
787        /// Sets the value of [filter][google_cloud_longrunning::model::ListOperationsRequest::filter].
788        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
789            self.0.request.filter = v.into();
790            self
791        }
792
793        /// Sets the value of [page_size][google_cloud_longrunning::model::ListOperationsRequest::page_size].
794        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
795            self.0.request.page_size = v.into();
796            self
797        }
798
799        /// Sets the value of [page_token][google_cloud_longrunning::model::ListOperationsRequest::page_token].
800        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
801            self.0.request.page_token = v.into();
802            self
803        }
804
805        /// Sets the value of [return_partial_success][google_cloud_longrunning::model::ListOperationsRequest::return_partial_success].
806        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
807            self.0.request.return_partial_success = v.into();
808            self
809        }
810    }
811
812    #[doc(hidden)]
813    impl crate::RequestBuilder for ListOperations {
814        fn request_options(&mut self) -> &mut crate::RequestOptions {
815            &mut self.0.options
816        }
817    }
818
819    /// The request builder for [ServiceUsage::get_operation][crate::client::ServiceUsage::get_operation] calls.
820    ///
821    /// # Example
822    /// ```
823    /// # use google_cloud_api_serviceusage_v1::builder::service_usage::GetOperation;
824    /// # async fn sample() -> google_cloud_api_serviceusage_v1::Result<()> {
825    ///
826    /// let builder = prepare_request_builder();
827    /// let response = builder.send().await?;
828    /// # Ok(()) }
829    ///
830    /// fn prepare_request_builder() -> GetOperation {
831    ///   # panic!();
832    ///   // ... details omitted ...
833    /// }
834    /// ```
835    #[derive(Clone, Debug)]
836    pub struct GetOperation(RequestBuilder<google_cloud_longrunning::model::GetOperationRequest>);
837
838    impl GetOperation {
839        pub(crate) fn new(
840            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
841        ) -> Self {
842            Self(RequestBuilder::new(stub))
843        }
844
845        /// Sets the full request, replacing any prior values.
846        pub fn with_request<V: Into<google_cloud_longrunning::model::GetOperationRequest>>(
847            mut self,
848            v: V,
849        ) -> Self {
850            self.0.request = v.into();
851            self
852        }
853
854        /// Sets all the options, replacing any prior values.
855        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
856            self.0.options = v.into();
857            self
858        }
859
860        /// Sends the request.
861        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
862            (*self.0.stub)
863                .get_operation(self.0.request, self.0.options)
864                .await
865                .map(crate::Response::into_body)
866        }
867
868        /// Sets the value of [name][google_cloud_longrunning::model::GetOperationRequest::name].
869        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
870            self.0.request.name = v.into();
871            self
872        }
873    }
874
875    #[doc(hidden)]
876    impl crate::RequestBuilder for GetOperation {
877        fn request_options(&mut self) -> &mut crate::RequestOptions {
878            &mut self.0.options
879        }
880    }
881}