1pub mod cloud_shell_service {
19 use crate::Result;
20
21 pub type ClientBuilder = crate::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 crate::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 ) -> crate::ClientBuilderResult<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: crate::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: crate::RequestOptions::default(),
70 }
71 }
72 }
73
74 #[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 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 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
108 self.0.options = v.into();
109 self
110 }
111
112 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(crate::Response::into_body)
118 }
119
120 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 crate::RequestBuilder for GetEnvironment {
131 fn request_options(&mut self) -> &mut crate::RequestOptions {
132 &mut self.0.options
133 }
134 }
135
136 #[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 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 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
174 self.0.options = v.into();
175 self
176 }
177
178 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
185 (*self.0.stub)
186 .start_environment(self.0.request, self.0.options)
187 .await
188 .map(crate::Response::into_body)
189 }
190
191 pub fn poller(
193 self,
194 ) -> impl google_cloud_lro::Poller<
195 crate::model::StartEnvironmentResponse,
196 crate::model::StartEnvironmentMetadata,
197 > {
198 type Operation = google_cloud_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(google_cloud_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 google_cloud_lro::internal::new_poller(
227 polling_error_policy,
228 polling_backoff_policy,
229 start,
230 query,
231 )
232 }
233
234 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
236 self.0.request.name = v.into();
237 self
238 }
239
240 pub fn set_access_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
242 self.0.request.access_token = v.into();
243 self
244 }
245
246 pub fn set_public_keys<T, V>(mut self, v: T) -> Self
248 where
249 T: std::iter::IntoIterator<Item = V>,
250 V: std::convert::Into<std::string::String>,
251 {
252 use std::iter::Iterator;
253 self.0.request.public_keys = v.into_iter().map(|i| i.into()).collect();
254 self
255 }
256 }
257
258 #[doc(hidden)]
259 impl crate::RequestBuilder for StartEnvironment {
260 fn request_options(&mut self) -> &mut crate::RequestOptions {
261 &mut self.0.options
262 }
263 }
264
265 #[derive(Clone, Debug)]
283 pub struct AuthorizeEnvironment(RequestBuilder<crate::model::AuthorizeEnvironmentRequest>);
284
285 impl AuthorizeEnvironment {
286 pub(crate) fn new(
287 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
288 ) -> Self {
289 Self(RequestBuilder::new(stub))
290 }
291
292 pub fn with_request<V: Into<crate::model::AuthorizeEnvironmentRequest>>(
294 mut self,
295 v: V,
296 ) -> Self {
297 self.0.request = v.into();
298 self
299 }
300
301 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
303 self.0.options = v.into();
304 self
305 }
306
307 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
314 (*self.0.stub)
315 .authorize_environment(self.0.request, self.0.options)
316 .await
317 .map(crate::Response::into_body)
318 }
319
320 pub fn poller(
322 self,
323 ) -> impl google_cloud_lro::Poller<
324 crate::model::AuthorizeEnvironmentResponse,
325 crate::model::AuthorizeEnvironmentMetadata,
326 > {
327 type Operation = google_cloud_lro::internal::Operation<
328 crate::model::AuthorizeEnvironmentResponse,
329 crate::model::AuthorizeEnvironmentMetadata,
330 >;
331 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
332 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
333
334 let stub = self.0.stub.clone();
335 let mut options = self.0.options.clone();
336 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
337 let query = move |name| {
338 let stub = stub.clone();
339 let options = options.clone();
340 async {
341 let op = GetOperation::new(stub)
342 .set_name(name)
343 .with_options(options)
344 .send()
345 .await?;
346 Ok(Operation::new(op))
347 }
348 };
349
350 let start = move || async {
351 let op = self.send().await?;
352 Ok(Operation::new(op))
353 };
354
355 google_cloud_lro::internal::new_poller(
356 polling_error_policy,
357 polling_backoff_policy,
358 start,
359 query,
360 )
361 }
362
363 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
365 self.0.request.name = v.into();
366 self
367 }
368
369 pub fn set_access_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
371 self.0.request.access_token = v.into();
372 self
373 }
374
375 pub fn set_id_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
377 self.0.request.id_token = v.into();
378 self
379 }
380
381 pub fn set_expire_time<T>(mut self, v: T) -> Self
383 where
384 T: std::convert::Into<wkt::Timestamp>,
385 {
386 self.0.request.expire_time = std::option::Option::Some(v.into());
387 self
388 }
389
390 pub fn set_or_clear_expire_time<T>(mut self, v: std::option::Option<T>) -> Self
392 where
393 T: std::convert::Into<wkt::Timestamp>,
394 {
395 self.0.request.expire_time = v.map(|x| x.into());
396 self
397 }
398 }
399
400 #[doc(hidden)]
401 impl crate::RequestBuilder for AuthorizeEnvironment {
402 fn request_options(&mut self) -> &mut crate::RequestOptions {
403 &mut self.0.options
404 }
405 }
406
407 #[derive(Clone, Debug)]
425 pub struct AddPublicKey(RequestBuilder<crate::model::AddPublicKeyRequest>);
426
427 impl AddPublicKey {
428 pub(crate) fn new(
429 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
430 ) -> Self {
431 Self(RequestBuilder::new(stub))
432 }
433
434 pub fn with_request<V: Into<crate::model::AddPublicKeyRequest>>(mut self, v: V) -> Self {
436 self.0.request = v.into();
437 self
438 }
439
440 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
442 self.0.options = v.into();
443 self
444 }
445
446 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
453 (*self.0.stub)
454 .add_public_key(self.0.request, self.0.options)
455 .await
456 .map(crate::Response::into_body)
457 }
458
459 pub fn poller(
461 self,
462 ) -> impl google_cloud_lro::Poller<
463 crate::model::AddPublicKeyResponse,
464 crate::model::AddPublicKeyMetadata,
465 > {
466 type Operation = google_cloud_lro::internal::Operation<
467 crate::model::AddPublicKeyResponse,
468 crate::model::AddPublicKeyMetadata,
469 >;
470 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
471 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
472
473 let stub = self.0.stub.clone();
474 let mut options = self.0.options.clone();
475 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
476 let query = move |name| {
477 let stub = stub.clone();
478 let options = options.clone();
479 async {
480 let op = GetOperation::new(stub)
481 .set_name(name)
482 .with_options(options)
483 .send()
484 .await?;
485 Ok(Operation::new(op))
486 }
487 };
488
489 let start = move || async {
490 let op = self.send().await?;
491 Ok(Operation::new(op))
492 };
493
494 google_cloud_lro::internal::new_poller(
495 polling_error_policy,
496 polling_backoff_policy,
497 start,
498 query,
499 )
500 }
501
502 pub fn set_environment<T: Into<std::string::String>>(mut self, v: T) -> Self {
504 self.0.request.environment = v.into();
505 self
506 }
507
508 pub fn set_key<T: Into<std::string::String>>(mut self, v: T) -> Self {
510 self.0.request.key = v.into();
511 self
512 }
513 }
514
515 #[doc(hidden)]
516 impl crate::RequestBuilder for AddPublicKey {
517 fn request_options(&mut self) -> &mut crate::RequestOptions {
518 &mut self.0.options
519 }
520 }
521
522 #[derive(Clone, Debug)]
540 pub struct RemovePublicKey(RequestBuilder<crate::model::RemovePublicKeyRequest>);
541
542 impl RemovePublicKey {
543 pub(crate) fn new(
544 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
545 ) -> Self {
546 Self(RequestBuilder::new(stub))
547 }
548
549 pub fn with_request<V: Into<crate::model::RemovePublicKeyRequest>>(mut self, v: V) -> Self {
551 self.0.request = v.into();
552 self
553 }
554
555 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
557 self.0.options = v.into();
558 self
559 }
560
561 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
568 (*self.0.stub)
569 .remove_public_key(self.0.request, self.0.options)
570 .await
571 .map(crate::Response::into_body)
572 }
573
574 pub fn poller(
576 self,
577 ) -> impl google_cloud_lro::Poller<
578 crate::model::RemovePublicKeyResponse,
579 crate::model::RemovePublicKeyMetadata,
580 > {
581 type Operation = google_cloud_lro::internal::Operation<
582 crate::model::RemovePublicKeyResponse,
583 crate::model::RemovePublicKeyMetadata,
584 >;
585 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
586 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
587
588 let stub = self.0.stub.clone();
589 let mut options = self.0.options.clone();
590 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
591 let query = move |name| {
592 let stub = stub.clone();
593 let options = options.clone();
594 async {
595 let op = GetOperation::new(stub)
596 .set_name(name)
597 .with_options(options)
598 .send()
599 .await?;
600 Ok(Operation::new(op))
601 }
602 };
603
604 let start = move || async {
605 let op = self.send().await?;
606 Ok(Operation::new(op))
607 };
608
609 google_cloud_lro::internal::new_poller(
610 polling_error_policy,
611 polling_backoff_policy,
612 start,
613 query,
614 )
615 }
616
617 pub fn set_environment<T: Into<std::string::String>>(mut self, v: T) -> Self {
619 self.0.request.environment = v.into();
620 self
621 }
622
623 pub fn set_key<T: Into<std::string::String>>(mut self, v: T) -> Self {
625 self.0.request.key = v.into();
626 self
627 }
628 }
629
630 #[doc(hidden)]
631 impl crate::RequestBuilder for RemovePublicKey {
632 fn request_options(&mut self) -> &mut crate::RequestOptions {
633 &mut self.0.options
634 }
635 }
636
637 #[derive(Clone, Debug)]
654 pub struct GetOperation(RequestBuilder<google_cloud_longrunning::model::GetOperationRequest>);
655
656 impl GetOperation {
657 pub(crate) fn new(
658 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
659 ) -> Self {
660 Self(RequestBuilder::new(stub))
661 }
662
663 pub fn with_request<V: Into<google_cloud_longrunning::model::GetOperationRequest>>(
665 mut self,
666 v: V,
667 ) -> Self {
668 self.0.request = v.into();
669 self
670 }
671
672 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
674 self.0.options = v.into();
675 self
676 }
677
678 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
680 (*self.0.stub)
681 .get_operation(self.0.request, self.0.options)
682 .await
683 .map(crate::Response::into_body)
684 }
685
686 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
688 self.0.request.name = v.into();
689 self
690 }
691 }
692
693 #[doc(hidden)]
694 impl crate::RequestBuilder for GetOperation {
695 fn request_options(&mut self) -> &mut crate::RequestOptions {
696 &mut self.0.options
697 }
698 }
699}