Skip to main content

google_cloud_apikeys_v2/
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 api_keys {
18    use crate::Result;
19
20    /// A builder for [ApiKeys][crate::client::ApiKeys].
21    ///
22    /// ```
23    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
24    /// # use google_cloud_apikeys_v2::*;
25    /// # use builder::api_keys::ClientBuilder;
26    /// # use client::ApiKeys;
27    /// let builder : ClientBuilder = ApiKeys::builder();
28    /// let client = builder
29    ///     .with_endpoint("https://apikeys.googleapis.com")
30    ///     .build().await?;
31    /// # Ok(()) }
32    /// ```
33    pub type ClientBuilder = crate::ClientBuilder<client::Factory, gaxi::options::Credentials>;
34
35    pub(crate) mod client {
36        use super::super::super::client::ApiKeys;
37        pub struct Factory;
38        impl crate::ClientFactory for Factory {
39            type Client = ApiKeys;
40            type Credentials = gaxi::options::Credentials;
41            async fn build(
42                self,
43                config: gaxi::options::ClientConfig,
44            ) -> crate::ClientBuilderResult<Self::Client> {
45                Self::Client::new(config).await
46            }
47        }
48    }
49
50    /// Common implementation for [crate::client::ApiKeys] request builders.
51    #[derive(Clone, Debug)]
52    pub(crate) struct RequestBuilder<R: std::default::Default> {
53        stub: std::sync::Arc<dyn super::super::stub::dynamic::ApiKeys>,
54        request: R,
55        options: crate::RequestOptions,
56    }
57
58    impl<R> RequestBuilder<R>
59    where
60        R: std::default::Default,
61    {
62        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::ApiKeys>) -> Self {
63            Self {
64                stub,
65                request: R::default(),
66                options: crate::RequestOptions::default(),
67            }
68        }
69    }
70
71    /// The request builder for [ApiKeys::create_key][crate::client::ApiKeys::create_key] calls.
72    ///
73    /// # Example
74    /// ```
75    /// # use google_cloud_apikeys_v2::builder::api_keys::CreateKey;
76    /// # async fn sample() -> google_cloud_apikeys_v2::Result<()> {
77    /// use google_cloud_lro::Poller;
78    ///
79    /// let builder = prepare_request_builder();
80    /// let response = builder.poller().until_done().await?;
81    /// # Ok(()) }
82    ///
83    /// fn prepare_request_builder() -> CreateKey {
84    ///   # panic!();
85    ///   // ... details omitted ...
86    /// }
87    /// ```
88    #[derive(Clone, Debug)]
89    pub struct CreateKey(RequestBuilder<crate::model::CreateKeyRequest>);
90
91    impl CreateKey {
92        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::ApiKeys>) -> Self {
93            Self(RequestBuilder::new(stub))
94        }
95
96        /// Sets the full request, replacing any prior values.
97        pub fn with_request<V: Into<crate::model::CreateKeyRequest>>(mut self, v: V) -> Self {
98            self.0.request = v.into();
99            self
100        }
101
102        /// Sets all the options, replacing any prior values.
103        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
104            self.0.options = v.into();
105            self
106        }
107
108        /// Sends the request.
109        ///
110        /// # Long running operations
111        ///
112        /// This starts, but does not poll, a longrunning operation. More information
113        /// on [create_key][crate::client::ApiKeys::create_key].
114        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
115            (*self.0.stub)
116                .create_key(self.0.request, self.0.options)
117                .await
118                .map(crate::Response::into_body)
119        }
120
121        /// Creates a [Poller][google_cloud_lro::Poller] to work with `create_key`.
122        pub fn poller(self) -> impl google_cloud_lro::Poller<crate::model::Key, ()> {
123            type Operation = google_cloud_lro::internal::Operation<crate::model::Key, wkt::Empty>;
124            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
125            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
126
127            let stub = self.0.stub.clone();
128            let mut options = self.0.options.clone();
129            options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
130            let query = move |name| {
131                let stub = stub.clone();
132                let options = options.clone();
133                async {
134                    let op = GetOperation::new(stub)
135                        .set_name(name)
136                        .with_options(options)
137                        .send()
138                        .await?;
139                    Ok(Operation::new(op))
140                }
141            };
142
143            let start = move || async {
144                let op = self.send().await?;
145                Ok(Operation::new(op))
146            };
147
148            google_cloud_lro::internal::new_unit_metadata_poller(
149                polling_error_policy,
150                polling_backoff_policy,
151                start,
152                query,
153            )
154        }
155
156        /// Sets the value of [parent][crate::model::CreateKeyRequest::parent].
157        ///
158        /// This is a **required** field for requests.
159        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
160            self.0.request.parent = v.into();
161            self
162        }
163
164        /// Sets the value of [key][crate::model::CreateKeyRequest::key].
165        ///
166        /// This is a **required** field for requests.
167        pub fn set_key<T>(mut self, v: T) -> Self
168        where
169            T: std::convert::Into<crate::model::Key>,
170        {
171            self.0.request.key = std::option::Option::Some(v.into());
172            self
173        }
174
175        /// Sets or clears the value of [key][crate::model::CreateKeyRequest::key].
176        ///
177        /// This is a **required** field for requests.
178        pub fn set_or_clear_key<T>(mut self, v: std::option::Option<T>) -> Self
179        where
180            T: std::convert::Into<crate::model::Key>,
181        {
182            self.0.request.key = v.map(|x| x.into());
183            self
184        }
185
186        /// Sets the value of [key_id][crate::model::CreateKeyRequest::key_id].
187        pub fn set_key_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
188            self.0.request.key_id = v.into();
189            self
190        }
191    }
192
193    #[doc(hidden)]
194    impl crate::RequestBuilder for CreateKey {
195        fn request_options(&mut self) -> &mut crate::RequestOptions {
196            &mut self.0.options
197        }
198    }
199
200    /// The request builder for [ApiKeys::list_keys][crate::client::ApiKeys::list_keys] calls.
201    ///
202    /// # Example
203    /// ```
204    /// # use google_cloud_apikeys_v2::builder::api_keys::ListKeys;
205    /// # async fn sample() -> google_cloud_apikeys_v2::Result<()> {
206    /// use google_cloud_gax::paginator::ItemPaginator;
207    ///
208    /// let builder = prepare_request_builder();
209    /// let mut items = builder.by_item();
210    /// while let Some(result) = items.next().await {
211    ///   let item = result?;
212    /// }
213    /// # Ok(()) }
214    ///
215    /// fn prepare_request_builder() -> ListKeys {
216    ///   # panic!();
217    ///   // ... details omitted ...
218    /// }
219    /// ```
220    #[derive(Clone, Debug)]
221    pub struct ListKeys(RequestBuilder<crate::model::ListKeysRequest>);
222
223    impl ListKeys {
224        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::ApiKeys>) -> Self {
225            Self(RequestBuilder::new(stub))
226        }
227
228        /// Sets the full request, replacing any prior values.
229        pub fn with_request<V: Into<crate::model::ListKeysRequest>>(mut self, v: V) -> Self {
230            self.0.request = v.into();
231            self
232        }
233
234        /// Sets all the options, replacing any prior values.
235        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
236            self.0.options = v.into();
237            self
238        }
239
240        /// Sends the request.
241        pub async fn send(self) -> Result<crate::model::ListKeysResponse> {
242            (*self.0.stub)
243                .list_keys(self.0.request, self.0.options)
244                .await
245                .map(crate::Response::into_body)
246        }
247
248        /// Streams each page in the collection.
249        pub fn by_page(
250            self,
251        ) -> impl google_cloud_gax::paginator::Paginator<crate::model::ListKeysResponse, crate::Error>
252        {
253            use std::clone::Clone;
254            let token = self.0.request.page_token.clone();
255            let execute = move |token: String| {
256                let mut builder = self.clone();
257                builder.0.request = builder.0.request.set_page_token(token);
258                builder.send()
259            };
260            google_cloud_gax::paginator::internal::new_paginator(token, execute)
261        }
262
263        /// Streams each item in the collection.
264        pub fn by_item(
265            self,
266        ) -> impl google_cloud_gax::paginator::ItemPaginator<crate::model::ListKeysResponse, crate::Error>
267        {
268            use google_cloud_gax::paginator::Paginator;
269            self.by_page().items()
270        }
271
272        /// Sets the value of [parent][crate::model::ListKeysRequest::parent].
273        ///
274        /// This is a **required** field for requests.
275        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
276            self.0.request.parent = v.into();
277            self
278        }
279
280        /// Sets the value of [page_size][crate::model::ListKeysRequest::page_size].
281        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
282            self.0.request.page_size = v.into();
283            self
284        }
285
286        /// Sets the value of [page_token][crate::model::ListKeysRequest::page_token].
287        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
288            self.0.request.page_token = v.into();
289            self
290        }
291
292        /// Sets the value of [show_deleted][crate::model::ListKeysRequest::show_deleted].
293        pub fn set_show_deleted<T: Into<bool>>(mut self, v: T) -> Self {
294            self.0.request.show_deleted = v.into();
295            self
296        }
297    }
298
299    #[doc(hidden)]
300    impl crate::RequestBuilder for ListKeys {
301        fn request_options(&mut self) -> &mut crate::RequestOptions {
302            &mut self.0.options
303        }
304    }
305
306    /// The request builder for [ApiKeys::get_key][crate::client::ApiKeys::get_key] calls.
307    ///
308    /// # Example
309    /// ```
310    /// # use google_cloud_apikeys_v2::builder::api_keys::GetKey;
311    /// # async fn sample() -> google_cloud_apikeys_v2::Result<()> {
312    ///
313    /// let builder = prepare_request_builder();
314    /// let response = builder.send().await?;
315    /// # Ok(()) }
316    ///
317    /// fn prepare_request_builder() -> GetKey {
318    ///   # panic!();
319    ///   // ... details omitted ...
320    /// }
321    /// ```
322    #[derive(Clone, Debug)]
323    pub struct GetKey(RequestBuilder<crate::model::GetKeyRequest>);
324
325    impl GetKey {
326        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::ApiKeys>) -> Self {
327            Self(RequestBuilder::new(stub))
328        }
329
330        /// Sets the full request, replacing any prior values.
331        pub fn with_request<V: Into<crate::model::GetKeyRequest>>(mut self, v: V) -> Self {
332            self.0.request = v.into();
333            self
334        }
335
336        /// Sets all the options, replacing any prior values.
337        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
338            self.0.options = v.into();
339            self
340        }
341
342        /// Sends the request.
343        pub async fn send(self) -> Result<crate::model::Key> {
344            (*self.0.stub)
345                .get_key(self.0.request, self.0.options)
346                .await
347                .map(crate::Response::into_body)
348        }
349
350        /// Sets the value of [name][crate::model::GetKeyRequest::name].
351        ///
352        /// This is a **required** field for requests.
353        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
354            self.0.request.name = v.into();
355            self
356        }
357    }
358
359    #[doc(hidden)]
360    impl crate::RequestBuilder for GetKey {
361        fn request_options(&mut self) -> &mut crate::RequestOptions {
362            &mut self.0.options
363        }
364    }
365
366    /// The request builder for [ApiKeys::get_key_string][crate::client::ApiKeys::get_key_string] calls.
367    ///
368    /// # Example
369    /// ```
370    /// # use google_cloud_apikeys_v2::builder::api_keys::GetKeyString;
371    /// # async fn sample() -> google_cloud_apikeys_v2::Result<()> {
372    ///
373    /// let builder = prepare_request_builder();
374    /// let response = builder.send().await?;
375    /// # Ok(()) }
376    ///
377    /// fn prepare_request_builder() -> GetKeyString {
378    ///   # panic!();
379    ///   // ... details omitted ...
380    /// }
381    /// ```
382    #[derive(Clone, Debug)]
383    pub struct GetKeyString(RequestBuilder<crate::model::GetKeyStringRequest>);
384
385    impl GetKeyString {
386        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::ApiKeys>) -> Self {
387            Self(RequestBuilder::new(stub))
388        }
389
390        /// Sets the full request, replacing any prior values.
391        pub fn with_request<V: Into<crate::model::GetKeyStringRequest>>(mut self, v: V) -> Self {
392            self.0.request = v.into();
393            self
394        }
395
396        /// Sets all the options, replacing any prior values.
397        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
398            self.0.options = v.into();
399            self
400        }
401
402        /// Sends the request.
403        pub async fn send(self) -> Result<crate::model::GetKeyStringResponse> {
404            (*self.0.stub)
405                .get_key_string(self.0.request, self.0.options)
406                .await
407                .map(crate::Response::into_body)
408        }
409
410        /// Sets the value of [name][crate::model::GetKeyStringRequest::name].
411        ///
412        /// This is a **required** field for requests.
413        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
414            self.0.request.name = v.into();
415            self
416        }
417    }
418
419    #[doc(hidden)]
420    impl crate::RequestBuilder for GetKeyString {
421        fn request_options(&mut self) -> &mut crate::RequestOptions {
422            &mut self.0.options
423        }
424    }
425
426    /// The request builder for [ApiKeys::update_key][crate::client::ApiKeys::update_key] calls.
427    ///
428    /// # Example
429    /// ```
430    /// # use google_cloud_apikeys_v2::builder::api_keys::UpdateKey;
431    /// # async fn sample() -> google_cloud_apikeys_v2::Result<()> {
432    /// use google_cloud_lro::Poller;
433    ///
434    /// let builder = prepare_request_builder();
435    /// let response = builder.poller().until_done().await?;
436    /// # Ok(()) }
437    ///
438    /// fn prepare_request_builder() -> UpdateKey {
439    ///   # panic!();
440    ///   // ... details omitted ...
441    /// }
442    /// ```
443    #[derive(Clone, Debug)]
444    pub struct UpdateKey(RequestBuilder<crate::model::UpdateKeyRequest>);
445
446    impl UpdateKey {
447        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::ApiKeys>) -> Self {
448            Self(RequestBuilder::new(stub))
449        }
450
451        /// Sets the full request, replacing any prior values.
452        pub fn with_request<V: Into<crate::model::UpdateKeyRequest>>(mut self, v: V) -> Self {
453            self.0.request = v.into();
454            self
455        }
456
457        /// Sets all the options, replacing any prior values.
458        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
459            self.0.options = v.into();
460            self
461        }
462
463        /// Sends the request.
464        ///
465        /// # Long running operations
466        ///
467        /// This starts, but does not poll, a longrunning operation. More information
468        /// on [update_key][crate::client::ApiKeys::update_key].
469        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
470            (*self.0.stub)
471                .update_key(self.0.request, self.0.options)
472                .await
473                .map(crate::Response::into_body)
474        }
475
476        /// Creates a [Poller][google_cloud_lro::Poller] to work with `update_key`.
477        pub fn poller(self) -> impl google_cloud_lro::Poller<crate::model::Key, ()> {
478            type Operation = google_cloud_lro::internal::Operation<crate::model::Key, wkt::Empty>;
479            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
480            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
481
482            let stub = self.0.stub.clone();
483            let mut options = self.0.options.clone();
484            options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
485            let query = move |name| {
486                let stub = stub.clone();
487                let options = options.clone();
488                async {
489                    let op = GetOperation::new(stub)
490                        .set_name(name)
491                        .with_options(options)
492                        .send()
493                        .await?;
494                    Ok(Operation::new(op))
495                }
496            };
497
498            let start = move || async {
499                let op = self.send().await?;
500                Ok(Operation::new(op))
501            };
502
503            google_cloud_lro::internal::new_unit_metadata_poller(
504                polling_error_policy,
505                polling_backoff_policy,
506                start,
507                query,
508            )
509        }
510
511        /// Sets the value of [key][crate::model::UpdateKeyRequest::key].
512        ///
513        /// This is a **required** field for requests.
514        pub fn set_key<T>(mut self, v: T) -> Self
515        where
516            T: std::convert::Into<crate::model::Key>,
517        {
518            self.0.request.key = std::option::Option::Some(v.into());
519            self
520        }
521
522        /// Sets or clears the value of [key][crate::model::UpdateKeyRequest::key].
523        ///
524        /// This is a **required** field for requests.
525        pub fn set_or_clear_key<T>(mut self, v: std::option::Option<T>) -> Self
526        where
527            T: std::convert::Into<crate::model::Key>,
528        {
529            self.0.request.key = v.map(|x| x.into());
530            self
531        }
532
533        /// Sets the value of [update_mask][crate::model::UpdateKeyRequest::update_mask].
534        pub fn set_update_mask<T>(mut self, v: T) -> Self
535        where
536            T: std::convert::Into<wkt::FieldMask>,
537        {
538            self.0.request.update_mask = std::option::Option::Some(v.into());
539            self
540        }
541
542        /// Sets or clears the value of [update_mask][crate::model::UpdateKeyRequest::update_mask].
543        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
544        where
545            T: std::convert::Into<wkt::FieldMask>,
546        {
547            self.0.request.update_mask = v.map(|x| x.into());
548            self
549        }
550    }
551
552    #[doc(hidden)]
553    impl crate::RequestBuilder for UpdateKey {
554        fn request_options(&mut self) -> &mut crate::RequestOptions {
555            &mut self.0.options
556        }
557    }
558
559    /// The request builder for [ApiKeys::delete_key][crate::client::ApiKeys::delete_key] calls.
560    ///
561    /// # Example
562    /// ```
563    /// # use google_cloud_apikeys_v2::builder::api_keys::DeleteKey;
564    /// # async fn sample() -> google_cloud_apikeys_v2::Result<()> {
565    /// use google_cloud_lro::Poller;
566    ///
567    /// let builder = prepare_request_builder();
568    /// let response = builder.poller().until_done().await?;
569    /// # Ok(()) }
570    ///
571    /// fn prepare_request_builder() -> DeleteKey {
572    ///   # panic!();
573    ///   // ... details omitted ...
574    /// }
575    /// ```
576    #[derive(Clone, Debug)]
577    pub struct DeleteKey(RequestBuilder<crate::model::DeleteKeyRequest>);
578
579    impl DeleteKey {
580        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::ApiKeys>) -> Self {
581            Self(RequestBuilder::new(stub))
582        }
583
584        /// Sets the full request, replacing any prior values.
585        pub fn with_request<V: Into<crate::model::DeleteKeyRequest>>(mut self, v: V) -> Self {
586            self.0.request = v.into();
587            self
588        }
589
590        /// Sets all the options, replacing any prior values.
591        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
592            self.0.options = v.into();
593            self
594        }
595
596        /// Sends the request.
597        ///
598        /// # Long running operations
599        ///
600        /// This starts, but does not poll, a longrunning operation. More information
601        /// on [delete_key][crate::client::ApiKeys::delete_key].
602        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
603            (*self.0.stub)
604                .delete_key(self.0.request, self.0.options)
605                .await
606                .map(crate::Response::into_body)
607        }
608
609        /// Creates a [Poller][google_cloud_lro::Poller] to work with `delete_key`.
610        pub fn poller(self) -> impl google_cloud_lro::Poller<crate::model::Key, ()> {
611            type Operation = google_cloud_lro::internal::Operation<crate::model::Key, wkt::Empty>;
612            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
613            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
614
615            let stub = self.0.stub.clone();
616            let mut options = self.0.options.clone();
617            options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
618            let query = move |name| {
619                let stub = stub.clone();
620                let options = options.clone();
621                async {
622                    let op = GetOperation::new(stub)
623                        .set_name(name)
624                        .with_options(options)
625                        .send()
626                        .await?;
627                    Ok(Operation::new(op))
628                }
629            };
630
631            let start = move || async {
632                let op = self.send().await?;
633                Ok(Operation::new(op))
634            };
635
636            google_cloud_lro::internal::new_unit_metadata_poller(
637                polling_error_policy,
638                polling_backoff_policy,
639                start,
640                query,
641            )
642        }
643
644        /// Sets the value of [name][crate::model::DeleteKeyRequest::name].
645        ///
646        /// This is a **required** field for requests.
647        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
648            self.0.request.name = v.into();
649            self
650        }
651
652        /// Sets the value of [etag][crate::model::DeleteKeyRequest::etag].
653        pub fn set_etag<T: Into<std::string::String>>(mut self, v: T) -> Self {
654            self.0.request.etag = v.into();
655            self
656        }
657    }
658
659    #[doc(hidden)]
660    impl crate::RequestBuilder for DeleteKey {
661        fn request_options(&mut self) -> &mut crate::RequestOptions {
662            &mut self.0.options
663        }
664    }
665
666    /// The request builder for [ApiKeys::undelete_key][crate::client::ApiKeys::undelete_key] calls.
667    ///
668    /// # Example
669    /// ```
670    /// # use google_cloud_apikeys_v2::builder::api_keys::UndeleteKey;
671    /// # async fn sample() -> google_cloud_apikeys_v2::Result<()> {
672    /// use google_cloud_lro::Poller;
673    ///
674    /// let builder = prepare_request_builder();
675    /// let response = builder.poller().until_done().await?;
676    /// # Ok(()) }
677    ///
678    /// fn prepare_request_builder() -> UndeleteKey {
679    ///   # panic!();
680    ///   // ... details omitted ...
681    /// }
682    /// ```
683    #[derive(Clone, Debug)]
684    pub struct UndeleteKey(RequestBuilder<crate::model::UndeleteKeyRequest>);
685
686    impl UndeleteKey {
687        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::ApiKeys>) -> Self {
688            Self(RequestBuilder::new(stub))
689        }
690
691        /// Sets the full request, replacing any prior values.
692        pub fn with_request<V: Into<crate::model::UndeleteKeyRequest>>(mut self, v: V) -> Self {
693            self.0.request = v.into();
694            self
695        }
696
697        /// Sets all the options, replacing any prior values.
698        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
699            self.0.options = v.into();
700            self
701        }
702
703        /// Sends the request.
704        ///
705        /// # Long running operations
706        ///
707        /// This starts, but does not poll, a longrunning operation. More information
708        /// on [undelete_key][crate::client::ApiKeys::undelete_key].
709        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
710            (*self.0.stub)
711                .undelete_key(self.0.request, self.0.options)
712                .await
713                .map(crate::Response::into_body)
714        }
715
716        /// Creates a [Poller][google_cloud_lro::Poller] to work with `undelete_key`.
717        pub fn poller(self) -> impl google_cloud_lro::Poller<crate::model::Key, ()> {
718            type Operation = google_cloud_lro::internal::Operation<crate::model::Key, wkt::Empty>;
719            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
720            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
721
722            let stub = self.0.stub.clone();
723            let mut options = self.0.options.clone();
724            options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
725            let query = move |name| {
726                let stub = stub.clone();
727                let options = options.clone();
728                async {
729                    let op = GetOperation::new(stub)
730                        .set_name(name)
731                        .with_options(options)
732                        .send()
733                        .await?;
734                    Ok(Operation::new(op))
735                }
736            };
737
738            let start = move || async {
739                let op = self.send().await?;
740                Ok(Operation::new(op))
741            };
742
743            google_cloud_lro::internal::new_unit_metadata_poller(
744                polling_error_policy,
745                polling_backoff_policy,
746                start,
747                query,
748            )
749        }
750
751        /// Sets the value of [name][crate::model::UndeleteKeyRequest::name].
752        ///
753        /// This is a **required** field for requests.
754        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
755            self.0.request.name = v.into();
756            self
757        }
758    }
759
760    #[doc(hidden)]
761    impl crate::RequestBuilder for UndeleteKey {
762        fn request_options(&mut self) -> &mut crate::RequestOptions {
763            &mut self.0.options
764        }
765    }
766
767    /// The request builder for [ApiKeys::lookup_key][crate::client::ApiKeys::lookup_key] calls.
768    ///
769    /// # Example
770    /// ```
771    /// # use google_cloud_apikeys_v2::builder::api_keys::LookupKey;
772    /// # async fn sample() -> google_cloud_apikeys_v2::Result<()> {
773    ///
774    /// let builder = prepare_request_builder();
775    /// let response = builder.send().await?;
776    /// # Ok(()) }
777    ///
778    /// fn prepare_request_builder() -> LookupKey {
779    ///   # panic!();
780    ///   // ... details omitted ...
781    /// }
782    /// ```
783    #[derive(Clone, Debug)]
784    pub struct LookupKey(RequestBuilder<crate::model::LookupKeyRequest>);
785
786    impl LookupKey {
787        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::ApiKeys>) -> Self {
788            Self(RequestBuilder::new(stub))
789        }
790
791        /// Sets the full request, replacing any prior values.
792        pub fn with_request<V: Into<crate::model::LookupKeyRequest>>(mut self, v: V) -> Self {
793            self.0.request = v.into();
794            self
795        }
796
797        /// Sets all the options, replacing any prior values.
798        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
799            self.0.options = v.into();
800            self
801        }
802
803        /// Sends the request.
804        pub async fn send(self) -> Result<crate::model::LookupKeyResponse> {
805            (*self.0.stub)
806                .lookup_key(self.0.request, self.0.options)
807                .await
808                .map(crate::Response::into_body)
809        }
810
811        /// Sets the value of [key_string][crate::model::LookupKeyRequest::key_string].
812        ///
813        /// This is a **required** field for requests.
814        pub fn set_key_string<T: Into<std::string::String>>(mut self, v: T) -> Self {
815            self.0.request.key_string = v.into();
816            self
817        }
818    }
819
820    #[doc(hidden)]
821    impl crate::RequestBuilder for LookupKey {
822        fn request_options(&mut self) -> &mut crate::RequestOptions {
823            &mut self.0.options
824        }
825    }
826
827    /// The request builder for [ApiKeys::get_operation][crate::client::ApiKeys::get_operation] calls.
828    ///
829    /// # Example
830    /// ```
831    /// # use google_cloud_apikeys_v2::builder::api_keys::GetOperation;
832    /// # async fn sample() -> google_cloud_apikeys_v2::Result<()> {
833    ///
834    /// let builder = prepare_request_builder();
835    /// let response = builder.send().await?;
836    /// # Ok(()) }
837    ///
838    /// fn prepare_request_builder() -> GetOperation {
839    ///   # panic!();
840    ///   // ... details omitted ...
841    /// }
842    /// ```
843    #[derive(Clone, Debug)]
844    pub struct GetOperation(RequestBuilder<google_cloud_longrunning::model::GetOperationRequest>);
845
846    impl GetOperation {
847        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::ApiKeys>) -> Self {
848            Self(RequestBuilder::new(stub))
849        }
850
851        /// Sets the full request, replacing any prior values.
852        pub fn with_request<V: Into<google_cloud_longrunning::model::GetOperationRequest>>(
853            mut self,
854            v: V,
855        ) -> Self {
856            self.0.request = v.into();
857            self
858        }
859
860        /// Sets all the options, replacing any prior values.
861        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
862            self.0.options = v.into();
863            self
864        }
865
866        /// Sends the request.
867        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
868            (*self.0.stub)
869                .get_operation(self.0.request, self.0.options)
870                .await
871                .map(crate::Response::into_body)
872        }
873
874        /// Sets the value of [name][google_cloud_longrunning::model::GetOperationRequest::name].
875        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
876            self.0.request.name = v.into();
877            self
878        }
879    }
880
881    #[doc(hidden)]
882    impl crate::RequestBuilder for GetOperation {
883        fn request_options(&mut self) -> &mut crate::RequestOptions {
884            &mut self.0.options
885        }
886    }
887}