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