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