google_cloud_shell_v1/
builders.rs1pub mod cloud_shell_service {
18 use crate::Result;
19 use std::sync::Arc;
20
21 #[derive(Clone, Debug)]
23 pub struct RequestBuilder<R: std::default::Default> {
24 stub: Arc<dyn crate::stubs::dynamic::CloudShellService>,
25 request: R,
26 options: gax::options::RequestOptions,
27 }
28
29 impl<R> RequestBuilder<R>
30 where
31 R: std::default::Default,
32 {
33 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::CloudShellService>) -> Self {
34 Self {
35 stub,
36 request: R::default(),
37 options: gax::options::RequestOptions::default(),
38 }
39 }
40 }
41
42 #[derive(Clone, Debug)]
44 pub struct GetEnvironment(RequestBuilder<crate::model::GetEnvironmentRequest>);
45
46 impl GetEnvironment {
47 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::CloudShellService>) -> Self {
48 Self(RequestBuilder::new(stub))
49 }
50
51 pub fn with_request<V: Into<crate::model::GetEnvironmentRequest>>(mut self, v: V) -> Self {
53 self.0.request = v.into();
54 self
55 }
56
57 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
59 self.0.options = v.into();
60 self
61 }
62
63 pub async fn send(self) -> Result<crate::model::Environment> {
65 (*self.0.stub)
66 .get_environment(self.0.request, self.0.options)
67 .await
68 }
69
70 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
72 self.0.request.name = v.into();
73 self
74 }
75 }
76
77 impl gax::options::RequestBuilder for GetEnvironment {
78 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
79 &mut self.0.options
80 }
81 }
82
83 #[derive(Clone, Debug)]
85 pub struct StartEnvironment(RequestBuilder<crate::model::StartEnvironmentRequest>);
86
87 impl StartEnvironment {
88 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::CloudShellService>) -> Self {
89 Self(RequestBuilder::new(stub))
90 }
91
92 pub fn with_request<V: Into<crate::model::StartEnvironmentRequest>>(
94 mut self,
95 v: V,
96 ) -> Self {
97 self.0.request = v.into();
98 self
99 }
100
101 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
103 self.0.options = v.into();
104 self
105 }
106
107 pub async fn send(self) -> Result<longrunning::model::Operation> {
114 (*self.0.stub)
115 .start_environment(self.0.request, self.0.options)
116 .await
117 }
118
119 pub fn poller(
121 self,
122 ) -> impl lro::Poller<
123 crate::model::StartEnvironmentResponse,
124 crate::model::StartEnvironmentMetadata,
125 > {
126 type Operation = lro::Operation<
127 crate::model::StartEnvironmentResponse,
128 crate::model::StartEnvironmentMetadata,
129 >;
130 let polling_policy = self.0.stub.get_polling_policy(&self.0.options);
131 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
132
133 let stub = self.0.stub.clone();
134 let mut options = self.0.options.clone();
135 options.set_retry_policy(gax::retry_policy::NeverRetry);
136 let query = move |name| {
137 let stub = stub.clone();
138 let options = options.clone();
139 async {
140 let op = GetOperation::new(stub)
141 .set_name(name)
142 .with_options(options)
143 .send()
144 .await?;
145 Ok(Operation::new(op))
146 }
147 };
148
149 let start = move || async {
150 let op = self.send().await?;
151 Ok(Operation::new(op))
152 };
153
154 lro::new_poller(polling_policy, polling_backoff_policy, start, query)
155 }
156
157 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
159 self.0.request.name = v.into();
160 self
161 }
162
163 pub fn set_access_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
165 self.0.request.access_token = v.into();
166 self
167 }
168
169 pub fn set_public_keys<T, V>(mut self, v: T) -> Self
171 where
172 T: std::iter::IntoIterator<Item = V>,
173 V: std::convert::Into<std::string::String>,
174 {
175 use std::iter::Iterator;
176 self.0.request.public_keys = v.into_iter().map(|i| i.into()).collect();
177 self
178 }
179 }
180
181 impl gax::options::RequestBuilder for StartEnvironment {
182 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
183 &mut self.0.options
184 }
185 }
186
187 #[derive(Clone, Debug)]
189 pub struct AuthorizeEnvironment(RequestBuilder<crate::model::AuthorizeEnvironmentRequest>);
190
191 impl AuthorizeEnvironment {
192 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::CloudShellService>) -> Self {
193 Self(RequestBuilder::new(stub))
194 }
195
196 pub fn with_request<V: Into<crate::model::AuthorizeEnvironmentRequest>>(
198 mut self,
199 v: V,
200 ) -> Self {
201 self.0.request = v.into();
202 self
203 }
204
205 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
207 self.0.options = v.into();
208 self
209 }
210
211 pub async fn send(self) -> Result<longrunning::model::Operation> {
218 (*self.0.stub)
219 .authorize_environment(self.0.request, self.0.options)
220 .await
221 }
222
223 pub fn poller(
225 self,
226 ) -> impl lro::Poller<
227 crate::model::AuthorizeEnvironmentResponse,
228 crate::model::AuthorizeEnvironmentMetadata,
229 > {
230 type Operation = lro::Operation<
231 crate::model::AuthorizeEnvironmentResponse,
232 crate::model::AuthorizeEnvironmentMetadata,
233 >;
234 let polling_policy = self.0.stub.get_polling_policy(&self.0.options);
235 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
236
237 let stub = self.0.stub.clone();
238 let mut options = self.0.options.clone();
239 options.set_retry_policy(gax::retry_policy::NeverRetry);
240 let query = move |name| {
241 let stub = stub.clone();
242 let options = options.clone();
243 async {
244 let op = GetOperation::new(stub)
245 .set_name(name)
246 .with_options(options)
247 .send()
248 .await?;
249 Ok(Operation::new(op))
250 }
251 };
252
253 let start = move || async {
254 let op = self.send().await?;
255 Ok(Operation::new(op))
256 };
257
258 lro::new_poller(polling_policy, polling_backoff_policy, start, query)
259 }
260
261 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
263 self.0.request.name = v.into();
264 self
265 }
266
267 pub fn set_access_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
269 self.0.request.access_token = v.into();
270 self
271 }
272
273 pub fn set_id_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
275 self.0.request.id_token = v.into();
276 self
277 }
278
279 pub fn set_expire_time<T: Into<std::option::Option<wkt::Timestamp>>>(
281 mut self,
282 v: T,
283 ) -> Self {
284 self.0.request.expire_time = v.into();
285 self
286 }
287 }
288
289 impl gax::options::RequestBuilder for AuthorizeEnvironment {
290 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
291 &mut self.0.options
292 }
293 }
294
295 #[derive(Clone, Debug)]
297 pub struct AddPublicKey(RequestBuilder<crate::model::AddPublicKeyRequest>);
298
299 impl AddPublicKey {
300 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::CloudShellService>) -> Self {
301 Self(RequestBuilder::new(stub))
302 }
303
304 pub fn with_request<V: Into<crate::model::AddPublicKeyRequest>>(mut self, v: V) -> Self {
306 self.0.request = v.into();
307 self
308 }
309
310 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
312 self.0.options = v.into();
313 self
314 }
315
316 pub async fn send(self) -> Result<longrunning::model::Operation> {
323 (*self.0.stub)
324 .add_public_key(self.0.request, self.0.options)
325 .await
326 }
327
328 pub fn poller(
330 self,
331 ) -> impl lro::Poller<crate::model::AddPublicKeyResponse, crate::model::AddPublicKeyMetadata>
332 {
333 type Operation = lro::Operation<
334 crate::model::AddPublicKeyResponse,
335 crate::model::AddPublicKeyMetadata,
336 >;
337 let polling_policy = self.0.stub.get_polling_policy(&self.0.options);
338 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
339
340 let stub = self.0.stub.clone();
341 let mut options = self.0.options.clone();
342 options.set_retry_policy(gax::retry_policy::NeverRetry);
343 let query = move |name| {
344 let stub = stub.clone();
345 let options = options.clone();
346 async {
347 let op = GetOperation::new(stub)
348 .set_name(name)
349 .with_options(options)
350 .send()
351 .await?;
352 Ok(Operation::new(op))
353 }
354 };
355
356 let start = move || async {
357 let op = self.send().await?;
358 Ok(Operation::new(op))
359 };
360
361 lro::new_poller(polling_policy, polling_backoff_policy, start, query)
362 }
363
364 pub fn set_environment<T: Into<std::string::String>>(mut self, v: T) -> Self {
366 self.0.request.environment = v.into();
367 self
368 }
369
370 pub fn set_key<T: Into<std::string::String>>(mut self, v: T) -> Self {
372 self.0.request.key = v.into();
373 self
374 }
375 }
376
377 impl gax::options::RequestBuilder for AddPublicKey {
378 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
379 &mut self.0.options
380 }
381 }
382
383 #[derive(Clone, Debug)]
385 pub struct RemovePublicKey(RequestBuilder<crate::model::RemovePublicKeyRequest>);
386
387 impl RemovePublicKey {
388 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::CloudShellService>) -> Self {
389 Self(RequestBuilder::new(stub))
390 }
391
392 pub fn with_request<V: Into<crate::model::RemovePublicKeyRequest>>(mut self, v: V) -> Self {
394 self.0.request = v.into();
395 self
396 }
397
398 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
400 self.0.options = v.into();
401 self
402 }
403
404 pub async fn send(self) -> Result<longrunning::model::Operation> {
411 (*self.0.stub)
412 .remove_public_key(self.0.request, self.0.options)
413 .await
414 }
415
416 pub fn poller(
418 self,
419 ) -> impl lro::Poller<crate::model::RemovePublicKeyResponse, crate::model::RemovePublicKeyMetadata>
420 {
421 type Operation = lro::Operation<
422 crate::model::RemovePublicKeyResponse,
423 crate::model::RemovePublicKeyMetadata,
424 >;
425 let polling_policy = self.0.stub.get_polling_policy(&self.0.options);
426 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
427
428 let stub = self.0.stub.clone();
429 let mut options = self.0.options.clone();
430 options.set_retry_policy(gax::retry_policy::NeverRetry);
431 let query = move |name| {
432 let stub = stub.clone();
433 let options = options.clone();
434 async {
435 let op = GetOperation::new(stub)
436 .set_name(name)
437 .with_options(options)
438 .send()
439 .await?;
440 Ok(Operation::new(op))
441 }
442 };
443
444 let start = move || async {
445 let op = self.send().await?;
446 Ok(Operation::new(op))
447 };
448
449 lro::new_poller(polling_policy, polling_backoff_policy, start, query)
450 }
451
452 pub fn set_environment<T: Into<std::string::String>>(mut self, v: T) -> Self {
454 self.0.request.environment = v.into();
455 self
456 }
457
458 pub fn set_key<T: Into<std::string::String>>(mut self, v: T) -> Self {
460 self.0.request.key = v.into();
461 self
462 }
463 }
464
465 impl gax::options::RequestBuilder for RemovePublicKey {
466 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
467 &mut self.0.options
468 }
469 }
470
471 #[derive(Clone, Debug)]
473 pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);
474
475 impl GetOperation {
476 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::CloudShellService>) -> Self {
477 Self(RequestBuilder::new(stub))
478 }
479
480 pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
482 mut self,
483 v: V,
484 ) -> Self {
485 self.0.request = v.into();
486 self
487 }
488
489 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
491 self.0.options = v.into();
492 self
493 }
494
495 pub async fn send(self) -> Result<longrunning::model::Operation> {
497 (*self.0.stub)
498 .get_operation(self.0.request, self.0.options)
499 .await
500 }
501
502 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
504 self.0.request.name = v.into();
505 self
506 }
507 }
508
509 impl gax::options::RequestBuilder for GetOperation {
510 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
511 &mut self.0.options
512 }
513 }
514}