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