google_cloud_storagebatchoperations_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 storage_batch_operations {
18    use crate::Result;
19
20    /// A builder for [StorageBatchOperations][crate::client::StorageBatchOperations].
21    ///
22    /// ```
23    /// # tokio_test::block_on(async {
24    /// # use google_cloud_storagebatchoperations_v1::*;
25    /// # use builder::storage_batch_operations::ClientBuilder;
26    /// # use client::StorageBatchOperations;
27    /// let builder : ClientBuilder = StorageBatchOperations::builder();
28    /// let client = builder
29    ///     .with_endpoint("https://storagebatchoperations.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::StorageBatchOperations;
38        pub struct Factory;
39        impl gax::client_builder::internal::ClientFactory for Factory {
40            type Client = StorageBatchOperations;
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::StorageBatchOperations] 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::StorageBatchOperations>,
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::StorageBatchOperations>,
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 [StorageBatchOperations::list_jobs][crate::client::StorageBatchOperations::list_jobs] calls.
75    ///
76    /// # Example
77    /// ```no_run
78    /// # use google_cloud_storagebatchoperations_v1::builder;
79    /// use builder::storage_batch_operations::ListJobs;
80    /// # tokio_test::block_on(async {
81    /// use gax::paginator::ItemPaginator;
82    ///
83    /// let builder = prepare_request_builder();
84    /// let mut items = builder.by_item();
85    /// while let Some(result) = items.next().await {
86    ///   let item = result?;
87    /// }
88    /// # gax::Result::<()>::Ok(()) });
89    ///
90    /// fn prepare_request_builder() -> ListJobs {
91    ///   # panic!();
92    ///   // ... details omitted ...
93    /// }
94    /// ```
95    #[derive(Clone, Debug)]
96    pub struct ListJobs(RequestBuilder<crate::model::ListJobsRequest>);
97
98    impl ListJobs {
99        pub(crate) fn new(
100            stub: std::sync::Arc<dyn super::super::stub::dynamic::StorageBatchOperations>,
101        ) -> Self {
102            Self(RequestBuilder::new(stub))
103        }
104
105        /// Sets the full request, replacing any prior values.
106        pub fn with_request<V: Into<crate::model::ListJobsRequest>>(mut self, v: V) -> Self {
107            self.0.request = v.into();
108            self
109        }
110
111        /// Sets all the options, replacing any prior values.
112        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
113            self.0.options = v.into();
114            self
115        }
116
117        /// Sends the request.
118        pub async fn send(self) -> Result<crate::model::ListJobsResponse> {
119            (*self.0.stub)
120                .list_jobs(self.0.request, self.0.options)
121                .await
122                .map(gax::response::Response::into_body)
123        }
124
125        /// Streams each page in the collection.
126        pub fn by_page(
127            self,
128        ) -> impl gax::paginator::Paginator<crate::model::ListJobsResponse, gax::error::Error>
129        {
130            use std::clone::Clone;
131            let token = self.0.request.page_token.clone();
132            let execute = move |token: String| {
133                let mut builder = self.clone();
134                builder.0.request = builder.0.request.set_page_token(token);
135                builder.send()
136            };
137            gax::paginator::internal::new_paginator(token, execute)
138        }
139
140        /// Streams each item in the collection.
141        pub fn by_item(
142            self,
143        ) -> impl gax::paginator::ItemPaginator<crate::model::ListJobsResponse, gax::error::Error>
144        {
145            use gax::paginator::Paginator;
146            self.by_page().items()
147        }
148
149        /// Sets the value of [parent][crate::model::ListJobsRequest::parent].
150        ///
151        /// This is a **required** field for requests.
152        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
153            self.0.request.parent = v.into();
154            self
155        }
156
157        /// Sets the value of [filter][crate::model::ListJobsRequest::filter].
158        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
159            self.0.request.filter = v.into();
160            self
161        }
162
163        /// Sets the value of [page_size][crate::model::ListJobsRequest::page_size].
164        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
165            self.0.request.page_size = v.into();
166            self
167        }
168
169        /// Sets the value of [page_token][crate::model::ListJobsRequest::page_token].
170        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
171            self.0.request.page_token = v.into();
172            self
173        }
174
175        /// Sets the value of [order_by][crate::model::ListJobsRequest::order_by].
176        pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
177            self.0.request.order_by = v.into();
178            self
179        }
180    }
181
182    #[doc(hidden)]
183    impl gax::options::internal::RequestBuilder for ListJobs {
184        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
185            &mut self.0.options
186        }
187    }
188
189    /// The request builder for [StorageBatchOperations::get_job][crate::client::StorageBatchOperations::get_job] calls.
190    ///
191    /// # Example
192    /// ```no_run
193    /// # use google_cloud_storagebatchoperations_v1::builder;
194    /// use builder::storage_batch_operations::GetJob;
195    /// # tokio_test::block_on(async {
196    ///
197    /// let builder = prepare_request_builder();
198    /// let response = builder.send().await?;
199    /// # gax::Result::<()>::Ok(()) });
200    ///
201    /// fn prepare_request_builder() -> GetJob {
202    ///   # panic!();
203    ///   // ... details omitted ...
204    /// }
205    /// ```
206    #[derive(Clone, Debug)]
207    pub struct GetJob(RequestBuilder<crate::model::GetJobRequest>);
208
209    impl GetJob {
210        pub(crate) fn new(
211            stub: std::sync::Arc<dyn super::super::stub::dynamic::StorageBatchOperations>,
212        ) -> Self {
213            Self(RequestBuilder::new(stub))
214        }
215
216        /// Sets the full request, replacing any prior values.
217        pub fn with_request<V: Into<crate::model::GetJobRequest>>(mut self, v: V) -> Self {
218            self.0.request = v.into();
219            self
220        }
221
222        /// Sets all the options, replacing any prior values.
223        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
224            self.0.options = v.into();
225            self
226        }
227
228        /// Sends the request.
229        pub async fn send(self) -> Result<crate::model::Job> {
230            (*self.0.stub)
231                .get_job(self.0.request, self.0.options)
232                .await
233                .map(gax::response::Response::into_body)
234        }
235
236        /// Sets the value of [name][crate::model::GetJobRequest::name].
237        ///
238        /// This is a **required** field for requests.
239        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
240            self.0.request.name = v.into();
241            self
242        }
243    }
244
245    #[doc(hidden)]
246    impl gax::options::internal::RequestBuilder for GetJob {
247        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
248            &mut self.0.options
249        }
250    }
251
252    /// The request builder for [StorageBatchOperations::create_job][crate::client::StorageBatchOperations::create_job] calls.
253    ///
254    /// # Example
255    /// ```no_run
256    /// # use google_cloud_storagebatchoperations_v1::builder;
257    /// use builder::storage_batch_operations::CreateJob;
258    /// # tokio_test::block_on(async {
259    /// use lro::Poller;
260    ///
261    /// let builder = prepare_request_builder();
262    /// let response = builder.poller().until_done().await?;
263    /// # gax::Result::<()>::Ok(()) });
264    ///
265    /// fn prepare_request_builder() -> CreateJob {
266    ///   # panic!();
267    ///   // ... details omitted ...
268    /// }
269    /// ```
270    #[derive(Clone, Debug)]
271    pub struct CreateJob(RequestBuilder<crate::model::CreateJobRequest>);
272
273    impl CreateJob {
274        pub(crate) fn new(
275            stub: std::sync::Arc<dyn super::super::stub::dynamic::StorageBatchOperations>,
276        ) -> Self {
277            Self(RequestBuilder::new(stub))
278        }
279
280        /// Sets the full request, replacing any prior values.
281        pub fn with_request<V: Into<crate::model::CreateJobRequest>>(mut self, v: V) -> Self {
282            self.0.request = v.into();
283            self
284        }
285
286        /// Sets all the options, replacing any prior values.
287        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
288            self.0.options = v.into();
289            self
290        }
291
292        /// Sends the request.
293        ///
294        /// # Long running operations
295        ///
296        /// This starts, but does not poll, a longrunning operation. More information
297        /// on [create_job][crate::client::StorageBatchOperations::create_job].
298        pub async fn send(self) -> Result<longrunning::model::Operation> {
299            (*self.0.stub)
300                .create_job(self.0.request, self.0.options)
301                .await
302                .map(gax::response::Response::into_body)
303        }
304
305        /// Creates a [Poller][lro::Poller] to work with `create_job`.
306        pub fn poller(
307            self,
308        ) -> impl lro::Poller<crate::model::Job, crate::model::OperationMetadata> {
309            type Operation =
310                lro::internal::Operation<crate::model::Job, crate::model::OperationMetadata>;
311            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
312            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
313
314            let stub = self.0.stub.clone();
315            let mut options = self.0.options.clone();
316            options.set_retry_policy(gax::retry_policy::NeverRetry);
317            let query = move |name| {
318                let stub = stub.clone();
319                let options = options.clone();
320                async {
321                    let op = GetOperation::new(stub)
322                        .set_name(name)
323                        .with_options(options)
324                        .send()
325                        .await?;
326                    Ok(Operation::new(op))
327                }
328            };
329
330            let start = move || async {
331                let op = self.send().await?;
332                Ok(Operation::new(op))
333            };
334
335            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
336        }
337
338        /// Sets the value of [parent][crate::model::CreateJobRequest::parent].
339        ///
340        /// This is a **required** field for requests.
341        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
342            self.0.request.parent = v.into();
343            self
344        }
345
346        /// Sets the value of [job_id][crate::model::CreateJobRequest::job_id].
347        ///
348        /// This is a **required** field for requests.
349        pub fn set_job_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
350            self.0.request.job_id = v.into();
351            self
352        }
353
354        /// Sets the value of [job][crate::model::CreateJobRequest::job].
355        ///
356        /// This is a **required** field for requests.
357        pub fn set_job<T>(mut self, v: T) -> Self
358        where
359            T: std::convert::Into<crate::model::Job>,
360        {
361            self.0.request.job = std::option::Option::Some(v.into());
362            self
363        }
364
365        /// Sets or clears the value of [job][crate::model::CreateJobRequest::job].
366        ///
367        /// This is a **required** field for requests.
368        pub fn set_or_clear_job<T>(mut self, v: std::option::Option<T>) -> Self
369        where
370            T: std::convert::Into<crate::model::Job>,
371        {
372            self.0.request.job = v.map(|x| x.into());
373            self
374        }
375
376        /// Sets the value of [request_id][crate::model::CreateJobRequest::request_id].
377        pub fn set_request_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
378            self.0.request.request_id = v.into();
379            self
380        }
381    }
382
383    #[doc(hidden)]
384    impl gax::options::internal::RequestBuilder for CreateJob {
385        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
386            &mut self.0.options
387        }
388    }
389
390    /// The request builder for [StorageBatchOperations::delete_job][crate::client::StorageBatchOperations::delete_job] calls.
391    ///
392    /// # Example
393    /// ```no_run
394    /// # use google_cloud_storagebatchoperations_v1::builder;
395    /// use builder::storage_batch_operations::DeleteJob;
396    /// # tokio_test::block_on(async {
397    ///
398    /// let builder = prepare_request_builder();
399    /// let response = builder.send().await?;
400    /// # gax::Result::<()>::Ok(()) });
401    ///
402    /// fn prepare_request_builder() -> DeleteJob {
403    ///   # panic!();
404    ///   // ... details omitted ...
405    /// }
406    /// ```
407    #[derive(Clone, Debug)]
408    pub struct DeleteJob(RequestBuilder<crate::model::DeleteJobRequest>);
409
410    impl DeleteJob {
411        pub(crate) fn new(
412            stub: std::sync::Arc<dyn super::super::stub::dynamic::StorageBatchOperations>,
413        ) -> Self {
414            Self(RequestBuilder::new(stub))
415        }
416
417        /// Sets the full request, replacing any prior values.
418        pub fn with_request<V: Into<crate::model::DeleteJobRequest>>(mut self, v: V) -> Self {
419            self.0.request = v.into();
420            self
421        }
422
423        /// Sets all the options, replacing any prior values.
424        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
425            self.0.options = v.into();
426            self
427        }
428
429        /// Sends the request.
430        pub async fn send(self) -> Result<()> {
431            (*self.0.stub)
432                .delete_job(self.0.request, self.0.options)
433                .await
434                .map(gax::response::Response::into_body)
435        }
436
437        /// Sets the value of [name][crate::model::DeleteJobRequest::name].
438        ///
439        /// This is a **required** field for requests.
440        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
441            self.0.request.name = v.into();
442            self
443        }
444
445        /// Sets the value of [request_id][crate::model::DeleteJobRequest::request_id].
446        pub fn set_request_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
447            self.0.request.request_id = v.into();
448            self
449        }
450    }
451
452    #[doc(hidden)]
453    impl gax::options::internal::RequestBuilder for DeleteJob {
454        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
455            &mut self.0.options
456        }
457    }
458
459    /// The request builder for [StorageBatchOperations::cancel_job][crate::client::StorageBatchOperations::cancel_job] calls.
460    ///
461    /// # Example
462    /// ```no_run
463    /// # use google_cloud_storagebatchoperations_v1::builder;
464    /// use builder::storage_batch_operations::CancelJob;
465    /// # tokio_test::block_on(async {
466    ///
467    /// let builder = prepare_request_builder();
468    /// let response = builder.send().await?;
469    /// # gax::Result::<()>::Ok(()) });
470    ///
471    /// fn prepare_request_builder() -> CancelJob {
472    ///   # panic!();
473    ///   // ... details omitted ...
474    /// }
475    /// ```
476    #[derive(Clone, Debug)]
477    pub struct CancelJob(RequestBuilder<crate::model::CancelJobRequest>);
478
479    impl CancelJob {
480        pub(crate) fn new(
481            stub: std::sync::Arc<dyn super::super::stub::dynamic::StorageBatchOperations>,
482        ) -> Self {
483            Self(RequestBuilder::new(stub))
484        }
485
486        /// Sets the full request, replacing any prior values.
487        pub fn with_request<V: Into<crate::model::CancelJobRequest>>(mut self, v: V) -> Self {
488            self.0.request = v.into();
489            self
490        }
491
492        /// Sets all the options, replacing any prior values.
493        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
494            self.0.options = v.into();
495            self
496        }
497
498        /// Sends the request.
499        pub async fn send(self) -> Result<crate::model::CancelJobResponse> {
500            (*self.0.stub)
501                .cancel_job(self.0.request, self.0.options)
502                .await
503                .map(gax::response::Response::into_body)
504        }
505
506        /// Sets the value of [name][crate::model::CancelJobRequest::name].
507        ///
508        /// This is a **required** field for requests.
509        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
510            self.0.request.name = v.into();
511            self
512        }
513
514        /// Sets the value of [request_id][crate::model::CancelJobRequest::request_id].
515        pub fn set_request_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
516            self.0.request.request_id = v.into();
517            self
518        }
519    }
520
521    #[doc(hidden)]
522    impl gax::options::internal::RequestBuilder for CancelJob {
523        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
524            &mut self.0.options
525        }
526    }
527
528    /// The request builder for [StorageBatchOperations::list_locations][crate::client::StorageBatchOperations::list_locations] calls.
529    ///
530    /// # Example
531    /// ```no_run
532    /// # use google_cloud_storagebatchoperations_v1::builder;
533    /// use builder::storage_batch_operations::ListLocations;
534    /// # tokio_test::block_on(async {
535    /// use gax::paginator::ItemPaginator;
536    ///
537    /// let builder = prepare_request_builder();
538    /// let mut items = builder.by_item();
539    /// while let Some(result) = items.next().await {
540    ///   let item = result?;
541    /// }
542    /// # gax::Result::<()>::Ok(()) });
543    ///
544    /// fn prepare_request_builder() -> ListLocations {
545    ///   # panic!();
546    ///   // ... details omitted ...
547    /// }
548    /// ```
549    #[derive(Clone, Debug)]
550    pub struct ListLocations(RequestBuilder<location::model::ListLocationsRequest>);
551
552    impl ListLocations {
553        pub(crate) fn new(
554            stub: std::sync::Arc<dyn super::super::stub::dynamic::StorageBatchOperations>,
555        ) -> Self {
556            Self(RequestBuilder::new(stub))
557        }
558
559        /// Sets the full request, replacing any prior values.
560        pub fn with_request<V: Into<location::model::ListLocationsRequest>>(
561            mut self,
562            v: V,
563        ) -> Self {
564            self.0.request = v.into();
565            self
566        }
567
568        /// Sets all the options, replacing any prior values.
569        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
570            self.0.options = v.into();
571            self
572        }
573
574        /// Sends the request.
575        pub async fn send(self) -> Result<location::model::ListLocationsResponse> {
576            (*self.0.stub)
577                .list_locations(self.0.request, self.0.options)
578                .await
579                .map(gax::response::Response::into_body)
580        }
581
582        /// Streams each page in the collection.
583        pub fn by_page(
584            self,
585        ) -> impl gax::paginator::Paginator<location::model::ListLocationsResponse, gax::error::Error>
586        {
587            use std::clone::Clone;
588            let token = self.0.request.page_token.clone();
589            let execute = move |token: String| {
590                let mut builder = self.clone();
591                builder.0.request = builder.0.request.set_page_token(token);
592                builder.send()
593            };
594            gax::paginator::internal::new_paginator(token, execute)
595        }
596
597        /// Streams each item in the collection.
598        pub fn by_item(
599            self,
600        ) -> impl gax::paginator::ItemPaginator<location::model::ListLocationsResponse, gax::error::Error>
601        {
602            use gax::paginator::Paginator;
603            self.by_page().items()
604        }
605
606        /// Sets the value of [name][location::model::ListLocationsRequest::name].
607        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
608            self.0.request.name = v.into();
609            self
610        }
611
612        /// Sets the value of [filter][location::model::ListLocationsRequest::filter].
613        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
614            self.0.request.filter = v.into();
615            self
616        }
617
618        /// Sets the value of [page_size][location::model::ListLocationsRequest::page_size].
619        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
620            self.0.request.page_size = v.into();
621            self
622        }
623
624        /// Sets the value of [page_token][location::model::ListLocationsRequest::page_token].
625        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
626            self.0.request.page_token = v.into();
627            self
628        }
629    }
630
631    #[doc(hidden)]
632    impl gax::options::internal::RequestBuilder for ListLocations {
633        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
634            &mut self.0.options
635        }
636    }
637
638    /// The request builder for [StorageBatchOperations::get_location][crate::client::StorageBatchOperations::get_location] calls.
639    ///
640    /// # Example
641    /// ```no_run
642    /// # use google_cloud_storagebatchoperations_v1::builder;
643    /// use builder::storage_batch_operations::GetLocation;
644    /// # tokio_test::block_on(async {
645    ///
646    /// let builder = prepare_request_builder();
647    /// let response = builder.send().await?;
648    /// # gax::Result::<()>::Ok(()) });
649    ///
650    /// fn prepare_request_builder() -> GetLocation {
651    ///   # panic!();
652    ///   // ... details omitted ...
653    /// }
654    /// ```
655    #[derive(Clone, Debug)]
656    pub struct GetLocation(RequestBuilder<location::model::GetLocationRequest>);
657
658    impl GetLocation {
659        pub(crate) fn new(
660            stub: std::sync::Arc<dyn super::super::stub::dynamic::StorageBatchOperations>,
661        ) -> Self {
662            Self(RequestBuilder::new(stub))
663        }
664
665        /// Sets the full request, replacing any prior values.
666        pub fn with_request<V: Into<location::model::GetLocationRequest>>(mut self, v: V) -> Self {
667            self.0.request = v.into();
668            self
669        }
670
671        /// Sets all the options, replacing any prior values.
672        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
673            self.0.options = v.into();
674            self
675        }
676
677        /// Sends the request.
678        pub async fn send(self) -> Result<location::model::Location> {
679            (*self.0.stub)
680                .get_location(self.0.request, self.0.options)
681                .await
682                .map(gax::response::Response::into_body)
683        }
684
685        /// Sets the value of [name][location::model::GetLocationRequest::name].
686        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
687            self.0.request.name = v.into();
688            self
689        }
690    }
691
692    #[doc(hidden)]
693    impl gax::options::internal::RequestBuilder for GetLocation {
694        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
695            &mut self.0.options
696        }
697    }
698
699    /// The request builder for [StorageBatchOperations::list_operations][crate::client::StorageBatchOperations::list_operations] calls.
700    ///
701    /// # Example
702    /// ```no_run
703    /// # use google_cloud_storagebatchoperations_v1::builder;
704    /// use builder::storage_batch_operations::ListOperations;
705    /// # tokio_test::block_on(async {
706    /// use gax::paginator::ItemPaginator;
707    ///
708    /// let builder = prepare_request_builder();
709    /// let mut items = builder.by_item();
710    /// while let Some(result) = items.next().await {
711    ///   let item = result?;
712    /// }
713    /// # gax::Result::<()>::Ok(()) });
714    ///
715    /// fn prepare_request_builder() -> ListOperations {
716    ///   # panic!();
717    ///   // ... details omitted ...
718    /// }
719    /// ```
720    #[derive(Clone, Debug)]
721    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);
722
723    impl ListOperations {
724        pub(crate) fn new(
725            stub: std::sync::Arc<dyn super::super::stub::dynamic::StorageBatchOperations>,
726        ) -> Self {
727            Self(RequestBuilder::new(stub))
728        }
729
730        /// Sets the full request, replacing any prior values.
731        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
732            mut self,
733            v: V,
734        ) -> Self {
735            self.0.request = v.into();
736            self
737        }
738
739        /// Sets all the options, replacing any prior values.
740        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
741            self.0.options = v.into();
742            self
743        }
744
745        /// Sends the request.
746        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
747            (*self.0.stub)
748                .list_operations(self.0.request, self.0.options)
749                .await
750                .map(gax::response::Response::into_body)
751        }
752
753        /// Streams each page in the collection.
754        pub fn by_page(
755            self,
756        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
757        {
758            use std::clone::Clone;
759            let token = self.0.request.page_token.clone();
760            let execute = move |token: String| {
761                let mut builder = self.clone();
762                builder.0.request = builder.0.request.set_page_token(token);
763                builder.send()
764            };
765            gax::paginator::internal::new_paginator(token, execute)
766        }
767
768        /// Streams each item in the collection.
769        pub fn by_item(
770            self,
771        ) -> impl gax::paginator::ItemPaginator<
772            longrunning::model::ListOperationsResponse,
773            gax::error::Error,
774        > {
775            use gax::paginator::Paginator;
776            self.by_page().items()
777        }
778
779        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
780        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
781            self.0.request.name = v.into();
782            self
783        }
784
785        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
786        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
787            self.0.request.filter = v.into();
788            self
789        }
790
791        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
792        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
793            self.0.request.page_size = v.into();
794            self
795        }
796
797        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
798        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
799            self.0.request.page_token = v.into();
800            self
801        }
802    }
803
804    #[doc(hidden)]
805    impl gax::options::internal::RequestBuilder for ListOperations {
806        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
807            &mut self.0.options
808        }
809    }
810
811    /// The request builder for [StorageBatchOperations::get_operation][crate::client::StorageBatchOperations::get_operation] calls.
812    ///
813    /// # Example
814    /// ```no_run
815    /// # use google_cloud_storagebatchoperations_v1::builder;
816    /// use builder::storage_batch_operations::GetOperation;
817    /// # tokio_test::block_on(async {
818    ///
819    /// let builder = prepare_request_builder();
820    /// let response = builder.send().await?;
821    /// # gax::Result::<()>::Ok(()) });
822    ///
823    /// fn prepare_request_builder() -> GetOperation {
824    ///   # panic!();
825    ///   // ... details omitted ...
826    /// }
827    /// ```
828    #[derive(Clone, Debug)]
829    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);
830
831    impl GetOperation {
832        pub(crate) fn new(
833            stub: std::sync::Arc<dyn super::super::stub::dynamic::StorageBatchOperations>,
834        ) -> Self {
835            Self(RequestBuilder::new(stub))
836        }
837
838        /// Sets the full request, replacing any prior values.
839        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
840            mut self,
841            v: V,
842        ) -> Self {
843            self.0.request = v.into();
844            self
845        }
846
847        /// Sets all the options, replacing any prior values.
848        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
849            self.0.options = v.into();
850            self
851        }
852
853        /// Sends the request.
854        pub async fn send(self) -> Result<longrunning::model::Operation> {
855            (*self.0.stub)
856                .get_operation(self.0.request, self.0.options)
857                .await
858                .map(gax::response::Response::into_body)
859        }
860
861        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
862        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
863            self.0.request.name = v.into();
864            self
865        }
866    }
867
868    #[doc(hidden)]
869    impl gax::options::internal::RequestBuilder for GetOperation {
870        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
871            &mut self.0.options
872        }
873    }
874
875    /// The request builder for [StorageBatchOperations::delete_operation][crate::client::StorageBatchOperations::delete_operation] calls.
876    ///
877    /// # Example
878    /// ```no_run
879    /// # use google_cloud_storagebatchoperations_v1::builder;
880    /// use builder::storage_batch_operations::DeleteOperation;
881    /// # tokio_test::block_on(async {
882    ///
883    /// let builder = prepare_request_builder();
884    /// let response = builder.send().await?;
885    /// # gax::Result::<()>::Ok(()) });
886    ///
887    /// fn prepare_request_builder() -> DeleteOperation {
888    ///   # panic!();
889    ///   // ... details omitted ...
890    /// }
891    /// ```
892    #[derive(Clone, Debug)]
893    pub struct DeleteOperation(RequestBuilder<longrunning::model::DeleteOperationRequest>);
894
895    impl DeleteOperation {
896        pub(crate) fn new(
897            stub: std::sync::Arc<dyn super::super::stub::dynamic::StorageBatchOperations>,
898        ) -> Self {
899            Self(RequestBuilder::new(stub))
900        }
901
902        /// Sets the full request, replacing any prior values.
903        pub fn with_request<V: Into<longrunning::model::DeleteOperationRequest>>(
904            mut self,
905            v: V,
906        ) -> Self {
907            self.0.request = v.into();
908            self
909        }
910
911        /// Sets all the options, replacing any prior values.
912        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
913            self.0.options = v.into();
914            self
915        }
916
917        /// Sends the request.
918        pub async fn send(self) -> Result<()> {
919            (*self.0.stub)
920                .delete_operation(self.0.request, self.0.options)
921                .await
922                .map(gax::response::Response::into_body)
923        }
924
925        /// Sets the value of [name][longrunning::model::DeleteOperationRequest::name].
926        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
927            self.0.request.name = v.into();
928            self
929        }
930    }
931
932    #[doc(hidden)]
933    impl gax::options::internal::RequestBuilder for DeleteOperation {
934        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
935            &mut self.0.options
936        }
937    }
938
939    /// The request builder for [StorageBatchOperations::cancel_operation][crate::client::StorageBatchOperations::cancel_operation] calls.
940    ///
941    /// # Example
942    /// ```no_run
943    /// # use google_cloud_storagebatchoperations_v1::builder;
944    /// use builder::storage_batch_operations::CancelOperation;
945    /// # tokio_test::block_on(async {
946    ///
947    /// let builder = prepare_request_builder();
948    /// let response = builder.send().await?;
949    /// # gax::Result::<()>::Ok(()) });
950    ///
951    /// fn prepare_request_builder() -> CancelOperation {
952    ///   # panic!();
953    ///   // ... details omitted ...
954    /// }
955    /// ```
956    #[derive(Clone, Debug)]
957    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);
958
959    impl CancelOperation {
960        pub(crate) fn new(
961            stub: std::sync::Arc<dyn super::super::stub::dynamic::StorageBatchOperations>,
962        ) -> Self {
963            Self(RequestBuilder::new(stub))
964        }
965
966        /// Sets the full request, replacing any prior values.
967        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
968            mut self,
969            v: V,
970        ) -> Self {
971            self.0.request = v.into();
972            self
973        }
974
975        /// Sets all the options, replacing any prior values.
976        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
977            self.0.options = v.into();
978            self
979        }
980
981        /// Sends the request.
982        pub async fn send(self) -> Result<()> {
983            (*self.0.stub)
984                .cancel_operation(self.0.request, self.0.options)
985                .await
986                .map(gax::response::Response::into_body)
987        }
988
989        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
990        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
991            self.0.request.name = v.into();
992            self
993        }
994    }
995
996    #[doc(hidden)]
997    impl gax::options::internal::RequestBuilder for CancelOperation {
998        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
999            &mut self.0.options
1000        }
1001    }
1002}