google_cloud_shell_v1/model.rs
1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gaxi;
23extern crate google_cloud_gax;
24extern crate google_cloud_longrunning;
25extern crate google_cloud_lro;
26extern crate serde;
27extern crate serde_json;
28extern crate serde_with;
29extern crate std;
30extern crate tracing;
31extern crate wkt;
32
33mod debug;
34mod deserialize;
35mod serialize;
36
37/// A Cloud Shell environment, which is defined as the combination of a Docker
38/// image specifying what is installed on the environment and a home directory
39/// containing the user's data that will remain across sessions. Each user has
40/// at least an environment with the ID "default".
41#[derive(Clone, Default, PartialEq)]
42#[non_exhaustive]
43pub struct Environment {
44 /// Immutable. Full name of this resource, in the format
45 /// `users/{owner_email}/environments/{environment_id}`. `{owner_email}` is the
46 /// email address of the user to whom this environment belongs, and
47 /// `{environment_id}` is the identifier of this environment. For example,
48 /// `users/someone@example.com/environments/default`.
49 pub name: std::string::String,
50
51 /// Output only. The environment's identifier, unique among the user's
52 /// environments.
53 pub id: std::string::String,
54
55 /// Required. Immutable. Full path to the Docker image used to run this environment, e.g.
56 /// "gcr.io/dev-con/cloud-devshell:latest".
57 pub docker_image: std::string::String,
58
59 /// Output only. Current execution state of this environment.
60 pub state: crate::model::environment::State,
61
62 /// Output only. Host to which clients can connect to initiate HTTPS or WSS
63 /// connections with the environment.
64 pub web_host: std::string::String,
65
66 /// Output only. Username that clients should use when initiating SSH sessions
67 /// with the environment.
68 pub ssh_username: std::string::String,
69
70 /// Output only. Host to which clients can connect to initiate SSH sessions
71 /// with the environment.
72 pub ssh_host: std::string::String,
73
74 /// Output only. Port to which clients can connect to initiate SSH sessions
75 /// with the environment.
76 pub ssh_port: i32,
77
78 /// Output only. Public keys associated with the environment. Clients can
79 /// connect to this environment via SSH only if they possess a private key
80 /// corresponding to at least one of these public keys. Keys can be added to or
81 /// removed from the environment using the AddPublicKey and RemovePublicKey
82 /// methods.
83 pub public_keys: std::vec::Vec<std::string::String>,
84
85 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
86}
87
88impl Environment {
89 /// Creates a new default instance.
90 pub fn new() -> Self {
91 std::default::Default::default()
92 }
93
94 /// Sets the value of [name][crate::model::Environment::name].
95 ///
96 /// # Example
97 /// ```ignore,no_run
98 /// # use google_cloud_shell_v1::model::Environment;
99 /// let x = Environment::new().set_name("example");
100 /// ```
101 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
102 self.name = v.into();
103 self
104 }
105
106 /// Sets the value of [id][crate::model::Environment::id].
107 ///
108 /// # Example
109 /// ```ignore,no_run
110 /// # use google_cloud_shell_v1::model::Environment;
111 /// let x = Environment::new().set_id("example");
112 /// ```
113 pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
114 self.id = v.into();
115 self
116 }
117
118 /// Sets the value of [docker_image][crate::model::Environment::docker_image].
119 ///
120 /// # Example
121 /// ```ignore,no_run
122 /// # use google_cloud_shell_v1::model::Environment;
123 /// let x = Environment::new().set_docker_image("example");
124 /// ```
125 pub fn set_docker_image<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
126 self.docker_image = v.into();
127 self
128 }
129
130 /// Sets the value of [state][crate::model::Environment::state].
131 ///
132 /// # Example
133 /// ```ignore,no_run
134 /// # use google_cloud_shell_v1::model::Environment;
135 /// use google_cloud_shell_v1::model::environment::State;
136 /// let x0 = Environment::new().set_state(State::Suspended);
137 /// let x1 = Environment::new().set_state(State::Pending);
138 /// let x2 = Environment::new().set_state(State::Running);
139 /// ```
140 pub fn set_state<T: std::convert::Into<crate::model::environment::State>>(
141 mut self,
142 v: T,
143 ) -> Self {
144 self.state = v.into();
145 self
146 }
147
148 /// Sets the value of [web_host][crate::model::Environment::web_host].
149 ///
150 /// # Example
151 /// ```ignore,no_run
152 /// # use google_cloud_shell_v1::model::Environment;
153 /// let x = Environment::new().set_web_host("example");
154 /// ```
155 pub fn set_web_host<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
156 self.web_host = v.into();
157 self
158 }
159
160 /// Sets the value of [ssh_username][crate::model::Environment::ssh_username].
161 ///
162 /// # Example
163 /// ```ignore,no_run
164 /// # use google_cloud_shell_v1::model::Environment;
165 /// let x = Environment::new().set_ssh_username("example");
166 /// ```
167 pub fn set_ssh_username<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
168 self.ssh_username = v.into();
169 self
170 }
171
172 /// Sets the value of [ssh_host][crate::model::Environment::ssh_host].
173 ///
174 /// # Example
175 /// ```ignore,no_run
176 /// # use google_cloud_shell_v1::model::Environment;
177 /// let x = Environment::new().set_ssh_host("example");
178 /// ```
179 pub fn set_ssh_host<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
180 self.ssh_host = v.into();
181 self
182 }
183
184 /// Sets the value of [ssh_port][crate::model::Environment::ssh_port].
185 ///
186 /// # Example
187 /// ```ignore,no_run
188 /// # use google_cloud_shell_v1::model::Environment;
189 /// let x = Environment::new().set_ssh_port(42);
190 /// ```
191 pub fn set_ssh_port<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
192 self.ssh_port = v.into();
193 self
194 }
195
196 /// Sets the value of [public_keys][crate::model::Environment::public_keys].
197 ///
198 /// # Example
199 /// ```ignore,no_run
200 /// # use google_cloud_shell_v1::model::Environment;
201 /// let x = Environment::new().set_public_keys(["a", "b", "c"]);
202 /// ```
203 pub fn set_public_keys<T, V>(mut self, v: T) -> Self
204 where
205 T: std::iter::IntoIterator<Item = V>,
206 V: std::convert::Into<std::string::String>,
207 {
208 use std::iter::Iterator;
209 self.public_keys = v.into_iter().map(|i| i.into()).collect();
210 self
211 }
212}
213
214impl wkt::message::Message for Environment {
215 fn typename() -> &'static str {
216 "type.googleapis.com/google.cloud.shell.v1.Environment"
217 }
218}
219
220/// Defines additional types related to [Environment].
221pub mod environment {
222 #[allow(unused_imports)]
223 use super::*;
224
225 /// Possible execution states for an environment.
226 ///
227 /// # Working with unknown values
228 ///
229 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
230 /// additional enum variants at any time. Adding new variants is not considered
231 /// a breaking change. Applications should write their code in anticipation of:
232 ///
233 /// - New values appearing in future releases of the client library, **and**
234 /// - New values received dynamically, without application changes.
235 ///
236 /// Please consult the [Working with enums] section in the user guide for some
237 /// guidelines.
238 ///
239 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
240 #[derive(Clone, Debug, PartialEq)]
241 #[non_exhaustive]
242 pub enum State {
243 /// The environment's states is unknown.
244 Unspecified,
245 /// The environment is not running and can't be connected to. Starting the
246 /// environment will transition it to the PENDING state.
247 Suspended,
248 /// The environment is being started but is not yet ready to accept
249 /// connections.
250 Pending,
251 /// The environment is running and ready to accept connections. It will
252 /// automatically transition back to DISABLED after a period of inactivity or
253 /// if another environment is started.
254 Running,
255 /// The environment is being deleted and can't be connected to.
256 Deleting,
257 /// If set, the enum was initialized with an unknown value.
258 ///
259 /// Applications can examine the value using [State::value] or
260 /// [State::name].
261 UnknownValue(state::UnknownValue),
262 }
263
264 #[doc(hidden)]
265 pub mod state {
266 #[allow(unused_imports)]
267 use super::*;
268 #[derive(Clone, Debug, PartialEq)]
269 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
270 }
271
272 impl State {
273 /// Gets the enum value.
274 ///
275 /// Returns `None` if the enum contains an unknown value deserialized from
276 /// the string representation of enums.
277 pub fn value(&self) -> std::option::Option<i32> {
278 match self {
279 Self::Unspecified => std::option::Option::Some(0),
280 Self::Suspended => std::option::Option::Some(1),
281 Self::Pending => std::option::Option::Some(2),
282 Self::Running => std::option::Option::Some(3),
283 Self::Deleting => std::option::Option::Some(4),
284 Self::UnknownValue(u) => u.0.value(),
285 }
286 }
287
288 /// Gets the enum value as a string.
289 ///
290 /// Returns `None` if the enum contains an unknown value deserialized from
291 /// the integer representation of enums.
292 pub fn name(&self) -> std::option::Option<&str> {
293 match self {
294 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
295 Self::Suspended => std::option::Option::Some("SUSPENDED"),
296 Self::Pending => std::option::Option::Some("PENDING"),
297 Self::Running => std::option::Option::Some("RUNNING"),
298 Self::Deleting => std::option::Option::Some("DELETING"),
299 Self::UnknownValue(u) => u.0.name(),
300 }
301 }
302 }
303
304 impl std::default::Default for State {
305 fn default() -> Self {
306 use std::convert::From;
307 Self::from(0)
308 }
309 }
310
311 impl std::fmt::Display for State {
312 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
313 wkt::internal::display_enum(f, self.name(), self.value())
314 }
315 }
316
317 impl std::convert::From<i32> for State {
318 fn from(value: i32) -> Self {
319 match value {
320 0 => Self::Unspecified,
321 1 => Self::Suspended,
322 2 => Self::Pending,
323 3 => Self::Running,
324 4 => Self::Deleting,
325 _ => Self::UnknownValue(state::UnknownValue(
326 wkt::internal::UnknownEnumValue::Integer(value),
327 )),
328 }
329 }
330 }
331
332 impl std::convert::From<&str> for State {
333 fn from(value: &str) -> Self {
334 use std::string::ToString;
335 match value {
336 "STATE_UNSPECIFIED" => Self::Unspecified,
337 "SUSPENDED" => Self::Suspended,
338 "PENDING" => Self::Pending,
339 "RUNNING" => Self::Running,
340 "DELETING" => Self::Deleting,
341 _ => Self::UnknownValue(state::UnknownValue(
342 wkt::internal::UnknownEnumValue::String(value.to_string()),
343 )),
344 }
345 }
346 }
347
348 impl serde::ser::Serialize for State {
349 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
350 where
351 S: serde::Serializer,
352 {
353 match self {
354 Self::Unspecified => serializer.serialize_i32(0),
355 Self::Suspended => serializer.serialize_i32(1),
356 Self::Pending => serializer.serialize_i32(2),
357 Self::Running => serializer.serialize_i32(3),
358 Self::Deleting => serializer.serialize_i32(4),
359 Self::UnknownValue(u) => u.0.serialize(serializer),
360 }
361 }
362 }
363
364 impl<'de> serde::de::Deserialize<'de> for State {
365 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
366 where
367 D: serde::Deserializer<'de>,
368 {
369 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
370 ".google.cloud.shell.v1.Environment.State",
371 ))
372 }
373 }
374}
375
376/// Request message for
377/// [GetEnvironment][google.cloud.shell.v1.CloudShellService.GetEnvironment].
378///
379/// [google.cloud.shell.v1.CloudShellService.GetEnvironment]: crate::client::CloudShellService::get_environment
380#[derive(Clone, Default, PartialEq)]
381#[non_exhaustive]
382pub struct GetEnvironmentRequest {
383 /// Required. Name of the requested resource, for example `users/me/environments/default`
384 /// or `users/someone@example.com/environments/default`.
385 pub name: std::string::String,
386
387 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
388}
389
390impl GetEnvironmentRequest {
391 /// Creates a new default instance.
392 pub fn new() -> Self {
393 std::default::Default::default()
394 }
395
396 /// Sets the value of [name][crate::model::GetEnvironmentRequest::name].
397 ///
398 /// # Example
399 /// ```ignore,no_run
400 /// # use google_cloud_shell_v1::model::GetEnvironmentRequest;
401 /// let x = GetEnvironmentRequest::new().set_name("example");
402 /// ```
403 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
404 self.name = v.into();
405 self
406 }
407}
408
409impl wkt::message::Message for GetEnvironmentRequest {
410 fn typename() -> &'static str {
411 "type.googleapis.com/google.cloud.shell.v1.GetEnvironmentRequest"
412 }
413}
414
415/// Message included in the metadata field of operations returned from
416/// [CreateEnvironment][google.cloud.shell.v1.CloudShellService.CreateEnvironment].
417#[derive(Clone, Default, PartialEq)]
418#[non_exhaustive]
419pub struct CreateEnvironmentMetadata {
420 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
421}
422
423impl CreateEnvironmentMetadata {
424 /// Creates a new default instance.
425 pub fn new() -> Self {
426 std::default::Default::default()
427 }
428}
429
430impl wkt::message::Message for CreateEnvironmentMetadata {
431 fn typename() -> &'static str {
432 "type.googleapis.com/google.cloud.shell.v1.CreateEnvironmentMetadata"
433 }
434}
435
436/// Message included in the metadata field of operations returned from
437/// [DeleteEnvironment][google.cloud.shell.v1.CloudShellService.DeleteEnvironment].
438#[derive(Clone, Default, PartialEq)]
439#[non_exhaustive]
440pub struct DeleteEnvironmentMetadata {
441 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
442}
443
444impl DeleteEnvironmentMetadata {
445 /// Creates a new default instance.
446 pub fn new() -> Self {
447 std::default::Default::default()
448 }
449}
450
451impl wkt::message::Message for DeleteEnvironmentMetadata {
452 fn typename() -> &'static str {
453 "type.googleapis.com/google.cloud.shell.v1.DeleteEnvironmentMetadata"
454 }
455}
456
457/// Request message for
458/// [StartEnvironment][google.cloud.shell.v1.CloudShellService.StartEnvironment].
459///
460/// [google.cloud.shell.v1.CloudShellService.StartEnvironment]: crate::client::CloudShellService::start_environment
461#[derive(Clone, Default, PartialEq)]
462#[non_exhaustive]
463pub struct StartEnvironmentRequest {
464 /// Name of the resource that should be started, for example
465 /// `users/me/environments/default` or
466 /// `users/someone@example.com/environments/default`.
467 pub name: std::string::String,
468
469 /// The initial access token passed to the environment. If this is present and
470 /// valid, the environment will be pre-authenticated with gcloud so that the
471 /// user can run gcloud commands in Cloud Shell without having to log in. This
472 /// code can be updated later by calling AuthorizeEnvironment.
473 pub access_token: std::string::String,
474
475 /// Public keys that should be added to the environment before it is started.
476 pub public_keys: std::vec::Vec<std::string::String>,
477
478 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
479}
480
481impl StartEnvironmentRequest {
482 /// Creates a new default instance.
483 pub fn new() -> Self {
484 std::default::Default::default()
485 }
486
487 /// Sets the value of [name][crate::model::StartEnvironmentRequest::name].
488 ///
489 /// # Example
490 /// ```ignore,no_run
491 /// # use google_cloud_shell_v1::model::StartEnvironmentRequest;
492 /// let x = StartEnvironmentRequest::new().set_name("example");
493 /// ```
494 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
495 self.name = v.into();
496 self
497 }
498
499 /// Sets the value of [access_token][crate::model::StartEnvironmentRequest::access_token].
500 ///
501 /// # Example
502 /// ```ignore,no_run
503 /// # use google_cloud_shell_v1::model::StartEnvironmentRequest;
504 /// let x = StartEnvironmentRequest::new().set_access_token("example");
505 /// ```
506 pub fn set_access_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
507 self.access_token = v.into();
508 self
509 }
510
511 /// Sets the value of [public_keys][crate::model::StartEnvironmentRequest::public_keys].
512 ///
513 /// # Example
514 /// ```ignore,no_run
515 /// # use google_cloud_shell_v1::model::StartEnvironmentRequest;
516 /// let x = StartEnvironmentRequest::new().set_public_keys(["a", "b", "c"]);
517 /// ```
518 pub fn set_public_keys<T, V>(mut self, v: T) -> Self
519 where
520 T: std::iter::IntoIterator<Item = V>,
521 V: std::convert::Into<std::string::String>,
522 {
523 use std::iter::Iterator;
524 self.public_keys = v.into_iter().map(|i| i.into()).collect();
525 self
526 }
527}
528
529impl wkt::message::Message for StartEnvironmentRequest {
530 fn typename() -> &'static str {
531 "type.googleapis.com/google.cloud.shell.v1.StartEnvironmentRequest"
532 }
533}
534
535/// Request message for
536/// [AuthorizeEnvironment][google.cloud.shell.v1.CloudShellService.AuthorizeEnvironment].
537///
538/// [google.cloud.shell.v1.CloudShellService.AuthorizeEnvironment]: crate::client::CloudShellService::authorize_environment
539#[derive(Clone, Default, PartialEq)]
540#[non_exhaustive]
541pub struct AuthorizeEnvironmentRequest {
542 /// Name of the resource that should receive the credentials, for example
543 /// `users/me/environments/default` or
544 /// `users/someone@example.com/environments/default`.
545 pub name: std::string::String,
546
547 /// The OAuth access token that should be sent to the environment.
548 pub access_token: std::string::String,
549
550 /// The OAuth ID token that should be sent to the environment.
551 pub id_token: std::string::String,
552
553 /// The time when the credentials expire. If not set, defaults to one hour from
554 /// when the server received the request.
555 pub expire_time: std::option::Option<wkt::Timestamp>,
556
557 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
558}
559
560impl AuthorizeEnvironmentRequest {
561 /// Creates a new default instance.
562 pub fn new() -> Self {
563 std::default::Default::default()
564 }
565
566 /// Sets the value of [name][crate::model::AuthorizeEnvironmentRequest::name].
567 ///
568 /// # Example
569 /// ```ignore,no_run
570 /// # use google_cloud_shell_v1::model::AuthorizeEnvironmentRequest;
571 /// let x = AuthorizeEnvironmentRequest::new().set_name("example");
572 /// ```
573 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
574 self.name = v.into();
575 self
576 }
577
578 /// Sets the value of [access_token][crate::model::AuthorizeEnvironmentRequest::access_token].
579 ///
580 /// # Example
581 /// ```ignore,no_run
582 /// # use google_cloud_shell_v1::model::AuthorizeEnvironmentRequest;
583 /// let x = AuthorizeEnvironmentRequest::new().set_access_token("example");
584 /// ```
585 pub fn set_access_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
586 self.access_token = v.into();
587 self
588 }
589
590 /// Sets the value of [id_token][crate::model::AuthorizeEnvironmentRequest::id_token].
591 ///
592 /// # Example
593 /// ```ignore,no_run
594 /// # use google_cloud_shell_v1::model::AuthorizeEnvironmentRequest;
595 /// let x = AuthorizeEnvironmentRequest::new().set_id_token("example");
596 /// ```
597 pub fn set_id_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
598 self.id_token = v.into();
599 self
600 }
601
602 /// Sets the value of [expire_time][crate::model::AuthorizeEnvironmentRequest::expire_time].
603 ///
604 /// # Example
605 /// ```ignore,no_run
606 /// # use google_cloud_shell_v1::model::AuthorizeEnvironmentRequest;
607 /// use wkt::Timestamp;
608 /// let x = AuthorizeEnvironmentRequest::new().set_expire_time(Timestamp::default()/* use setters */);
609 /// ```
610 pub fn set_expire_time<T>(mut self, v: T) -> Self
611 where
612 T: std::convert::Into<wkt::Timestamp>,
613 {
614 self.expire_time = std::option::Option::Some(v.into());
615 self
616 }
617
618 /// Sets or clears the value of [expire_time][crate::model::AuthorizeEnvironmentRequest::expire_time].
619 ///
620 /// # Example
621 /// ```ignore,no_run
622 /// # use google_cloud_shell_v1::model::AuthorizeEnvironmentRequest;
623 /// use wkt::Timestamp;
624 /// let x = AuthorizeEnvironmentRequest::new().set_or_clear_expire_time(Some(Timestamp::default()/* use setters */));
625 /// let x = AuthorizeEnvironmentRequest::new().set_or_clear_expire_time(None::<Timestamp>);
626 /// ```
627 pub fn set_or_clear_expire_time<T>(mut self, v: std::option::Option<T>) -> Self
628 where
629 T: std::convert::Into<wkt::Timestamp>,
630 {
631 self.expire_time = v.map(|x| x.into());
632 self
633 }
634}
635
636impl wkt::message::Message for AuthorizeEnvironmentRequest {
637 fn typename() -> &'static str {
638 "type.googleapis.com/google.cloud.shell.v1.AuthorizeEnvironmentRequest"
639 }
640}
641
642/// Response message for
643/// [AuthorizeEnvironment][google.cloud.shell.v1.CloudShellService.AuthorizeEnvironment].
644///
645/// [google.cloud.shell.v1.CloudShellService.AuthorizeEnvironment]: crate::client::CloudShellService::authorize_environment
646#[derive(Clone, Default, PartialEq)]
647#[non_exhaustive]
648pub struct AuthorizeEnvironmentResponse {
649 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
650}
651
652impl AuthorizeEnvironmentResponse {
653 /// Creates a new default instance.
654 pub fn new() -> Self {
655 std::default::Default::default()
656 }
657}
658
659impl wkt::message::Message for AuthorizeEnvironmentResponse {
660 fn typename() -> &'static str {
661 "type.googleapis.com/google.cloud.shell.v1.AuthorizeEnvironmentResponse"
662 }
663}
664
665/// Message included in the metadata field of operations returned from
666/// [AuthorizeEnvironment][google.cloud.shell.v1.CloudShellService.AuthorizeEnvironment].
667///
668/// [google.cloud.shell.v1.CloudShellService.AuthorizeEnvironment]: crate::client::CloudShellService::authorize_environment
669#[derive(Clone, Default, PartialEq)]
670#[non_exhaustive]
671pub struct AuthorizeEnvironmentMetadata {
672 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
673}
674
675impl AuthorizeEnvironmentMetadata {
676 /// Creates a new default instance.
677 pub fn new() -> Self {
678 std::default::Default::default()
679 }
680}
681
682impl wkt::message::Message for AuthorizeEnvironmentMetadata {
683 fn typename() -> &'static str {
684 "type.googleapis.com/google.cloud.shell.v1.AuthorizeEnvironmentMetadata"
685 }
686}
687
688/// Message included in the metadata field of operations returned from
689/// [StartEnvironment][google.cloud.shell.v1.CloudShellService.StartEnvironment].
690///
691/// [google.cloud.shell.v1.CloudShellService.StartEnvironment]: crate::client::CloudShellService::start_environment
692#[derive(Clone, Default, PartialEq)]
693#[non_exhaustive]
694pub struct StartEnvironmentMetadata {
695 /// Current state of the environment being started.
696 pub state: crate::model::start_environment_metadata::State,
697
698 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
699}
700
701impl StartEnvironmentMetadata {
702 /// Creates a new default instance.
703 pub fn new() -> Self {
704 std::default::Default::default()
705 }
706
707 /// Sets the value of [state][crate::model::StartEnvironmentMetadata::state].
708 ///
709 /// # Example
710 /// ```ignore,no_run
711 /// # use google_cloud_shell_v1::model::StartEnvironmentMetadata;
712 /// use google_cloud_shell_v1::model::start_environment_metadata::State;
713 /// let x0 = StartEnvironmentMetadata::new().set_state(State::Starting);
714 /// let x1 = StartEnvironmentMetadata::new().set_state(State::UnarchivingDisk);
715 /// let x2 = StartEnvironmentMetadata::new().set_state(State::AwaitingComputeResources);
716 /// ```
717 pub fn set_state<T: std::convert::Into<crate::model::start_environment_metadata::State>>(
718 mut self,
719 v: T,
720 ) -> Self {
721 self.state = v.into();
722 self
723 }
724}
725
726impl wkt::message::Message for StartEnvironmentMetadata {
727 fn typename() -> &'static str {
728 "type.googleapis.com/google.cloud.shell.v1.StartEnvironmentMetadata"
729 }
730}
731
732/// Defines additional types related to [StartEnvironmentMetadata].
733pub mod start_environment_metadata {
734 #[allow(unused_imports)]
735 use super::*;
736
737 /// Possible states an environment might transition between during startup.
738 /// These states are not normally actionable by clients, but may be used to
739 /// show a progress message to the user. An environment won't necessarily go
740 /// through all of these states when starting. More states are likely to be
741 /// added in the future.
742 ///
743 /// # Working with unknown values
744 ///
745 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
746 /// additional enum variants at any time. Adding new variants is not considered
747 /// a breaking change. Applications should write their code in anticipation of:
748 ///
749 /// - New values appearing in future releases of the client library, **and**
750 /// - New values received dynamically, without application changes.
751 ///
752 /// Please consult the [Working with enums] section in the user guide for some
753 /// guidelines.
754 ///
755 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
756 #[derive(Clone, Debug, PartialEq)]
757 #[non_exhaustive]
758 pub enum State {
759 /// The environment's start state is unknown.
760 Unspecified,
761 /// The environment is in the process of being started, but no additional
762 /// details are available.
763 Starting,
764 /// Startup is waiting for the user's disk to be unarchived. This can happen
765 /// when the user returns to Cloud Shell after not having used it for a
766 /// while, and suggests that startup will take longer than normal.
767 UnarchivingDisk,
768 /// Startup is waiting for compute resources to be assigned to the
769 /// environment. This should normally happen very quickly, but an environment
770 /// might stay in this state for an extended period of time if the system is
771 /// experiencing heavy load.
772 AwaitingComputeResources,
773 /// Startup has completed. If the start operation was successful, the user
774 /// should be able to establish an SSH connection to their environment.
775 /// Otherwise, the operation will contain details of the failure.
776 Finished,
777 /// If set, the enum was initialized with an unknown value.
778 ///
779 /// Applications can examine the value using [State::value] or
780 /// [State::name].
781 UnknownValue(state::UnknownValue),
782 }
783
784 #[doc(hidden)]
785 pub mod state {
786 #[allow(unused_imports)]
787 use super::*;
788 #[derive(Clone, Debug, PartialEq)]
789 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
790 }
791
792 impl State {
793 /// Gets the enum value.
794 ///
795 /// Returns `None` if the enum contains an unknown value deserialized from
796 /// the string representation of enums.
797 pub fn value(&self) -> std::option::Option<i32> {
798 match self {
799 Self::Unspecified => std::option::Option::Some(0),
800 Self::Starting => std::option::Option::Some(1),
801 Self::UnarchivingDisk => std::option::Option::Some(2),
802 Self::AwaitingComputeResources => std::option::Option::Some(4),
803 Self::Finished => std::option::Option::Some(3),
804 Self::UnknownValue(u) => u.0.value(),
805 }
806 }
807
808 /// Gets the enum value as a string.
809 ///
810 /// Returns `None` if the enum contains an unknown value deserialized from
811 /// the integer representation of enums.
812 pub fn name(&self) -> std::option::Option<&str> {
813 match self {
814 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
815 Self::Starting => std::option::Option::Some("STARTING"),
816 Self::UnarchivingDisk => std::option::Option::Some("UNARCHIVING_DISK"),
817 Self::AwaitingComputeResources => {
818 std::option::Option::Some("AWAITING_COMPUTE_RESOURCES")
819 }
820 Self::Finished => std::option::Option::Some("FINISHED"),
821 Self::UnknownValue(u) => u.0.name(),
822 }
823 }
824 }
825
826 impl std::default::Default for State {
827 fn default() -> Self {
828 use std::convert::From;
829 Self::from(0)
830 }
831 }
832
833 impl std::fmt::Display for State {
834 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
835 wkt::internal::display_enum(f, self.name(), self.value())
836 }
837 }
838
839 impl std::convert::From<i32> for State {
840 fn from(value: i32) -> Self {
841 match value {
842 0 => Self::Unspecified,
843 1 => Self::Starting,
844 2 => Self::UnarchivingDisk,
845 3 => Self::Finished,
846 4 => Self::AwaitingComputeResources,
847 _ => Self::UnknownValue(state::UnknownValue(
848 wkt::internal::UnknownEnumValue::Integer(value),
849 )),
850 }
851 }
852 }
853
854 impl std::convert::From<&str> for State {
855 fn from(value: &str) -> Self {
856 use std::string::ToString;
857 match value {
858 "STATE_UNSPECIFIED" => Self::Unspecified,
859 "STARTING" => Self::Starting,
860 "UNARCHIVING_DISK" => Self::UnarchivingDisk,
861 "AWAITING_COMPUTE_RESOURCES" => Self::AwaitingComputeResources,
862 "FINISHED" => Self::Finished,
863 _ => Self::UnknownValue(state::UnknownValue(
864 wkt::internal::UnknownEnumValue::String(value.to_string()),
865 )),
866 }
867 }
868 }
869
870 impl serde::ser::Serialize for State {
871 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
872 where
873 S: serde::Serializer,
874 {
875 match self {
876 Self::Unspecified => serializer.serialize_i32(0),
877 Self::Starting => serializer.serialize_i32(1),
878 Self::UnarchivingDisk => serializer.serialize_i32(2),
879 Self::AwaitingComputeResources => serializer.serialize_i32(4),
880 Self::Finished => serializer.serialize_i32(3),
881 Self::UnknownValue(u) => u.0.serialize(serializer),
882 }
883 }
884 }
885
886 impl<'de> serde::de::Deserialize<'de> for State {
887 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
888 where
889 D: serde::Deserializer<'de>,
890 {
891 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
892 ".google.cloud.shell.v1.StartEnvironmentMetadata.State",
893 ))
894 }
895 }
896}
897
898/// Message included in the response field of operations returned from
899/// [StartEnvironment][google.cloud.shell.v1.CloudShellService.StartEnvironment]
900/// once the operation is complete.
901///
902/// [google.cloud.shell.v1.CloudShellService.StartEnvironment]: crate::client::CloudShellService::start_environment
903#[derive(Clone, Default, PartialEq)]
904#[non_exhaustive]
905pub struct StartEnvironmentResponse {
906 /// Environment that was started.
907 pub environment: std::option::Option<crate::model::Environment>,
908
909 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
910}
911
912impl StartEnvironmentResponse {
913 /// Creates a new default instance.
914 pub fn new() -> Self {
915 std::default::Default::default()
916 }
917
918 /// Sets the value of [environment][crate::model::StartEnvironmentResponse::environment].
919 ///
920 /// # Example
921 /// ```ignore,no_run
922 /// # use google_cloud_shell_v1::model::StartEnvironmentResponse;
923 /// use google_cloud_shell_v1::model::Environment;
924 /// let x = StartEnvironmentResponse::new().set_environment(Environment::default()/* use setters */);
925 /// ```
926 pub fn set_environment<T>(mut self, v: T) -> Self
927 where
928 T: std::convert::Into<crate::model::Environment>,
929 {
930 self.environment = std::option::Option::Some(v.into());
931 self
932 }
933
934 /// Sets or clears the value of [environment][crate::model::StartEnvironmentResponse::environment].
935 ///
936 /// # Example
937 /// ```ignore,no_run
938 /// # use google_cloud_shell_v1::model::StartEnvironmentResponse;
939 /// use google_cloud_shell_v1::model::Environment;
940 /// let x = StartEnvironmentResponse::new().set_or_clear_environment(Some(Environment::default()/* use setters */));
941 /// let x = StartEnvironmentResponse::new().set_or_clear_environment(None::<Environment>);
942 /// ```
943 pub fn set_or_clear_environment<T>(mut self, v: std::option::Option<T>) -> Self
944 where
945 T: std::convert::Into<crate::model::Environment>,
946 {
947 self.environment = v.map(|x| x.into());
948 self
949 }
950}
951
952impl wkt::message::Message for StartEnvironmentResponse {
953 fn typename() -> &'static str {
954 "type.googleapis.com/google.cloud.shell.v1.StartEnvironmentResponse"
955 }
956}
957
958/// Request message for
959/// [AddPublicKey][google.cloud.shell.v1.CloudShellService.AddPublicKey].
960///
961/// [google.cloud.shell.v1.CloudShellService.AddPublicKey]: crate::client::CloudShellService::add_public_key
962#[derive(Clone, Default, PartialEq)]
963#[non_exhaustive]
964pub struct AddPublicKeyRequest {
965 /// Environment this key should be added to, e.g.
966 /// `users/me/environments/default`.
967 pub environment: std::string::String,
968
969 /// Key that should be added to the environment. Supported formats are
970 /// `ssh-dss` (see RFC4253), `ssh-rsa` (see RFC4253), `ecdsa-sha2-nistp256`
971 /// (see RFC5656), `ecdsa-sha2-nistp384` (see RFC5656) and
972 /// `ecdsa-sha2-nistp521` (see RFC5656). It should be structured as
973 /// <format> <content>, where <content> part is encoded with
974 /// Base64.
975 pub key: std::string::String,
976
977 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
978}
979
980impl AddPublicKeyRequest {
981 /// Creates a new default instance.
982 pub fn new() -> Self {
983 std::default::Default::default()
984 }
985
986 /// Sets the value of [environment][crate::model::AddPublicKeyRequest::environment].
987 ///
988 /// # Example
989 /// ```ignore,no_run
990 /// # use google_cloud_shell_v1::model::AddPublicKeyRequest;
991 /// let x = AddPublicKeyRequest::new().set_environment("example");
992 /// ```
993 pub fn set_environment<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
994 self.environment = v.into();
995 self
996 }
997
998 /// Sets the value of [key][crate::model::AddPublicKeyRequest::key].
999 ///
1000 /// # Example
1001 /// ```ignore,no_run
1002 /// # use google_cloud_shell_v1::model::AddPublicKeyRequest;
1003 /// let x = AddPublicKeyRequest::new().set_key("example");
1004 /// ```
1005 pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1006 self.key = v.into();
1007 self
1008 }
1009}
1010
1011impl wkt::message::Message for AddPublicKeyRequest {
1012 fn typename() -> &'static str {
1013 "type.googleapis.com/google.cloud.shell.v1.AddPublicKeyRequest"
1014 }
1015}
1016
1017/// Response message for
1018/// [AddPublicKey][google.cloud.shell.v1.CloudShellService.AddPublicKey].
1019///
1020/// [google.cloud.shell.v1.CloudShellService.AddPublicKey]: crate::client::CloudShellService::add_public_key
1021#[derive(Clone, Default, PartialEq)]
1022#[non_exhaustive]
1023pub struct AddPublicKeyResponse {
1024 /// Key that was added to the environment.
1025 pub key: std::string::String,
1026
1027 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1028}
1029
1030impl AddPublicKeyResponse {
1031 /// Creates a new default instance.
1032 pub fn new() -> Self {
1033 std::default::Default::default()
1034 }
1035
1036 /// Sets the value of [key][crate::model::AddPublicKeyResponse::key].
1037 ///
1038 /// # Example
1039 /// ```ignore,no_run
1040 /// # use google_cloud_shell_v1::model::AddPublicKeyResponse;
1041 /// let x = AddPublicKeyResponse::new().set_key("example");
1042 /// ```
1043 pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1044 self.key = v.into();
1045 self
1046 }
1047}
1048
1049impl wkt::message::Message for AddPublicKeyResponse {
1050 fn typename() -> &'static str {
1051 "type.googleapis.com/google.cloud.shell.v1.AddPublicKeyResponse"
1052 }
1053}
1054
1055/// Message included in the metadata field of operations returned from
1056/// [AddPublicKey][google.cloud.shell.v1.CloudShellService.AddPublicKey].
1057///
1058/// [google.cloud.shell.v1.CloudShellService.AddPublicKey]: crate::client::CloudShellService::add_public_key
1059#[derive(Clone, Default, PartialEq)]
1060#[non_exhaustive]
1061pub struct AddPublicKeyMetadata {
1062 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1063}
1064
1065impl AddPublicKeyMetadata {
1066 /// Creates a new default instance.
1067 pub fn new() -> Self {
1068 std::default::Default::default()
1069 }
1070}
1071
1072impl wkt::message::Message for AddPublicKeyMetadata {
1073 fn typename() -> &'static str {
1074 "type.googleapis.com/google.cloud.shell.v1.AddPublicKeyMetadata"
1075 }
1076}
1077
1078/// Request message for
1079/// [RemovePublicKey][google.cloud.shell.v1.CloudShellService.RemovePublicKey].
1080///
1081/// [google.cloud.shell.v1.CloudShellService.RemovePublicKey]: crate::client::CloudShellService::remove_public_key
1082#[derive(Clone, Default, PartialEq)]
1083#[non_exhaustive]
1084pub struct RemovePublicKeyRequest {
1085 /// Environment this key should be removed from, e.g.
1086 /// `users/me/environments/default`.
1087 pub environment: std::string::String,
1088
1089 /// Key that should be removed from the environment.
1090 pub key: std::string::String,
1091
1092 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1093}
1094
1095impl RemovePublicKeyRequest {
1096 /// Creates a new default instance.
1097 pub fn new() -> Self {
1098 std::default::Default::default()
1099 }
1100
1101 /// Sets the value of [environment][crate::model::RemovePublicKeyRequest::environment].
1102 ///
1103 /// # Example
1104 /// ```ignore,no_run
1105 /// # use google_cloud_shell_v1::model::RemovePublicKeyRequest;
1106 /// let x = RemovePublicKeyRequest::new().set_environment("example");
1107 /// ```
1108 pub fn set_environment<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1109 self.environment = v.into();
1110 self
1111 }
1112
1113 /// Sets the value of [key][crate::model::RemovePublicKeyRequest::key].
1114 ///
1115 /// # Example
1116 /// ```ignore,no_run
1117 /// # use google_cloud_shell_v1::model::RemovePublicKeyRequest;
1118 /// let x = RemovePublicKeyRequest::new().set_key("example");
1119 /// ```
1120 pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1121 self.key = v.into();
1122 self
1123 }
1124}
1125
1126impl wkt::message::Message for RemovePublicKeyRequest {
1127 fn typename() -> &'static str {
1128 "type.googleapis.com/google.cloud.shell.v1.RemovePublicKeyRequest"
1129 }
1130}
1131
1132/// Response message for
1133/// [RemovePublicKey][google.cloud.shell.v1.CloudShellService.RemovePublicKey].
1134///
1135/// [google.cloud.shell.v1.CloudShellService.RemovePublicKey]: crate::client::CloudShellService::remove_public_key
1136#[derive(Clone, Default, PartialEq)]
1137#[non_exhaustive]
1138pub struct RemovePublicKeyResponse {
1139 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1140}
1141
1142impl RemovePublicKeyResponse {
1143 /// Creates a new default instance.
1144 pub fn new() -> Self {
1145 std::default::Default::default()
1146 }
1147}
1148
1149impl wkt::message::Message for RemovePublicKeyResponse {
1150 fn typename() -> &'static str {
1151 "type.googleapis.com/google.cloud.shell.v1.RemovePublicKeyResponse"
1152 }
1153}
1154
1155/// Message included in the metadata field of operations returned from
1156/// [RemovePublicKey][google.cloud.shell.v1.CloudShellService.RemovePublicKey].
1157///
1158/// [google.cloud.shell.v1.CloudShellService.RemovePublicKey]: crate::client::CloudShellService::remove_public_key
1159#[derive(Clone, Default, PartialEq)]
1160#[non_exhaustive]
1161pub struct RemovePublicKeyMetadata {
1162 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1163}
1164
1165impl RemovePublicKeyMetadata {
1166 /// Creates a new default instance.
1167 pub fn new() -> Self {
1168 std::default::Default::default()
1169 }
1170}
1171
1172impl wkt::message::Message for RemovePublicKeyMetadata {
1173 fn typename() -> &'static str {
1174 "type.googleapis.com/google.cloud.shell.v1.RemovePublicKeyMetadata"
1175 }
1176}
1177
1178/// Cloud-shell specific information that will be included as details in failure
1179/// responses.
1180#[derive(Clone, Default, PartialEq)]
1181#[non_exhaustive]
1182pub struct CloudShellErrorDetails {
1183 /// Code indicating the specific error the occurred.
1184 pub code: crate::model::cloud_shell_error_details::CloudShellErrorCode,
1185
1186 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1187}
1188
1189impl CloudShellErrorDetails {
1190 /// Creates a new default instance.
1191 pub fn new() -> Self {
1192 std::default::Default::default()
1193 }
1194
1195 /// Sets the value of [code][crate::model::CloudShellErrorDetails::code].
1196 ///
1197 /// # Example
1198 /// ```ignore,no_run
1199 /// # use google_cloud_shell_v1::model::CloudShellErrorDetails;
1200 /// use google_cloud_shell_v1::model::cloud_shell_error_details::CloudShellErrorCode;
1201 /// let x0 = CloudShellErrorDetails::new().set_code(CloudShellErrorCode::ImageUnavailable);
1202 /// let x1 = CloudShellErrorDetails::new().set_code(CloudShellErrorCode::CloudShellDisabled);
1203 /// let x2 = CloudShellErrorDetails::new().set_code(CloudShellErrorCode::TosViolation);
1204 /// ```
1205 pub fn set_code<
1206 T: std::convert::Into<crate::model::cloud_shell_error_details::CloudShellErrorCode>,
1207 >(
1208 mut self,
1209 v: T,
1210 ) -> Self {
1211 self.code = v.into();
1212 self
1213 }
1214}
1215
1216impl wkt::message::Message for CloudShellErrorDetails {
1217 fn typename() -> &'static str {
1218 "type.googleapis.com/google.cloud.shell.v1.CloudShellErrorDetails"
1219 }
1220}
1221
1222/// Defines additional types related to [CloudShellErrorDetails].
1223pub mod cloud_shell_error_details {
1224 #[allow(unused_imports)]
1225 use super::*;
1226
1227 /// Set of possible errors returned from API calls.
1228 ///
1229 /// # Working with unknown values
1230 ///
1231 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1232 /// additional enum variants at any time. Adding new variants is not considered
1233 /// a breaking change. Applications should write their code in anticipation of:
1234 ///
1235 /// - New values appearing in future releases of the client library, **and**
1236 /// - New values received dynamically, without application changes.
1237 ///
1238 /// Please consult the [Working with enums] section in the user guide for some
1239 /// guidelines.
1240 ///
1241 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1242 #[derive(Clone, Debug, PartialEq)]
1243 #[non_exhaustive]
1244 pub enum CloudShellErrorCode {
1245 /// An unknown error occurred.
1246 Unspecified,
1247 /// The image used by the Cloud Shell environment either does not exist or
1248 /// the user does not have access to it.
1249 ImageUnavailable,
1250 /// Cloud Shell has been disabled by an administrator for the user making the
1251 /// request.
1252 CloudShellDisabled,
1253 /// Cloud Shell has been permanently disabled due to a Terms of Service
1254 /// violation by the user.
1255 TosViolation,
1256 /// The user has exhausted their weekly Cloud Shell quota, and Cloud Shell
1257 /// will be disabled until the quota resets.
1258 QuotaExceeded,
1259 /// The Cloud Shell environment is unavailable and cannot be connected to at
1260 /// the moment.
1261 EnvironmentUnavailable,
1262 /// If set, the enum was initialized with an unknown value.
1263 ///
1264 /// Applications can examine the value using [CloudShellErrorCode::value] or
1265 /// [CloudShellErrorCode::name].
1266 UnknownValue(cloud_shell_error_code::UnknownValue),
1267 }
1268
1269 #[doc(hidden)]
1270 pub mod cloud_shell_error_code {
1271 #[allow(unused_imports)]
1272 use super::*;
1273 #[derive(Clone, Debug, PartialEq)]
1274 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1275 }
1276
1277 impl CloudShellErrorCode {
1278 /// Gets the enum value.
1279 ///
1280 /// Returns `None` if the enum contains an unknown value deserialized from
1281 /// the string representation of enums.
1282 pub fn value(&self) -> std::option::Option<i32> {
1283 match self {
1284 Self::Unspecified => std::option::Option::Some(0),
1285 Self::ImageUnavailable => std::option::Option::Some(1),
1286 Self::CloudShellDisabled => std::option::Option::Some(2),
1287 Self::TosViolation => std::option::Option::Some(4),
1288 Self::QuotaExceeded => std::option::Option::Some(5),
1289 Self::EnvironmentUnavailable => std::option::Option::Some(6),
1290 Self::UnknownValue(u) => u.0.value(),
1291 }
1292 }
1293
1294 /// Gets the enum value as a string.
1295 ///
1296 /// Returns `None` if the enum contains an unknown value deserialized from
1297 /// the integer representation of enums.
1298 pub fn name(&self) -> std::option::Option<&str> {
1299 match self {
1300 Self::Unspecified => {
1301 std::option::Option::Some("CLOUD_SHELL_ERROR_CODE_UNSPECIFIED")
1302 }
1303 Self::ImageUnavailable => std::option::Option::Some("IMAGE_UNAVAILABLE"),
1304 Self::CloudShellDisabled => std::option::Option::Some("CLOUD_SHELL_DISABLED"),
1305 Self::TosViolation => std::option::Option::Some("TOS_VIOLATION"),
1306 Self::QuotaExceeded => std::option::Option::Some("QUOTA_EXCEEDED"),
1307 Self::EnvironmentUnavailable => {
1308 std::option::Option::Some("ENVIRONMENT_UNAVAILABLE")
1309 }
1310 Self::UnknownValue(u) => u.0.name(),
1311 }
1312 }
1313 }
1314
1315 impl std::default::Default for CloudShellErrorCode {
1316 fn default() -> Self {
1317 use std::convert::From;
1318 Self::from(0)
1319 }
1320 }
1321
1322 impl std::fmt::Display for CloudShellErrorCode {
1323 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1324 wkt::internal::display_enum(f, self.name(), self.value())
1325 }
1326 }
1327
1328 impl std::convert::From<i32> for CloudShellErrorCode {
1329 fn from(value: i32) -> Self {
1330 match value {
1331 0 => Self::Unspecified,
1332 1 => Self::ImageUnavailable,
1333 2 => Self::CloudShellDisabled,
1334 4 => Self::TosViolation,
1335 5 => Self::QuotaExceeded,
1336 6 => Self::EnvironmentUnavailable,
1337 _ => Self::UnknownValue(cloud_shell_error_code::UnknownValue(
1338 wkt::internal::UnknownEnumValue::Integer(value),
1339 )),
1340 }
1341 }
1342 }
1343
1344 impl std::convert::From<&str> for CloudShellErrorCode {
1345 fn from(value: &str) -> Self {
1346 use std::string::ToString;
1347 match value {
1348 "CLOUD_SHELL_ERROR_CODE_UNSPECIFIED" => Self::Unspecified,
1349 "IMAGE_UNAVAILABLE" => Self::ImageUnavailable,
1350 "CLOUD_SHELL_DISABLED" => Self::CloudShellDisabled,
1351 "TOS_VIOLATION" => Self::TosViolation,
1352 "QUOTA_EXCEEDED" => Self::QuotaExceeded,
1353 "ENVIRONMENT_UNAVAILABLE" => Self::EnvironmentUnavailable,
1354 _ => Self::UnknownValue(cloud_shell_error_code::UnknownValue(
1355 wkt::internal::UnknownEnumValue::String(value.to_string()),
1356 )),
1357 }
1358 }
1359 }
1360
1361 impl serde::ser::Serialize for CloudShellErrorCode {
1362 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1363 where
1364 S: serde::Serializer,
1365 {
1366 match self {
1367 Self::Unspecified => serializer.serialize_i32(0),
1368 Self::ImageUnavailable => serializer.serialize_i32(1),
1369 Self::CloudShellDisabled => serializer.serialize_i32(2),
1370 Self::TosViolation => serializer.serialize_i32(4),
1371 Self::QuotaExceeded => serializer.serialize_i32(5),
1372 Self::EnvironmentUnavailable => serializer.serialize_i32(6),
1373 Self::UnknownValue(u) => u.0.serialize(serializer),
1374 }
1375 }
1376 }
1377
1378 impl<'de> serde::de::Deserialize<'de> for CloudShellErrorCode {
1379 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1380 where
1381 D: serde::Deserializer<'de>,
1382 {
1383 deserializer.deserialize_any(wkt::internal::EnumVisitor::<CloudShellErrorCode>::new(
1384 ".google.cloud.shell.v1.CloudShellErrorDetails.CloudShellErrorCode",
1385 ))
1386 }
1387 }
1388}