1pub mod cloud_shell_service {
18 use crate::Result;
19
20 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 #[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 #[derive(Clone, Debug)]
92 pub struct GetEnvironment(RequestBuilder<crate::model::GetEnvironmentRequest>);
93
94 impl GetEnvironment {
95 pub(crate) fn new(
96 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
97 ) -> Self {
98 Self(RequestBuilder::new(stub))
99 }
100
101 pub fn with_request<V: Into<crate::model::GetEnvironmentRequest>>(mut self, v: V) -> Self {
103 self.0.request = v.into();
104 self
105 }
106
107 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
109 self.0.options = v.into();
110 self
111 }
112
113 pub async fn send(self) -> Result<crate::model::Environment> {
115 (*self.0.stub)
116 .get_environment(self.0.request, self.0.options)
117 .await
118 .map(gax::response::Response::into_body)
119 }
120
121 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
125 self.0.request.name = v.into();
126 self
127 }
128 }
129
130 #[doc(hidden)]
131 impl gax::options::internal::RequestBuilder for GetEnvironment {
132 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
133 &mut self.0.options
134 }
135 }
136
137 #[derive(Clone, Debug)]
156 pub struct StartEnvironment(RequestBuilder<crate::model::StartEnvironmentRequest>);
157
158 impl StartEnvironment {
159 pub(crate) fn new(
160 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
161 ) -> Self {
162 Self(RequestBuilder::new(stub))
163 }
164
165 pub fn with_request<V: Into<crate::model::StartEnvironmentRequest>>(
167 mut self,
168 v: V,
169 ) -> Self {
170 self.0.request = v.into();
171 self
172 }
173
174 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
176 self.0.options = v.into();
177 self
178 }
179
180 pub async fn send(self) -> Result<longrunning::model::Operation> {
187 (*self.0.stub)
188 .start_environment(self.0.request, self.0.options)
189 .await
190 .map(gax::response::Response::into_body)
191 }
192
193 pub fn poller(
195 self,
196 ) -> impl lro::Poller<
197 crate::model::StartEnvironmentResponse,
198 crate::model::StartEnvironmentMetadata,
199 > {
200 type Operation = lro::internal::Operation<
201 crate::model::StartEnvironmentResponse,
202 crate::model::StartEnvironmentMetadata,
203 >;
204 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
205 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
206
207 let stub = self.0.stub.clone();
208 let mut options = self.0.options.clone();
209 options.set_retry_policy(gax::retry_policy::NeverRetry);
210 let query = move |name| {
211 let stub = stub.clone();
212 let options = options.clone();
213 async {
214 let op = GetOperation::new(stub)
215 .set_name(name)
216 .with_options(options)
217 .send()
218 .await?;
219 Ok(Operation::new(op))
220 }
221 };
222
223 let start = move || async {
224 let op = self.send().await?;
225 Ok(Operation::new(op))
226 };
227
228 lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
229 }
230
231 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
233 self.0.request.name = v.into();
234 self
235 }
236
237 pub fn set_access_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
239 self.0.request.access_token = v.into();
240 self
241 }
242
243 pub fn set_public_keys<T, V>(mut self, v: T) -> Self
245 where
246 T: std::iter::IntoIterator<Item = V>,
247 V: std::convert::Into<std::string::String>,
248 {
249 use std::iter::Iterator;
250 self.0.request.public_keys = v.into_iter().map(|i| i.into()).collect();
251 self
252 }
253 }
254
255 #[doc(hidden)]
256 impl gax::options::internal::RequestBuilder for StartEnvironment {
257 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
258 &mut self.0.options
259 }
260 }
261
262 #[derive(Clone, Debug)]
281 pub struct AuthorizeEnvironment(RequestBuilder<crate::model::AuthorizeEnvironmentRequest>);
282
283 impl AuthorizeEnvironment {
284 pub(crate) fn new(
285 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
286 ) -> Self {
287 Self(RequestBuilder::new(stub))
288 }
289
290 pub fn with_request<V: Into<crate::model::AuthorizeEnvironmentRequest>>(
292 mut self,
293 v: V,
294 ) -> Self {
295 self.0.request = v.into();
296 self
297 }
298
299 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
301 self.0.options = v.into();
302 self
303 }
304
305 pub async fn send(self) -> Result<longrunning::model::Operation> {
312 (*self.0.stub)
313 .authorize_environment(self.0.request, self.0.options)
314 .await
315 .map(gax::response::Response::into_body)
316 }
317
318 pub fn poller(
320 self,
321 ) -> impl lro::Poller<
322 crate::model::AuthorizeEnvironmentResponse,
323 crate::model::AuthorizeEnvironmentMetadata,
324 > {
325 type Operation = lro::internal::Operation<
326 crate::model::AuthorizeEnvironmentResponse,
327 crate::model::AuthorizeEnvironmentMetadata,
328 >;
329 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
330 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
331
332 let stub = self.0.stub.clone();
333 let mut options = self.0.options.clone();
334 options.set_retry_policy(gax::retry_policy::NeverRetry);
335 let query = move |name| {
336 let stub = stub.clone();
337 let options = options.clone();
338 async {
339 let op = GetOperation::new(stub)
340 .set_name(name)
341 .with_options(options)
342 .send()
343 .await?;
344 Ok(Operation::new(op))
345 }
346 };
347
348 let start = move || async {
349 let op = self.send().await?;
350 Ok(Operation::new(op))
351 };
352
353 lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
354 }
355
356 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
358 self.0.request.name = v.into();
359 self
360 }
361
362 pub fn set_access_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
364 self.0.request.access_token = v.into();
365 self
366 }
367
368 pub fn set_id_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
370 self.0.request.id_token = v.into();
371 self
372 }
373
374 pub fn set_expire_time<T>(mut self, v: T) -> Self
376 where
377 T: std::convert::Into<wkt::Timestamp>,
378 {
379 self.0.request.expire_time = std::option::Option::Some(v.into());
380 self
381 }
382
383 pub fn set_or_clear_expire_time<T>(mut self, v: std::option::Option<T>) -> Self
385 where
386 T: std::convert::Into<wkt::Timestamp>,
387 {
388 self.0.request.expire_time = v.map(|x| x.into());
389 self
390 }
391 }
392
393 #[doc(hidden)]
394 impl gax::options::internal::RequestBuilder for AuthorizeEnvironment {
395 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
396 &mut self.0.options
397 }
398 }
399
400 #[derive(Clone, Debug)]
419 pub struct AddPublicKey(RequestBuilder<crate::model::AddPublicKeyRequest>);
420
421 impl AddPublicKey {
422 pub(crate) fn new(
423 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
424 ) -> Self {
425 Self(RequestBuilder::new(stub))
426 }
427
428 pub fn with_request<V: Into<crate::model::AddPublicKeyRequest>>(mut self, v: V) -> Self {
430 self.0.request = v.into();
431 self
432 }
433
434 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 pub async fn send(self) -> Result<longrunning::model::Operation> {
447 (*self.0.stub)
448 .add_public_key(self.0.request, self.0.options)
449 .await
450 .map(gax::response::Response::into_body)
451 }
452
453 pub fn poller(
455 self,
456 ) -> impl lro::Poller<crate::model::AddPublicKeyResponse, crate::model::AddPublicKeyMetadata>
457 {
458 type Operation = lro::internal::Operation<
459 crate::model::AddPublicKeyResponse,
460 crate::model::AddPublicKeyMetadata,
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::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
487 }
488
489 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 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 AddPublicKey {
504 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
505 &mut self.0.options
506 }
507 }
508
509 #[derive(Clone, Debug)]
528 pub struct RemovePublicKey(RequestBuilder<crate::model::RemovePublicKeyRequest>);
529
530 impl RemovePublicKey {
531 pub(crate) fn new(
532 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
533 ) -> Self {
534 Self(RequestBuilder::new(stub))
535 }
536
537 pub fn with_request<V: Into<crate::model::RemovePublicKeyRequest>>(mut self, v: V) -> Self {
539 self.0.request = v.into();
540 self
541 }
542
543 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
545 self.0.options = v.into();
546 self
547 }
548
549 pub async fn send(self) -> Result<longrunning::model::Operation> {
556 (*self.0.stub)
557 .remove_public_key(self.0.request, self.0.options)
558 .await
559 .map(gax::response::Response::into_body)
560 }
561
562 pub fn poller(
564 self,
565 ) -> impl lro::Poller<crate::model::RemovePublicKeyResponse, crate::model::RemovePublicKeyMetadata>
566 {
567 type Operation = lro::internal::Operation<
568 crate::model::RemovePublicKeyResponse,
569 crate::model::RemovePublicKeyMetadata,
570 >;
571 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
572 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
573
574 let stub = self.0.stub.clone();
575 let mut options = self.0.options.clone();
576 options.set_retry_policy(gax::retry_policy::NeverRetry);
577 let query = move |name| {
578 let stub = stub.clone();
579 let options = options.clone();
580 async {
581 let op = GetOperation::new(stub)
582 .set_name(name)
583 .with_options(options)
584 .send()
585 .await?;
586 Ok(Operation::new(op))
587 }
588 };
589
590 let start = move || async {
591 let op = self.send().await?;
592 Ok(Operation::new(op))
593 };
594
595 lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
596 }
597
598 pub fn set_environment<T: Into<std::string::String>>(mut self, v: T) -> Self {
600 self.0.request.environment = v.into();
601 self
602 }
603
604 pub fn set_key<T: Into<std::string::String>>(mut self, v: T) -> Self {
606 self.0.request.key = v.into();
607 self
608 }
609 }
610
611 #[doc(hidden)]
612 impl gax::options::internal::RequestBuilder for RemovePublicKey {
613 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
614 &mut self.0.options
615 }
616 }
617
618 #[derive(Clone, Debug)]
636 pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);
637
638 impl GetOperation {
639 pub(crate) fn new(
640 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
641 ) -> Self {
642 Self(RequestBuilder::new(stub))
643 }
644
645 pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
647 mut self,
648 v: V,
649 ) -> Self {
650 self.0.request = v.into();
651 self
652 }
653
654 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
656 self.0.options = v.into();
657 self
658 }
659
660 pub async fn send(self) -> Result<longrunning::model::Operation> {
662 (*self.0.stub)
663 .get_operation(self.0.request, self.0.options)
664 .await
665 .map(gax::response::Response::into_body)
666 }
667
668 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
670 self.0.request.name = v.into();
671 self
672 }
673 }
674
675 #[doc(hidden)]
676 impl gax::options::internal::RequestBuilder for GetOperation {
677 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
678 &mut self.0.options
679 }
680 }
681}