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 /// Sets the value of [force][crate::model::DeleteJobRequest::force].
455 pub fn set_force<T: Into<bool>>(mut self, v: T) -> Self {
456 self.0.request.force = v.into();
457 self
458 }
459 }
460
461 #[doc(hidden)]
462 impl crate::RequestBuilder for DeleteJob {
463 fn request_options(&mut self) -> &mut crate::RequestOptions {
464 &mut self.0.options
465 }
466 }
467
468 /// The request builder for [StorageBatchOperations::cancel_job][crate::client::StorageBatchOperations::cancel_job] calls.
469 ///
470 /// # Example
471 /// ```
472 /// # use google_cloud_storagebatchoperations_v1::builder::storage_batch_operations::CancelJob;
473 /// # async fn sample() -> google_cloud_storagebatchoperations_v1::Result<()> {
474 ///
475 /// let builder = prepare_request_builder();
476 /// let response = builder.send().await?;
477 /// # Ok(()) }
478 ///
479 /// fn prepare_request_builder() -> CancelJob {
480 /// # panic!();
481 /// // ... details omitted ...
482 /// }
483 /// ```
484 #[derive(Clone, Debug)]
485 pub struct CancelJob(RequestBuilder<crate::model::CancelJobRequest>);
486
487 impl CancelJob {
488 pub(crate) fn new(
489 stub: std::sync::Arc<dyn super::super::stub::dynamic::StorageBatchOperations>,
490 ) -> Self {
491 Self(RequestBuilder::new(stub))
492 }
493
494 /// Sets the full request, replacing any prior values.
495 pub fn with_request<V: Into<crate::model::CancelJobRequest>>(mut self, v: V) -> Self {
496 self.0.request = v.into();
497 self
498 }
499
500 /// Sets all the options, replacing any prior values.
501 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
502 self.0.options = v.into();
503 self
504 }
505
506 /// Sends the request.
507 pub async fn send(self) -> Result<crate::model::CancelJobResponse> {
508 (*self.0.stub)
509 .cancel_job(self.0.request, self.0.options)
510 .await
511 .map(crate::Response::into_body)
512 }
513
514 /// Sets the value of [name][crate::model::CancelJobRequest::name].
515 ///
516 /// This is a **required** field for requests.
517 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
518 self.0.request.name = v.into();
519 self
520 }
521
522 /// Sets the value of [request_id][crate::model::CancelJobRequest::request_id].
523 pub fn set_request_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
524 self.0.request.request_id = v.into();
525 self
526 }
527 }
528
529 #[doc(hidden)]
530 impl crate::RequestBuilder for CancelJob {
531 fn request_options(&mut self) -> &mut crate::RequestOptions {
532 &mut self.0.options
533 }
534 }
535
536 /// The request builder for [StorageBatchOperations::list_bucket_operations][crate::client::StorageBatchOperations::list_bucket_operations] calls.
537 ///
538 /// # Example
539 /// ```
540 /// # use google_cloud_storagebatchoperations_v1::builder::storage_batch_operations::ListBucketOperations;
541 /// # async fn sample() -> google_cloud_storagebatchoperations_v1::Result<()> {
542 /// use google_cloud_gax::paginator::ItemPaginator;
543 ///
544 /// let builder = prepare_request_builder();
545 /// let mut items = builder.by_item();
546 /// while let Some(result) = items.next().await {
547 /// let item = result?;
548 /// }
549 /// # Ok(()) }
550 ///
551 /// fn prepare_request_builder() -> ListBucketOperations {
552 /// # panic!();
553 /// // ... details omitted ...
554 /// }
555 /// ```
556 #[derive(Clone, Debug)]
557 pub struct ListBucketOperations(RequestBuilder<crate::model::ListBucketOperationsRequest>);
558
559 impl ListBucketOperations {
560 pub(crate) fn new(
561 stub: std::sync::Arc<dyn super::super::stub::dynamic::StorageBatchOperations>,
562 ) -> Self {
563 Self(RequestBuilder::new(stub))
564 }
565
566 /// Sets the full request, replacing any prior values.
567 pub fn with_request<V: Into<crate::model::ListBucketOperationsRequest>>(
568 mut self,
569 v: V,
570 ) -> Self {
571 self.0.request = v.into();
572 self
573 }
574
575 /// Sets all the options, replacing any prior values.
576 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
577 self.0.options = v.into();
578 self
579 }
580
581 /// Sends the request.
582 pub async fn send(self) -> Result<crate::model::ListBucketOperationsResponse> {
583 (*self.0.stub)
584 .list_bucket_operations(self.0.request, self.0.options)
585 .await
586 .map(crate::Response::into_body)
587 }
588
589 /// Streams each page in the collection.
590 pub fn by_page(
591 self,
592 ) -> impl google_cloud_gax::paginator::Paginator<
593 crate::model::ListBucketOperationsResponse,
594 crate::Error,
595 > {
596 use std::clone::Clone;
597 let token = self.0.request.page_token.clone();
598 let execute = move |token: String| {
599 let mut builder = self.clone();
600 builder.0.request = builder.0.request.set_page_token(token);
601 builder.send()
602 };
603 google_cloud_gax::paginator::internal::new_paginator(token, execute)
604 }
605
606 /// Streams each item in the collection.
607 pub fn by_item(
608 self,
609 ) -> impl google_cloud_gax::paginator::ItemPaginator<
610 crate::model::ListBucketOperationsResponse,
611 crate::Error,
612 > {
613 use google_cloud_gax::paginator::Paginator;
614 self.by_page().items()
615 }
616
617 /// Sets the value of [parent][crate::model::ListBucketOperationsRequest::parent].
618 ///
619 /// This is a **required** field for requests.
620 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
621 self.0.request.parent = v.into();
622 self
623 }
624
625 /// Sets the value of [filter][crate::model::ListBucketOperationsRequest::filter].
626 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
627 self.0.request.filter = v.into();
628 self
629 }
630
631 /// Sets the value of [page_size][crate::model::ListBucketOperationsRequest::page_size].
632 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
633 self.0.request.page_size = v.into();
634 self
635 }
636
637 /// Sets the value of [page_token][crate::model::ListBucketOperationsRequest::page_token].
638 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
639 self.0.request.page_token = v.into();
640 self
641 }
642
643 /// Sets the value of [order_by][crate::model::ListBucketOperationsRequest::order_by].
644 pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
645 self.0.request.order_by = v.into();
646 self
647 }
648 }
649
650 #[doc(hidden)]
651 impl crate::RequestBuilder for ListBucketOperations {
652 fn request_options(&mut self) -> &mut crate::RequestOptions {
653 &mut self.0.options
654 }
655 }
656
657 /// The request builder for [StorageBatchOperations::get_bucket_operation][crate::client::StorageBatchOperations::get_bucket_operation] calls.
658 ///
659 /// # Example
660 /// ```
661 /// # use google_cloud_storagebatchoperations_v1::builder::storage_batch_operations::GetBucketOperation;
662 /// # async fn sample() -> google_cloud_storagebatchoperations_v1::Result<()> {
663 ///
664 /// let builder = prepare_request_builder();
665 /// let response = builder.send().await?;
666 /// # Ok(()) }
667 ///
668 /// fn prepare_request_builder() -> GetBucketOperation {
669 /// # panic!();
670 /// // ... details omitted ...
671 /// }
672 /// ```
673 #[derive(Clone, Debug)]
674 pub struct GetBucketOperation(RequestBuilder<crate::model::GetBucketOperationRequest>);
675
676 impl GetBucketOperation {
677 pub(crate) fn new(
678 stub: std::sync::Arc<dyn super::super::stub::dynamic::StorageBatchOperations>,
679 ) -> Self {
680 Self(RequestBuilder::new(stub))
681 }
682
683 /// Sets the full request, replacing any prior values.
684 pub fn with_request<V: Into<crate::model::GetBucketOperationRequest>>(
685 mut self,
686 v: V,
687 ) -> Self {
688 self.0.request = v.into();
689 self
690 }
691
692 /// Sets all the options, replacing any prior values.
693 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
694 self.0.options = v.into();
695 self
696 }
697
698 /// Sends the request.
699 pub async fn send(self) -> Result<crate::model::BucketOperation> {
700 (*self.0.stub)
701 .get_bucket_operation(self.0.request, self.0.options)
702 .await
703 .map(crate::Response::into_body)
704 }
705
706 /// Sets the value of [name][crate::model::GetBucketOperationRequest::name].
707 ///
708 /// This is a **required** field for requests.
709 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
710 self.0.request.name = v.into();
711 self
712 }
713 }
714
715 #[doc(hidden)]
716 impl crate::RequestBuilder for GetBucketOperation {
717 fn request_options(&mut self) -> &mut crate::RequestOptions {
718 &mut self.0.options
719 }
720 }
721
722 /// The request builder for [StorageBatchOperations::list_locations][crate::client::StorageBatchOperations::list_locations] calls.
723 ///
724 /// # Example
725 /// ```
726 /// # use google_cloud_storagebatchoperations_v1::builder::storage_batch_operations::ListLocations;
727 /// # async fn sample() -> google_cloud_storagebatchoperations_v1::Result<()> {
728 /// use google_cloud_gax::paginator::ItemPaginator;
729 ///
730 /// let builder = prepare_request_builder();
731 /// let mut items = builder.by_item();
732 /// while let Some(result) = items.next().await {
733 /// let item = result?;
734 /// }
735 /// # Ok(()) }
736 ///
737 /// fn prepare_request_builder() -> ListLocations {
738 /// # panic!();
739 /// // ... details omitted ...
740 /// }
741 /// ```
742 #[derive(Clone, Debug)]
743 pub struct ListLocations(RequestBuilder<google_cloud_location::model::ListLocationsRequest>);
744
745 impl ListLocations {
746 pub(crate) fn new(
747 stub: std::sync::Arc<dyn super::super::stub::dynamic::StorageBatchOperations>,
748 ) -> Self {
749 Self(RequestBuilder::new(stub))
750 }
751
752 /// Sets the full request, replacing any prior values.
753 pub fn with_request<V: Into<google_cloud_location::model::ListLocationsRequest>>(
754 mut self,
755 v: V,
756 ) -> Self {
757 self.0.request = v.into();
758 self
759 }
760
761 /// Sets all the options, replacing any prior values.
762 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
763 self.0.options = v.into();
764 self
765 }
766
767 /// Sends the request.
768 pub async fn send(self) -> Result<google_cloud_location::model::ListLocationsResponse> {
769 (*self.0.stub)
770 .list_locations(self.0.request, self.0.options)
771 .await
772 .map(crate::Response::into_body)
773 }
774
775 /// Streams each page in the collection.
776 pub fn by_page(
777 self,
778 ) -> impl google_cloud_gax::paginator::Paginator<
779 google_cloud_location::model::ListLocationsResponse,
780 crate::Error,
781 > {
782 use std::clone::Clone;
783 let token = self.0.request.page_token.clone();
784 let execute = move |token: String| {
785 let mut builder = self.clone();
786 builder.0.request = builder.0.request.set_page_token(token);
787 builder.send()
788 };
789 google_cloud_gax::paginator::internal::new_paginator(token, execute)
790 }
791
792 /// Streams each item in the collection.
793 pub fn by_item(
794 self,
795 ) -> impl google_cloud_gax::paginator::ItemPaginator<
796 google_cloud_location::model::ListLocationsResponse,
797 crate::Error,
798 > {
799 use google_cloud_gax::paginator::Paginator;
800 self.by_page().items()
801 }
802
803 /// Sets the value of [name][google_cloud_location::model::ListLocationsRequest::name].
804 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
805 self.0.request.name = v.into();
806 self
807 }
808
809 /// Sets the value of [filter][google_cloud_location::model::ListLocationsRequest::filter].
810 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
811 self.0.request.filter = v.into();
812 self
813 }
814
815 /// Sets the value of [page_size][google_cloud_location::model::ListLocationsRequest::page_size].
816 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
817 self.0.request.page_size = v.into();
818 self
819 }
820
821 /// Sets the value of [page_token][google_cloud_location::model::ListLocationsRequest::page_token].
822 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
823 self.0.request.page_token = v.into();
824 self
825 }
826 }
827
828 #[doc(hidden)]
829 impl crate::RequestBuilder for ListLocations {
830 fn request_options(&mut self) -> &mut crate::RequestOptions {
831 &mut self.0.options
832 }
833 }
834
835 /// The request builder for [StorageBatchOperations::get_location][crate::client::StorageBatchOperations::get_location] calls.
836 ///
837 /// # Example
838 /// ```
839 /// # use google_cloud_storagebatchoperations_v1::builder::storage_batch_operations::GetLocation;
840 /// # async fn sample() -> google_cloud_storagebatchoperations_v1::Result<()> {
841 ///
842 /// let builder = prepare_request_builder();
843 /// let response = builder.send().await?;
844 /// # Ok(()) }
845 ///
846 /// fn prepare_request_builder() -> GetLocation {
847 /// # panic!();
848 /// // ... details omitted ...
849 /// }
850 /// ```
851 #[derive(Clone, Debug)]
852 pub struct GetLocation(RequestBuilder<google_cloud_location::model::GetLocationRequest>);
853
854 impl GetLocation {
855 pub(crate) fn new(
856 stub: std::sync::Arc<dyn super::super::stub::dynamic::StorageBatchOperations>,
857 ) -> Self {
858 Self(RequestBuilder::new(stub))
859 }
860
861 /// Sets the full request, replacing any prior values.
862 pub fn with_request<V: Into<google_cloud_location::model::GetLocationRequest>>(
863 mut self,
864 v: V,
865 ) -> Self {
866 self.0.request = v.into();
867 self
868 }
869
870 /// Sets all the options, replacing any prior values.
871 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
872 self.0.options = v.into();
873 self
874 }
875
876 /// Sends the request.
877 pub async fn send(self) -> Result<google_cloud_location::model::Location> {
878 (*self.0.stub)
879 .get_location(self.0.request, self.0.options)
880 .await
881 .map(crate::Response::into_body)
882 }
883
884 /// Sets the value of [name][google_cloud_location::model::GetLocationRequest::name].
885 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
886 self.0.request.name = v.into();
887 self
888 }
889 }
890
891 #[doc(hidden)]
892 impl crate::RequestBuilder for GetLocation {
893 fn request_options(&mut self) -> &mut crate::RequestOptions {
894 &mut self.0.options
895 }
896 }
897
898 /// The request builder for [StorageBatchOperations::list_operations][crate::client::StorageBatchOperations::list_operations] calls.
899 ///
900 /// # Example
901 /// ```
902 /// # use google_cloud_storagebatchoperations_v1::builder::storage_batch_operations::ListOperations;
903 /// # async fn sample() -> google_cloud_storagebatchoperations_v1::Result<()> {
904 /// use google_cloud_gax::paginator::ItemPaginator;
905 ///
906 /// let builder = prepare_request_builder();
907 /// let mut items = builder.by_item();
908 /// while let Some(result) = items.next().await {
909 /// let item = result?;
910 /// }
911 /// # Ok(()) }
912 ///
913 /// fn prepare_request_builder() -> ListOperations {
914 /// # panic!();
915 /// // ... details omitted ...
916 /// }
917 /// ```
918 #[derive(Clone, Debug)]
919 pub struct ListOperations(
920 RequestBuilder<google_cloud_longrunning::model::ListOperationsRequest>,
921 );
922
923 impl ListOperations {
924 pub(crate) fn new(
925 stub: std::sync::Arc<dyn super::super::stub::dynamic::StorageBatchOperations>,
926 ) -> Self {
927 Self(RequestBuilder::new(stub))
928 }
929
930 /// Sets the full request, replacing any prior values.
931 pub fn with_request<V: Into<google_cloud_longrunning::model::ListOperationsRequest>>(
932 mut self,
933 v: V,
934 ) -> Self {
935 self.0.request = v.into();
936 self
937 }
938
939 /// Sets all the options, replacing any prior values.
940 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
941 self.0.options = v.into();
942 self
943 }
944
945 /// Sends the request.
946 pub async fn send(self) -> Result<google_cloud_longrunning::model::ListOperationsResponse> {
947 (*self.0.stub)
948 .list_operations(self.0.request, self.0.options)
949 .await
950 .map(crate::Response::into_body)
951 }
952
953 /// Streams each page in the collection.
954 pub fn by_page(
955 self,
956 ) -> impl google_cloud_gax::paginator::Paginator<
957 google_cloud_longrunning::model::ListOperationsResponse,
958 crate::Error,
959 > {
960 use std::clone::Clone;
961 let token = self.0.request.page_token.clone();
962 let execute = move |token: String| {
963 let mut builder = self.clone();
964 builder.0.request = builder.0.request.set_page_token(token);
965 builder.send()
966 };
967 google_cloud_gax::paginator::internal::new_paginator(token, execute)
968 }
969
970 /// Streams each item in the collection.
971 pub fn by_item(
972 self,
973 ) -> impl google_cloud_gax::paginator::ItemPaginator<
974 google_cloud_longrunning::model::ListOperationsResponse,
975 crate::Error,
976 > {
977 use google_cloud_gax::paginator::Paginator;
978 self.by_page().items()
979 }
980
981 /// Sets the value of [name][google_cloud_longrunning::model::ListOperationsRequest::name].
982 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
983 self.0.request.name = v.into();
984 self
985 }
986
987 /// Sets the value of [filter][google_cloud_longrunning::model::ListOperationsRequest::filter].
988 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
989 self.0.request.filter = v.into();
990 self
991 }
992
993 /// Sets the value of [page_size][google_cloud_longrunning::model::ListOperationsRequest::page_size].
994 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
995 self.0.request.page_size = v.into();
996 self
997 }
998
999 /// Sets the value of [page_token][google_cloud_longrunning::model::ListOperationsRequest::page_token].
1000 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
1001 self.0.request.page_token = v.into();
1002 self
1003 }
1004
1005 /// Sets the value of [return_partial_success][google_cloud_longrunning::model::ListOperationsRequest::return_partial_success].
1006 pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
1007 self.0.request.return_partial_success = v.into();
1008 self
1009 }
1010 }
1011
1012 #[doc(hidden)]
1013 impl crate::RequestBuilder for ListOperations {
1014 fn request_options(&mut self) -> &mut crate::RequestOptions {
1015 &mut self.0.options
1016 }
1017 }
1018
1019 /// The request builder for [StorageBatchOperations::get_operation][crate::client::StorageBatchOperations::get_operation] calls.
1020 ///
1021 /// # Example
1022 /// ```
1023 /// # use google_cloud_storagebatchoperations_v1::builder::storage_batch_operations::GetOperation;
1024 /// # async fn sample() -> google_cloud_storagebatchoperations_v1::Result<()> {
1025 ///
1026 /// let builder = prepare_request_builder();
1027 /// let response = builder.send().await?;
1028 /// # Ok(()) }
1029 ///
1030 /// fn prepare_request_builder() -> GetOperation {
1031 /// # panic!();
1032 /// // ... details omitted ...
1033 /// }
1034 /// ```
1035 #[derive(Clone, Debug)]
1036 pub struct GetOperation(RequestBuilder<google_cloud_longrunning::model::GetOperationRequest>);
1037
1038 impl GetOperation {
1039 pub(crate) fn new(
1040 stub: std::sync::Arc<dyn super::super::stub::dynamic::StorageBatchOperations>,
1041 ) -> Self {
1042 Self(RequestBuilder::new(stub))
1043 }
1044
1045 /// Sets the full request, replacing any prior values.
1046 pub fn with_request<V: Into<google_cloud_longrunning::model::GetOperationRequest>>(
1047 mut self,
1048 v: V,
1049 ) -> Self {
1050 self.0.request = v.into();
1051 self
1052 }
1053
1054 /// Sets all the options, replacing any prior values.
1055 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1056 self.0.options = v.into();
1057 self
1058 }
1059
1060 /// Sends the request.
1061 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
1062 (*self.0.stub)
1063 .get_operation(self.0.request, self.0.options)
1064 .await
1065 .map(crate::Response::into_body)
1066 }
1067
1068 /// Sets the value of [name][google_cloud_longrunning::model::GetOperationRequest::name].
1069 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1070 self.0.request.name = v.into();
1071 self
1072 }
1073 }
1074
1075 #[doc(hidden)]
1076 impl crate::RequestBuilder for GetOperation {
1077 fn request_options(&mut self) -> &mut crate::RequestOptions {
1078 &mut self.0.options
1079 }
1080 }
1081
1082 /// The request builder for [StorageBatchOperations::delete_operation][crate::client::StorageBatchOperations::delete_operation] calls.
1083 ///
1084 /// # Example
1085 /// ```
1086 /// # use google_cloud_storagebatchoperations_v1::builder::storage_batch_operations::DeleteOperation;
1087 /// # async fn sample() -> google_cloud_storagebatchoperations_v1::Result<()> {
1088 ///
1089 /// let builder = prepare_request_builder();
1090 /// let response = builder.send().await?;
1091 /// # Ok(()) }
1092 ///
1093 /// fn prepare_request_builder() -> DeleteOperation {
1094 /// # panic!();
1095 /// // ... details omitted ...
1096 /// }
1097 /// ```
1098 #[derive(Clone, Debug)]
1099 pub struct DeleteOperation(
1100 RequestBuilder<google_cloud_longrunning::model::DeleteOperationRequest>,
1101 );
1102
1103 impl DeleteOperation {
1104 pub(crate) fn new(
1105 stub: std::sync::Arc<dyn super::super::stub::dynamic::StorageBatchOperations>,
1106 ) -> Self {
1107 Self(RequestBuilder::new(stub))
1108 }
1109
1110 /// Sets the full request, replacing any prior values.
1111 pub fn with_request<V: Into<google_cloud_longrunning::model::DeleteOperationRequest>>(
1112 mut self,
1113 v: V,
1114 ) -> Self {
1115 self.0.request = v.into();
1116 self
1117 }
1118
1119 /// Sets all the options, replacing any prior values.
1120 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1121 self.0.options = v.into();
1122 self
1123 }
1124
1125 /// Sends the request.
1126 pub async fn send(self) -> Result<()> {
1127 (*self.0.stub)
1128 .delete_operation(self.0.request, self.0.options)
1129 .await
1130 .map(crate::Response::into_body)
1131 }
1132
1133 /// Sets the value of [name][google_cloud_longrunning::model::DeleteOperationRequest::name].
1134 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1135 self.0.request.name = v.into();
1136 self
1137 }
1138 }
1139
1140 #[doc(hidden)]
1141 impl crate::RequestBuilder for DeleteOperation {
1142 fn request_options(&mut self) -> &mut crate::RequestOptions {
1143 &mut self.0.options
1144 }
1145 }
1146
1147 /// The request builder for [StorageBatchOperations::cancel_operation][crate::client::StorageBatchOperations::cancel_operation] calls.
1148 ///
1149 /// # Example
1150 /// ```
1151 /// # use google_cloud_storagebatchoperations_v1::builder::storage_batch_operations::CancelOperation;
1152 /// # async fn sample() -> google_cloud_storagebatchoperations_v1::Result<()> {
1153 ///
1154 /// let builder = prepare_request_builder();
1155 /// let response = builder.send().await?;
1156 /// # Ok(()) }
1157 ///
1158 /// fn prepare_request_builder() -> CancelOperation {
1159 /// # panic!();
1160 /// // ... details omitted ...
1161 /// }
1162 /// ```
1163 #[derive(Clone, Debug)]
1164 pub struct CancelOperation(
1165 RequestBuilder<google_cloud_longrunning::model::CancelOperationRequest>,
1166 );
1167
1168 impl CancelOperation {
1169 pub(crate) fn new(
1170 stub: std::sync::Arc<dyn super::super::stub::dynamic::StorageBatchOperations>,
1171 ) -> Self {
1172 Self(RequestBuilder::new(stub))
1173 }
1174
1175 /// Sets the full request, replacing any prior values.
1176 pub fn with_request<V: Into<google_cloud_longrunning::model::CancelOperationRequest>>(
1177 mut self,
1178 v: V,
1179 ) -> Self {
1180 self.0.request = v.into();
1181 self
1182 }
1183
1184 /// Sets all the options, replacing any prior values.
1185 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1186 self.0.options = v.into();
1187 self
1188 }
1189
1190 /// Sends the request.
1191 pub async fn send(self) -> Result<()> {
1192 (*self.0.stub)
1193 .cancel_operation(self.0.request, self.0.options)
1194 .await
1195 .map(crate::Response::into_body)
1196 }
1197
1198 /// Sets the value of [name][google_cloud_longrunning::model::CancelOperationRequest::name].
1199 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1200 self.0.request.name = v.into();
1201 self
1202 }
1203 }
1204
1205 #[doc(hidden)]
1206 impl crate::RequestBuilder for CancelOperation {
1207 fn request_options(&mut self) -> &mut crate::RequestOptions {
1208 &mut self.0.options
1209 }
1210 }
1211}