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)]
93 pub struct ExportEntities(RequestBuilder<crate::model::ExportEntitiesRequest>);
94
95 impl ExportEntities {
96 pub(crate) fn new(
97 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
98 ) -> Self {
99 Self(RequestBuilder::new(stub))
100 }
101
102 pub fn with_request<V: Into<crate::model::ExportEntitiesRequest>>(mut self, v: V) -> Self {
104 self.0.request = v.into();
105 self
106 }
107
108 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
110 self.0.options = v.into();
111 self
112 }
113
114 pub async fn send(self) -> Result<longrunning::model::Operation> {
121 (*self.0.stub)
122 .export_entities(self.0.request, self.0.options)
123 .await
124 .map(gax::response::Response::into_body)
125 }
126
127 pub fn poller(
129 self,
130 ) -> impl lro::Poller<crate::model::ExportEntitiesResponse, crate::model::ExportEntitiesMetadata>
131 {
132 type Operation = lro::internal::Operation<
133 crate::model::ExportEntitiesResponse,
134 crate::model::ExportEntitiesMetadata,
135 >;
136 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
137 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
138
139 let stub = self.0.stub.clone();
140 let mut options = self.0.options.clone();
141 options.set_retry_policy(gax::retry_policy::NeverRetry);
142 let query = move |name| {
143 let stub = stub.clone();
144 let options = options.clone();
145 async {
146 let op = GetOperation::new(stub)
147 .set_name(name)
148 .with_options(options)
149 .send()
150 .await?;
151 Ok(Operation::new(op))
152 }
153 };
154
155 let start = move || async {
156 let op = self.send().await?;
157 Ok(Operation::new(op))
158 };
159
160 lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
161 }
162
163 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
167 self.0.request.project_id = v.into();
168 self
169 }
170
171 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
173 where
174 T: std::iter::IntoIterator<Item = (K, V)>,
175 K: std::convert::Into<std::string::String>,
176 V: std::convert::Into<std::string::String>,
177 {
178 self.0.request.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
179 self
180 }
181
182 pub fn set_entity_filter<T>(mut self, v: T) -> Self
184 where
185 T: std::convert::Into<crate::model::EntityFilter>,
186 {
187 self.0.request.entity_filter = std::option::Option::Some(v.into());
188 self
189 }
190
191 pub fn set_or_clear_entity_filter<T>(mut self, v: std::option::Option<T>) -> Self
193 where
194 T: std::convert::Into<crate::model::EntityFilter>,
195 {
196 self.0.request.entity_filter = v.map(|x| x.into());
197 self
198 }
199
200 pub fn set_output_url_prefix<T: Into<std::string::String>>(mut self, v: T) -> Self {
204 self.0.request.output_url_prefix = v.into();
205 self
206 }
207 }
208
209 #[doc(hidden)]
210 impl gax::options::internal::RequestBuilder for ExportEntities {
211 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
212 &mut self.0.options
213 }
214 }
215
216 #[derive(Clone, Debug)]
235 pub struct ImportEntities(RequestBuilder<crate::model::ImportEntitiesRequest>);
236
237 impl ImportEntities {
238 pub(crate) fn new(
239 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
240 ) -> Self {
241 Self(RequestBuilder::new(stub))
242 }
243
244 pub fn with_request<V: Into<crate::model::ImportEntitiesRequest>>(mut self, v: V) -> Self {
246 self.0.request = v.into();
247 self
248 }
249
250 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
252 self.0.options = v.into();
253 self
254 }
255
256 pub async fn send(self) -> Result<longrunning::model::Operation> {
263 (*self.0.stub)
264 .import_entities(self.0.request, self.0.options)
265 .await
266 .map(gax::response::Response::into_body)
267 }
268
269 pub fn poller(self) -> impl lro::Poller<(), crate::model::ImportEntitiesMetadata> {
271 type Operation =
272 lro::internal::Operation<wkt::Empty, crate::model::ImportEntitiesMetadata>;
273 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
274 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
275
276 let stub = self.0.stub.clone();
277 let mut options = self.0.options.clone();
278 options.set_retry_policy(gax::retry_policy::NeverRetry);
279 let query = move |name| {
280 let stub = stub.clone();
281 let options = options.clone();
282 async {
283 let op = GetOperation::new(stub)
284 .set_name(name)
285 .with_options(options)
286 .send()
287 .await?;
288 Ok(Operation::new(op))
289 }
290 };
291
292 let start = move || async {
293 let op = self.send().await?;
294 Ok(Operation::new(op))
295 };
296
297 lro::internal::new_unit_response_poller(
298 polling_error_policy,
299 polling_backoff_policy,
300 start,
301 query,
302 )
303 }
304
305 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
309 self.0.request.project_id = v.into();
310 self
311 }
312
313 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
315 where
316 T: std::iter::IntoIterator<Item = (K, V)>,
317 K: std::convert::Into<std::string::String>,
318 V: std::convert::Into<std::string::String>,
319 {
320 self.0.request.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
321 self
322 }
323
324 pub fn set_input_url<T: Into<std::string::String>>(mut self, v: T) -> Self {
328 self.0.request.input_url = v.into();
329 self
330 }
331
332 pub fn set_entity_filter<T>(mut self, v: T) -> Self
334 where
335 T: std::convert::Into<crate::model::EntityFilter>,
336 {
337 self.0.request.entity_filter = std::option::Option::Some(v.into());
338 self
339 }
340
341 pub fn set_or_clear_entity_filter<T>(mut self, v: std::option::Option<T>) -> Self
343 where
344 T: std::convert::Into<crate::model::EntityFilter>,
345 {
346 self.0.request.entity_filter = v.map(|x| x.into());
347 self
348 }
349 }
350
351 #[doc(hidden)]
352 impl gax::options::internal::RequestBuilder for ImportEntities {
353 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
354 &mut self.0.options
355 }
356 }
357
358 #[derive(Clone, Debug)]
377 pub struct CreateIndex(RequestBuilder<crate::model::CreateIndexRequest>);
378
379 impl CreateIndex {
380 pub(crate) fn new(
381 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
382 ) -> Self {
383 Self(RequestBuilder::new(stub))
384 }
385
386 pub fn with_request<V: Into<crate::model::CreateIndexRequest>>(mut self, v: V) -> Self {
388 self.0.request = v.into();
389 self
390 }
391
392 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
394 self.0.options = v.into();
395 self
396 }
397
398 pub async fn send(self) -> Result<longrunning::model::Operation> {
405 (*self.0.stub)
406 .create_index(self.0.request, self.0.options)
407 .await
408 .map(gax::response::Response::into_body)
409 }
410
411 pub fn poller(
413 self,
414 ) -> impl lro::Poller<crate::model::Index, crate::model::IndexOperationMetadata> {
415 type Operation =
416 lro::internal::Operation<crate::model::Index, crate::model::IndexOperationMetadata>;
417 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
418 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
419
420 let stub = self.0.stub.clone();
421 let mut options = self.0.options.clone();
422 options.set_retry_policy(gax::retry_policy::NeverRetry);
423 let query = move |name| {
424 let stub = stub.clone();
425 let options = options.clone();
426 async {
427 let op = GetOperation::new(stub)
428 .set_name(name)
429 .with_options(options)
430 .send()
431 .await?;
432 Ok(Operation::new(op))
433 }
434 };
435
436 let start = move || async {
437 let op = self.send().await?;
438 Ok(Operation::new(op))
439 };
440
441 lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
442 }
443
444 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
446 self.0.request.project_id = v.into();
447 self
448 }
449
450 pub fn set_index<T>(mut self, v: T) -> Self
452 where
453 T: std::convert::Into<crate::model::Index>,
454 {
455 self.0.request.index = std::option::Option::Some(v.into());
456 self
457 }
458
459 pub fn set_or_clear_index<T>(mut self, v: std::option::Option<T>) -> Self
461 where
462 T: std::convert::Into<crate::model::Index>,
463 {
464 self.0.request.index = v.map(|x| x.into());
465 self
466 }
467 }
468
469 #[doc(hidden)]
470 impl gax::options::internal::RequestBuilder for CreateIndex {
471 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
472 &mut self.0.options
473 }
474 }
475
476 #[derive(Clone, Debug)]
495 pub struct DeleteIndex(RequestBuilder<crate::model::DeleteIndexRequest>);
496
497 impl DeleteIndex {
498 pub(crate) fn new(
499 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
500 ) -> Self {
501 Self(RequestBuilder::new(stub))
502 }
503
504 pub fn with_request<V: Into<crate::model::DeleteIndexRequest>>(mut self, v: V) -> Self {
506 self.0.request = v.into();
507 self
508 }
509
510 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
512 self.0.options = v.into();
513 self
514 }
515
516 pub async fn send(self) -> Result<longrunning::model::Operation> {
523 (*self.0.stub)
524 .delete_index(self.0.request, self.0.options)
525 .await
526 .map(gax::response::Response::into_body)
527 }
528
529 pub fn poller(
531 self,
532 ) -> impl lro::Poller<crate::model::Index, crate::model::IndexOperationMetadata> {
533 type Operation =
534 lro::internal::Operation<crate::model::Index, crate::model::IndexOperationMetadata>;
535 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
536 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
537
538 let stub = self.0.stub.clone();
539 let mut options = self.0.options.clone();
540 options.set_retry_policy(gax::retry_policy::NeverRetry);
541 let query = move |name| {
542 let stub = stub.clone();
543 let options = options.clone();
544 async {
545 let op = GetOperation::new(stub)
546 .set_name(name)
547 .with_options(options)
548 .send()
549 .await?;
550 Ok(Operation::new(op))
551 }
552 };
553
554 let start = move || async {
555 let op = self.send().await?;
556 Ok(Operation::new(op))
557 };
558
559 lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
560 }
561
562 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
564 self.0.request.project_id = v.into();
565 self
566 }
567
568 pub fn set_index_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
570 self.0.request.index_id = v.into();
571 self
572 }
573 }
574
575 #[doc(hidden)]
576 impl gax::options::internal::RequestBuilder for DeleteIndex {
577 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
578 &mut self.0.options
579 }
580 }
581
582 #[derive(Clone, Debug)]
600 pub struct GetIndex(RequestBuilder<crate::model::GetIndexRequest>);
601
602 impl GetIndex {
603 pub(crate) fn new(
604 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
605 ) -> Self {
606 Self(RequestBuilder::new(stub))
607 }
608
609 pub fn with_request<V: Into<crate::model::GetIndexRequest>>(mut self, v: V) -> Self {
611 self.0.request = v.into();
612 self
613 }
614
615 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
617 self.0.options = v.into();
618 self
619 }
620
621 pub async fn send(self) -> Result<crate::model::Index> {
623 (*self.0.stub)
624 .get_index(self.0.request, self.0.options)
625 .await
626 .map(gax::response::Response::into_body)
627 }
628
629 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
631 self.0.request.project_id = v.into();
632 self
633 }
634
635 pub fn set_index_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
637 self.0.request.index_id = v.into();
638 self
639 }
640 }
641
642 #[doc(hidden)]
643 impl gax::options::internal::RequestBuilder for GetIndex {
644 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
645 &mut self.0.options
646 }
647 }
648
649 #[derive(Clone, Debug)]
671 pub struct ListIndexes(RequestBuilder<crate::model::ListIndexesRequest>);
672
673 impl ListIndexes {
674 pub(crate) fn new(
675 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
676 ) -> Self {
677 Self(RequestBuilder::new(stub))
678 }
679
680 pub fn with_request<V: Into<crate::model::ListIndexesRequest>>(mut self, v: V) -> Self {
682 self.0.request = v.into();
683 self
684 }
685
686 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
688 self.0.options = v.into();
689 self
690 }
691
692 pub async fn send(self) -> Result<crate::model::ListIndexesResponse> {
694 (*self.0.stub)
695 .list_indexes(self.0.request, self.0.options)
696 .await
697 .map(gax::response::Response::into_body)
698 }
699
700 pub fn by_page(
702 self,
703 ) -> impl gax::paginator::Paginator<crate::model::ListIndexesResponse, gax::error::Error>
704 {
705 use std::clone::Clone;
706 let token = self.0.request.page_token.clone();
707 let execute = move |token: String| {
708 let mut builder = self.clone();
709 builder.0.request = builder.0.request.set_page_token(token);
710 builder.send()
711 };
712 gax::paginator::internal::new_paginator(token, execute)
713 }
714
715 pub fn by_item(
717 self,
718 ) -> impl gax::paginator::ItemPaginator<crate::model::ListIndexesResponse, gax::error::Error>
719 {
720 use gax::paginator::Paginator;
721 self.by_page().items()
722 }
723
724 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
726 self.0.request.project_id = v.into();
727 self
728 }
729
730 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
732 self.0.request.filter = v.into();
733 self
734 }
735
736 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
738 self.0.request.page_size = v.into();
739 self
740 }
741
742 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
744 self.0.request.page_token = v.into();
745 self
746 }
747 }
748
749 #[doc(hidden)]
750 impl gax::options::internal::RequestBuilder for ListIndexes {
751 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
752 &mut self.0.options
753 }
754 }
755
756 #[derive(Clone, Debug)]
778 pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);
779
780 impl ListOperations {
781 pub(crate) fn new(
782 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
783 ) -> Self {
784 Self(RequestBuilder::new(stub))
785 }
786
787 pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
789 mut self,
790 v: V,
791 ) -> Self {
792 self.0.request = v.into();
793 self
794 }
795
796 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
798 self.0.options = v.into();
799 self
800 }
801
802 pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
804 (*self.0.stub)
805 .list_operations(self.0.request, self.0.options)
806 .await
807 .map(gax::response::Response::into_body)
808 }
809
810 pub fn by_page(
812 self,
813 ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
814 {
815 use std::clone::Clone;
816 let token = self.0.request.page_token.clone();
817 let execute = move |token: String| {
818 let mut builder = self.clone();
819 builder.0.request = builder.0.request.set_page_token(token);
820 builder.send()
821 };
822 gax::paginator::internal::new_paginator(token, execute)
823 }
824
825 pub fn by_item(
827 self,
828 ) -> impl gax::paginator::ItemPaginator<
829 longrunning::model::ListOperationsResponse,
830 gax::error::Error,
831 > {
832 use gax::paginator::Paginator;
833 self.by_page().items()
834 }
835
836 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
838 self.0.request.name = v.into();
839 self
840 }
841
842 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
844 self.0.request.filter = v.into();
845 self
846 }
847
848 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
850 self.0.request.page_size = v.into();
851 self
852 }
853
854 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
856 self.0.request.page_token = v.into();
857 self
858 }
859 }
860
861 #[doc(hidden)]
862 impl gax::options::internal::RequestBuilder for ListOperations {
863 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
864 &mut self.0.options
865 }
866 }
867
868 #[derive(Clone, Debug)]
886 pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);
887
888 impl GetOperation {
889 pub(crate) fn new(
890 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
891 ) -> Self {
892 Self(RequestBuilder::new(stub))
893 }
894
895 pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
897 mut self,
898 v: V,
899 ) -> Self {
900 self.0.request = v.into();
901 self
902 }
903
904 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
906 self.0.options = v.into();
907 self
908 }
909
910 pub async fn send(self) -> Result<longrunning::model::Operation> {
912 (*self.0.stub)
913 .get_operation(self.0.request, self.0.options)
914 .await
915 .map(gax::response::Response::into_body)
916 }
917
918 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
920 self.0.request.name = v.into();
921 self
922 }
923 }
924
925 #[doc(hidden)]
926 impl gax::options::internal::RequestBuilder for GetOperation {
927 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
928 &mut self.0.options
929 }
930 }
931
932 #[derive(Clone, Debug)]
950 pub struct DeleteOperation(RequestBuilder<longrunning::model::DeleteOperationRequest>);
951
952 impl DeleteOperation {
953 pub(crate) fn new(
954 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
955 ) -> Self {
956 Self(RequestBuilder::new(stub))
957 }
958
959 pub fn with_request<V: Into<longrunning::model::DeleteOperationRequest>>(
961 mut self,
962 v: V,
963 ) -> Self {
964 self.0.request = v.into();
965 self
966 }
967
968 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
970 self.0.options = v.into();
971 self
972 }
973
974 pub async fn send(self) -> Result<()> {
976 (*self.0.stub)
977 .delete_operation(self.0.request, self.0.options)
978 .await
979 .map(gax::response::Response::into_body)
980 }
981
982 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
984 self.0.request.name = v.into();
985 self
986 }
987 }
988
989 #[doc(hidden)]
990 impl gax::options::internal::RequestBuilder for DeleteOperation {
991 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
992 &mut self.0.options
993 }
994 }
995
996 #[derive(Clone, Debug)]
1014 pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);
1015
1016 impl CancelOperation {
1017 pub(crate) fn new(
1018 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
1019 ) -> Self {
1020 Self(RequestBuilder::new(stub))
1021 }
1022
1023 pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
1025 mut self,
1026 v: V,
1027 ) -> Self {
1028 self.0.request = v.into();
1029 self
1030 }
1031
1032 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
1034 self.0.options = v.into();
1035 self
1036 }
1037
1038 pub async fn send(self) -> Result<()> {
1040 (*self.0.stub)
1041 .cancel_operation(self.0.request, self.0.options)
1042 .await
1043 .map(gax::response::Response::into_body)
1044 }
1045
1046 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1048 self.0.request.name = v.into();
1049 self
1050 }
1051 }
1052
1053 #[doc(hidden)]
1054 impl gax::options::internal::RequestBuilder for CancelOperation {
1055 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
1056 &mut self.0.options
1057 }
1058 }
1059}