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