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