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