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