google_cloud_shell_v1/
builder.rs1pub mod cloud_shell_service {
18 use crate::Result;
19 use std::sync::Arc;
20
21 pub type ClientBuilder =
35 gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;
36
37 pub(crate) mod client {
38 use super::super::super::client::CloudShellService;
39 pub struct Factory;
40 impl gax::client_builder::internal::ClientFactory for Factory {
41 type Client = CloudShellService;
42 type Credentials = gaxi::options::Credentials;
43 async fn build(self, config: gaxi::options::ClientConfig) -> gax::Result<Self::Client> {
44 Self::Client::new(config).await
45 }
46 }
47 }
48
49 #[derive(Clone, Debug)]
51 pub(crate) struct RequestBuilder<R: std::default::Default> {
52 stub: Arc<dyn super::super::stub::dynamic::CloudShellService>,
53 request: R,
54 options: gax::options::RequestOptions,
55 }
56
57 impl<R> RequestBuilder<R>
58 where
59 R: std::default::Default,
60 {
61 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::CloudShellService>) -> Self {
62 Self {
63 stub,
64 request: R::default(),
65 options: gax::options::RequestOptions::default(),
66 }
67 }
68 }
69
70 #[derive(Clone, Debug)]
72 pub struct GetEnvironment(RequestBuilder<crate::model::GetEnvironmentRequest>);
73
74 impl GetEnvironment {
75 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::CloudShellService>) -> Self {
76 Self(RequestBuilder::new(stub))
77 }
78
79 pub fn with_request<V: Into<crate::model::GetEnvironmentRequest>>(mut self, v: V) -> Self {
81 self.0.request = v.into();
82 self
83 }
84
85 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
87 self.0.options = v.into();
88 self
89 }
90
91 pub async fn send(self) -> Result<crate::model::Environment> {
93 (*self.0.stub)
94 .get_environment(self.0.request, self.0.options)
95 .await
96 .map(gax::response::Response::into_body)
97 }
98
99 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
101 self.0.request.name = v.into();
102 self
103 }
104 }
105
106 #[doc(hidden)]
107 impl gax::options::internal::RequestBuilder for GetEnvironment {
108 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
109 &mut self.0.options
110 }
111 }
112
113 #[derive(Clone, Debug)]
115 pub struct StartEnvironment(RequestBuilder<crate::model::StartEnvironmentRequest>);
116
117 impl StartEnvironment {
118 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::CloudShellService>) -> Self {
119 Self(RequestBuilder::new(stub))
120 }
121
122 pub fn with_request<V: Into<crate::model::StartEnvironmentRequest>>(
124 mut self,
125 v: V,
126 ) -> Self {
127 self.0.request = v.into();
128 self
129 }
130
131 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
133 self.0.options = v.into();
134 self
135 }
136
137 pub async fn send(self) -> Result<longrunning::model::Operation> {
144 (*self.0.stub)
145 .start_environment(self.0.request, self.0.options)
146 .await
147 .map(gax::response::Response::into_body)
148 }
149
150 pub fn poller(
152 self,
153 ) -> impl lro::Poller<
154 crate::model::StartEnvironmentResponse,
155 crate::model::StartEnvironmentMetadata,
156 > {
157 type Operation = lro::Operation<
158 crate::model::StartEnvironmentResponse,
159 crate::model::StartEnvironmentMetadata,
160 >;
161 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
162 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
163
164 let stub = self.0.stub.clone();
165 let mut options = self.0.options.clone();
166 options.set_retry_policy(gax::retry_policy::NeverRetry);
167 let query = move |name| {
168 let stub = stub.clone();
169 let options = options.clone();
170 async {
171 let op = GetOperation::new(stub)
172 .set_name(name)
173 .with_options(options)
174 .send()
175 .await?;
176 Ok(Operation::new(op))
177 }
178 };
179
180 let start = move || async {
181 let op = self.send().await?;
182 Ok(Operation::new(op))
183 };
184
185 lro::new_poller(polling_error_policy, polling_backoff_policy, start, query)
186 }
187
188 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
190 self.0.request.name = v.into();
191 self
192 }
193
194 pub fn set_access_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
196 self.0.request.access_token = v.into();
197 self
198 }
199
200 pub fn set_public_keys<T, V>(mut self, v: T) -> Self
202 where
203 T: std::iter::IntoIterator<Item = V>,
204 V: std::convert::Into<std::string::String>,
205 {
206 use std::iter::Iterator;
207 self.0.request.public_keys = v.into_iter().map(|i| i.into()).collect();
208 self
209 }
210 }
211
212 #[doc(hidden)]
213 impl gax::options::internal::RequestBuilder for StartEnvironment {
214 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
215 &mut self.0.options
216 }
217 }
218
219 #[derive(Clone, Debug)]
221 pub struct AuthorizeEnvironment(RequestBuilder<crate::model::AuthorizeEnvironmentRequest>);
222
223 impl AuthorizeEnvironment {
224 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::CloudShellService>) -> Self {
225 Self(RequestBuilder::new(stub))
226 }
227
228 pub fn with_request<V: Into<crate::model::AuthorizeEnvironmentRequest>>(
230 mut self,
231 v: V,
232 ) -> Self {
233 self.0.request = v.into();
234 self
235 }
236
237 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
239 self.0.options = v.into();
240 self
241 }
242
243 pub async fn send(self) -> Result<longrunning::model::Operation> {
250 (*self.0.stub)
251 .authorize_environment(self.0.request, self.0.options)
252 .await
253 .map(gax::response::Response::into_body)
254 }
255
256 pub fn poller(
258 self,
259 ) -> impl lro::Poller<
260 crate::model::AuthorizeEnvironmentResponse,
261 crate::model::AuthorizeEnvironmentMetadata,
262 > {
263 type Operation = lro::Operation<
264 crate::model::AuthorizeEnvironmentResponse,
265 crate::model::AuthorizeEnvironmentMetadata,
266 >;
267 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
268 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
269
270 let stub = self.0.stub.clone();
271 let mut options = self.0.options.clone();
272 options.set_retry_policy(gax::retry_policy::NeverRetry);
273 let query = move |name| {
274 let stub = stub.clone();
275 let options = options.clone();
276 async {
277 let op = GetOperation::new(stub)
278 .set_name(name)
279 .with_options(options)
280 .send()
281 .await?;
282 Ok(Operation::new(op))
283 }
284 };
285
286 let start = move || async {
287 let op = self.send().await?;
288 Ok(Operation::new(op))
289 };
290
291 lro::new_poller(polling_error_policy, polling_backoff_policy, start, query)
292 }
293
294 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
296 self.0.request.name = v.into();
297 self
298 }
299
300 pub fn set_access_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
302 self.0.request.access_token = v.into();
303 self
304 }
305
306 pub fn set_id_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
308 self.0.request.id_token = v.into();
309 self
310 }
311
312 pub fn set_expire_time<T: Into<std::option::Option<wkt::Timestamp>>>(
314 mut self,
315 v: T,
316 ) -> Self {
317 self.0.request.expire_time = v.into();
318 self
319 }
320 }
321
322 #[doc(hidden)]
323 impl gax::options::internal::RequestBuilder for AuthorizeEnvironment {
324 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
325 &mut self.0.options
326 }
327 }
328
329 #[derive(Clone, Debug)]
331 pub struct AddPublicKey(RequestBuilder<crate::model::AddPublicKeyRequest>);
332
333 impl AddPublicKey {
334 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::CloudShellService>) -> Self {
335 Self(RequestBuilder::new(stub))
336 }
337
338 pub fn with_request<V: Into<crate::model::AddPublicKeyRequest>>(mut self, v: V) -> Self {
340 self.0.request = v.into();
341 self
342 }
343
344 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
346 self.0.options = v.into();
347 self
348 }
349
350 pub async fn send(self) -> Result<longrunning::model::Operation> {
357 (*self.0.stub)
358 .add_public_key(self.0.request, self.0.options)
359 .await
360 .map(gax::response::Response::into_body)
361 }
362
363 pub fn poller(
365 self,
366 ) -> impl lro::Poller<crate::model::AddPublicKeyResponse, crate::model::AddPublicKeyMetadata>
367 {
368 type Operation = lro::Operation<
369 crate::model::AddPublicKeyResponse,
370 crate::model::AddPublicKeyMetadata,
371 >;
372 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
373 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
374
375 let stub = self.0.stub.clone();
376 let mut options = self.0.options.clone();
377 options.set_retry_policy(gax::retry_policy::NeverRetry);
378 let query = move |name| {
379 let stub = stub.clone();
380 let options = options.clone();
381 async {
382 let op = GetOperation::new(stub)
383 .set_name(name)
384 .with_options(options)
385 .send()
386 .await?;
387 Ok(Operation::new(op))
388 }
389 };
390
391 let start = move || async {
392 let op = self.send().await?;
393 Ok(Operation::new(op))
394 };
395
396 lro::new_poller(polling_error_policy, polling_backoff_policy, start, query)
397 }
398
399 pub fn set_environment<T: Into<std::string::String>>(mut self, v: T) -> Self {
401 self.0.request.environment = v.into();
402 self
403 }
404
405 pub fn set_key<T: Into<std::string::String>>(mut self, v: T) -> Self {
407 self.0.request.key = v.into();
408 self
409 }
410 }
411
412 #[doc(hidden)]
413 impl gax::options::internal::RequestBuilder for AddPublicKey {
414 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
415 &mut self.0.options
416 }
417 }
418
419 #[derive(Clone, Debug)]
421 pub struct RemovePublicKey(RequestBuilder<crate::model::RemovePublicKeyRequest>);
422
423 impl RemovePublicKey {
424 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::CloudShellService>) -> Self {
425 Self(RequestBuilder::new(stub))
426 }
427
428 pub fn with_request<V: Into<crate::model::RemovePublicKeyRequest>>(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 .remove_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::RemovePublicKeyResponse, crate::model::RemovePublicKeyMetadata>
457 {
458 type Operation = lro::Operation<
459 crate::model::RemovePublicKeyResponse,
460 crate::model::RemovePublicKeyMetadata,
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::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 RemovePublicKey {
504 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
505 &mut self.0.options
506 }
507 }
508
509 #[derive(Clone, Debug)]
511 pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);
512
513 impl GetOperation {
514 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::CloudShellService>) -> Self {
515 Self(RequestBuilder::new(stub))
516 }
517
518 pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
520 mut self,
521 v: V,
522 ) -> Self {
523 self.0.request = v.into();
524 self
525 }
526
527 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
529 self.0.options = v.into();
530 self
531 }
532
533 pub async fn send(self) -> Result<longrunning::model::Operation> {
535 (*self.0.stub)
536 .get_operation(self.0.request, self.0.options)
537 .await
538 .map(gax::response::Response::into_body)
539 }
540
541 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
543 self.0.request.name = v.into();
544 self
545 }
546 }
547
548 #[doc(hidden)]
549 impl gax::options::internal::RequestBuilder for GetOperation {
550 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
551 &mut self.0.options
552 }
553 }
554}