google_cloud_shell_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 cloud_shell_service {
18    use crate::Result;
19
20    /// A builder for [CloudShellService][crate::client::CloudShellService].
21    ///
22    /// ```
23    /// # tokio_test::block_on(async {
24    /// # use google_cloud_shell_v1::*;
25    /// # use builder::cloud_shell_service::ClientBuilder;
26    /// # use client::CloudShellService;
27    /// let builder : ClientBuilder = CloudShellService::builder();
28    /// let client = builder
29    ///     .with_endpoint("https://cloudshell.googleapis.com")
30    ///     .build().await?;
31    /// # gax::client_builder::Result::<()>::Ok(()) });
32    /// ```
33    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::CloudShellService;
38        pub struct Factory;
39        impl gax::client_builder::internal::ClientFactory for Factory {
40            type Client = CloudShellService;
41            type Credentials = gaxi::options::Credentials;
42            async fn build(
43                self,
44                config: gaxi::options::ClientConfig,
45            ) -> gax::client_builder::Result<Self::Client> {
46                Self::Client::new(config).await
47            }
48        }
49    }
50
51    /// Common implementation for [crate::client::CloudShellService] request builders.
52    #[derive(Clone, Debug)]
53    pub(crate) struct RequestBuilder<R: std::default::Default> {
54        stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
55        request: R,
56        options: gax::options::RequestOptions,
57    }
58
59    impl<R> RequestBuilder<R>
60    where
61        R: std::default::Default,
62    {
63        pub(crate) fn new(
64            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
65        ) -> Self {
66            Self {
67                stub,
68                request: R::default(),
69                options: gax::options::RequestOptions::default(),
70            }
71        }
72    }
73
74    /// The request builder for [CloudShellService::get_environment][crate::client::CloudShellService::get_environment] calls.
75    ///
76    /// # Example
77    /// ```no_run
78    /// # use google_cloud_shell_v1::builder;
79    /// use builder::cloud_shell_service::GetEnvironment;
80    /// # tokio_test::block_on(async {
81    ///
82    /// let builder = prepare_request_builder();
83    /// let response = builder.send().await?;
84    /// # gax::Result::<()>::Ok(()) });
85    ///
86    /// fn prepare_request_builder() -> GetEnvironment {
87    ///   # panic!();
88    ///   // ... details omitted ...
89    /// }
90    /// ```
91    #[derive(Clone, Debug)]
92    pub struct GetEnvironment(RequestBuilder<crate::model::GetEnvironmentRequest>);
93
94    impl GetEnvironment {
95        pub(crate) fn new(
96            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
97        ) -> Self {
98            Self(RequestBuilder::new(stub))
99        }
100
101        /// Sets the full request, replacing any prior values.
102        pub fn with_request<V: Into<crate::model::GetEnvironmentRequest>>(mut self, v: V) -> Self {
103            self.0.request = v.into();
104            self
105        }
106
107        /// Sets all the options, replacing any prior values.
108        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
109            self.0.options = v.into();
110            self
111        }
112
113        /// Sends the request.
114        pub async fn send(self) -> Result<crate::model::Environment> {
115            (*self.0.stub)
116                .get_environment(self.0.request, self.0.options)
117                .await
118                .map(gax::response::Response::into_body)
119        }
120
121        /// Sets the value of [name][crate::model::GetEnvironmentRequest::name].
122        ///
123        /// This is a **required** field for requests.
124        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
125            self.0.request.name = v.into();
126            self
127        }
128    }
129
130    #[doc(hidden)]
131    impl gax::options::internal::RequestBuilder for GetEnvironment {
132        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
133            &mut self.0.options
134        }
135    }
136
137    /// The request builder for [CloudShellService::start_environment][crate::client::CloudShellService::start_environment] calls.
138    ///
139    /// # Example
140    /// ```no_run
141    /// # use google_cloud_shell_v1::builder;
142    /// use builder::cloud_shell_service::StartEnvironment;
143    /// # tokio_test::block_on(async {
144    /// use lro::Poller;
145    ///
146    /// let builder = prepare_request_builder();
147    /// let response = builder.poller().until_done().await?;
148    /// # gax::Result::<()>::Ok(()) });
149    ///
150    /// fn prepare_request_builder() -> StartEnvironment {
151    ///   # panic!();
152    ///   // ... details omitted ...
153    /// }
154    /// ```
155    #[derive(Clone, Debug)]
156    pub struct StartEnvironment(RequestBuilder<crate::model::StartEnvironmentRequest>);
157
158    impl StartEnvironment {
159        pub(crate) fn new(
160            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
161        ) -> Self {
162            Self(RequestBuilder::new(stub))
163        }
164
165        /// Sets the full request, replacing any prior values.
166        pub fn with_request<V: Into<crate::model::StartEnvironmentRequest>>(
167            mut self,
168            v: V,
169        ) -> Self {
170            self.0.request = v.into();
171            self
172        }
173
174        /// Sets all the options, replacing any prior values.
175        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
176            self.0.options = v.into();
177            self
178        }
179
180        /// Sends the request.
181        ///
182        /// # Long running operations
183        ///
184        /// This starts, but does not poll, a longrunning operation. More information
185        /// on [start_environment][crate::client::CloudShellService::start_environment].
186        pub async fn send(self) -> Result<longrunning::model::Operation> {
187            (*self.0.stub)
188                .start_environment(self.0.request, self.0.options)
189                .await
190                .map(gax::response::Response::into_body)
191        }
192
193        /// Creates a [Poller][lro::Poller] to work with `start_environment`.
194        pub fn poller(
195            self,
196        ) -> impl lro::Poller<
197            crate::model::StartEnvironmentResponse,
198            crate::model::StartEnvironmentMetadata,
199        > {
200            type Operation = lro::internal::Operation<
201                crate::model::StartEnvironmentResponse,
202                crate::model::StartEnvironmentMetadata,
203            >;
204            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
205            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
206
207            let stub = self.0.stub.clone();
208            let mut options = self.0.options.clone();
209            options.set_retry_policy(gax::retry_policy::NeverRetry);
210            let query = move |name| {
211                let stub = stub.clone();
212                let options = options.clone();
213                async {
214                    let op = GetOperation::new(stub)
215                        .set_name(name)
216                        .with_options(options)
217                        .send()
218                        .await?;
219                    Ok(Operation::new(op))
220                }
221            };
222
223            let start = move || async {
224                let op = self.send().await?;
225                Ok(Operation::new(op))
226            };
227
228            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
229        }
230
231        /// Sets the value of [name][crate::model::StartEnvironmentRequest::name].
232        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
233            self.0.request.name = v.into();
234            self
235        }
236
237        /// Sets the value of [access_token][crate::model::StartEnvironmentRequest::access_token].
238        pub fn set_access_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
239            self.0.request.access_token = v.into();
240            self
241        }
242
243        /// Sets the value of [public_keys][crate::model::StartEnvironmentRequest::public_keys].
244        pub fn set_public_keys<T, V>(mut self, v: T) -> Self
245        where
246            T: std::iter::IntoIterator<Item = V>,
247            V: std::convert::Into<std::string::String>,
248        {
249            use std::iter::Iterator;
250            self.0.request.public_keys = v.into_iter().map(|i| i.into()).collect();
251            self
252        }
253    }
254
255    #[doc(hidden)]
256    impl gax::options::internal::RequestBuilder for StartEnvironment {
257        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
258            &mut self.0.options
259        }
260    }
261
262    /// The request builder for [CloudShellService::authorize_environment][crate::client::CloudShellService::authorize_environment] calls.
263    ///
264    /// # Example
265    /// ```no_run
266    /// # use google_cloud_shell_v1::builder;
267    /// use builder::cloud_shell_service::AuthorizeEnvironment;
268    /// # tokio_test::block_on(async {
269    /// use lro::Poller;
270    ///
271    /// let builder = prepare_request_builder();
272    /// let response = builder.poller().until_done().await?;
273    /// # gax::Result::<()>::Ok(()) });
274    ///
275    /// fn prepare_request_builder() -> AuthorizeEnvironment {
276    ///   # panic!();
277    ///   // ... details omitted ...
278    /// }
279    /// ```
280    #[derive(Clone, Debug)]
281    pub struct AuthorizeEnvironment(RequestBuilder<crate::model::AuthorizeEnvironmentRequest>);
282
283    impl AuthorizeEnvironment {
284        pub(crate) fn new(
285            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
286        ) -> Self {
287            Self(RequestBuilder::new(stub))
288        }
289
290        /// Sets the full request, replacing any prior values.
291        pub fn with_request<V: Into<crate::model::AuthorizeEnvironmentRequest>>(
292            mut self,
293            v: V,
294        ) -> Self {
295            self.0.request = v.into();
296            self
297        }
298
299        /// Sets all the options, replacing any prior values.
300        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
301            self.0.options = v.into();
302            self
303        }
304
305        /// Sends the request.
306        ///
307        /// # Long running operations
308        ///
309        /// This starts, but does not poll, a longrunning operation. More information
310        /// on [authorize_environment][crate::client::CloudShellService::authorize_environment].
311        pub async fn send(self) -> Result<longrunning::model::Operation> {
312            (*self.0.stub)
313                .authorize_environment(self.0.request, self.0.options)
314                .await
315                .map(gax::response::Response::into_body)
316        }
317
318        /// Creates a [Poller][lro::Poller] to work with `authorize_environment`.
319        pub fn poller(
320            self,
321        ) -> impl lro::Poller<
322            crate::model::AuthorizeEnvironmentResponse,
323            crate::model::AuthorizeEnvironmentMetadata,
324        > {
325            type Operation = lro::internal::Operation<
326                crate::model::AuthorizeEnvironmentResponse,
327                crate::model::AuthorizeEnvironmentMetadata,
328            >;
329            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
330            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
331
332            let stub = self.0.stub.clone();
333            let mut options = self.0.options.clone();
334            options.set_retry_policy(gax::retry_policy::NeverRetry);
335            let query = move |name| {
336                let stub = stub.clone();
337                let options = options.clone();
338                async {
339                    let op = GetOperation::new(stub)
340                        .set_name(name)
341                        .with_options(options)
342                        .send()
343                        .await?;
344                    Ok(Operation::new(op))
345                }
346            };
347
348            let start = move || async {
349                let op = self.send().await?;
350                Ok(Operation::new(op))
351            };
352
353            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
354        }
355
356        /// Sets the value of [name][crate::model::AuthorizeEnvironmentRequest::name].
357        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
358            self.0.request.name = v.into();
359            self
360        }
361
362        /// Sets the value of [access_token][crate::model::AuthorizeEnvironmentRequest::access_token].
363        pub fn set_access_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
364            self.0.request.access_token = v.into();
365            self
366        }
367
368        /// Sets the value of [id_token][crate::model::AuthorizeEnvironmentRequest::id_token].
369        pub fn set_id_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
370            self.0.request.id_token = v.into();
371            self
372        }
373
374        /// Sets the value of [expire_time][crate::model::AuthorizeEnvironmentRequest::expire_time].
375        pub fn set_expire_time<T>(mut self, v: T) -> Self
376        where
377            T: std::convert::Into<wkt::Timestamp>,
378        {
379            self.0.request.expire_time = std::option::Option::Some(v.into());
380            self
381        }
382
383        /// Sets or clears the value of [expire_time][crate::model::AuthorizeEnvironmentRequest::expire_time].
384        pub fn set_or_clear_expire_time<T>(mut self, v: std::option::Option<T>) -> Self
385        where
386            T: std::convert::Into<wkt::Timestamp>,
387        {
388            self.0.request.expire_time = v.map(|x| x.into());
389            self
390        }
391    }
392
393    #[doc(hidden)]
394    impl gax::options::internal::RequestBuilder for AuthorizeEnvironment {
395        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
396            &mut self.0.options
397        }
398    }
399
400    /// The request builder for [CloudShellService::add_public_key][crate::client::CloudShellService::add_public_key] calls.
401    ///
402    /// # Example
403    /// ```no_run
404    /// # use google_cloud_shell_v1::builder;
405    /// use builder::cloud_shell_service::AddPublicKey;
406    /// # tokio_test::block_on(async {
407    /// use lro::Poller;
408    ///
409    /// let builder = prepare_request_builder();
410    /// let response = builder.poller().until_done().await?;
411    /// # gax::Result::<()>::Ok(()) });
412    ///
413    /// fn prepare_request_builder() -> AddPublicKey {
414    ///   # panic!();
415    ///   // ... details omitted ...
416    /// }
417    /// ```
418    #[derive(Clone, Debug)]
419    pub struct AddPublicKey(RequestBuilder<crate::model::AddPublicKeyRequest>);
420
421    impl AddPublicKey {
422        pub(crate) fn new(
423            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
424        ) -> Self {
425            Self(RequestBuilder::new(stub))
426        }
427
428        /// Sets the full request, replacing any prior values.
429        pub fn with_request<V: Into<crate::model::AddPublicKeyRequest>>(mut self, v: V) -> Self {
430            self.0.request = v.into();
431            self
432        }
433
434        /// Sets all the options, replacing any prior values.
435        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
436            self.0.options = v.into();
437            self
438        }
439
440        /// Sends the request.
441        ///
442        /// # Long running operations
443        ///
444        /// This starts, but does not poll, a longrunning operation. More information
445        /// on [add_public_key][crate::client::CloudShellService::add_public_key].
446        pub async fn send(self) -> Result<longrunning::model::Operation> {
447            (*self.0.stub)
448                .add_public_key(self.0.request, self.0.options)
449                .await
450                .map(gax::response::Response::into_body)
451        }
452
453        /// Creates a [Poller][lro::Poller] to work with `add_public_key`.
454        pub fn poller(
455            self,
456        ) -> impl lro::Poller<crate::model::AddPublicKeyResponse, crate::model::AddPublicKeyMetadata>
457        {
458            type Operation = lro::internal::Operation<
459                crate::model::AddPublicKeyResponse,
460                crate::model::AddPublicKeyMetadata,
461            >;
462            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
463            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
464
465            let stub = self.0.stub.clone();
466            let mut options = self.0.options.clone();
467            options.set_retry_policy(gax::retry_policy::NeverRetry);
468            let query = move |name| {
469                let stub = stub.clone();
470                let options = options.clone();
471                async {
472                    let op = GetOperation::new(stub)
473                        .set_name(name)
474                        .with_options(options)
475                        .send()
476                        .await?;
477                    Ok(Operation::new(op))
478                }
479            };
480
481            let start = move || async {
482                let op = self.send().await?;
483                Ok(Operation::new(op))
484            };
485
486            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
487        }
488
489        /// Sets the value of [environment][crate::model::AddPublicKeyRequest::environment].
490        pub fn set_environment<T: Into<std::string::String>>(mut self, v: T) -> Self {
491            self.0.request.environment = v.into();
492            self
493        }
494
495        /// Sets the value of [key][crate::model::AddPublicKeyRequest::key].
496        pub fn set_key<T: Into<std::string::String>>(mut self, v: T) -> Self {
497            self.0.request.key = v.into();
498            self
499        }
500    }
501
502    #[doc(hidden)]
503    impl gax::options::internal::RequestBuilder for AddPublicKey {
504        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
505            &mut self.0.options
506        }
507    }
508
509    /// The request builder for [CloudShellService::remove_public_key][crate::client::CloudShellService::remove_public_key] calls.
510    ///
511    /// # Example
512    /// ```no_run
513    /// # use google_cloud_shell_v1::builder;
514    /// use builder::cloud_shell_service::RemovePublicKey;
515    /// # tokio_test::block_on(async {
516    /// use lro::Poller;
517    ///
518    /// let builder = prepare_request_builder();
519    /// let response = builder.poller().until_done().await?;
520    /// # gax::Result::<()>::Ok(()) });
521    ///
522    /// fn prepare_request_builder() -> RemovePublicKey {
523    ///   # panic!();
524    ///   // ... details omitted ...
525    /// }
526    /// ```
527    #[derive(Clone, Debug)]
528    pub struct RemovePublicKey(RequestBuilder<crate::model::RemovePublicKeyRequest>);
529
530    impl RemovePublicKey {
531        pub(crate) fn new(
532            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
533        ) -> Self {
534            Self(RequestBuilder::new(stub))
535        }
536
537        /// Sets the full request, replacing any prior values.
538        pub fn with_request<V: Into<crate::model::RemovePublicKeyRequest>>(mut self, v: V) -> Self {
539            self.0.request = v.into();
540            self
541        }
542
543        /// Sets all the options, replacing any prior values.
544        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
545            self.0.options = v.into();
546            self
547        }
548
549        /// Sends the request.
550        ///
551        /// # Long running operations
552        ///
553        /// This starts, but does not poll, a longrunning operation. More information
554        /// on [remove_public_key][crate::client::CloudShellService::remove_public_key].
555        pub async fn send(self) -> Result<longrunning::model::Operation> {
556            (*self.0.stub)
557                .remove_public_key(self.0.request, self.0.options)
558                .await
559                .map(gax::response::Response::into_body)
560        }
561
562        /// Creates a [Poller][lro::Poller] to work with `remove_public_key`.
563        pub fn poller(
564            self,
565        ) -> impl lro::Poller<crate::model::RemovePublicKeyResponse, crate::model::RemovePublicKeyMetadata>
566        {
567            type Operation = lro::internal::Operation<
568                crate::model::RemovePublicKeyResponse,
569                crate::model::RemovePublicKeyMetadata,
570            >;
571            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
572            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
573
574            let stub = self.0.stub.clone();
575            let mut options = self.0.options.clone();
576            options.set_retry_policy(gax::retry_policy::NeverRetry);
577            let query = move |name| {
578                let stub = stub.clone();
579                let options = options.clone();
580                async {
581                    let op = GetOperation::new(stub)
582                        .set_name(name)
583                        .with_options(options)
584                        .send()
585                        .await?;
586                    Ok(Operation::new(op))
587                }
588            };
589
590            let start = move || async {
591                let op = self.send().await?;
592                Ok(Operation::new(op))
593            };
594
595            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
596        }
597
598        /// Sets the value of [environment][crate::model::RemovePublicKeyRequest::environment].
599        pub fn set_environment<T: Into<std::string::String>>(mut self, v: T) -> Self {
600            self.0.request.environment = v.into();
601            self
602        }
603
604        /// Sets the value of [key][crate::model::RemovePublicKeyRequest::key].
605        pub fn set_key<T: Into<std::string::String>>(mut self, v: T) -> Self {
606            self.0.request.key = v.into();
607            self
608        }
609    }
610
611    #[doc(hidden)]
612    impl gax::options::internal::RequestBuilder for RemovePublicKey {
613        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
614            &mut self.0.options
615        }
616    }
617
618    /// The request builder for [CloudShellService::get_operation][crate::client::CloudShellService::get_operation] calls.
619    ///
620    /// # Example
621    /// ```no_run
622    /// # use google_cloud_shell_v1::builder;
623    /// use builder::cloud_shell_service::GetOperation;
624    /// # tokio_test::block_on(async {
625    ///
626    /// let builder = prepare_request_builder();
627    /// let response = builder.send().await?;
628    /// # gax::Result::<()>::Ok(()) });
629    ///
630    /// fn prepare_request_builder() -> GetOperation {
631    ///   # panic!();
632    ///   // ... details omitted ...
633    /// }
634    /// ```
635    #[derive(Clone, Debug)]
636    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);
637
638    impl GetOperation {
639        pub(crate) fn new(
640            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
641        ) -> Self {
642            Self(RequestBuilder::new(stub))
643        }
644
645        /// Sets the full request, replacing any prior values.
646        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
647            mut self,
648            v: V,
649        ) -> Self {
650            self.0.request = v.into();
651            self
652        }
653
654        /// Sets all the options, replacing any prior values.
655        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
656            self.0.options = v.into();
657            self
658        }
659
660        /// Sends the request.
661        pub async fn send(self) -> Result<longrunning::model::Operation> {
662            (*self.0.stub)
663                .get_operation(self.0.request, self.0.options)
664                .await
665                .map(gax::response::Response::into_body)
666        }
667
668        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
669        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
670            self.0.request.name = v.into();
671            self
672        }
673    }
674
675    #[doc(hidden)]
676    impl gax::options::internal::RequestBuilder for GetOperation {
677        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
678            &mut self.0.options
679        }
680    }
681}