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