google_cloud_datastore_admin_v1/
builder.rs1pub mod datastore_admin {
18 use crate::Result;
19 use std::sync::Arc;
20
21 pub type ClientBuilder =
35 gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;
36
37 pub(crate) mod client {
38 use super::super::super::client::DatastoreAdmin;
39 pub struct Factory;
40 impl gax::client_builder::internal::ClientFactory for Factory {
41 type Client = DatastoreAdmin;
42 type Credentials = gaxi::options::Credentials;
43 async fn build(self, config: gaxi::options::ClientConfig) -> gax::Result<Self::Client> {
44 Self::Client::new(config).await
45 }
46 }
47 }
48
49 #[derive(Clone, Debug)]
51 pub(crate) struct RequestBuilder<R: std::default::Default> {
52 stub: Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
53 request: R,
54 options: gax::options::RequestOptions,
55 }
56
57 impl<R> RequestBuilder<R>
58 where
59 R: std::default::Default,
60 {
61 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::DatastoreAdmin>) -> Self {
62 Self {
63 stub,
64 request: R::default(),
65 options: gax::options::RequestOptions::default(),
66 }
67 }
68 }
69
70 #[derive(Clone, Debug)]
72 pub struct ExportEntities(RequestBuilder<crate::model::ExportEntitiesRequest>);
73
74 impl ExportEntities {
75 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::DatastoreAdmin>) -> Self {
76 Self(RequestBuilder::new(stub))
77 }
78
79 pub fn with_request<V: Into<crate::model::ExportEntitiesRequest>>(mut self, v: V) -> Self {
81 self.0.request = v.into();
82 self
83 }
84
85 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
87 self.0.options = v.into();
88 self
89 }
90
91 pub async fn send(self) -> Result<longrunning::model::Operation> {
98 (*self.0.stub)
99 .export_entities(self.0.request, self.0.options)
100 .await
101 .map(gax::response::Response::into_body)
102 }
103
104 pub fn poller(
106 self,
107 ) -> impl lro::Poller<crate::model::ExportEntitiesResponse, crate::model::ExportEntitiesMetadata>
108 {
109 type Operation = lro::Operation<
110 crate::model::ExportEntitiesResponse,
111 crate::model::ExportEntitiesMetadata,
112 >;
113 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
114 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
115
116 let stub = self.0.stub.clone();
117 let mut options = self.0.options.clone();
118 options.set_retry_policy(gax::retry_policy::NeverRetry);
119 let query = move |name| {
120 let stub = stub.clone();
121 let options = options.clone();
122 async {
123 let op = GetOperation::new(stub)
124 .set_name(name)
125 .with_options(options)
126 .send()
127 .await?;
128 Ok(Operation::new(op))
129 }
130 };
131
132 let start = move || async {
133 let op = self.send().await?;
134 Ok(Operation::new(op))
135 };
136
137 lro::new_poller(polling_error_policy, polling_backoff_policy, start, query)
138 }
139
140 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
142 self.0.request.project_id = v.into();
143 self
144 }
145
146 pub fn set_entity_filter<T: Into<std::option::Option<crate::model::EntityFilter>>>(
148 mut self,
149 v: T,
150 ) -> Self {
151 self.0.request.entity_filter = v.into();
152 self
153 }
154
155 pub fn set_output_url_prefix<T: Into<std::string::String>>(mut self, v: T) -> Self {
157 self.0.request.output_url_prefix = v.into();
158 self
159 }
160
161 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
163 where
164 T: std::iter::IntoIterator<Item = (K, V)>,
165 K: std::convert::Into<std::string::String>,
166 V: std::convert::Into<std::string::String>,
167 {
168 self.0.request.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
169 self
170 }
171 }
172
173 #[doc(hidden)]
174 impl gax::options::internal::RequestBuilder for ExportEntities {
175 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
176 &mut self.0.options
177 }
178 }
179
180 #[derive(Clone, Debug)]
182 pub struct ImportEntities(RequestBuilder<crate::model::ImportEntitiesRequest>);
183
184 impl ImportEntities {
185 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::DatastoreAdmin>) -> Self {
186 Self(RequestBuilder::new(stub))
187 }
188
189 pub fn with_request<V: Into<crate::model::ImportEntitiesRequest>>(mut self, v: V) -> Self {
191 self.0.request = v.into();
192 self
193 }
194
195 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
197 self.0.options = v.into();
198 self
199 }
200
201 pub async fn send(self) -> Result<longrunning::model::Operation> {
208 (*self.0.stub)
209 .import_entities(self.0.request, self.0.options)
210 .await
211 .map(gax::response::Response::into_body)
212 }
213
214 pub fn poller(self) -> impl lro::Poller<wkt::Empty, crate::model::ImportEntitiesMetadata> {
216 type Operation = lro::Operation<wkt::Empty, crate::model::ImportEntitiesMetadata>;
217 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
218 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
219
220 let stub = self.0.stub.clone();
221 let mut options = self.0.options.clone();
222 options.set_retry_policy(gax::retry_policy::NeverRetry);
223 let query = move |name| {
224 let stub = stub.clone();
225 let options = options.clone();
226 async {
227 let op = GetOperation::new(stub)
228 .set_name(name)
229 .with_options(options)
230 .send()
231 .await?;
232 Ok(Operation::new(op))
233 }
234 };
235
236 let start = move || async {
237 let op = self.send().await?;
238 Ok(Operation::new(op))
239 };
240
241 lro::new_poller(polling_error_policy, polling_backoff_policy, start, query)
242 }
243
244 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
246 self.0.request.project_id = v.into();
247 self
248 }
249
250 pub fn set_input_url<T: Into<std::string::String>>(mut self, v: T) -> Self {
252 self.0.request.input_url = v.into();
253 self
254 }
255
256 pub fn set_entity_filter<T: Into<std::option::Option<crate::model::EntityFilter>>>(
258 mut self,
259 v: T,
260 ) -> Self {
261 self.0.request.entity_filter = v.into();
262 self
263 }
264
265 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
267 where
268 T: std::iter::IntoIterator<Item = (K, V)>,
269 K: std::convert::Into<std::string::String>,
270 V: std::convert::Into<std::string::String>,
271 {
272 self.0.request.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
273 self
274 }
275 }
276
277 #[doc(hidden)]
278 impl gax::options::internal::RequestBuilder for ImportEntities {
279 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
280 &mut self.0.options
281 }
282 }
283
284 #[derive(Clone, Debug)]
286 pub struct CreateIndex(RequestBuilder<crate::model::CreateIndexRequest>);
287
288 impl CreateIndex {
289 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::DatastoreAdmin>) -> Self {
290 Self(RequestBuilder::new(stub))
291 }
292
293 pub fn with_request<V: Into<crate::model::CreateIndexRequest>>(mut self, v: V) -> Self {
295 self.0.request = v.into();
296 self
297 }
298
299 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
301 self.0.options = v.into();
302 self
303 }
304
305 pub async fn send(self) -> Result<longrunning::model::Operation> {
312 (*self.0.stub)
313 .create_index(self.0.request, self.0.options)
314 .await
315 .map(gax::response::Response::into_body)
316 }
317
318 pub fn poller(
320 self,
321 ) -> impl lro::Poller<crate::model::Index, crate::model::IndexOperationMetadata> {
322 type Operation =
323 lro::Operation<crate::model::Index, crate::model::IndexOperationMetadata>;
324 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
325 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
326
327 let stub = self.0.stub.clone();
328 let mut options = self.0.options.clone();
329 options.set_retry_policy(gax::retry_policy::NeverRetry);
330 let query = move |name| {
331 let stub = stub.clone();
332 let options = options.clone();
333 async {
334 let op = GetOperation::new(stub)
335 .set_name(name)
336 .with_options(options)
337 .send()
338 .await?;
339 Ok(Operation::new(op))
340 }
341 };
342
343 let start = move || async {
344 let op = self.send().await?;
345 Ok(Operation::new(op))
346 };
347
348 lro::new_poller(polling_error_policy, polling_backoff_policy, start, query)
349 }
350
351 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
353 self.0.request.project_id = v.into();
354 self
355 }
356
357 pub fn set_index<T: Into<std::option::Option<crate::model::Index>>>(
359 mut self,
360 v: T,
361 ) -> Self {
362 self.0.request.index = v.into();
363 self
364 }
365 }
366
367 #[doc(hidden)]
368 impl gax::options::internal::RequestBuilder for CreateIndex {
369 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
370 &mut self.0.options
371 }
372 }
373
374 #[derive(Clone, Debug)]
376 pub struct DeleteIndex(RequestBuilder<crate::model::DeleteIndexRequest>);
377
378 impl DeleteIndex {
379 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::DatastoreAdmin>) -> Self {
380 Self(RequestBuilder::new(stub))
381 }
382
383 pub fn with_request<V: Into<crate::model::DeleteIndexRequest>>(mut self, v: V) -> Self {
385 self.0.request = v.into();
386 self
387 }
388
389 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
391 self.0.options = v.into();
392 self
393 }
394
395 pub async fn send(self) -> Result<longrunning::model::Operation> {
402 (*self.0.stub)
403 .delete_index(self.0.request, self.0.options)
404 .await
405 .map(gax::response::Response::into_body)
406 }
407
408 pub fn poller(
410 self,
411 ) -> impl lro::Poller<crate::model::Index, crate::model::IndexOperationMetadata> {
412 type Operation =
413 lro::Operation<crate::model::Index, crate::model::IndexOperationMetadata>;
414 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
415 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
416
417 let stub = self.0.stub.clone();
418 let mut options = self.0.options.clone();
419 options.set_retry_policy(gax::retry_policy::NeverRetry);
420 let query = move |name| {
421 let stub = stub.clone();
422 let options = options.clone();
423 async {
424 let op = GetOperation::new(stub)
425 .set_name(name)
426 .with_options(options)
427 .send()
428 .await?;
429 Ok(Operation::new(op))
430 }
431 };
432
433 let start = move || async {
434 let op = self.send().await?;
435 Ok(Operation::new(op))
436 };
437
438 lro::new_poller(polling_error_policy, polling_backoff_policy, start, query)
439 }
440
441 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
443 self.0.request.project_id = v.into();
444 self
445 }
446
447 pub fn set_index_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
449 self.0.request.index_id = v.into();
450 self
451 }
452 }
453
454 #[doc(hidden)]
455 impl gax::options::internal::RequestBuilder for DeleteIndex {
456 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
457 &mut self.0.options
458 }
459 }
460
461 #[derive(Clone, Debug)]
463 pub struct GetIndex(RequestBuilder<crate::model::GetIndexRequest>);
464
465 impl GetIndex {
466 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::DatastoreAdmin>) -> Self {
467 Self(RequestBuilder::new(stub))
468 }
469
470 pub fn with_request<V: Into<crate::model::GetIndexRequest>>(mut self, v: V) -> Self {
472 self.0.request = v.into();
473 self
474 }
475
476 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
478 self.0.options = v.into();
479 self
480 }
481
482 pub async fn send(self) -> Result<crate::model::Index> {
484 (*self.0.stub)
485 .get_index(self.0.request, self.0.options)
486 .await
487 .map(gax::response::Response::into_body)
488 }
489
490 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
492 self.0.request.project_id = v.into();
493 self
494 }
495
496 pub fn set_index_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
498 self.0.request.index_id = v.into();
499 self
500 }
501 }
502
503 #[doc(hidden)]
504 impl gax::options::internal::RequestBuilder for GetIndex {
505 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
506 &mut self.0.options
507 }
508 }
509
510 #[derive(Clone, Debug)]
512 pub struct ListIndexes(RequestBuilder<crate::model::ListIndexesRequest>);
513
514 impl ListIndexes {
515 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::DatastoreAdmin>) -> Self {
516 Self(RequestBuilder::new(stub))
517 }
518
519 pub fn with_request<V: Into<crate::model::ListIndexesRequest>>(mut self, v: V) -> Self {
521 self.0.request = v.into();
522 self
523 }
524
525 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
527 self.0.options = v.into();
528 self
529 }
530
531 pub async fn send(self) -> Result<crate::model::ListIndexesResponse> {
533 (*self.0.stub)
534 .list_indexes(self.0.request, self.0.options)
535 .await
536 .map(gax::response::Response::into_body)
537 }
538
539 pub async fn paginator(
541 self,
542 ) -> impl gax::paginator::Paginator<crate::model::ListIndexesResponse, gax::error::Error>
543 {
544 use std::clone::Clone;
545 let token = self.0.request.page_token.clone();
546 let execute = move |token: String| {
547 let mut builder = self.clone();
548 builder.0.request = builder.0.request.set_page_token(token);
549 builder.send()
550 };
551 gax::paginator::internal::new_paginator(token, execute)
552 }
553
554 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
556 self.0.request.project_id = v.into();
557 self
558 }
559
560 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
562 self.0.request.filter = v.into();
563 self
564 }
565
566 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
568 self.0.request.page_size = v.into();
569 self
570 }
571
572 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
574 self.0.request.page_token = v.into();
575 self
576 }
577 }
578
579 #[doc(hidden)]
580 impl gax::options::internal::RequestBuilder for ListIndexes {
581 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
582 &mut self.0.options
583 }
584 }
585
586 #[derive(Clone, Debug)]
588 pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);
589
590 impl ListOperations {
591 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::DatastoreAdmin>) -> Self {
592 Self(RequestBuilder::new(stub))
593 }
594
595 pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
597 mut self,
598 v: V,
599 ) -> Self {
600 self.0.request = v.into();
601 self
602 }
603
604 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
606 self.0.options = v.into();
607 self
608 }
609
610 pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
612 (*self.0.stub)
613 .list_operations(self.0.request, self.0.options)
614 .await
615 .map(gax::response::Response::into_body)
616 }
617
618 pub async fn paginator(
620 self,
621 ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
622 {
623 use std::clone::Clone;
624 let token = self.0.request.page_token.clone();
625 let execute = move |token: String| {
626 let mut builder = self.clone();
627 builder.0.request = builder.0.request.set_page_token(token);
628 builder.send()
629 };
630 gax::paginator::internal::new_paginator(token, execute)
631 }
632
633 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
635 self.0.request.name = v.into();
636 self
637 }
638
639 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
641 self.0.request.filter = v.into();
642 self
643 }
644
645 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
647 self.0.request.page_size = v.into();
648 self
649 }
650
651 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
653 self.0.request.page_token = v.into();
654 self
655 }
656 }
657
658 #[doc(hidden)]
659 impl gax::options::internal::RequestBuilder for ListOperations {
660 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
661 &mut self.0.options
662 }
663 }
664
665 #[derive(Clone, Debug)]
667 pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);
668
669 impl GetOperation {
670 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::DatastoreAdmin>) -> Self {
671 Self(RequestBuilder::new(stub))
672 }
673
674 pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
676 mut self,
677 v: V,
678 ) -> Self {
679 self.0.request = v.into();
680 self
681 }
682
683 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
685 self.0.options = v.into();
686 self
687 }
688
689 pub async fn send(self) -> Result<longrunning::model::Operation> {
691 (*self.0.stub)
692 .get_operation(self.0.request, self.0.options)
693 .await
694 .map(gax::response::Response::into_body)
695 }
696
697 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
699 self.0.request.name = v.into();
700 self
701 }
702 }
703
704 #[doc(hidden)]
705 impl gax::options::internal::RequestBuilder for GetOperation {
706 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
707 &mut self.0.options
708 }
709 }
710
711 #[derive(Clone, Debug)]
713 pub struct DeleteOperation(RequestBuilder<longrunning::model::DeleteOperationRequest>);
714
715 impl DeleteOperation {
716 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::DatastoreAdmin>) -> Self {
717 Self(RequestBuilder::new(stub))
718 }
719
720 pub fn with_request<V: Into<longrunning::model::DeleteOperationRequest>>(
722 mut self,
723 v: V,
724 ) -> Self {
725 self.0.request = v.into();
726 self
727 }
728
729 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
731 self.0.options = v.into();
732 self
733 }
734
735 pub async fn send(self) -> Result<()> {
737 (*self.0.stub)
738 .delete_operation(self.0.request, self.0.options)
739 .await
740 .map(gax::response::Response::into_body)
741 }
742
743 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
745 self.0.request.name = v.into();
746 self
747 }
748 }
749
750 #[doc(hidden)]
751 impl gax::options::internal::RequestBuilder for DeleteOperation {
752 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
753 &mut self.0.options
754 }
755 }
756
757 #[derive(Clone, Debug)]
759 pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);
760
761 impl CancelOperation {
762 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::DatastoreAdmin>) -> Self {
763 Self(RequestBuilder::new(stub))
764 }
765
766 pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
768 mut self,
769 v: V,
770 ) -> Self {
771 self.0.request = v.into();
772 self
773 }
774
775 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
777 self.0.options = v.into();
778 self
779 }
780
781 pub async fn send(self) -> Result<()> {
783 (*self.0.stub)
784 .cancel_operation(self.0.request, self.0.options)
785 .await
786 .map(gax::response::Response::into_body)
787 }
788
789 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
796 #[doc(hidden)]
797 impl gax::options::internal::RequestBuilder for CancelOperation {
798 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
799 &mut self.0.options
800 }
801 }
802}