Skip to main content

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