google_cloud_ids_v1/
builder.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17pub mod ids {
18    use crate::Result;
19    use std::sync::Arc;
20
21    /// A builder for [Ids][super::super::client::Ids].
22    ///
23    /// ```
24    /// # tokio_test::block_on(async {
25    /// # use google_cloud_ids_v1::*;
26    /// # use builder::ids::ClientBuilder;
27    /// # use client::Ids;
28    /// let builder : ClientBuilder = Ids::builder();
29    /// let client = builder
30    ///     .with_endpoint("https://ids.googleapis.com")
31    ///     .build().await?;
32    /// # gax::Result::<()>::Ok(()) });
33    /// ```
34    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    /// Common implementation for [super::super::client::Ids] request builders.
50    #[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    /// The request builder for [Ids::list_endpoints][super::super::client::Ids::list_endpoints] calls.
71    #[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        /// Sets the full request, replacing any prior values.
80        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        /// Sets all the options, replacing any prior values.
86        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        /// Sends the request.
92        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        /// Streams the responses back.
100        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        /// Sets the value of [parent][crate::model::ListEndpointsRequest::parent].
115        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        /// Sets the value of [page_size][crate::model::ListEndpointsRequest::page_size].
121        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        /// Sets the value of [page_token][crate::model::ListEndpointsRequest::page_token].
127        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        /// Sets the value of [filter][crate::model::ListEndpointsRequest::filter].
133        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        /// Sets the value of [order_by][crate::model::ListEndpointsRequest::order_by].
139        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    /// The request builder for [Ids::get_endpoint][super::super::client::Ids::get_endpoint] calls.
153    #[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        /// Sets the full request, replacing any prior values.
162        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        /// Sets all the options, replacing any prior values.
168        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        /// Sends the request.
174        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        /// Sets the value of [name][crate::model::GetEndpointRequest::name].
182        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    /// The request builder for [Ids::create_endpoint][super::super::client::Ids::create_endpoint] calls.
196    #[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        /// Sets the full request, replacing any prior values.
205        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        /// Sets all the options, replacing any prior values.
211        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        /// Sends the request.
217        ///
218        /// # Long running operations
219        ///
220        /// This starts, but does not poll, a longrunning operation. More information
221        /// on [create_endpoint][super::super::client::Ids::create_endpoint].
222        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        /// Creates a [Poller][lro::Poller] to work with `create_endpoint`.
230        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        /// Sets the value of [parent][crate::model::CreateEndpointRequest::parent].
263        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        /// Sets the value of [endpoint_id][crate::model::CreateEndpointRequest::endpoint_id].
269        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        /// Sets the value of [endpoint][crate::model::CreateEndpointRequest::endpoint].
275        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        /// Sets the value of [request_id][crate::model::CreateEndpointRequest::request_id].
284        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    /// The request builder for [Ids::delete_endpoint][super::super::client::Ids::delete_endpoint] calls.
298    #[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        /// Sets the full request, replacing any prior values.
307        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        /// Sets all the options, replacing any prior values.
313        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        /// Sends the request.
319        ///
320        /// # Long running operations
321        ///
322        /// This starts, but does not poll, a longrunning operation. More information
323        /// on [delete_endpoint][super::super::client::Ids::delete_endpoint].
324        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        /// Creates a [Poller][lro::Poller] to work with `delete_endpoint`.
332        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        /// Sets the value of [name][crate::model::DeleteEndpointRequest::name].
362        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        /// Sets the value of [request_id][crate::model::DeleteEndpointRequest::request_id].
368        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    /// The request builder for [Ids::list_operations][super::super::client::Ids::list_operations] calls.
382    #[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        /// Sets the full request, replacing any prior values.
391        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        /// Sets all the options, replacing any prior values.
400        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        /// Sends the request.
406        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        /// Streams the responses back.
414        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        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
429        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        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
435        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        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
441        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        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
447        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    /// The request builder for [Ids::get_operation][super::super::client::Ids::get_operation] calls.
461    #[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        /// Sets the full request, replacing any prior values.
470        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        /// Sets all the options, replacing any prior values.
479        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        /// Sends the request.
485        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        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
493        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    /// The request builder for [Ids::delete_operation][super::super::client::Ids::delete_operation] calls.
507    #[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        /// Sets the full request, replacing any prior values.
516        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        /// Sets all the options, replacing any prior values.
525        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        /// Sends the request.
531        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        /// Sets the value of [name][longrunning::model::DeleteOperationRequest::name].
539        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    /// The request builder for [Ids::cancel_operation][super::super::client::Ids::cancel_operation] calls.
553    #[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        /// Sets the full request, replacing any prior values.
562        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        /// Sets all the options, replacing any prior values.
571        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        /// Sends the request.
577        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        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
585        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}