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