google_cloud_datastore_admin_v1/
builders.rs1pub mod datastore_admin {
18 use crate::Result;
19 use std::sync::Arc;
20
21 #[derive(Clone, Debug)]
23 pub struct RequestBuilder<R: std::default::Default> {
24 stub: Arc<dyn crate::stubs::dynamic::DatastoreAdmin>,
25 request: R,
26 options: gax::options::RequestOptions,
27 }
28
29 impl<R> RequestBuilder<R>
30 where
31 R: std::default::Default,
32 {
33 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::DatastoreAdmin>) -> Self {
34 Self {
35 stub,
36 request: R::default(),
37 options: gax::options::RequestOptions::default(),
38 }
39 }
40 }
41
42 #[derive(Clone, Debug)]
44 pub struct ExportEntities(RequestBuilder<crate::model::ExportEntitiesRequest>);
45
46 impl ExportEntities {
47 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::DatastoreAdmin>) -> Self {
48 Self(RequestBuilder::new(stub))
49 }
50
51 pub fn with_request<V: Into<crate::model::ExportEntitiesRequest>>(mut self, v: V) -> Self {
53 self.0.request = v.into();
54 self
55 }
56
57 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
59 self.0.options = v.into();
60 self
61 }
62
63 pub async fn send(self) -> Result<longrunning::model::Operation> {
70 (*self.0.stub)
71 .export_entities(self.0.request, self.0.options)
72 .await
73 }
74
75 pub fn poller(
77 self,
78 ) -> impl lro::Poller<crate::model::ExportEntitiesResponse, crate::model::ExportEntitiesMetadata>
79 {
80 type Operation = lro::Operation<
81 crate::model::ExportEntitiesResponse,
82 crate::model::ExportEntitiesMetadata,
83 >;
84 let polling_policy = self.0.stub.get_polling_policy(&self.0.options);
85 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
86
87 let stub = self.0.stub.clone();
88 let mut options = self.0.options.clone();
89 options.set_retry_policy(gax::retry_policy::NeverRetry);
90 let query = move |name| {
91 let stub = stub.clone();
92 let options = options.clone();
93 async {
94 let op = GetOperation::new(stub)
95 .set_name(name)
96 .with_options(options)
97 .send()
98 .await?;
99 Ok(Operation::new(op))
100 }
101 };
102
103 let start = move || async {
104 let op = self.send().await?;
105 Ok(Operation::new(op))
106 };
107
108 lro::new_poller(polling_policy, polling_backoff_policy, start, query)
109 }
110
111 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
113 self.0.request.project_id = v.into();
114 self
115 }
116
117 pub fn set_entity_filter<T: Into<std::option::Option<crate::model::EntityFilter>>>(
119 mut self,
120 v: T,
121 ) -> Self {
122 self.0.request.entity_filter = v.into();
123 self
124 }
125
126 pub fn set_output_url_prefix<T: Into<std::string::String>>(mut self, v: T) -> Self {
128 self.0.request.output_url_prefix = v.into();
129 self
130 }
131
132 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
134 where
135 T: std::iter::IntoIterator<Item = (K, V)>,
136 K: std::convert::Into<std::string::String>,
137 V: std::convert::Into<std::string::String>,
138 {
139 self.0.request.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
140 self
141 }
142 }
143
144 impl gax::options::RequestBuilder for ExportEntities {
145 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
146 &mut self.0.options
147 }
148 }
149
150 #[derive(Clone, Debug)]
152 pub struct ImportEntities(RequestBuilder<crate::model::ImportEntitiesRequest>);
153
154 impl ImportEntities {
155 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::DatastoreAdmin>) -> Self {
156 Self(RequestBuilder::new(stub))
157 }
158
159 pub fn with_request<V: Into<crate::model::ImportEntitiesRequest>>(mut self, v: V) -> Self {
161 self.0.request = v.into();
162 self
163 }
164
165 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
167 self.0.options = v.into();
168 self
169 }
170
171 pub async fn send(self) -> Result<longrunning::model::Operation> {
178 (*self.0.stub)
179 .import_entities(self.0.request, self.0.options)
180 .await
181 }
182
183 pub fn poller(self) -> impl lro::Poller<wkt::Empty, crate::model::ImportEntitiesMetadata> {
185 type Operation = lro::Operation<wkt::Empty, crate::model::ImportEntitiesMetadata>;
186 let polling_policy = self.0.stub.get_polling_policy(&self.0.options);
187 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
188
189 let stub = self.0.stub.clone();
190 let mut options = self.0.options.clone();
191 options.set_retry_policy(gax::retry_policy::NeverRetry);
192 let query = move |name| {
193 let stub = stub.clone();
194 let options = options.clone();
195 async {
196 let op = GetOperation::new(stub)
197 .set_name(name)
198 .with_options(options)
199 .send()
200 .await?;
201 Ok(Operation::new(op))
202 }
203 };
204
205 let start = move || async {
206 let op = self.send().await?;
207 Ok(Operation::new(op))
208 };
209
210 lro::new_poller(polling_policy, polling_backoff_policy, start, query)
211 }
212
213 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
215 self.0.request.project_id = v.into();
216 self
217 }
218
219 pub fn set_input_url<T: Into<std::string::String>>(mut self, v: T) -> Self {
221 self.0.request.input_url = v.into();
222 self
223 }
224
225 pub fn set_entity_filter<T: Into<std::option::Option<crate::model::EntityFilter>>>(
227 mut self,
228 v: T,
229 ) -> Self {
230 self.0.request.entity_filter = v.into();
231 self
232 }
233
234 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
236 where
237 T: std::iter::IntoIterator<Item = (K, V)>,
238 K: std::convert::Into<std::string::String>,
239 V: std::convert::Into<std::string::String>,
240 {
241 self.0.request.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
242 self
243 }
244 }
245
246 impl gax::options::RequestBuilder for ImportEntities {
247 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
248 &mut self.0.options
249 }
250 }
251
252 #[derive(Clone, Debug)]
254 pub struct CreateIndex(RequestBuilder<crate::model::CreateIndexRequest>);
255
256 impl CreateIndex {
257 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::DatastoreAdmin>) -> Self {
258 Self(RequestBuilder::new(stub))
259 }
260
261 pub fn with_request<V: Into<crate::model::CreateIndexRequest>>(mut self, v: V) -> Self {
263 self.0.request = v.into();
264 self
265 }
266
267 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
269 self.0.options = v.into();
270 self
271 }
272
273 pub async fn send(self) -> Result<longrunning::model::Operation> {
280 (*self.0.stub)
281 .create_index(self.0.request, self.0.options)
282 .await
283 }
284
285 pub fn poller(
287 self,
288 ) -> impl lro::Poller<crate::model::Index, crate::model::IndexOperationMetadata> {
289 type Operation =
290 lro::Operation<crate::model::Index, crate::model::IndexOperationMetadata>;
291 let polling_policy = self.0.stub.get_polling_policy(&self.0.options);
292 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
293
294 let stub = self.0.stub.clone();
295 let mut options = self.0.options.clone();
296 options.set_retry_policy(gax::retry_policy::NeverRetry);
297 let query = move |name| {
298 let stub = stub.clone();
299 let options = options.clone();
300 async {
301 let op = GetOperation::new(stub)
302 .set_name(name)
303 .with_options(options)
304 .send()
305 .await?;
306 Ok(Operation::new(op))
307 }
308 };
309
310 let start = move || async {
311 let op = self.send().await?;
312 Ok(Operation::new(op))
313 };
314
315 lro::new_poller(polling_policy, polling_backoff_policy, start, query)
316 }
317
318 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
320 self.0.request.project_id = v.into();
321 self
322 }
323
324 pub fn set_index<T: Into<std::option::Option<crate::model::Index>>>(
326 mut self,
327 v: T,
328 ) -> Self {
329 self.0.request.index = v.into();
330 self
331 }
332 }
333
334 impl gax::options::RequestBuilder for CreateIndex {
335 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
336 &mut self.0.options
337 }
338 }
339
340 #[derive(Clone, Debug)]
342 pub struct DeleteIndex(RequestBuilder<crate::model::DeleteIndexRequest>);
343
344 impl DeleteIndex {
345 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::DatastoreAdmin>) -> Self {
346 Self(RequestBuilder::new(stub))
347 }
348
349 pub fn with_request<V: Into<crate::model::DeleteIndexRequest>>(mut self, v: V) -> Self {
351 self.0.request = v.into();
352 self
353 }
354
355 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
357 self.0.options = v.into();
358 self
359 }
360
361 pub async fn send(self) -> Result<longrunning::model::Operation> {
368 (*self.0.stub)
369 .delete_index(self.0.request, self.0.options)
370 .await
371 }
372
373 pub fn poller(
375 self,
376 ) -> impl lro::Poller<crate::model::Index, crate::model::IndexOperationMetadata> {
377 type Operation =
378 lro::Operation<crate::model::Index, crate::model::IndexOperationMetadata>;
379 let polling_policy = self.0.stub.get_polling_policy(&self.0.options);
380 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
381
382 let stub = self.0.stub.clone();
383 let mut options = self.0.options.clone();
384 options.set_retry_policy(gax::retry_policy::NeverRetry);
385 let query = move |name| {
386 let stub = stub.clone();
387 let options = options.clone();
388 async {
389 let op = GetOperation::new(stub)
390 .set_name(name)
391 .with_options(options)
392 .send()
393 .await?;
394 Ok(Operation::new(op))
395 }
396 };
397
398 let start = move || async {
399 let op = self.send().await?;
400 Ok(Operation::new(op))
401 };
402
403 lro::new_poller(polling_policy, polling_backoff_policy, start, query)
404 }
405
406 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
408 self.0.request.project_id = v.into();
409 self
410 }
411
412 pub fn set_index_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
414 self.0.request.index_id = v.into();
415 self
416 }
417 }
418
419 impl gax::options::RequestBuilder for DeleteIndex {
420 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
421 &mut self.0.options
422 }
423 }
424
425 #[derive(Clone, Debug)]
427 pub struct GetIndex(RequestBuilder<crate::model::GetIndexRequest>);
428
429 impl GetIndex {
430 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::DatastoreAdmin>) -> Self {
431 Self(RequestBuilder::new(stub))
432 }
433
434 pub fn with_request<V: Into<crate::model::GetIndexRequest>>(mut self, v: V) -> Self {
436 self.0.request = v.into();
437 self
438 }
439
440 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
442 self.0.options = v.into();
443 self
444 }
445
446 pub async fn send(self) -> Result<crate::model::Index> {
448 (*self.0.stub)
449 .get_index(self.0.request, self.0.options)
450 .await
451 }
452
453 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
455 self.0.request.project_id = v.into();
456 self
457 }
458
459 pub fn set_index_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
461 self.0.request.index_id = v.into();
462 self
463 }
464 }
465
466 impl gax::options::RequestBuilder for GetIndex {
467 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
468 &mut self.0.options
469 }
470 }
471
472 #[derive(Clone, Debug)]
474 pub struct ListIndexes(RequestBuilder<crate::model::ListIndexesRequest>);
475
476 impl ListIndexes {
477 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::DatastoreAdmin>) -> Self {
478 Self(RequestBuilder::new(stub))
479 }
480
481 pub fn with_request<V: Into<crate::model::ListIndexesRequest>>(mut self, v: V) -> Self {
483 self.0.request = v.into();
484 self
485 }
486
487 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
489 self.0.options = v.into();
490 self
491 }
492
493 pub async fn send(self) -> Result<crate::model::ListIndexesResponse> {
495 (*self.0.stub)
496 .list_indexes(self.0.request, self.0.options)
497 .await
498 }
499
500 #[cfg(feature = "unstable-stream")]
502 pub async fn stream(
503 self,
504 ) -> gax::paginator::Paginator<crate::model::ListIndexesResponse, gax::error::Error>
505 {
506 let token = gax::paginator::extract_token(&self.0.request.page_token);
507 let execute = move |token: String| {
508 let mut builder = self.clone();
509 builder.0.request = builder.0.request.set_page_token(token);
510 builder.send()
511 };
512 gax::paginator::Paginator::new(token, execute)
513 }
514
515 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
517 self.0.request.project_id = v.into();
518 self
519 }
520
521 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
523 self.0.request.filter = v.into();
524 self
525 }
526
527 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
529 self.0.request.page_size = v.into();
530 self
531 }
532
533 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
535 self.0.request.page_token = v.into();
536 self
537 }
538 }
539
540 impl gax::options::RequestBuilder for ListIndexes {
541 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
542 &mut self.0.options
543 }
544 }
545
546 #[derive(Clone, Debug)]
548 pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);
549
550 impl ListOperations {
551 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::DatastoreAdmin>) -> Self {
552 Self(RequestBuilder::new(stub))
553 }
554
555 pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
557 mut self,
558 v: V,
559 ) -> Self {
560 self.0.request = v.into();
561 self
562 }
563
564 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
566 self.0.options = v.into();
567 self
568 }
569
570 pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
572 (*self.0.stub)
573 .list_operations(self.0.request, self.0.options)
574 .await
575 }
576
577 #[cfg(feature = "unstable-stream")]
579 pub async fn stream(
580 self,
581 ) -> gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
582 {
583 let token = gax::paginator::extract_token(&self.0.request.page_token);
584 let execute = move |token: String| {
585 let mut builder = self.clone();
586 builder.0.request = builder.0.request.set_page_token(token);
587 builder.send()
588 };
589 gax::paginator::Paginator::new(token, execute)
590 }
591
592 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
594 self.0.request.name = v.into();
595 self
596 }
597
598 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
600 self.0.request.filter = v.into();
601 self
602 }
603
604 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
606 self.0.request.page_size = v.into();
607 self
608 }
609
610 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
612 self.0.request.page_token = v.into();
613 self
614 }
615 }
616
617 impl gax::options::RequestBuilder for ListOperations {
618 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
619 &mut self.0.options
620 }
621 }
622
623 #[derive(Clone, Debug)]
625 pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);
626
627 impl GetOperation {
628 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::DatastoreAdmin>) -> Self {
629 Self(RequestBuilder::new(stub))
630 }
631
632 pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
634 mut self,
635 v: V,
636 ) -> Self {
637 self.0.request = v.into();
638 self
639 }
640
641 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
643 self.0.options = v.into();
644 self
645 }
646
647 pub async fn send(self) -> Result<longrunning::model::Operation> {
649 (*self.0.stub)
650 .get_operation(self.0.request, self.0.options)
651 .await
652 }
653
654 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
656 self.0.request.name = v.into();
657 self
658 }
659 }
660
661 impl gax::options::RequestBuilder for GetOperation {
662 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
663 &mut self.0.options
664 }
665 }
666
667 #[derive(Clone, Debug)]
669 pub struct DeleteOperation(RequestBuilder<longrunning::model::DeleteOperationRequest>);
670
671 impl DeleteOperation {
672 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::DatastoreAdmin>) -> Self {
673 Self(RequestBuilder::new(stub))
674 }
675
676 pub fn with_request<V: Into<longrunning::model::DeleteOperationRequest>>(
678 mut self,
679 v: V,
680 ) -> Self {
681 self.0.request = v.into();
682 self
683 }
684
685 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
687 self.0.options = v.into();
688 self
689 }
690
691 pub async fn send(self) -> Result<wkt::Empty> {
693 (*self.0.stub)
694 .delete_operation(self.0.request, self.0.options)
695 .await
696 }
697
698 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
700 self.0.request.name = v.into();
701 self
702 }
703 }
704
705 impl gax::options::RequestBuilder for DeleteOperation {
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 CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);
714
715 impl CancelOperation {
716 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::DatastoreAdmin>) -> Self {
717 Self(RequestBuilder::new(stub))
718 }
719
720 pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
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<wkt::Empty> {
737 (*self.0.stub)
738 .cancel_operation(self.0.request, self.0.options)
739 .await
740 }
741
742 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
744 self.0.request.name = v.into();
745 self
746 }
747 }
748
749 impl gax::options::RequestBuilder for CancelOperation {
750 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
751 &mut self.0.options
752 }
753 }
754}