google_cloud_datastore_admin_v1/
builder.rs1pub mod datastore_admin {
18 use crate::Result;
19
20 pub type ClientBuilder =
34 gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;
35
36 pub(crate) mod client {
37 use super::super::super::client::DatastoreAdmin;
38 pub struct Factory;
39 impl gax::client_builder::internal::ClientFactory for Factory {
40 type Client = DatastoreAdmin;
41 type Credentials = gaxi::options::Credentials;
42 async fn build(
43 self,
44 config: gaxi::options::ClientConfig,
45 ) -> gax::client_builder::Result<Self::Client> {
46 Self::Client::new(config).await
47 }
48 }
49 }
50
51 #[derive(Clone, Debug)]
53 pub(crate) struct RequestBuilder<R: std::default::Default> {
54 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
55 request: R,
56 options: gax::options::RequestOptions,
57 }
58
59 impl<R> RequestBuilder<R>
60 where
61 R: std::default::Default,
62 {
63 pub(crate) fn new(
64 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
65 ) -> Self {
66 Self {
67 stub,
68 request: R::default(),
69 options: gax::options::RequestOptions::default(),
70 }
71 }
72 }
73
74 #[derive(Clone, Debug)]
92 pub struct ExportEntities(RequestBuilder<crate::model::ExportEntitiesRequest>);
93
94 impl ExportEntities {
95 pub(crate) fn new(
96 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
97 ) -> Self {
98 Self(RequestBuilder::new(stub))
99 }
100
101 pub fn with_request<V: Into<crate::model::ExportEntitiesRequest>>(mut self, v: V) -> Self {
103 self.0.request = v.into();
104 self
105 }
106
107 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
109 self.0.options = v.into();
110 self
111 }
112
113 pub async fn send(self) -> Result<longrunning::model::Operation> {
120 (*self.0.stub)
121 .export_entities(self.0.request, self.0.options)
122 .await
123 .map(gax::response::Response::into_body)
124 }
125
126 pub fn poller(
128 self,
129 ) -> impl lro::Poller<crate::model::ExportEntitiesResponse, crate::model::ExportEntitiesMetadata>
130 {
131 type Operation = lro::internal::Operation<
132 crate::model::ExportEntitiesResponse,
133 crate::model::ExportEntitiesMetadata,
134 >;
135 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
136 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
137
138 let stub = self.0.stub.clone();
139 let mut options = self.0.options.clone();
140 options.set_retry_policy(gax::retry_policy::NeverRetry);
141 let query = move |name| {
142 let stub = stub.clone();
143 let options = options.clone();
144 async {
145 let op = GetOperation::new(stub)
146 .set_name(name)
147 .with_options(options)
148 .send()
149 .await?;
150 Ok(Operation::new(op))
151 }
152 };
153
154 let start = move || async {
155 let op = self.send().await?;
156 Ok(Operation::new(op))
157 };
158
159 lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
160 }
161
162 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
166 self.0.request.project_id = v.into();
167 self
168 }
169
170 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
172 where
173 T: std::iter::IntoIterator<Item = (K, V)>,
174 K: std::convert::Into<std::string::String>,
175 V: std::convert::Into<std::string::String>,
176 {
177 self.0.request.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
178 self
179 }
180
181 pub fn set_entity_filter<T>(mut self, v: T) -> Self
183 where
184 T: std::convert::Into<crate::model::EntityFilter>,
185 {
186 self.0.request.entity_filter = std::option::Option::Some(v.into());
187 self
188 }
189
190 pub fn set_or_clear_entity_filter<T>(mut self, v: std::option::Option<T>) -> Self
192 where
193 T: std::convert::Into<crate::model::EntityFilter>,
194 {
195 self.0.request.entity_filter = v.map(|x| x.into());
196 self
197 }
198
199 pub fn set_output_url_prefix<T: Into<std::string::String>>(mut self, v: T) -> Self {
203 self.0.request.output_url_prefix = v.into();
204 self
205 }
206 }
207
208 #[doc(hidden)]
209 impl gax::options::internal::RequestBuilder for ExportEntities {
210 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
211 &mut self.0.options
212 }
213 }
214
215 #[derive(Clone, Debug)]
233 pub struct ImportEntities(RequestBuilder<crate::model::ImportEntitiesRequest>);
234
235 impl ImportEntities {
236 pub(crate) fn new(
237 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
238 ) -> Self {
239 Self(RequestBuilder::new(stub))
240 }
241
242 pub fn with_request<V: Into<crate::model::ImportEntitiesRequest>>(mut self, v: V) -> Self {
244 self.0.request = v.into();
245 self
246 }
247
248 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
250 self.0.options = v.into();
251 self
252 }
253
254 pub async fn send(self) -> Result<longrunning::model::Operation> {
261 (*self.0.stub)
262 .import_entities(self.0.request, self.0.options)
263 .await
264 .map(gax::response::Response::into_body)
265 }
266
267 pub fn poller(self) -> impl lro::Poller<(), crate::model::ImportEntitiesMetadata> {
269 type Operation =
270 lro::internal::Operation<wkt::Empty, crate::model::ImportEntitiesMetadata>;
271 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
272 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
273
274 let stub = self.0.stub.clone();
275 let mut options = self.0.options.clone();
276 options.set_retry_policy(gax::retry_policy::NeverRetry);
277 let query = move |name| {
278 let stub = stub.clone();
279 let options = options.clone();
280 async {
281 let op = GetOperation::new(stub)
282 .set_name(name)
283 .with_options(options)
284 .send()
285 .await?;
286 Ok(Operation::new(op))
287 }
288 };
289
290 let start = move || async {
291 let op = self.send().await?;
292 Ok(Operation::new(op))
293 };
294
295 lro::internal::new_unit_response_poller(
296 polling_error_policy,
297 polling_backoff_policy,
298 start,
299 query,
300 )
301 }
302
303 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
307 self.0.request.project_id = v.into();
308 self
309 }
310
311 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
313 where
314 T: std::iter::IntoIterator<Item = (K, V)>,
315 K: std::convert::Into<std::string::String>,
316 V: std::convert::Into<std::string::String>,
317 {
318 self.0.request.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
319 self
320 }
321
322 pub fn set_input_url<T: Into<std::string::String>>(mut self, v: T) -> Self {
326 self.0.request.input_url = v.into();
327 self
328 }
329
330 pub fn set_entity_filter<T>(mut self, v: T) -> Self
332 where
333 T: std::convert::Into<crate::model::EntityFilter>,
334 {
335 self.0.request.entity_filter = std::option::Option::Some(v.into());
336 self
337 }
338
339 pub fn set_or_clear_entity_filter<T>(mut self, v: std::option::Option<T>) -> Self
341 where
342 T: std::convert::Into<crate::model::EntityFilter>,
343 {
344 self.0.request.entity_filter = v.map(|x| x.into());
345 self
346 }
347 }
348
349 #[doc(hidden)]
350 impl gax::options::internal::RequestBuilder for ImportEntities {
351 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
352 &mut self.0.options
353 }
354 }
355
356 #[derive(Clone, Debug)]
374 pub struct CreateIndex(RequestBuilder<crate::model::CreateIndexRequest>);
375
376 impl CreateIndex {
377 pub(crate) fn new(
378 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
379 ) -> Self {
380 Self(RequestBuilder::new(stub))
381 }
382
383 pub fn with_request<V: Into<crate::model::CreateIndexRequest>>(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 .create_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::internal::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::internal::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<T>(mut self, v: T) -> Self
449 where
450 T: std::convert::Into<crate::model::Index>,
451 {
452 self.0.request.index = std::option::Option::Some(v.into());
453 self
454 }
455
456 pub fn set_or_clear_index<T>(mut self, v: std::option::Option<T>) -> Self
458 where
459 T: std::convert::Into<crate::model::Index>,
460 {
461 self.0.request.index = v.map(|x| x.into());
462 self
463 }
464 }
465
466 #[doc(hidden)]
467 impl gax::options::internal::RequestBuilder for CreateIndex {
468 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
469 &mut self.0.options
470 }
471 }
472
473 #[derive(Clone, Debug)]
491 pub struct DeleteIndex(RequestBuilder<crate::model::DeleteIndexRequest>);
492
493 impl DeleteIndex {
494 pub(crate) fn new(
495 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
496 ) -> Self {
497 Self(RequestBuilder::new(stub))
498 }
499
500 pub fn with_request<V: Into<crate::model::DeleteIndexRequest>>(mut self, v: V) -> Self {
502 self.0.request = v.into();
503 self
504 }
505
506 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
508 self.0.options = v.into();
509 self
510 }
511
512 pub async fn send(self) -> Result<longrunning::model::Operation> {
519 (*self.0.stub)
520 .delete_index(self.0.request, self.0.options)
521 .await
522 .map(gax::response::Response::into_body)
523 }
524
525 pub fn poller(
527 self,
528 ) -> impl lro::Poller<crate::model::Index, crate::model::IndexOperationMetadata> {
529 type Operation =
530 lro::internal::Operation<crate::model::Index, crate::model::IndexOperationMetadata>;
531 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
532 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
533
534 let stub = self.0.stub.clone();
535 let mut options = self.0.options.clone();
536 options.set_retry_policy(gax::retry_policy::NeverRetry);
537 let query = move |name| {
538 let stub = stub.clone();
539 let options = options.clone();
540 async {
541 let op = GetOperation::new(stub)
542 .set_name(name)
543 .with_options(options)
544 .send()
545 .await?;
546 Ok(Operation::new(op))
547 }
548 };
549
550 let start = move || async {
551 let op = self.send().await?;
552 Ok(Operation::new(op))
553 };
554
555 lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
556 }
557
558 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
560 self.0.request.project_id = v.into();
561 self
562 }
563
564 pub fn set_index_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
566 self.0.request.index_id = v.into();
567 self
568 }
569 }
570
571 #[doc(hidden)]
572 impl gax::options::internal::RequestBuilder for DeleteIndex {
573 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
574 &mut self.0.options
575 }
576 }
577
578 #[derive(Clone, Debug)]
595 pub struct GetIndex(RequestBuilder<crate::model::GetIndexRequest>);
596
597 impl GetIndex {
598 pub(crate) fn new(
599 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
600 ) -> Self {
601 Self(RequestBuilder::new(stub))
602 }
603
604 pub fn with_request<V: Into<crate::model::GetIndexRequest>>(mut self, v: V) -> Self {
606 self.0.request = v.into();
607 self
608 }
609
610 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
612 self.0.options = v.into();
613 self
614 }
615
616 pub async fn send(self) -> Result<crate::model::Index> {
618 (*self.0.stub)
619 .get_index(self.0.request, self.0.options)
620 .await
621 .map(gax::response::Response::into_body)
622 }
623
624 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
626 self.0.request.project_id = v.into();
627 self
628 }
629
630 pub fn set_index_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
632 self.0.request.index_id = v.into();
633 self
634 }
635 }
636
637 #[doc(hidden)]
638 impl gax::options::internal::RequestBuilder for GetIndex {
639 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
640 &mut self.0.options
641 }
642 }
643
644 #[derive(Clone, Debug)]
665 pub struct ListIndexes(RequestBuilder<crate::model::ListIndexesRequest>);
666
667 impl ListIndexes {
668 pub(crate) fn new(
669 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
670 ) -> Self {
671 Self(RequestBuilder::new(stub))
672 }
673
674 pub fn with_request<V: Into<crate::model::ListIndexesRequest>>(mut self, v: V) -> Self {
676 self.0.request = v.into();
677 self
678 }
679
680 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
682 self.0.options = v.into();
683 self
684 }
685
686 pub async fn send(self) -> Result<crate::model::ListIndexesResponse> {
688 (*self.0.stub)
689 .list_indexes(self.0.request, self.0.options)
690 .await
691 .map(gax::response::Response::into_body)
692 }
693
694 pub fn by_page(
696 self,
697 ) -> impl gax::paginator::Paginator<crate::model::ListIndexesResponse, gax::error::Error>
698 {
699 use std::clone::Clone;
700 let token = self.0.request.page_token.clone();
701 let execute = move |token: String| {
702 let mut builder = self.clone();
703 builder.0.request = builder.0.request.set_page_token(token);
704 builder.send()
705 };
706 gax::paginator::internal::new_paginator(token, execute)
707 }
708
709 pub fn by_item(
711 self,
712 ) -> impl gax::paginator::ItemPaginator<crate::model::ListIndexesResponse, gax::error::Error>
713 {
714 use gax::paginator::Paginator;
715 self.by_page().items()
716 }
717
718 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
720 self.0.request.project_id = v.into();
721 self
722 }
723
724 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
726 self.0.request.filter = v.into();
727 self
728 }
729
730 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
732 self.0.request.page_size = v.into();
733 self
734 }
735
736 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
738 self.0.request.page_token = v.into();
739 self
740 }
741 }
742
743 #[doc(hidden)]
744 impl gax::options::internal::RequestBuilder for ListIndexes {
745 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
746 &mut self.0.options
747 }
748 }
749
750 #[derive(Clone, Debug)]
771 pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);
772
773 impl ListOperations {
774 pub(crate) fn new(
775 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
776 ) -> Self {
777 Self(RequestBuilder::new(stub))
778 }
779
780 pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
782 mut self,
783 v: V,
784 ) -> Self {
785 self.0.request = v.into();
786 self
787 }
788
789 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
791 self.0.options = v.into();
792 self
793 }
794
795 pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
797 (*self.0.stub)
798 .list_operations(self.0.request, self.0.options)
799 .await
800 .map(gax::response::Response::into_body)
801 }
802
803 pub fn by_page(
805 self,
806 ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
807 {
808 use std::clone::Clone;
809 let token = self.0.request.page_token.clone();
810 let execute = move |token: String| {
811 let mut builder = self.clone();
812 builder.0.request = builder.0.request.set_page_token(token);
813 builder.send()
814 };
815 gax::paginator::internal::new_paginator(token, execute)
816 }
817
818 pub fn by_item(
820 self,
821 ) -> impl gax::paginator::ItemPaginator<
822 longrunning::model::ListOperationsResponse,
823 gax::error::Error,
824 > {
825 use gax::paginator::Paginator;
826 self.by_page().items()
827 }
828
829 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
831 self.0.request.name = v.into();
832 self
833 }
834
835 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
837 self.0.request.filter = v.into();
838 self
839 }
840
841 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
843 self.0.request.page_size = v.into();
844 self
845 }
846
847 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
849 self.0.request.page_token = v.into();
850 self
851 }
852
853 pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
855 self.0.request.return_partial_success = v.into();
856 self
857 }
858 }
859
860 #[doc(hidden)]
861 impl gax::options::internal::RequestBuilder for ListOperations {
862 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
863 &mut self.0.options
864 }
865 }
866
867 #[derive(Clone, Debug)]
884 pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);
885
886 impl GetOperation {
887 pub(crate) fn new(
888 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
889 ) -> Self {
890 Self(RequestBuilder::new(stub))
891 }
892
893 pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
895 mut self,
896 v: V,
897 ) -> Self {
898 self.0.request = v.into();
899 self
900 }
901
902 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
904 self.0.options = v.into();
905 self
906 }
907
908 pub async fn send(self) -> Result<longrunning::model::Operation> {
910 (*self.0.stub)
911 .get_operation(self.0.request, self.0.options)
912 .await
913 .map(gax::response::Response::into_body)
914 }
915
916 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
918 self.0.request.name = v.into();
919 self
920 }
921 }
922
923 #[doc(hidden)]
924 impl gax::options::internal::RequestBuilder for GetOperation {
925 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
926 &mut self.0.options
927 }
928 }
929
930 #[derive(Clone, Debug)]
947 pub struct DeleteOperation(RequestBuilder<longrunning::model::DeleteOperationRequest>);
948
949 impl DeleteOperation {
950 pub(crate) fn new(
951 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
952 ) -> Self {
953 Self(RequestBuilder::new(stub))
954 }
955
956 pub fn with_request<V: Into<longrunning::model::DeleteOperationRequest>>(
958 mut self,
959 v: V,
960 ) -> Self {
961 self.0.request = v.into();
962 self
963 }
964
965 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
967 self.0.options = v.into();
968 self
969 }
970
971 pub async fn send(self) -> Result<()> {
973 (*self.0.stub)
974 .delete_operation(self.0.request, self.0.options)
975 .await
976 .map(gax::response::Response::into_body)
977 }
978
979 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
981 self.0.request.name = v.into();
982 self
983 }
984 }
985
986 #[doc(hidden)]
987 impl gax::options::internal::RequestBuilder for DeleteOperation {
988 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
989 &mut self.0.options
990 }
991 }
992
993 #[derive(Clone, Debug)]
1010 pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);
1011
1012 impl CancelOperation {
1013 pub(crate) fn new(
1014 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
1015 ) -> Self {
1016 Self(RequestBuilder::new(stub))
1017 }
1018
1019 pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
1021 mut self,
1022 v: V,
1023 ) -> Self {
1024 self.0.request = v.into();
1025 self
1026 }
1027
1028 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
1030 self.0.options = v.into();
1031 self
1032 }
1033
1034 pub async fn send(self) -> Result<()> {
1036 (*self.0.stub)
1037 .cancel_operation(self.0.request, self.0.options)
1038 .await
1039 .map(gax::response::Response::into_body)
1040 }
1041
1042 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1044 self.0.request.name = v.into();
1045 self
1046 }
1047 }
1048
1049 #[doc(hidden)]
1050 impl gax::options::internal::RequestBuilder for CancelOperation {
1051 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
1052 &mut self.0.options
1053 }
1054 }
1055}