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() -> 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 =
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    /// ```
78    /// # use google_cloud_shell_v1::builder::cloud_shell_service::GetEnvironment;
79    /// # async fn sample() -> gax::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<gax::options::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(gax::response::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 gax::options::internal::RequestBuilder for GetEnvironment {
131        fn request_options(&mut self) -> &mut gax::options::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() -> gax::Result<()> {
142    /// use 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<gax::options::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<longrunning::model::Operation> {
185            (*self.0.stub)
186                .start_environment(self.0.request, self.0.options)
187                .await
188                .map(gax::response::Response::into_body)
189        }
190
191        /// Creates a [Poller][lro::Poller] to work with `start_environment`.
192        pub fn poller(
193            self,
194        ) -> impl lro::Poller<
195            crate::model::StartEnvironmentResponse,
196            crate::model::StartEnvironmentMetadata,
197        > {
198            type Operation = 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(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            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
227        }
228
229        /// Sets the value of [name][crate::model::StartEnvironmentRequest::name].
230        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
231            self.0.request.name = v.into();
232            self
233        }
234
235        /// Sets the value of [access_token][crate::model::StartEnvironmentRequest::access_token].
236        pub fn set_access_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
237            self.0.request.access_token = v.into();
238            self
239        }
240
241        /// Sets the value of [public_keys][crate::model::StartEnvironmentRequest::public_keys].
242        pub fn set_public_keys<T, V>(mut self, v: T) -> Self
243        where
244            T: std::iter::IntoIterator<Item = V>,
245            V: std::convert::Into<std::string::String>,
246        {
247            use std::iter::Iterator;
248            self.0.request.public_keys = v.into_iter().map(|i| i.into()).collect();
249            self
250        }
251    }
252
253    #[doc(hidden)]
254    impl gax::options::internal::RequestBuilder for StartEnvironment {
255        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
256            &mut self.0.options
257        }
258    }
259
260    /// The request builder for [CloudShellService::authorize_environment][crate::client::CloudShellService::authorize_environment] calls.
261    ///
262    /// # Example
263    /// ```
264    /// # use google_cloud_shell_v1::builder::cloud_shell_service::AuthorizeEnvironment;
265    /// # async fn sample() -> gax::Result<()> {
266    /// use lro::Poller;
267    ///
268    /// let builder = prepare_request_builder();
269    /// let response = builder.poller().until_done().await?;
270    /// # Ok(()) }
271    ///
272    /// fn prepare_request_builder() -> AuthorizeEnvironment {
273    ///   # panic!();
274    ///   // ... details omitted ...
275    /// }
276    /// ```
277    #[derive(Clone, Debug)]
278    pub struct AuthorizeEnvironment(RequestBuilder<crate::model::AuthorizeEnvironmentRequest>);
279
280    impl AuthorizeEnvironment {
281        pub(crate) fn new(
282            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
283        ) -> Self {
284            Self(RequestBuilder::new(stub))
285        }
286
287        /// Sets the full request, replacing any prior values.
288        pub fn with_request<V: Into<crate::model::AuthorizeEnvironmentRequest>>(
289            mut self,
290            v: V,
291        ) -> Self {
292            self.0.request = v.into();
293            self
294        }
295
296        /// Sets all the options, replacing any prior values.
297        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
298            self.0.options = v.into();
299            self
300        }
301
302        /// Sends the request.
303        ///
304        /// # Long running operations
305        ///
306        /// This starts, but does not poll, a longrunning operation. More information
307        /// on [authorize_environment][crate::client::CloudShellService::authorize_environment].
308        pub async fn send(self) -> Result<longrunning::model::Operation> {
309            (*self.0.stub)
310                .authorize_environment(self.0.request, self.0.options)
311                .await
312                .map(gax::response::Response::into_body)
313        }
314
315        /// Creates a [Poller][lro::Poller] to work with `authorize_environment`.
316        pub fn poller(
317            self,
318        ) -> impl lro::Poller<
319            crate::model::AuthorizeEnvironmentResponse,
320            crate::model::AuthorizeEnvironmentMetadata,
321        > {
322            type Operation = lro::internal::Operation<
323                crate::model::AuthorizeEnvironmentResponse,
324                crate::model::AuthorizeEnvironmentMetadata,
325            >;
326            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
327            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
328
329            let stub = self.0.stub.clone();
330            let mut options = self.0.options.clone();
331            options.set_retry_policy(gax::retry_policy::NeverRetry);
332            let query = move |name| {
333                let stub = stub.clone();
334                let options = options.clone();
335                async {
336                    let op = GetOperation::new(stub)
337                        .set_name(name)
338                        .with_options(options)
339                        .send()
340                        .await?;
341                    Ok(Operation::new(op))
342                }
343            };
344
345            let start = move || async {
346                let op = self.send().await?;
347                Ok(Operation::new(op))
348            };
349
350            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
351        }
352
353        /// Sets the value of [name][crate::model::AuthorizeEnvironmentRequest::name].
354        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
355            self.0.request.name = v.into();
356            self
357        }
358
359        /// Sets the value of [access_token][crate::model::AuthorizeEnvironmentRequest::access_token].
360        pub fn set_access_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
361            self.0.request.access_token = v.into();
362            self
363        }
364
365        /// Sets the value of [id_token][crate::model::AuthorizeEnvironmentRequest::id_token].
366        pub fn set_id_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
367            self.0.request.id_token = v.into();
368            self
369        }
370
371        /// Sets the value of [expire_time][crate::model::AuthorizeEnvironmentRequest::expire_time].
372        pub fn set_expire_time<T>(mut self, v: T) -> Self
373        where
374            T: std::convert::Into<wkt::Timestamp>,
375        {
376            self.0.request.expire_time = std::option::Option::Some(v.into());
377            self
378        }
379
380        /// Sets or clears the value of [expire_time][crate::model::AuthorizeEnvironmentRequest::expire_time].
381        pub fn set_or_clear_expire_time<T>(mut self, v: std::option::Option<T>) -> Self
382        where
383            T: std::convert::Into<wkt::Timestamp>,
384        {
385            self.0.request.expire_time = v.map(|x| x.into());
386            self
387        }
388    }
389
390    #[doc(hidden)]
391    impl gax::options::internal::RequestBuilder for AuthorizeEnvironment {
392        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
393            &mut self.0.options
394        }
395    }
396
397    /// The request builder for [CloudShellService::add_public_key][crate::client::CloudShellService::add_public_key] calls.
398    ///
399    /// # Example
400    /// ```
401    /// # use google_cloud_shell_v1::builder::cloud_shell_service::AddPublicKey;
402    /// # async fn sample() -> gax::Result<()> {
403    /// use lro::Poller;
404    ///
405    /// let builder = prepare_request_builder();
406    /// let response = builder.poller().until_done().await?;
407    /// # Ok(()) }
408    ///
409    /// fn prepare_request_builder() -> AddPublicKey {
410    ///   # panic!();
411    ///   // ... details omitted ...
412    /// }
413    /// ```
414    #[derive(Clone, Debug)]
415    pub struct AddPublicKey(RequestBuilder<crate::model::AddPublicKeyRequest>);
416
417    impl AddPublicKey {
418        pub(crate) fn new(
419            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
420        ) -> Self {
421            Self(RequestBuilder::new(stub))
422        }
423
424        /// Sets the full request, replacing any prior values.
425        pub fn with_request<V: Into<crate::model::AddPublicKeyRequest>>(mut self, v: V) -> Self {
426            self.0.request = v.into();
427            self
428        }
429
430        /// Sets all the options, replacing any prior values.
431        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
432            self.0.options = v.into();
433            self
434        }
435
436        /// Sends the request.
437        ///
438        /// # Long running operations
439        ///
440        /// This starts, but does not poll, a longrunning operation. More information
441        /// on [add_public_key][crate::client::CloudShellService::add_public_key].
442        pub async fn send(self) -> Result<longrunning::model::Operation> {
443            (*self.0.stub)
444                .add_public_key(self.0.request, self.0.options)
445                .await
446                .map(gax::response::Response::into_body)
447        }
448
449        /// Creates a [Poller][lro::Poller] to work with `add_public_key`.
450        pub fn poller(
451            self,
452        ) -> impl lro::Poller<crate::model::AddPublicKeyResponse, crate::model::AddPublicKeyMetadata>
453        {
454            type Operation = lro::internal::Operation<
455                crate::model::AddPublicKeyResponse,
456                crate::model::AddPublicKeyMetadata,
457            >;
458            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
459            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
460
461            let stub = self.0.stub.clone();
462            let mut options = self.0.options.clone();
463            options.set_retry_policy(gax::retry_policy::NeverRetry);
464            let query = move |name| {
465                let stub = stub.clone();
466                let options = options.clone();
467                async {
468                    let op = GetOperation::new(stub)
469                        .set_name(name)
470                        .with_options(options)
471                        .send()
472                        .await?;
473                    Ok(Operation::new(op))
474                }
475            };
476
477            let start = move || async {
478                let op = self.send().await?;
479                Ok(Operation::new(op))
480            };
481
482            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
483        }
484
485        /// Sets the value of [environment][crate::model::AddPublicKeyRequest::environment].
486        pub fn set_environment<T: Into<std::string::String>>(mut self, v: T) -> Self {
487            self.0.request.environment = v.into();
488            self
489        }
490
491        /// Sets the value of [key][crate::model::AddPublicKeyRequest::key].
492        pub fn set_key<T: Into<std::string::String>>(mut self, v: T) -> Self {
493            self.0.request.key = v.into();
494            self
495        }
496    }
497
498    #[doc(hidden)]
499    impl gax::options::internal::RequestBuilder for AddPublicKey {
500        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
501            &mut self.0.options
502        }
503    }
504
505    /// The request builder for [CloudShellService::remove_public_key][crate::client::CloudShellService::remove_public_key] calls.
506    ///
507    /// # Example
508    /// ```
509    /// # use google_cloud_shell_v1::builder::cloud_shell_service::RemovePublicKey;
510    /// # async fn sample() -> gax::Result<()> {
511    /// use lro::Poller;
512    ///
513    /// let builder = prepare_request_builder();
514    /// let response = builder.poller().until_done().await?;
515    /// # Ok(()) }
516    ///
517    /// fn prepare_request_builder() -> RemovePublicKey {
518    ///   # panic!();
519    ///   // ... details omitted ...
520    /// }
521    /// ```
522    #[derive(Clone, Debug)]
523    pub struct RemovePublicKey(RequestBuilder<crate::model::RemovePublicKeyRequest>);
524
525    impl RemovePublicKey {
526        pub(crate) fn new(
527            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
528        ) -> Self {
529            Self(RequestBuilder::new(stub))
530        }
531
532        /// Sets the full request, replacing any prior values.
533        pub fn with_request<V: Into<crate::model::RemovePublicKeyRequest>>(mut self, v: V) -> Self {
534            self.0.request = v.into();
535            self
536        }
537
538        /// Sets all the options, replacing any prior values.
539        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
540            self.0.options = v.into();
541            self
542        }
543
544        /// Sends the request.
545        ///
546        /// # Long running operations
547        ///
548        /// This starts, but does not poll, a longrunning operation. More information
549        /// on [remove_public_key][crate::client::CloudShellService::remove_public_key].
550        pub async fn send(self) -> Result<longrunning::model::Operation> {
551            (*self.0.stub)
552                .remove_public_key(self.0.request, self.0.options)
553                .await
554                .map(gax::response::Response::into_body)
555        }
556
557        /// Creates a [Poller][lro::Poller] to work with `remove_public_key`.
558        pub fn poller(
559            self,
560        ) -> impl lro::Poller<crate::model::RemovePublicKeyResponse, crate::model::RemovePublicKeyMetadata>
561        {
562            type Operation = lro::internal::Operation<
563                crate::model::RemovePublicKeyResponse,
564                crate::model::RemovePublicKeyMetadata,
565            >;
566            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
567            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
568
569            let stub = self.0.stub.clone();
570            let mut options = self.0.options.clone();
571            options.set_retry_policy(gax::retry_policy::NeverRetry);
572            let query = move |name| {
573                let stub = stub.clone();
574                let options = options.clone();
575                async {
576                    let op = GetOperation::new(stub)
577                        .set_name(name)
578                        .with_options(options)
579                        .send()
580                        .await?;
581                    Ok(Operation::new(op))
582                }
583            };
584
585            let start = move || async {
586                let op = self.send().await?;
587                Ok(Operation::new(op))
588            };
589
590            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
591        }
592
593        /// Sets the value of [environment][crate::model::RemovePublicKeyRequest::environment].
594        pub fn set_environment<T: Into<std::string::String>>(mut self, v: T) -> Self {
595            self.0.request.environment = v.into();
596            self
597        }
598
599        /// Sets the value of [key][crate::model::RemovePublicKeyRequest::key].
600        pub fn set_key<T: Into<std::string::String>>(mut self, v: T) -> Self {
601            self.0.request.key = v.into();
602            self
603        }
604    }
605
606    #[doc(hidden)]
607    impl gax::options::internal::RequestBuilder for RemovePublicKey {
608        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
609            &mut self.0.options
610        }
611    }
612
613    /// The request builder for [CloudShellService::get_operation][crate::client::CloudShellService::get_operation] calls.
614    ///
615    /// # Example
616    /// ```
617    /// # use google_cloud_shell_v1::builder::cloud_shell_service::GetOperation;
618    /// # async fn sample() -> gax::Result<()> {
619    ///
620    /// let builder = prepare_request_builder();
621    /// let response = builder.send().await?;
622    /// # Ok(()) }
623    ///
624    /// fn prepare_request_builder() -> GetOperation {
625    ///   # panic!();
626    ///   // ... details omitted ...
627    /// }
628    /// ```
629    #[derive(Clone, Debug)]
630    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);
631
632    impl GetOperation {
633        pub(crate) fn new(
634            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
635        ) -> Self {
636            Self(RequestBuilder::new(stub))
637        }
638
639        /// Sets the full request, replacing any prior values.
640        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
641            mut self,
642            v: V,
643        ) -> Self {
644            self.0.request = v.into();
645            self
646        }
647
648        /// Sets all the options, replacing any prior values.
649        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
650            self.0.options = v.into();
651            self
652        }
653
654        /// Sends the request.
655        pub async fn send(self) -> Result<longrunning::model::Operation> {
656            (*self.0.stub)
657                .get_operation(self.0.request, self.0.options)
658                .await
659                .map(gax::response::Response::into_body)
660        }
661
662        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
663        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
664            self.0.request.name = v.into();
665            self
666        }
667    }
668
669    #[doc(hidden)]
670    impl gax::options::internal::RequestBuilder for GetOperation {
671        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
672            &mut self.0.options
673        }
674    }
675}