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(self, config: gaxi::options::ClientConfig) -> gax::Result<Self::Client> {
43 Self::Client::new(config).await
44 }
45 }
46 }
47
48 #[derive(Clone, Debug)]
50 pub(crate) struct RequestBuilder<R: std::default::Default> {
51 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
52 request: R,
53 options: gax::options::RequestOptions,
54 }
55
56 impl<R> RequestBuilder<R>
57 where
58 R: std::default::Default,
59 {
60 pub(crate) fn new(
61 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
62 ) -> Self {
63 Self {
64 stub,
65 request: R::default(),
66 options: gax::options::RequestOptions::default(),
67 }
68 }
69 }
70
71 #[derive(Clone, Debug)]
89 pub struct ExportEntities(RequestBuilder<crate::model::ExportEntitiesRequest>);
90
91 impl ExportEntities {
92 pub(crate) fn new(
93 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
94 ) -> Self {
95 Self(RequestBuilder::new(stub))
96 }
97
98 pub fn with_request<V: Into<crate::model::ExportEntitiesRequest>>(mut self, v: V) -> Self {
100 self.0.request = v.into();
101 self
102 }
103
104 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
106 self.0.options = v.into();
107 self
108 }
109
110 pub async fn send(self) -> Result<longrunning::model::Operation> {
117 (*self.0.stub)
118 .export_entities(self.0.request, self.0.options)
119 .await
120 .map(gax::response::Response::into_body)
121 }
122
123 pub fn poller(
125 self,
126 ) -> impl lro::Poller<crate::model::ExportEntitiesResponse, crate::model::ExportEntitiesMetadata>
127 {
128 type Operation = lro::internal::Operation<
129 crate::model::ExportEntitiesResponse,
130 crate::model::ExportEntitiesMetadata,
131 >;
132 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
133 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
134
135 let stub = self.0.stub.clone();
136 let mut options = self.0.options.clone();
137 options.set_retry_policy(gax::retry_policy::NeverRetry);
138 let query = move |name| {
139 let stub = stub.clone();
140 let options = options.clone();
141 async {
142 let op = GetOperation::new(stub)
143 .set_name(name)
144 .with_options(options)
145 .send()
146 .await?;
147 Ok(Operation::new(op))
148 }
149 };
150
151 let start = move || async {
152 let op = self.send().await?;
153 Ok(Operation::new(op))
154 };
155
156 lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
157 }
158
159 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
163 self.0.request.project_id = v.into();
164 self
165 }
166
167 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
169 where
170 T: std::iter::IntoIterator<Item = (K, V)>,
171 K: std::convert::Into<std::string::String>,
172 V: std::convert::Into<std::string::String>,
173 {
174 self.0.request.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
175 self
176 }
177
178 pub fn set_entity_filter<T: Into<std::option::Option<crate::model::EntityFilter>>>(
180 mut self,
181 v: T,
182 ) -> Self {
183 self.0.request.entity_filter = v.into();
184 self
185 }
186
187 pub fn set_output_url_prefix<T: Into<std::string::String>>(mut self, v: T) -> Self {
191 self.0.request.output_url_prefix = v.into();
192 self
193 }
194 }
195
196 #[doc(hidden)]
197 impl gax::options::internal::RequestBuilder for ExportEntities {
198 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
199 &mut self.0.options
200 }
201 }
202
203 #[derive(Clone, Debug)]
221 pub struct ImportEntities(RequestBuilder<crate::model::ImportEntitiesRequest>);
222
223 impl ImportEntities {
224 pub(crate) fn new(
225 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
226 ) -> Self {
227 Self(RequestBuilder::new(stub))
228 }
229
230 pub fn with_request<V: Into<crate::model::ImportEntitiesRequest>>(mut self, v: V) -> Self {
232 self.0.request = v.into();
233 self
234 }
235
236 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
238 self.0.options = v.into();
239 self
240 }
241
242 pub async fn send(self) -> Result<longrunning::model::Operation> {
249 (*self.0.stub)
250 .import_entities(self.0.request, self.0.options)
251 .await
252 .map(gax::response::Response::into_body)
253 }
254
255 pub fn poller(self) -> impl lro::Poller<(), crate::model::ImportEntitiesMetadata> {
257 type Operation =
258 lro::internal::Operation<wkt::Empty, crate::model::ImportEntitiesMetadata>;
259 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
260 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
261
262 let stub = self.0.stub.clone();
263 let mut options = self.0.options.clone();
264 options.set_retry_policy(gax::retry_policy::NeverRetry);
265 let query = move |name| {
266 let stub = stub.clone();
267 let options = options.clone();
268 async {
269 let op = GetOperation::new(stub)
270 .set_name(name)
271 .with_options(options)
272 .send()
273 .await?;
274 Ok(Operation::new(op))
275 }
276 };
277
278 let start = move || async {
279 let op = self.send().await?;
280 Ok(Operation::new(op))
281 };
282
283 lro::internal::new_unit_response_poller(
284 polling_error_policy,
285 polling_backoff_policy,
286 start,
287 query,
288 )
289 }
290
291 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
295 self.0.request.project_id = v.into();
296 self
297 }
298
299 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
301 where
302 T: std::iter::IntoIterator<Item = (K, V)>,
303 K: std::convert::Into<std::string::String>,
304 V: std::convert::Into<std::string::String>,
305 {
306 self.0.request.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
307 self
308 }
309
310 pub fn set_input_url<T: Into<std::string::String>>(mut self, v: T) -> Self {
314 self.0.request.input_url = v.into();
315 self
316 }
317
318 pub fn set_entity_filter<T: Into<std::option::Option<crate::model::EntityFilter>>>(
320 mut self,
321 v: T,
322 ) -> Self {
323 self.0.request.entity_filter = v.into();
324 self
325 }
326 }
327
328 #[doc(hidden)]
329 impl gax::options::internal::RequestBuilder for ImportEntities {
330 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
331 &mut self.0.options
332 }
333 }
334
335 #[derive(Clone, Debug)]
353 pub struct CreateIndex(RequestBuilder<crate::model::CreateIndexRequest>);
354
355 impl CreateIndex {
356 pub(crate) fn new(
357 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
358 ) -> Self {
359 Self(RequestBuilder::new(stub))
360 }
361
362 pub fn with_request<V: Into<crate::model::CreateIndexRequest>>(mut self, v: V) -> Self {
364 self.0.request = v.into();
365 self
366 }
367
368 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
370 self.0.options = v.into();
371 self
372 }
373
374 pub async fn send(self) -> Result<longrunning::model::Operation> {
381 (*self.0.stub)
382 .create_index(self.0.request, self.0.options)
383 .await
384 .map(gax::response::Response::into_body)
385 }
386
387 pub fn poller(
389 self,
390 ) -> impl lro::Poller<crate::model::Index, crate::model::IndexOperationMetadata> {
391 type Operation =
392 lro::internal::Operation<crate::model::Index, crate::model::IndexOperationMetadata>;
393 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
394 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
395
396 let stub = self.0.stub.clone();
397 let mut options = self.0.options.clone();
398 options.set_retry_policy(gax::retry_policy::NeverRetry);
399 let query = move |name| {
400 let stub = stub.clone();
401 let options = options.clone();
402 async {
403 let op = GetOperation::new(stub)
404 .set_name(name)
405 .with_options(options)
406 .send()
407 .await?;
408 Ok(Operation::new(op))
409 }
410 };
411
412 let start = move || async {
413 let op = self.send().await?;
414 Ok(Operation::new(op))
415 };
416
417 lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
418 }
419
420 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
422 self.0.request.project_id = v.into();
423 self
424 }
425
426 pub fn set_index<T: Into<std::option::Option<crate::model::Index>>>(
428 mut self,
429 v: T,
430 ) -> Self {
431 self.0.request.index = v.into();
432 self
433 }
434 }
435
436 #[doc(hidden)]
437 impl gax::options::internal::RequestBuilder for CreateIndex {
438 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
439 &mut self.0.options
440 }
441 }
442
443 #[derive(Clone, Debug)]
461 pub struct DeleteIndex(RequestBuilder<crate::model::DeleteIndexRequest>);
462
463 impl DeleteIndex {
464 pub(crate) fn new(
465 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
466 ) -> Self {
467 Self(RequestBuilder::new(stub))
468 }
469
470 pub fn with_request<V: Into<crate::model::DeleteIndexRequest>>(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<longrunning::model::Operation> {
489 (*self.0.stub)
490 .delete_index(self.0.request, self.0.options)
491 .await
492 .map(gax::response::Response::into_body)
493 }
494
495 pub fn poller(
497 self,
498 ) -> impl lro::Poller<crate::model::Index, crate::model::IndexOperationMetadata> {
499 type Operation =
500 lro::internal::Operation<crate::model::Index, crate::model::IndexOperationMetadata>;
501 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
502 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
503
504 let stub = self.0.stub.clone();
505 let mut options = self.0.options.clone();
506 options.set_retry_policy(gax::retry_policy::NeverRetry);
507 let query = move |name| {
508 let stub = stub.clone();
509 let options = options.clone();
510 async {
511 let op = GetOperation::new(stub)
512 .set_name(name)
513 .with_options(options)
514 .send()
515 .await?;
516 Ok(Operation::new(op))
517 }
518 };
519
520 let start = move || async {
521 let op = self.send().await?;
522 Ok(Operation::new(op))
523 };
524
525 lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
526 }
527
528 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
530 self.0.request.project_id = v.into();
531 self
532 }
533
534 pub fn set_index_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
536 self.0.request.index_id = v.into();
537 self
538 }
539 }
540
541 #[doc(hidden)]
542 impl gax::options::internal::RequestBuilder for DeleteIndex {
543 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
544 &mut self.0.options
545 }
546 }
547
548 #[derive(Clone, Debug)]
565 pub struct GetIndex(RequestBuilder<crate::model::GetIndexRequest>);
566
567 impl GetIndex {
568 pub(crate) fn new(
569 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
570 ) -> Self {
571 Self(RequestBuilder::new(stub))
572 }
573
574 pub fn with_request<V: Into<crate::model::GetIndexRequest>>(mut self, v: V) -> Self {
576 self.0.request = v.into();
577 self
578 }
579
580 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
582 self.0.options = v.into();
583 self
584 }
585
586 pub async fn send(self) -> Result<crate::model::Index> {
588 (*self.0.stub)
589 .get_index(self.0.request, self.0.options)
590 .await
591 .map(gax::response::Response::into_body)
592 }
593
594 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
596 self.0.request.project_id = v.into();
597 self
598 }
599
600 pub fn set_index_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
602 self.0.request.index_id = v.into();
603 self
604 }
605 }
606
607 #[doc(hidden)]
608 impl gax::options::internal::RequestBuilder for GetIndex {
609 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
610 &mut self.0.options
611 }
612 }
613
614 #[derive(Clone, Debug)]
635 pub struct ListIndexes(RequestBuilder<crate::model::ListIndexesRequest>);
636
637 impl ListIndexes {
638 pub(crate) fn new(
639 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
640 ) -> Self {
641 Self(RequestBuilder::new(stub))
642 }
643
644 pub fn with_request<V: Into<crate::model::ListIndexesRequest>>(mut self, v: V) -> Self {
646 self.0.request = v.into();
647 self
648 }
649
650 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
652 self.0.options = v.into();
653 self
654 }
655
656 pub async fn send(self) -> Result<crate::model::ListIndexesResponse> {
658 (*self.0.stub)
659 .list_indexes(self.0.request, self.0.options)
660 .await
661 .map(gax::response::Response::into_body)
662 }
663
664 pub fn by_page(
666 self,
667 ) -> impl gax::paginator::Paginator<crate::model::ListIndexesResponse, gax::error::Error>
668 {
669 use std::clone::Clone;
670 let token = self.0.request.page_token.clone();
671 let execute = move |token: String| {
672 let mut builder = self.clone();
673 builder.0.request = builder.0.request.set_page_token(token);
674 builder.send()
675 };
676 gax::paginator::internal::new_paginator(token, execute)
677 }
678
679 pub fn by_item(
681 self,
682 ) -> impl gax::paginator::ItemPaginator<crate::model::ListIndexesResponse, gax::error::Error>
683 {
684 use gax::paginator::Paginator;
685 self.by_page().items()
686 }
687
688 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
690 self.0.request.project_id = v.into();
691 self
692 }
693
694 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
696 self.0.request.filter = v.into();
697 self
698 }
699
700 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
702 self.0.request.page_size = v.into();
703 self
704 }
705
706 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
708 self.0.request.page_token = v.into();
709 self
710 }
711 }
712
713 #[doc(hidden)]
714 impl gax::options::internal::RequestBuilder for ListIndexes {
715 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
716 &mut self.0.options
717 }
718 }
719
720 #[derive(Clone, Debug)]
741 pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);
742
743 impl ListOperations {
744 pub(crate) fn new(
745 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
746 ) -> Self {
747 Self(RequestBuilder::new(stub))
748 }
749
750 pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
752 mut self,
753 v: V,
754 ) -> Self {
755 self.0.request = v.into();
756 self
757 }
758
759 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
761 self.0.options = v.into();
762 self
763 }
764
765 pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
767 (*self.0.stub)
768 .list_operations(self.0.request, self.0.options)
769 .await
770 .map(gax::response::Response::into_body)
771 }
772
773 pub fn by_page(
775 self,
776 ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
777 {
778 use std::clone::Clone;
779 let token = self.0.request.page_token.clone();
780 let execute = move |token: String| {
781 let mut builder = self.clone();
782 builder.0.request = builder.0.request.set_page_token(token);
783 builder.send()
784 };
785 gax::paginator::internal::new_paginator(token, execute)
786 }
787
788 pub fn by_item(
790 self,
791 ) -> impl gax::paginator::ItemPaginator<
792 longrunning::model::ListOperationsResponse,
793 gax::error::Error,
794 > {
795 use gax::paginator::Paginator;
796 self.by_page().items()
797 }
798
799 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
801 self.0.request.name = v.into();
802 self
803 }
804
805 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
807 self.0.request.filter = v.into();
808 self
809 }
810
811 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
813 self.0.request.page_size = v.into();
814 self
815 }
816
817 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
819 self.0.request.page_token = v.into();
820 self
821 }
822 }
823
824 #[doc(hidden)]
825 impl gax::options::internal::RequestBuilder for ListOperations {
826 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
827 &mut self.0.options
828 }
829 }
830
831 #[derive(Clone, Debug)]
848 pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);
849
850 impl GetOperation {
851 pub(crate) fn new(
852 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
853 ) -> Self {
854 Self(RequestBuilder::new(stub))
855 }
856
857 pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
859 mut self,
860 v: V,
861 ) -> Self {
862 self.0.request = v.into();
863 self
864 }
865
866 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
868 self.0.options = v.into();
869 self
870 }
871
872 pub async fn send(self) -> Result<longrunning::model::Operation> {
874 (*self.0.stub)
875 .get_operation(self.0.request, self.0.options)
876 .await
877 .map(gax::response::Response::into_body)
878 }
879
880 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
882 self.0.request.name = v.into();
883 self
884 }
885 }
886
887 #[doc(hidden)]
888 impl gax::options::internal::RequestBuilder for GetOperation {
889 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
890 &mut self.0.options
891 }
892 }
893
894 #[derive(Clone, Debug)]
911 pub struct DeleteOperation(RequestBuilder<longrunning::model::DeleteOperationRequest>);
912
913 impl DeleteOperation {
914 pub(crate) fn new(
915 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
916 ) -> Self {
917 Self(RequestBuilder::new(stub))
918 }
919
920 pub fn with_request<V: Into<longrunning::model::DeleteOperationRequest>>(
922 mut self,
923 v: V,
924 ) -> Self {
925 self.0.request = v.into();
926 self
927 }
928
929 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
931 self.0.options = v.into();
932 self
933 }
934
935 pub async fn send(self) -> Result<()> {
937 (*self.0.stub)
938 .delete_operation(self.0.request, self.0.options)
939 .await
940 .map(gax::response::Response::into_body)
941 }
942
943 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
945 self.0.request.name = v.into();
946 self
947 }
948 }
949
950 #[doc(hidden)]
951 impl gax::options::internal::RequestBuilder for DeleteOperation {
952 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
953 &mut self.0.options
954 }
955 }
956
957 #[derive(Clone, Debug)]
974 pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);
975
976 impl CancelOperation {
977 pub(crate) fn new(
978 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatastoreAdmin>,
979 ) -> Self {
980 Self(RequestBuilder::new(stub))
981 }
982
983 pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
985 mut self,
986 v: V,
987 ) -> Self {
988 self.0.request = v.into();
989 self
990 }
991
992 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
994 self.0.options = v.into();
995 self
996 }
997
998 pub async fn send(self) -> Result<()> {
1000 (*self.0.stub)
1001 .cancel_operation(self.0.request, self.0.options)
1002 .await
1003 .map(gax::response::Response::into_body)
1004 }
1005
1006 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1008 self.0.request.name = v.into();
1009 self
1010 }
1011 }
1012
1013 #[doc(hidden)]
1014 impl gax::options::internal::RequestBuilder for CancelOperation {
1015 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
1016 &mut self.0.options
1017 }
1018 }
1019}