google_cloud_ids_v1/
builder.rs1pub mod ids {
18 use crate::Result;
19 use std::sync::Arc;
20
21 pub type ClientBuilder =
35 gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;
36
37 pub(crate) mod client {
38 use super::super::super::client::Ids;
39 pub struct Factory;
40 impl gax::client_builder::internal::ClientFactory for Factory {
41 type Client = Ids;
42 type Credentials = gaxi::options::Credentials;
43 async fn build(self, config: gaxi::options::ClientConfig) -> gax::Result<Self::Client> {
44 Self::Client::new(config).await
45 }
46 }
47 }
48
49 #[derive(Clone, Debug)]
51 pub(crate) struct RequestBuilder<R: std::default::Default> {
52 stub: Arc<dyn super::super::stub::dynamic::Ids>,
53 request: R,
54 options: gax::options::RequestOptions,
55 }
56
57 impl<R> RequestBuilder<R>
58 where
59 R: std::default::Default,
60 {
61 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::Ids>) -> Self {
62 Self {
63 stub,
64 request: R::default(),
65 options: gax::options::RequestOptions::default(),
66 }
67 }
68 }
69
70 #[derive(Clone, Debug)]
72 pub struct ListEndpoints(RequestBuilder<crate::model::ListEndpointsRequest>);
73
74 impl ListEndpoints {
75 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::Ids>) -> Self {
76 Self(RequestBuilder::new(stub))
77 }
78
79 pub fn with_request<V: Into<crate::model::ListEndpointsRequest>>(mut self, v: V) -> Self {
81 self.0.request = v.into();
82 self
83 }
84
85 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
87 self.0.options = v.into();
88 self
89 }
90
91 pub async fn send(self) -> Result<crate::model::ListEndpointsResponse> {
93 (*self.0.stub)
94 .list_endpoints(self.0.request, self.0.options)
95 .await
96 .map(gax::response::Response::into_body)
97 }
98
99 pub async fn paginator(
101 self,
102 ) -> impl gax::paginator::Paginator<crate::model::ListEndpointsResponse, gax::error::Error>
103 {
104 use std::clone::Clone;
105 let token = self.0.request.page_token.clone();
106 let execute = move |token: String| {
107 let mut builder = self.clone();
108 builder.0.request = builder.0.request.set_page_token(token);
109 builder.send()
110 };
111 gax::paginator::internal::new_paginator(token, execute)
112 }
113
114 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
116 self.0.request.parent = v.into();
117 self
118 }
119
120 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
122 self.0.request.page_size = v.into();
123 self
124 }
125
126 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
128 self.0.request.page_token = v.into();
129 self
130 }
131
132 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
134 self.0.request.filter = v.into();
135 self
136 }
137
138 pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
140 self.0.request.order_by = v.into();
141 self
142 }
143 }
144
145 #[doc(hidden)]
146 impl gax::options::internal::RequestBuilder for ListEndpoints {
147 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
148 &mut self.0.options
149 }
150 }
151
152 #[derive(Clone, Debug)]
154 pub struct GetEndpoint(RequestBuilder<crate::model::GetEndpointRequest>);
155
156 impl GetEndpoint {
157 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::Ids>) -> Self {
158 Self(RequestBuilder::new(stub))
159 }
160
161 pub fn with_request<V: Into<crate::model::GetEndpointRequest>>(mut self, v: V) -> Self {
163 self.0.request = v.into();
164 self
165 }
166
167 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
169 self.0.options = v.into();
170 self
171 }
172
173 pub async fn send(self) -> Result<crate::model::Endpoint> {
175 (*self.0.stub)
176 .get_endpoint(self.0.request, self.0.options)
177 .await
178 .map(gax::response::Response::into_body)
179 }
180
181 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
183 self.0.request.name = v.into();
184 self
185 }
186 }
187
188 #[doc(hidden)]
189 impl gax::options::internal::RequestBuilder for GetEndpoint {
190 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
191 &mut self.0.options
192 }
193 }
194
195 #[derive(Clone, Debug)]
197 pub struct CreateEndpoint(RequestBuilder<crate::model::CreateEndpointRequest>);
198
199 impl CreateEndpoint {
200 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::Ids>) -> Self {
201 Self(RequestBuilder::new(stub))
202 }
203
204 pub fn with_request<V: Into<crate::model::CreateEndpointRequest>>(mut self, v: V) -> Self {
206 self.0.request = v.into();
207 self
208 }
209
210 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
212 self.0.options = v.into();
213 self
214 }
215
216 pub async fn send(self) -> Result<longrunning::model::Operation> {
223 (*self.0.stub)
224 .create_endpoint(self.0.request, self.0.options)
225 .await
226 .map(gax::response::Response::into_body)
227 }
228
229 pub fn poller(
231 self,
232 ) -> impl lro::Poller<crate::model::Endpoint, crate::model::OperationMetadata> {
233 type Operation =
234 lro::Operation<crate::model::Endpoint, crate::model::OperationMetadata>;
235 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
236 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
237
238 let stub = self.0.stub.clone();
239 let mut options = self.0.options.clone();
240 options.set_retry_policy(gax::retry_policy::NeverRetry);
241 let query = move |name| {
242 let stub = stub.clone();
243 let options = options.clone();
244 async {
245 let op = GetOperation::new(stub)
246 .set_name(name)
247 .with_options(options)
248 .send()
249 .await?;
250 Ok(Operation::new(op))
251 }
252 };
253
254 let start = move || async {
255 let op = self.send().await?;
256 Ok(Operation::new(op))
257 };
258
259 lro::new_poller(polling_error_policy, polling_backoff_policy, start, query)
260 }
261
262 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
264 self.0.request.parent = v.into();
265 self
266 }
267
268 pub fn set_endpoint_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
270 self.0.request.endpoint_id = v.into();
271 self
272 }
273
274 pub fn set_endpoint<T: Into<std::option::Option<crate::model::Endpoint>>>(
276 mut self,
277 v: T,
278 ) -> Self {
279 self.0.request.endpoint = v.into();
280 self
281 }
282
283 pub fn set_request_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
285 self.0.request.request_id = v.into();
286 self
287 }
288 }
289
290 #[doc(hidden)]
291 impl gax::options::internal::RequestBuilder for CreateEndpoint {
292 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
293 &mut self.0.options
294 }
295 }
296
297 #[derive(Clone, Debug)]
299 pub struct DeleteEndpoint(RequestBuilder<crate::model::DeleteEndpointRequest>);
300
301 impl DeleteEndpoint {
302 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::Ids>) -> Self {
303 Self(RequestBuilder::new(stub))
304 }
305
306 pub fn with_request<V: Into<crate::model::DeleteEndpointRequest>>(mut self, v: V) -> Self {
308 self.0.request = v.into();
309 self
310 }
311
312 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
314 self.0.options = v.into();
315 self
316 }
317
318 pub async fn send(self) -> Result<longrunning::model::Operation> {
325 (*self.0.stub)
326 .delete_endpoint(self.0.request, self.0.options)
327 .await
328 .map(gax::response::Response::into_body)
329 }
330
331 pub fn poller(self) -> impl lro::Poller<wkt::Empty, crate::model::OperationMetadata> {
333 type Operation = lro::Operation<wkt::Empty, crate::model::OperationMetadata>;
334 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
335 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
336
337 let stub = self.0.stub.clone();
338 let mut options = self.0.options.clone();
339 options.set_retry_policy(gax::retry_policy::NeverRetry);
340 let query = move |name| {
341 let stub = stub.clone();
342 let options = options.clone();
343 async {
344 let op = GetOperation::new(stub)
345 .set_name(name)
346 .with_options(options)
347 .send()
348 .await?;
349 Ok(Operation::new(op))
350 }
351 };
352
353 let start = move || async {
354 let op = self.send().await?;
355 Ok(Operation::new(op))
356 };
357
358 lro::new_poller(polling_error_policy, polling_backoff_policy, start, query)
359 }
360
361 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
363 self.0.request.name = v.into();
364 self
365 }
366
367 pub fn set_request_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
369 self.0.request.request_id = v.into();
370 self
371 }
372 }
373
374 #[doc(hidden)]
375 impl gax::options::internal::RequestBuilder for DeleteEndpoint {
376 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
377 &mut self.0.options
378 }
379 }
380
381 #[derive(Clone, Debug)]
383 pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);
384
385 impl ListOperations {
386 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::Ids>) -> Self {
387 Self(RequestBuilder::new(stub))
388 }
389
390 pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
392 mut self,
393 v: V,
394 ) -> Self {
395 self.0.request = v.into();
396 self
397 }
398
399 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
401 self.0.options = v.into();
402 self
403 }
404
405 pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
407 (*self.0.stub)
408 .list_operations(self.0.request, self.0.options)
409 .await
410 .map(gax::response::Response::into_body)
411 }
412
413 pub async fn paginator(
415 self,
416 ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
417 {
418 use std::clone::Clone;
419 let token = self.0.request.page_token.clone();
420 let execute = move |token: String| {
421 let mut builder = self.clone();
422 builder.0.request = builder.0.request.set_page_token(token);
423 builder.send()
424 };
425 gax::paginator::internal::new_paginator(token, execute)
426 }
427
428 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
430 self.0.request.name = v.into();
431 self
432 }
433
434 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
436 self.0.request.filter = v.into();
437 self
438 }
439
440 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
442 self.0.request.page_size = v.into();
443 self
444 }
445
446 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
448 self.0.request.page_token = v.into();
449 self
450 }
451 }
452
453 #[doc(hidden)]
454 impl gax::options::internal::RequestBuilder for ListOperations {
455 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
456 &mut self.0.options
457 }
458 }
459
460 #[derive(Clone, Debug)]
462 pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);
463
464 impl GetOperation {
465 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::Ids>) -> Self {
466 Self(RequestBuilder::new(stub))
467 }
468
469 pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
471 mut self,
472 v: V,
473 ) -> Self {
474 self.0.request = v.into();
475 self
476 }
477
478 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
480 self.0.options = v.into();
481 self
482 }
483
484 pub async fn send(self) -> Result<longrunning::model::Operation> {
486 (*self.0.stub)
487 .get_operation(self.0.request, self.0.options)
488 .await
489 .map(gax::response::Response::into_body)
490 }
491
492 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
494 self.0.request.name = v.into();
495 self
496 }
497 }
498
499 #[doc(hidden)]
500 impl gax::options::internal::RequestBuilder for GetOperation {
501 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
502 &mut self.0.options
503 }
504 }
505
506 #[derive(Clone, Debug)]
508 pub struct DeleteOperation(RequestBuilder<longrunning::model::DeleteOperationRequest>);
509
510 impl DeleteOperation {
511 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::Ids>) -> Self {
512 Self(RequestBuilder::new(stub))
513 }
514
515 pub fn with_request<V: Into<longrunning::model::DeleteOperationRequest>>(
517 mut self,
518 v: V,
519 ) -> Self {
520 self.0.request = v.into();
521 self
522 }
523
524 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
526 self.0.options = v.into();
527 self
528 }
529
530 pub async fn send(self) -> Result<()> {
532 (*self.0.stub)
533 .delete_operation(self.0.request, self.0.options)
534 .await
535 .map(gax::response::Response::into_body)
536 }
537
538 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
540 self.0.request.name = v.into();
541 self
542 }
543 }
544
545 #[doc(hidden)]
546 impl gax::options::internal::RequestBuilder for DeleteOperation {
547 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
548 &mut self.0.options
549 }
550 }
551
552 #[derive(Clone, Debug)]
554 pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);
555
556 impl CancelOperation {
557 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::Ids>) -> Self {
558 Self(RequestBuilder::new(stub))
559 }
560
561 pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
563 mut self,
564 v: V,
565 ) -> Self {
566 self.0.request = v.into();
567 self
568 }
569
570 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
572 self.0.options = v.into();
573 self
574 }
575
576 pub async fn send(self) -> Result<()> {
578 (*self.0.stub)
579 .cancel_operation(self.0.request, self.0.options)
580 .await
581 .map(gax::response::Response::into_body)
582 }
583
584 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
586 self.0.request.name = v.into();
587 self
588 }
589 }
590
591 #[doc(hidden)]
592 impl gax::options::internal::RequestBuilder for CancelOperation {
593 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
594 &mut self.0.options
595 }
596 }
597}