1pub mod cloud_shell_service {
18 use crate::Result;
19
20 pub type ClientBuilder = crate::ClientBuilder<client::Factory, gaxi::options::Credentials>;
34
35 pub(crate) mod client {
36 use super::super::super::client::CloudShellService;
37 pub struct Factory;
38 impl crate::ClientFactory for Factory {
39 type Client = CloudShellService;
40 type Credentials = gaxi::options::Credentials;
41 async fn build(
42 self,
43 config: gaxi::options::ClientConfig,
44 ) -> crate::ClientBuilderResult<Self::Client> {
45 Self::Client::new(config).await
46 }
47 }
48 }
49
50 #[derive(Clone, Debug)]
52 pub(crate) struct RequestBuilder<R: std::default::Default> {
53 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
54 request: R,
55 options: crate::RequestOptions,
56 }
57
58 impl<R> RequestBuilder<R>
59 where
60 R: std::default::Default,
61 {
62 pub(crate) fn new(
63 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
64 ) -> Self {
65 Self {
66 stub,
67 request: R::default(),
68 options: crate::RequestOptions::default(),
69 }
70 }
71 }
72
73 #[derive(Clone, Debug)]
90 pub struct GetEnvironment(RequestBuilder<crate::model::GetEnvironmentRequest>);
91
92 impl GetEnvironment {
93 pub(crate) fn new(
94 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
95 ) -> Self {
96 Self(RequestBuilder::new(stub))
97 }
98
99 pub fn with_request<V: Into<crate::model::GetEnvironmentRequest>>(mut self, v: V) -> Self {
101 self.0.request = v.into();
102 self
103 }
104
105 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
107 self.0.options = v.into();
108 self
109 }
110
111 pub async fn send(self) -> Result<crate::model::Environment> {
113 (*self.0.stub)
114 .get_environment(self.0.request, self.0.options)
115 .await
116 .map(crate::Response::into_body)
117 }
118
119 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
123 self.0.request.name = v.into();
124 self
125 }
126 }
127
128 #[doc(hidden)]
129 impl crate::RequestBuilder for GetEnvironment {
130 fn request_options(&mut self) -> &mut crate::RequestOptions {
131 &mut self.0.options
132 }
133 }
134
135 #[derive(Clone, Debug)]
153 pub struct StartEnvironment(RequestBuilder<crate::model::StartEnvironmentRequest>);
154
155 impl StartEnvironment {
156 pub(crate) fn new(
157 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
158 ) -> Self {
159 Self(RequestBuilder::new(stub))
160 }
161
162 pub fn with_request<V: Into<crate::model::StartEnvironmentRequest>>(
164 mut self,
165 v: V,
166 ) -> Self {
167 self.0.request = v.into();
168 self
169 }
170
171 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
173 self.0.options = v.into();
174 self
175 }
176
177 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
184 (*self.0.stub)
185 .start_environment(self.0.request, self.0.options)
186 .await
187 .map(crate::Response::into_body)
188 }
189
190 pub fn poller(
192 self,
193 ) -> impl google_cloud_lro::Poller<
194 crate::model::StartEnvironmentResponse,
195 crate::model::StartEnvironmentMetadata,
196 > {
197 type Operation = google_cloud_lro::internal::Operation<
198 crate::model::StartEnvironmentResponse,
199 crate::model::StartEnvironmentMetadata,
200 >;
201 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
202 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
203
204 let stub = self.0.stub.clone();
205 let mut options = self.0.options.clone();
206 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
207 let query = move |name| {
208 let stub = stub.clone();
209 let options = options.clone();
210 async {
211 let op = GetOperation::new(stub)
212 .set_name(name)
213 .with_options(options)
214 .send()
215 .await?;
216 Ok(Operation::new(op))
217 }
218 };
219
220 let start = move || async {
221 let op = self.send().await?;
222 Ok(Operation::new(op))
223 };
224
225 google_cloud_lro::internal::new_poller(
226 polling_error_policy,
227 polling_backoff_policy,
228 start,
229 query,
230 )
231 }
232
233 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
235 self.0.request.name = v.into();
236 self
237 }
238
239 pub fn set_access_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
241 self.0.request.access_token = v.into();
242 self
243 }
244
245 pub fn set_public_keys<T, V>(mut self, v: T) -> Self
247 where
248 T: std::iter::IntoIterator<Item = V>,
249 V: std::convert::Into<std::string::String>,
250 {
251 use std::iter::Iterator;
252 self.0.request.public_keys = v.into_iter().map(|i| i.into()).collect();
253 self
254 }
255 }
256
257 #[doc(hidden)]
258 impl crate::RequestBuilder for StartEnvironment {
259 fn request_options(&mut self) -> &mut crate::RequestOptions {
260 &mut self.0.options
261 }
262 }
263
264 #[derive(Clone, Debug)]
282 pub struct AuthorizeEnvironment(RequestBuilder<crate::model::AuthorizeEnvironmentRequest>);
283
284 impl AuthorizeEnvironment {
285 pub(crate) fn new(
286 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
287 ) -> Self {
288 Self(RequestBuilder::new(stub))
289 }
290
291 pub fn with_request<V: Into<crate::model::AuthorizeEnvironmentRequest>>(
293 mut self,
294 v: V,
295 ) -> Self {
296 self.0.request = v.into();
297 self
298 }
299
300 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
302 self.0.options = v.into();
303 self
304 }
305
306 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
313 (*self.0.stub)
314 .authorize_environment(self.0.request, self.0.options)
315 .await
316 .map(crate::Response::into_body)
317 }
318
319 pub fn poller(
321 self,
322 ) -> impl google_cloud_lro::Poller<
323 crate::model::AuthorizeEnvironmentResponse,
324 crate::model::AuthorizeEnvironmentMetadata,
325 > {
326 type Operation = google_cloud_lro::internal::Operation<
327 crate::model::AuthorizeEnvironmentResponse,
328 crate::model::AuthorizeEnvironmentMetadata,
329 >;
330 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
331 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
332
333 let stub = self.0.stub.clone();
334 let mut options = self.0.options.clone();
335 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
336 let query = move |name| {
337 let stub = stub.clone();
338 let options = options.clone();
339 async {
340 let op = GetOperation::new(stub)
341 .set_name(name)
342 .with_options(options)
343 .send()
344 .await?;
345 Ok(Operation::new(op))
346 }
347 };
348
349 let start = move || async {
350 let op = self.send().await?;
351 Ok(Operation::new(op))
352 };
353
354 google_cloud_lro::internal::new_poller(
355 polling_error_policy,
356 polling_backoff_policy,
357 start,
358 query,
359 )
360 }
361
362 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
364 self.0.request.name = v.into();
365 self
366 }
367
368 pub fn set_access_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
370 self.0.request.access_token = v.into();
371 self
372 }
373
374 pub fn set_id_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
376 self.0.request.id_token = v.into();
377 self
378 }
379
380 pub fn set_expire_time<T>(mut self, v: T) -> Self
382 where
383 T: std::convert::Into<wkt::Timestamp>,
384 {
385 self.0.request.expire_time = std::option::Option::Some(v.into());
386 self
387 }
388
389 pub fn set_or_clear_expire_time<T>(mut self, v: std::option::Option<T>) -> Self
391 where
392 T: std::convert::Into<wkt::Timestamp>,
393 {
394 self.0.request.expire_time = v.map(|x| x.into());
395 self
396 }
397 }
398
399 #[doc(hidden)]
400 impl crate::RequestBuilder for AuthorizeEnvironment {
401 fn request_options(&mut self) -> &mut crate::RequestOptions {
402 &mut self.0.options
403 }
404 }
405
406 #[derive(Clone, Debug)]
424 pub struct AddPublicKey(RequestBuilder<crate::model::AddPublicKeyRequest>);
425
426 impl AddPublicKey {
427 pub(crate) fn new(
428 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
429 ) -> Self {
430 Self(RequestBuilder::new(stub))
431 }
432
433 pub fn with_request<V: Into<crate::model::AddPublicKeyRequest>>(mut self, v: V) -> Self {
435 self.0.request = v.into();
436 self
437 }
438
439 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
441 self.0.options = v.into();
442 self
443 }
444
445 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
452 (*self.0.stub)
453 .add_public_key(self.0.request, self.0.options)
454 .await
455 .map(crate::Response::into_body)
456 }
457
458 pub fn poller(
460 self,
461 ) -> impl google_cloud_lro::Poller<
462 crate::model::AddPublicKeyResponse,
463 crate::model::AddPublicKeyMetadata,
464 > {
465 type Operation = google_cloud_lro::internal::Operation<
466 crate::model::AddPublicKeyResponse,
467 crate::model::AddPublicKeyMetadata,
468 >;
469 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
470 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
471
472 let stub = self.0.stub.clone();
473 let mut options = self.0.options.clone();
474 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
475 let query = move |name| {
476 let stub = stub.clone();
477 let options = options.clone();
478 async {
479 let op = GetOperation::new(stub)
480 .set_name(name)
481 .with_options(options)
482 .send()
483 .await?;
484 Ok(Operation::new(op))
485 }
486 };
487
488 let start = move || async {
489 let op = self.send().await?;
490 Ok(Operation::new(op))
491 };
492
493 google_cloud_lro::internal::new_poller(
494 polling_error_policy,
495 polling_backoff_policy,
496 start,
497 query,
498 )
499 }
500
501 pub fn set_environment<T: Into<std::string::String>>(mut self, v: T) -> Self {
503 self.0.request.environment = v.into();
504 self
505 }
506
507 pub fn set_key<T: Into<std::string::String>>(mut self, v: T) -> Self {
509 self.0.request.key = v.into();
510 self
511 }
512 }
513
514 #[doc(hidden)]
515 impl crate::RequestBuilder for AddPublicKey {
516 fn request_options(&mut self) -> &mut crate::RequestOptions {
517 &mut self.0.options
518 }
519 }
520
521 #[derive(Clone, Debug)]
539 pub struct RemovePublicKey(RequestBuilder<crate::model::RemovePublicKeyRequest>);
540
541 impl RemovePublicKey {
542 pub(crate) fn new(
543 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
544 ) -> Self {
545 Self(RequestBuilder::new(stub))
546 }
547
548 pub fn with_request<V: Into<crate::model::RemovePublicKeyRequest>>(mut self, v: V) -> Self {
550 self.0.request = v.into();
551 self
552 }
553
554 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
556 self.0.options = v.into();
557 self
558 }
559
560 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
567 (*self.0.stub)
568 .remove_public_key(self.0.request, self.0.options)
569 .await
570 .map(crate::Response::into_body)
571 }
572
573 pub fn poller(
575 self,
576 ) -> impl google_cloud_lro::Poller<
577 crate::model::RemovePublicKeyResponse,
578 crate::model::RemovePublicKeyMetadata,
579 > {
580 type Operation = google_cloud_lro::internal::Operation<
581 crate::model::RemovePublicKeyResponse,
582 crate::model::RemovePublicKeyMetadata,
583 >;
584 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
585 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
586
587 let stub = self.0.stub.clone();
588 let mut options = self.0.options.clone();
589 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
590 let query = move |name| {
591 let stub = stub.clone();
592 let options = options.clone();
593 async {
594 let op = GetOperation::new(stub)
595 .set_name(name)
596 .with_options(options)
597 .send()
598 .await?;
599 Ok(Operation::new(op))
600 }
601 };
602
603 let start = move || async {
604 let op = self.send().await?;
605 Ok(Operation::new(op))
606 };
607
608 google_cloud_lro::internal::new_poller(
609 polling_error_policy,
610 polling_backoff_policy,
611 start,
612 query,
613 )
614 }
615
616 pub fn set_environment<T: Into<std::string::String>>(mut self, v: T) -> Self {
618 self.0.request.environment = v.into();
619 self
620 }
621
622 pub fn set_key<T: Into<std::string::String>>(mut self, v: T) -> Self {
624 self.0.request.key = v.into();
625 self
626 }
627 }
628
629 #[doc(hidden)]
630 impl crate::RequestBuilder for RemovePublicKey {
631 fn request_options(&mut self) -> &mut crate::RequestOptions {
632 &mut self.0.options
633 }
634 }
635
636 #[derive(Clone, Debug)]
653 pub struct GetOperation(RequestBuilder<google_cloud_longrunning::model::GetOperationRequest>);
654
655 impl GetOperation {
656 pub(crate) fn new(
657 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
658 ) -> Self {
659 Self(RequestBuilder::new(stub))
660 }
661
662 pub fn with_request<V: Into<google_cloud_longrunning::model::GetOperationRequest>>(
664 mut self,
665 v: V,
666 ) -> Self {
667 self.0.request = v.into();
668 self
669 }
670
671 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
673 self.0.options = v.into();
674 self
675 }
676
677 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
679 (*self.0.stub)
680 .get_operation(self.0.request, self.0.options)
681 .await
682 .map(crate::Response::into_body)
683 }
684
685 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
687 self.0.request.name = v.into();
688 self
689 }
690 }
691
692 #[doc(hidden)]
693 impl crate::RequestBuilder for GetOperation {
694 fn request_options(&mut self) -> &mut crate::RequestOptions {
695 &mut self.0.options
696 }
697 }
698}