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)]
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<gax::options::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(gax::response::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 gax::options::internal::RequestBuilder for GetEnvironment {
131 fn request_options(&mut self) -> &mut gax::options::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<gax::options::RequestOptions>>(mut self, v: V) -> Self {
174 self.0.options = v.into();
175 self
176 }
177
178 pub async fn send(self) -> Result<longrunning::model::Operation> {
185 (*self.0.stub)
186 .start_environment(self.0.request, self.0.options)
187 .await
188 .map(gax::response::Response::into_body)
189 }
190
191 pub fn poller(
193 self,
194 ) -> impl lro::Poller<
195 crate::model::StartEnvironmentResponse,
196 crate::model::StartEnvironmentMetadata,
197 > {
198 type Operation = 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(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 lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
227 }
228
229 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
231 self.0.request.name = v.into();
232 self
233 }
234
235 pub fn set_access_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
237 self.0.request.access_token = v.into();
238 self
239 }
240
241 pub fn set_public_keys<T, V>(mut self, v: T) -> Self
243 where
244 T: std::iter::IntoIterator<Item = V>,
245 V: std::convert::Into<std::string::String>,
246 {
247 use std::iter::Iterator;
248 self.0.request.public_keys = v.into_iter().map(|i| i.into()).collect();
249 self
250 }
251 }
252
253 #[doc(hidden)]
254 impl gax::options::internal::RequestBuilder for StartEnvironment {
255 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
256 &mut self.0.options
257 }
258 }
259
260 #[derive(Clone, Debug)]
278 pub struct AuthorizeEnvironment(RequestBuilder<crate::model::AuthorizeEnvironmentRequest>);
279
280 impl AuthorizeEnvironment {
281 pub(crate) fn new(
282 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
283 ) -> Self {
284 Self(RequestBuilder::new(stub))
285 }
286
287 pub fn with_request<V: Into<crate::model::AuthorizeEnvironmentRequest>>(
289 mut self,
290 v: V,
291 ) -> Self {
292 self.0.request = v.into();
293 self
294 }
295
296 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
298 self.0.options = v.into();
299 self
300 }
301
302 pub async fn send(self) -> Result<longrunning::model::Operation> {
309 (*self.0.stub)
310 .authorize_environment(self.0.request, self.0.options)
311 .await
312 .map(gax::response::Response::into_body)
313 }
314
315 pub fn poller(
317 self,
318 ) -> impl lro::Poller<
319 crate::model::AuthorizeEnvironmentResponse,
320 crate::model::AuthorizeEnvironmentMetadata,
321 > {
322 type Operation = lro::internal::Operation<
323 crate::model::AuthorizeEnvironmentResponse,
324 crate::model::AuthorizeEnvironmentMetadata,
325 >;
326 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
327 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
328
329 let stub = self.0.stub.clone();
330 let mut options = self.0.options.clone();
331 options.set_retry_policy(gax::retry_policy::NeverRetry);
332 let query = move |name| {
333 let stub = stub.clone();
334 let options = options.clone();
335 async {
336 let op = GetOperation::new(stub)
337 .set_name(name)
338 .with_options(options)
339 .send()
340 .await?;
341 Ok(Operation::new(op))
342 }
343 };
344
345 let start = move || async {
346 let op = self.send().await?;
347 Ok(Operation::new(op))
348 };
349
350 lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
351 }
352
353 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
355 self.0.request.name = v.into();
356 self
357 }
358
359 pub fn set_access_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
361 self.0.request.access_token = v.into();
362 self
363 }
364
365 pub fn set_id_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
367 self.0.request.id_token = v.into();
368 self
369 }
370
371 pub fn set_expire_time<T>(mut self, v: T) -> Self
373 where
374 T: std::convert::Into<wkt::Timestamp>,
375 {
376 self.0.request.expire_time = std::option::Option::Some(v.into());
377 self
378 }
379
380 pub fn set_or_clear_expire_time<T>(mut self, v: std::option::Option<T>) -> Self
382 where
383 T: std::convert::Into<wkt::Timestamp>,
384 {
385 self.0.request.expire_time = v.map(|x| x.into());
386 self
387 }
388 }
389
390 #[doc(hidden)]
391 impl gax::options::internal::RequestBuilder for AuthorizeEnvironment {
392 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
393 &mut self.0.options
394 }
395 }
396
397 #[derive(Clone, Debug)]
415 pub struct AddPublicKey(RequestBuilder<crate::model::AddPublicKeyRequest>);
416
417 impl AddPublicKey {
418 pub(crate) fn new(
419 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
420 ) -> Self {
421 Self(RequestBuilder::new(stub))
422 }
423
424 pub fn with_request<V: Into<crate::model::AddPublicKeyRequest>>(mut self, v: V) -> Self {
426 self.0.request = v.into();
427 self
428 }
429
430 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
432 self.0.options = v.into();
433 self
434 }
435
436 pub async fn send(self) -> Result<longrunning::model::Operation> {
443 (*self.0.stub)
444 .add_public_key(self.0.request, self.0.options)
445 .await
446 .map(gax::response::Response::into_body)
447 }
448
449 pub fn poller(
451 self,
452 ) -> impl lro::Poller<crate::model::AddPublicKeyResponse, crate::model::AddPublicKeyMetadata>
453 {
454 type Operation = lro::internal::Operation<
455 crate::model::AddPublicKeyResponse,
456 crate::model::AddPublicKeyMetadata,
457 >;
458 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
459 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
460
461 let stub = self.0.stub.clone();
462 let mut options = self.0.options.clone();
463 options.set_retry_policy(gax::retry_policy::NeverRetry);
464 let query = move |name| {
465 let stub = stub.clone();
466 let options = options.clone();
467 async {
468 let op = GetOperation::new(stub)
469 .set_name(name)
470 .with_options(options)
471 .send()
472 .await?;
473 Ok(Operation::new(op))
474 }
475 };
476
477 let start = move || async {
478 let op = self.send().await?;
479 Ok(Operation::new(op))
480 };
481
482 lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
483 }
484
485 pub fn set_environment<T: Into<std::string::String>>(mut self, v: T) -> Self {
487 self.0.request.environment = v.into();
488 self
489 }
490
491 pub fn set_key<T: Into<std::string::String>>(mut self, v: T) -> Self {
493 self.0.request.key = v.into();
494 self
495 }
496 }
497
498 #[doc(hidden)]
499 impl gax::options::internal::RequestBuilder for AddPublicKey {
500 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
501 &mut self.0.options
502 }
503 }
504
505 #[derive(Clone, Debug)]
523 pub struct RemovePublicKey(RequestBuilder<crate::model::RemovePublicKeyRequest>);
524
525 impl RemovePublicKey {
526 pub(crate) fn new(
527 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
528 ) -> Self {
529 Self(RequestBuilder::new(stub))
530 }
531
532 pub fn with_request<V: Into<crate::model::RemovePublicKeyRequest>>(mut self, v: V) -> Self {
534 self.0.request = v.into();
535 self
536 }
537
538 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
540 self.0.options = v.into();
541 self
542 }
543
544 pub async fn send(self) -> Result<longrunning::model::Operation> {
551 (*self.0.stub)
552 .remove_public_key(self.0.request, self.0.options)
553 .await
554 .map(gax::response::Response::into_body)
555 }
556
557 pub fn poller(
559 self,
560 ) -> impl lro::Poller<crate::model::RemovePublicKeyResponse, crate::model::RemovePublicKeyMetadata>
561 {
562 type Operation = lro::internal::Operation<
563 crate::model::RemovePublicKeyResponse,
564 crate::model::RemovePublicKeyMetadata,
565 >;
566 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
567 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
568
569 let stub = self.0.stub.clone();
570 let mut options = self.0.options.clone();
571 options.set_retry_policy(gax::retry_policy::NeverRetry);
572 let query = move |name| {
573 let stub = stub.clone();
574 let options = options.clone();
575 async {
576 let op = GetOperation::new(stub)
577 .set_name(name)
578 .with_options(options)
579 .send()
580 .await?;
581 Ok(Operation::new(op))
582 }
583 };
584
585 let start = move || async {
586 let op = self.send().await?;
587 Ok(Operation::new(op))
588 };
589
590 lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
591 }
592
593 pub fn set_environment<T: Into<std::string::String>>(mut self, v: T) -> Self {
595 self.0.request.environment = v.into();
596 self
597 }
598
599 pub fn set_key<T: Into<std::string::String>>(mut self, v: T) -> Self {
601 self.0.request.key = v.into();
602 self
603 }
604 }
605
606 #[doc(hidden)]
607 impl gax::options::internal::RequestBuilder for RemovePublicKey {
608 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
609 &mut self.0.options
610 }
611 }
612
613 #[derive(Clone, Debug)]
630 pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);
631
632 impl GetOperation {
633 pub(crate) fn new(
634 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudShellService>,
635 ) -> Self {
636 Self(RequestBuilder::new(stub))
637 }
638
639 pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
641 mut self,
642 v: V,
643 ) -> Self {
644 self.0.request = v.into();
645 self
646 }
647
648 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
650 self.0.options = v.into();
651 self
652 }
653
654 pub async fn send(self) -> Result<longrunning::model::Operation> {
656 (*self.0.stub)
657 .get_operation(self.0.request, self.0.options)
658 .await
659 .map(gax::response::Response::into_body)
660 }
661
662 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
664 self.0.request.name = v.into();
665 self
666 }
667 }
668
669 #[doc(hidden)]
670 impl gax::options::internal::RequestBuilder for GetOperation {
671 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
672 &mut self.0.options
673 }
674 }
675}