1pub mod ids {
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::Ids;
38 pub struct Factory;
39 impl gax::client_builder::internal::ClientFactory for Factory {
40 type Client = Ids;
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::Ids>,
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(stub: std::sync::Arc<dyn super::super::stub::dynamic::Ids>) -> Self {
61 Self {
62 stub,
63 request: R::default(),
64 options: gax::options::RequestOptions::default(),
65 }
66 }
67 }
68
69 #[derive(Clone, Debug)]
90 pub struct ListEndpoints(RequestBuilder<crate::model::ListEndpointsRequest>);
91
92 impl ListEndpoints {
93 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Ids>) -> Self {
94 Self(RequestBuilder::new(stub))
95 }
96
97 pub fn with_request<V: Into<crate::model::ListEndpointsRequest>>(mut self, v: V) -> Self {
99 self.0.request = v.into();
100 self
101 }
102
103 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
105 self.0.options = v.into();
106 self
107 }
108
109 pub async fn send(self) -> Result<crate::model::ListEndpointsResponse> {
111 (*self.0.stub)
112 .list_endpoints(self.0.request, self.0.options)
113 .await
114 .map(gax::response::Response::into_body)
115 }
116
117 pub fn by_page(
119 self,
120 ) -> impl gax::paginator::Paginator<crate::model::ListEndpointsResponse, gax::error::Error>
121 {
122 use std::clone::Clone;
123 let token = self.0.request.page_token.clone();
124 let execute = move |token: String| {
125 let mut builder = self.clone();
126 builder.0.request = builder.0.request.set_page_token(token);
127 builder.send()
128 };
129 gax::paginator::internal::new_paginator(token, execute)
130 }
131
132 pub fn by_item(
134 self,
135 ) -> impl gax::paginator::ItemPaginator<crate::model::ListEndpointsResponse, gax::error::Error>
136 {
137 use gax::paginator::Paginator;
138 self.by_page().items()
139 }
140
141 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
145 self.0.request.parent = v.into();
146 self
147 }
148
149 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
151 self.0.request.page_size = v.into();
152 self
153 }
154
155 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
157 self.0.request.page_token = v.into();
158 self
159 }
160
161 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
163 self.0.request.filter = v.into();
164 self
165 }
166
167 pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
169 self.0.request.order_by = v.into();
170 self
171 }
172 }
173
174 #[doc(hidden)]
175 impl gax::options::internal::RequestBuilder for ListEndpoints {
176 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
177 &mut self.0.options
178 }
179 }
180
181 #[derive(Clone, Debug)]
198 pub struct GetEndpoint(RequestBuilder<crate::model::GetEndpointRequest>);
199
200 impl GetEndpoint {
201 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Ids>) -> Self {
202 Self(RequestBuilder::new(stub))
203 }
204
205 pub fn with_request<V: Into<crate::model::GetEndpointRequest>>(mut self, v: V) -> Self {
207 self.0.request = v.into();
208 self
209 }
210
211 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
213 self.0.options = v.into();
214 self
215 }
216
217 pub async fn send(self) -> Result<crate::model::Endpoint> {
219 (*self.0.stub)
220 .get_endpoint(self.0.request, self.0.options)
221 .await
222 .map(gax::response::Response::into_body)
223 }
224
225 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
229 self.0.request.name = v.into();
230 self
231 }
232 }
233
234 #[doc(hidden)]
235 impl gax::options::internal::RequestBuilder for GetEndpoint {
236 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
237 &mut self.0.options
238 }
239 }
240
241 #[derive(Clone, Debug)]
259 pub struct CreateEndpoint(RequestBuilder<crate::model::CreateEndpointRequest>);
260
261 impl CreateEndpoint {
262 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Ids>) -> Self {
263 Self(RequestBuilder::new(stub))
264 }
265
266 pub fn with_request<V: Into<crate::model::CreateEndpointRequest>>(mut self, v: V) -> Self {
268 self.0.request = v.into();
269 self
270 }
271
272 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
274 self.0.options = v.into();
275 self
276 }
277
278 pub async fn send(self) -> Result<longrunning::model::Operation> {
285 (*self.0.stub)
286 .create_endpoint(self.0.request, self.0.options)
287 .await
288 .map(gax::response::Response::into_body)
289 }
290
291 pub fn poller(
293 self,
294 ) -> impl lro::Poller<crate::model::Endpoint, crate::model::OperationMetadata> {
295 type Operation =
296 lro::internal::Operation<crate::model::Endpoint, crate::model::OperationMetadata>;
297 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
298 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
299
300 let stub = self.0.stub.clone();
301 let mut options = self.0.options.clone();
302 options.set_retry_policy(gax::retry_policy::NeverRetry);
303 let query = move |name| {
304 let stub = stub.clone();
305 let options = options.clone();
306 async {
307 let op = GetOperation::new(stub)
308 .set_name(name)
309 .with_options(options)
310 .send()
311 .await?;
312 Ok(Operation::new(op))
313 }
314 };
315
316 let start = move || async {
317 let op = self.send().await?;
318 Ok(Operation::new(op))
319 };
320
321 lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
322 }
323
324 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
328 self.0.request.parent = v.into();
329 self
330 }
331
332 pub fn set_endpoint_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
336 self.0.request.endpoint_id = v.into();
337 self
338 }
339
340 pub fn set_endpoint<T: Into<std::option::Option<crate::model::Endpoint>>>(
344 mut self,
345 v: T,
346 ) -> Self {
347 self.0.request.endpoint = v.into();
348 self
349 }
350
351 pub fn set_request_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
353 self.0.request.request_id = v.into();
354 self
355 }
356 }
357
358 #[doc(hidden)]
359 impl gax::options::internal::RequestBuilder for CreateEndpoint {
360 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
361 &mut self.0.options
362 }
363 }
364
365 #[derive(Clone, Debug)]
383 pub struct DeleteEndpoint(RequestBuilder<crate::model::DeleteEndpointRequest>);
384
385 impl DeleteEndpoint {
386 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Ids>) -> Self {
387 Self(RequestBuilder::new(stub))
388 }
389
390 pub fn with_request<V: Into<crate::model::DeleteEndpointRequest>>(mut self, v: V) -> Self {
392 self.0.request = v.into();
393 self
394 }
395
396 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
398 self.0.options = v.into();
399 self
400 }
401
402 pub async fn send(self) -> Result<longrunning::model::Operation> {
409 (*self.0.stub)
410 .delete_endpoint(self.0.request, self.0.options)
411 .await
412 .map(gax::response::Response::into_body)
413 }
414
415 pub fn poller(self) -> impl lro::Poller<(), crate::model::OperationMetadata> {
417 type Operation = lro::internal::Operation<wkt::Empty, crate::model::OperationMetadata>;
418 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
419 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
420
421 let stub = self.0.stub.clone();
422 let mut options = self.0.options.clone();
423 options.set_retry_policy(gax::retry_policy::NeverRetry);
424 let query = move |name| {
425 let stub = stub.clone();
426 let options = options.clone();
427 async {
428 let op = GetOperation::new(stub)
429 .set_name(name)
430 .with_options(options)
431 .send()
432 .await?;
433 Ok(Operation::new(op))
434 }
435 };
436
437 let start = move || async {
438 let op = self.send().await?;
439 Ok(Operation::new(op))
440 };
441
442 lro::internal::new_unit_response_poller(
443 polling_error_policy,
444 polling_backoff_policy,
445 start,
446 query,
447 )
448 }
449
450 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
454 self.0.request.name = v.into();
455 self
456 }
457
458 pub fn set_request_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
460 self.0.request.request_id = v.into();
461 self
462 }
463 }
464
465 #[doc(hidden)]
466 impl gax::options::internal::RequestBuilder for DeleteEndpoint {
467 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
468 &mut self.0.options
469 }
470 }
471
472 #[derive(Clone, Debug)]
493 pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);
494
495 impl ListOperations {
496 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Ids>) -> Self {
497 Self(RequestBuilder::new(stub))
498 }
499
500 pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
502 mut self,
503 v: V,
504 ) -> Self {
505 self.0.request = v.into();
506 self
507 }
508
509 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
511 self.0.options = v.into();
512 self
513 }
514
515 pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
517 (*self.0.stub)
518 .list_operations(self.0.request, self.0.options)
519 .await
520 .map(gax::response::Response::into_body)
521 }
522
523 pub fn by_page(
525 self,
526 ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
527 {
528 use std::clone::Clone;
529 let token = self.0.request.page_token.clone();
530 let execute = move |token: String| {
531 let mut builder = self.clone();
532 builder.0.request = builder.0.request.set_page_token(token);
533 builder.send()
534 };
535 gax::paginator::internal::new_paginator(token, execute)
536 }
537
538 pub fn by_item(
540 self,
541 ) -> impl gax::paginator::ItemPaginator<
542 longrunning::model::ListOperationsResponse,
543 gax::error::Error,
544 > {
545 use gax::paginator::Paginator;
546 self.by_page().items()
547 }
548
549 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
551 self.0.request.name = v.into();
552 self
553 }
554
555 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
557 self.0.request.filter = v.into();
558 self
559 }
560
561 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
563 self.0.request.page_size = v.into();
564 self
565 }
566
567 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
569 self.0.request.page_token = v.into();
570 self
571 }
572 }
573
574 #[doc(hidden)]
575 impl gax::options::internal::RequestBuilder for ListOperations {
576 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
577 &mut self.0.options
578 }
579 }
580
581 #[derive(Clone, Debug)]
598 pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);
599
600 impl GetOperation {
601 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Ids>) -> Self {
602 Self(RequestBuilder::new(stub))
603 }
604
605 pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
607 mut self,
608 v: V,
609 ) -> Self {
610 self.0.request = v.into();
611 self
612 }
613
614 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
616 self.0.options = v.into();
617 self
618 }
619
620 pub async fn send(self) -> Result<longrunning::model::Operation> {
622 (*self.0.stub)
623 .get_operation(self.0.request, self.0.options)
624 .await
625 .map(gax::response::Response::into_body)
626 }
627
628 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
630 self.0.request.name = v.into();
631 self
632 }
633 }
634
635 #[doc(hidden)]
636 impl gax::options::internal::RequestBuilder for GetOperation {
637 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
638 &mut self.0.options
639 }
640 }
641
642 #[derive(Clone, Debug)]
659 pub struct DeleteOperation(RequestBuilder<longrunning::model::DeleteOperationRequest>);
660
661 impl DeleteOperation {
662 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Ids>) -> Self {
663 Self(RequestBuilder::new(stub))
664 }
665
666 pub fn with_request<V: Into<longrunning::model::DeleteOperationRequest>>(
668 mut self,
669 v: V,
670 ) -> Self {
671 self.0.request = v.into();
672 self
673 }
674
675 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
677 self.0.options = v.into();
678 self
679 }
680
681 pub async fn send(self) -> Result<()> {
683 (*self.0.stub)
684 .delete_operation(self.0.request, self.0.options)
685 .await
686 .map(gax::response::Response::into_body)
687 }
688
689 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
691 self.0.request.name = v.into();
692 self
693 }
694 }
695
696 #[doc(hidden)]
697 impl gax::options::internal::RequestBuilder for DeleteOperation {
698 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
699 &mut self.0.options
700 }
701 }
702
703 #[derive(Clone, Debug)]
720 pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);
721
722 impl CancelOperation {
723 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Ids>) -> Self {
724 Self(RequestBuilder::new(stub))
725 }
726
727 pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
729 mut self,
730 v: V,
731 ) -> Self {
732 self.0.request = v.into();
733 self
734 }
735
736 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
738 self.0.options = v.into();
739 self
740 }
741
742 pub async fn send(self) -> Result<()> {
744 (*self.0.stub)
745 .cancel_operation(self.0.request, self.0.options)
746 .await
747 .map(gax::response::Response::into_body)
748 }
749
750 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
752 self.0.request.name = v.into();
753 self
754 }
755 }
756
757 #[doc(hidden)]
758 impl gax::options::internal::RequestBuilder for CancelOperation {
759 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
760 &mut self.0.options
761 }
762 }
763}