Skip to main content

google_cloud_devicestreaming_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 serde;
25extern crate serde_json;
26extern crate serde_with;
27extern crate std;
28extern crate tracing;
29extern crate wkt;
30
31mod debug;
32mod deserialize;
33mod serialize;
34
35/// A message returned from a device.
36#[derive(Clone, Default, PartialEq)]
37#[non_exhaustive]
38pub struct DeviceMessage {
39    pub contents: std::option::Option<crate::model::device_message::Contents>,
40
41    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
42}
43
44impl DeviceMessage {
45    pub fn new() -> Self {
46        std::default::Default::default()
47    }
48
49    /// Sets the value of [contents][crate::model::DeviceMessage::contents].
50    ///
51    /// Note that all the setters affecting `contents` are mutually
52    /// exclusive.
53    ///
54    /// # Example
55    /// ```ignore,no_run
56    /// # use google_cloud_devicestreaming_v1::model::DeviceMessage;
57    /// use google_cloud_devicestreaming_v1::model::StatusUpdate;
58    /// let x = DeviceMessage::new().set_contents(Some(
59    ///     google_cloud_devicestreaming_v1::model::device_message::Contents::StatusUpdate(StatusUpdate::default().into())));
60    /// ```
61    pub fn set_contents<
62        T: std::convert::Into<std::option::Option<crate::model::device_message::Contents>>,
63    >(
64        mut self,
65        v: T,
66    ) -> Self {
67        self.contents = v.into();
68        self
69    }
70
71    /// The value of [contents][crate::model::DeviceMessage::contents]
72    /// if it holds a `StatusUpdate`, `None` if the field is not set or
73    /// holds a different branch.
74    pub fn status_update(
75        &self,
76    ) -> std::option::Option<&std::boxed::Box<crate::model::StatusUpdate>> {
77        #[allow(unreachable_patterns)]
78        self.contents.as_ref().and_then(|v| match v {
79            crate::model::device_message::Contents::StatusUpdate(v) => std::option::Option::Some(v),
80            _ => std::option::Option::None,
81        })
82    }
83
84    /// Sets the value of [contents][crate::model::DeviceMessage::contents]
85    /// to hold a `StatusUpdate`.
86    ///
87    /// Note that all the setters affecting `contents` are
88    /// mutually exclusive.
89    ///
90    /// # Example
91    /// ```ignore,no_run
92    /// # use google_cloud_devicestreaming_v1::model::DeviceMessage;
93    /// use google_cloud_devicestreaming_v1::model::StatusUpdate;
94    /// let x = DeviceMessage::new().set_status_update(StatusUpdate::default()/* use setters */);
95    /// assert!(x.status_update().is_some());
96    /// assert!(x.stream_status().is_none());
97    /// assert!(x.stream_data().is_none());
98    /// ```
99    pub fn set_status_update<T: std::convert::Into<std::boxed::Box<crate::model::StatusUpdate>>>(
100        mut self,
101        v: T,
102    ) -> Self {
103        self.contents = std::option::Option::Some(
104            crate::model::device_message::Contents::StatusUpdate(v.into()),
105        );
106        self
107    }
108
109    /// The value of [contents][crate::model::DeviceMessage::contents]
110    /// if it holds a `StreamStatus`, `None` if the field is not set or
111    /// holds a different branch.
112    pub fn stream_status(
113        &self,
114    ) -> std::option::Option<&std::boxed::Box<crate::model::StreamStatus>> {
115        #[allow(unreachable_patterns)]
116        self.contents.as_ref().and_then(|v| match v {
117            crate::model::device_message::Contents::StreamStatus(v) => std::option::Option::Some(v),
118            _ => std::option::Option::None,
119        })
120    }
121
122    /// Sets the value of [contents][crate::model::DeviceMessage::contents]
123    /// to hold a `StreamStatus`.
124    ///
125    /// Note that all the setters affecting `contents` are
126    /// mutually exclusive.
127    ///
128    /// # Example
129    /// ```ignore,no_run
130    /// # use google_cloud_devicestreaming_v1::model::DeviceMessage;
131    /// use google_cloud_devicestreaming_v1::model::StreamStatus;
132    /// let x = DeviceMessage::new().set_stream_status(StreamStatus::default()/* use setters */);
133    /// assert!(x.stream_status().is_some());
134    /// assert!(x.status_update().is_none());
135    /// assert!(x.stream_data().is_none());
136    /// ```
137    pub fn set_stream_status<T: std::convert::Into<std::boxed::Box<crate::model::StreamStatus>>>(
138        mut self,
139        v: T,
140    ) -> Self {
141        self.contents = std::option::Option::Some(
142            crate::model::device_message::Contents::StreamStatus(v.into()),
143        );
144        self
145    }
146
147    /// The value of [contents][crate::model::DeviceMessage::contents]
148    /// if it holds a `StreamData`, `None` if the field is not set or
149    /// holds a different branch.
150    pub fn stream_data(&self) -> std::option::Option<&std::boxed::Box<crate::model::StreamData>> {
151        #[allow(unreachable_patterns)]
152        self.contents.as_ref().and_then(|v| match v {
153            crate::model::device_message::Contents::StreamData(v) => std::option::Option::Some(v),
154            _ => std::option::Option::None,
155        })
156    }
157
158    /// Sets the value of [contents][crate::model::DeviceMessage::contents]
159    /// to hold a `StreamData`.
160    ///
161    /// Note that all the setters affecting `contents` are
162    /// mutually exclusive.
163    ///
164    /// # Example
165    /// ```ignore,no_run
166    /// # use google_cloud_devicestreaming_v1::model::DeviceMessage;
167    /// use google_cloud_devicestreaming_v1::model::StreamData;
168    /// let x = DeviceMessage::new().set_stream_data(StreamData::default()/* use setters */);
169    /// assert!(x.stream_data().is_some());
170    /// assert!(x.status_update().is_none());
171    /// assert!(x.stream_status().is_none());
172    /// ```
173    pub fn set_stream_data<T: std::convert::Into<std::boxed::Box<crate::model::StreamData>>>(
174        mut self,
175        v: T,
176    ) -> Self {
177        self.contents =
178            std::option::Option::Some(crate::model::device_message::Contents::StreamData(v.into()));
179        self
180    }
181}
182
183impl wkt::message::Message for DeviceMessage {
184    fn typename() -> &'static str {
185        "type.googleapis.com/google.cloud.devicestreaming.v1.DeviceMessage"
186    }
187}
188
189/// Defines additional types related to [DeviceMessage].
190pub mod device_message {
191    #[allow(unused_imports)]
192    use super::*;
193
194    #[derive(Clone, Debug, PartialEq)]
195    #[non_exhaustive]
196    pub enum Contents {
197        /// Information about the device's state.
198        StatusUpdate(std::boxed::Box<crate::model::StatusUpdate>),
199        /// The result of a device stream from ADB.
200        StreamStatus(std::boxed::Box<crate::model::StreamStatus>),
201        /// Data from an open stream.
202        StreamData(std::boxed::Box<crate::model::StreamData>),
203    }
204}
205
206/// A message to an ADB server.
207#[derive(Clone, Default, PartialEq)]
208#[non_exhaustive]
209pub struct AdbMessage {
210    pub contents: std::option::Option<crate::model::adb_message::Contents>,
211
212    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
213}
214
215impl AdbMessage {
216    pub fn new() -> Self {
217        std::default::Default::default()
218    }
219
220    /// Sets the value of [contents][crate::model::AdbMessage::contents].
221    ///
222    /// Note that all the setters affecting `contents` are mutually
223    /// exclusive.
224    ///
225    /// # Example
226    /// ```ignore,no_run
227    /// # use google_cloud_devicestreaming_v1::model::AdbMessage;
228    /// use google_cloud_devicestreaming_v1::model::Open;
229    /// let x = AdbMessage::new().set_contents(Some(
230    ///     google_cloud_devicestreaming_v1::model::adb_message::Contents::Open(Open::default().into())));
231    /// ```
232    pub fn set_contents<
233        T: std::convert::Into<std::option::Option<crate::model::adb_message::Contents>>,
234    >(
235        mut self,
236        v: T,
237    ) -> Self {
238        self.contents = v.into();
239        self
240    }
241
242    /// The value of [contents][crate::model::AdbMessage::contents]
243    /// if it holds a `Open`, `None` if the field is not set or
244    /// holds a different branch.
245    pub fn open(&self) -> std::option::Option<&std::boxed::Box<crate::model::Open>> {
246        #[allow(unreachable_patterns)]
247        self.contents.as_ref().and_then(|v| match v {
248            crate::model::adb_message::Contents::Open(v) => std::option::Option::Some(v),
249            _ => std::option::Option::None,
250        })
251    }
252
253    /// Sets the value of [contents][crate::model::AdbMessage::contents]
254    /// to hold a `Open`.
255    ///
256    /// Note that all the setters affecting `contents` are
257    /// mutually exclusive.
258    ///
259    /// # Example
260    /// ```ignore,no_run
261    /// # use google_cloud_devicestreaming_v1::model::AdbMessage;
262    /// use google_cloud_devicestreaming_v1::model::Open;
263    /// let x = AdbMessage::new().set_open(Open::default()/* use setters */);
264    /// assert!(x.open().is_some());
265    /// assert!(x.stream_data().is_none());
266    /// ```
267    pub fn set_open<T: std::convert::Into<std::boxed::Box<crate::model::Open>>>(
268        mut self,
269        v: T,
270    ) -> Self {
271        self.contents =
272            std::option::Option::Some(crate::model::adb_message::Contents::Open(v.into()));
273        self
274    }
275
276    /// The value of [contents][crate::model::AdbMessage::contents]
277    /// if it holds a `StreamData`, `None` if the field is not set or
278    /// holds a different branch.
279    pub fn stream_data(&self) -> std::option::Option<&std::boxed::Box<crate::model::StreamData>> {
280        #[allow(unreachable_patterns)]
281        self.contents.as_ref().and_then(|v| match v {
282            crate::model::adb_message::Contents::StreamData(v) => std::option::Option::Some(v),
283            _ => std::option::Option::None,
284        })
285    }
286
287    /// Sets the value of [contents][crate::model::AdbMessage::contents]
288    /// to hold a `StreamData`.
289    ///
290    /// Note that all the setters affecting `contents` are
291    /// mutually exclusive.
292    ///
293    /// # Example
294    /// ```ignore,no_run
295    /// # use google_cloud_devicestreaming_v1::model::AdbMessage;
296    /// use google_cloud_devicestreaming_v1::model::StreamData;
297    /// let x = AdbMessage::new().set_stream_data(StreamData::default()/* use setters */);
298    /// assert!(x.stream_data().is_some());
299    /// assert!(x.open().is_none());
300    /// ```
301    pub fn set_stream_data<T: std::convert::Into<std::boxed::Box<crate::model::StreamData>>>(
302        mut self,
303        v: T,
304    ) -> Self {
305        self.contents =
306            std::option::Option::Some(crate::model::adb_message::Contents::StreamData(v.into()));
307        self
308    }
309}
310
311impl wkt::message::Message for AdbMessage {
312    fn typename() -> &'static str {
313        "type.googleapis.com/google.cloud.devicestreaming.v1.AdbMessage"
314    }
315}
316
317/// Defines additional types related to [AdbMessage].
318pub mod adb_message {
319    #[allow(unused_imports)]
320    use super::*;
321
322    #[derive(Clone, Debug, PartialEq)]
323    #[non_exhaustive]
324    pub enum Contents {
325        /// Open a new stream.
326        Open(std::boxed::Box<crate::model::Open>),
327        /// Send data to a stream.
328        StreamData(std::boxed::Box<crate::model::StreamData>),
329    }
330}
331
332/// A StatusUpdate message given over the ADB protocol for the device state.
333#[derive(Clone, Default, PartialEq)]
334#[non_exhaustive]
335pub struct StatusUpdate {
336    /// The device's state
337    pub state: crate::model::status_update::DeviceState,
338
339    /// A map of properties with information about this device.
340    pub properties: std::collections::HashMap<std::string::String, std::string::String>,
341
342    /// A comma-separated list of "features" that this device supports.
343    pub features: std::string::String,
344
345    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
346}
347
348impl StatusUpdate {
349    pub fn new() -> Self {
350        std::default::Default::default()
351    }
352
353    /// Sets the value of [state][crate::model::StatusUpdate::state].
354    ///
355    /// # Example
356    /// ```ignore,no_run
357    /// # use google_cloud_devicestreaming_v1::model::StatusUpdate;
358    /// use google_cloud_devicestreaming_v1::model::status_update::DeviceState;
359    /// let x0 = StatusUpdate::new().set_state(DeviceState::Device);
360    /// let x1 = StatusUpdate::new().set_state(DeviceState::Recovery);
361    /// let x2 = StatusUpdate::new().set_state(DeviceState::Rescue);
362    /// ```
363    pub fn set_state<T: std::convert::Into<crate::model::status_update::DeviceState>>(
364        mut self,
365        v: T,
366    ) -> Self {
367        self.state = v.into();
368        self
369    }
370
371    /// Sets the value of [properties][crate::model::StatusUpdate::properties].
372    ///
373    /// # Example
374    /// ```ignore,no_run
375    /// # use google_cloud_devicestreaming_v1::model::StatusUpdate;
376    /// let x = StatusUpdate::new().set_properties([
377    ///     ("key0", "abc"),
378    ///     ("key1", "xyz"),
379    /// ]);
380    /// ```
381    pub fn set_properties<T, K, V>(mut self, v: T) -> Self
382    where
383        T: std::iter::IntoIterator<Item = (K, V)>,
384        K: std::convert::Into<std::string::String>,
385        V: std::convert::Into<std::string::String>,
386    {
387        use std::iter::Iterator;
388        self.properties = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
389        self
390    }
391
392    /// Sets the value of [features][crate::model::StatusUpdate::features].
393    ///
394    /// # Example
395    /// ```ignore,no_run
396    /// # use google_cloud_devicestreaming_v1::model::StatusUpdate;
397    /// let x = StatusUpdate::new().set_features("example");
398    /// ```
399    pub fn set_features<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
400        self.features = v.into();
401        self
402    }
403}
404
405impl wkt::message::Message for StatusUpdate {
406    fn typename() -> &'static str {
407        "type.googleapis.com/google.cloud.devicestreaming.v1.StatusUpdate"
408    }
409}
410
411/// Defines additional types related to [StatusUpdate].
412pub mod status_update {
413    #[allow(unused_imports)]
414    use super::*;
415
416    /// The state displayed with the ADB Device when running "adb devices"
417    ///
418    /// # Working with unknown values
419    ///
420    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
421    /// additional enum variants at any time. Adding new variants is not considered
422    /// a breaking change. Applications should write their code in anticipation of:
423    ///
424    /// - New values appearing in future releases of the client library, **and**
425    /// - New values received dynamically, without application changes.
426    ///
427    /// Please consult the [Working with enums] section in the user guide for some
428    /// guidelines.
429    ///
430    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
431    #[derive(Clone, Debug, PartialEq)]
432    #[non_exhaustive]
433    pub enum DeviceState {
434        /// The device state is unknown.
435        Unspecified,
436        /// The ADB device is in the "device" status.
437        Device,
438        /// The ADB device is in the "recovery" status.
439        Recovery,
440        /// The ADB device is in the "rescue" status.
441        Rescue,
442        /// The ADB device is in the "sideload" status.
443        Sideload,
444        /// The ADB device is in the "missing" status.
445        Missing,
446        /// The ADB device is in the "offline" status.
447        Offline,
448        /// The ADB device is in the "unauthorized" status.
449        Unauthorized,
450        /// The ADB device is in the "authorizing" status.
451        Authorizing,
452        /// The ADB device is in the "connecting" status.
453        Connecting,
454        /// If set, the enum was initialized with an unknown value.
455        ///
456        /// Applications can examine the value using [DeviceState::value] or
457        /// [DeviceState::name].
458        UnknownValue(device_state::UnknownValue),
459    }
460
461    #[doc(hidden)]
462    pub mod device_state {
463        #[allow(unused_imports)]
464        use super::*;
465        #[derive(Clone, Debug, PartialEq)]
466        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
467    }
468
469    impl DeviceState {
470        /// Gets the enum value.
471        ///
472        /// Returns `None` if the enum contains an unknown value deserialized from
473        /// the string representation of enums.
474        pub fn value(&self) -> std::option::Option<i32> {
475            match self {
476                Self::Unspecified => std::option::Option::Some(0),
477                Self::Device => std::option::Option::Some(1),
478                Self::Recovery => std::option::Option::Some(2),
479                Self::Rescue => std::option::Option::Some(3),
480                Self::Sideload => std::option::Option::Some(4),
481                Self::Missing => std::option::Option::Some(10),
482                Self::Offline => std::option::Option::Some(11),
483                Self::Unauthorized => std::option::Option::Some(12),
484                Self::Authorizing => std::option::Option::Some(13),
485                Self::Connecting => std::option::Option::Some(14),
486                Self::UnknownValue(u) => u.0.value(),
487            }
488        }
489
490        /// Gets the enum value as a string.
491        ///
492        /// Returns `None` if the enum contains an unknown value deserialized from
493        /// the integer representation of enums.
494        pub fn name(&self) -> std::option::Option<&str> {
495            match self {
496                Self::Unspecified => std::option::Option::Some("DEVICE_STATE_UNSPECIFIED"),
497                Self::Device => std::option::Option::Some("DEVICE"),
498                Self::Recovery => std::option::Option::Some("RECOVERY"),
499                Self::Rescue => std::option::Option::Some("RESCUE"),
500                Self::Sideload => std::option::Option::Some("SIDELOAD"),
501                Self::Missing => std::option::Option::Some("MISSING"),
502                Self::Offline => std::option::Option::Some("OFFLINE"),
503                Self::Unauthorized => std::option::Option::Some("UNAUTHORIZED"),
504                Self::Authorizing => std::option::Option::Some("AUTHORIZING"),
505                Self::Connecting => std::option::Option::Some("CONNECTING"),
506                Self::UnknownValue(u) => u.0.name(),
507            }
508        }
509    }
510
511    impl std::default::Default for DeviceState {
512        fn default() -> Self {
513            use std::convert::From;
514            Self::from(0)
515        }
516    }
517
518    impl std::fmt::Display for DeviceState {
519        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
520            wkt::internal::display_enum(f, self.name(), self.value())
521        }
522    }
523
524    impl std::convert::From<i32> for DeviceState {
525        fn from(value: i32) -> Self {
526            match value {
527                0 => Self::Unspecified,
528                1 => Self::Device,
529                2 => Self::Recovery,
530                3 => Self::Rescue,
531                4 => Self::Sideload,
532                10 => Self::Missing,
533                11 => Self::Offline,
534                12 => Self::Unauthorized,
535                13 => Self::Authorizing,
536                14 => Self::Connecting,
537                _ => Self::UnknownValue(device_state::UnknownValue(
538                    wkt::internal::UnknownEnumValue::Integer(value),
539                )),
540            }
541        }
542    }
543
544    impl std::convert::From<&str> for DeviceState {
545        fn from(value: &str) -> Self {
546            use std::string::ToString;
547            match value {
548                "DEVICE_STATE_UNSPECIFIED" => Self::Unspecified,
549                "DEVICE" => Self::Device,
550                "RECOVERY" => Self::Recovery,
551                "RESCUE" => Self::Rescue,
552                "SIDELOAD" => Self::Sideload,
553                "MISSING" => Self::Missing,
554                "OFFLINE" => Self::Offline,
555                "UNAUTHORIZED" => Self::Unauthorized,
556                "AUTHORIZING" => Self::Authorizing,
557                "CONNECTING" => Self::Connecting,
558                _ => Self::UnknownValue(device_state::UnknownValue(
559                    wkt::internal::UnknownEnumValue::String(value.to_string()),
560                )),
561            }
562        }
563    }
564
565    impl serde::ser::Serialize for DeviceState {
566        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
567        where
568            S: serde::Serializer,
569        {
570            match self {
571                Self::Unspecified => serializer.serialize_i32(0),
572                Self::Device => serializer.serialize_i32(1),
573                Self::Recovery => serializer.serialize_i32(2),
574                Self::Rescue => serializer.serialize_i32(3),
575                Self::Sideload => serializer.serialize_i32(4),
576                Self::Missing => serializer.serialize_i32(10),
577                Self::Offline => serializer.serialize_i32(11),
578                Self::Unauthorized => serializer.serialize_i32(12),
579                Self::Authorizing => serializer.serialize_i32(13),
580                Self::Connecting => serializer.serialize_i32(14),
581                Self::UnknownValue(u) => u.0.serialize(serializer),
582            }
583        }
584    }
585
586    impl<'de> serde::de::Deserialize<'de> for DeviceState {
587        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
588        where
589            D: serde::Deserializer<'de>,
590        {
591            deserializer.deserialize_any(wkt::internal::EnumVisitor::<DeviceState>::new(
592                ".google.cloud.devicestreaming.v1.StatusUpdate.DeviceState",
593            ))
594        }
595    }
596}
597
598/// The result of a stream.
599#[derive(Clone, Default, PartialEq)]
600#[non_exhaustive]
601pub struct StreamStatus {
602    /// The unique ID of this stream, assigned by the client.
603    pub stream_id: i32,
604
605    /// The result of the stream. Either "Okay" for success or "Fail" for failure.
606    pub status: std::option::Option<crate::model::stream_status::Status>,
607
608    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
609}
610
611impl StreamStatus {
612    pub fn new() -> Self {
613        std::default::Default::default()
614    }
615
616    /// Sets the value of [stream_id][crate::model::StreamStatus::stream_id].
617    ///
618    /// # Example
619    /// ```ignore,no_run
620    /// # use google_cloud_devicestreaming_v1::model::StreamStatus;
621    /// let x = StreamStatus::new().set_stream_id(42);
622    /// ```
623    pub fn set_stream_id<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
624        self.stream_id = v.into();
625        self
626    }
627
628    /// Sets the value of [status][crate::model::StreamStatus::status].
629    ///
630    /// Note that all the setters affecting `status` are mutually
631    /// exclusive.
632    ///
633    /// # Example
634    /// ```ignore,no_run
635    /// # use google_cloud_devicestreaming_v1::model::StreamStatus;
636    /// use google_cloud_devicestreaming_v1::model::Okay;
637    /// let x = StreamStatus::new().set_status(Some(
638    ///     google_cloud_devicestreaming_v1::model::stream_status::Status::Okay(Okay::default().into())));
639    /// ```
640    pub fn set_status<
641        T: std::convert::Into<std::option::Option<crate::model::stream_status::Status>>,
642    >(
643        mut self,
644        v: T,
645    ) -> Self {
646        self.status = v.into();
647        self
648    }
649
650    /// The value of [status][crate::model::StreamStatus::status]
651    /// if it holds a `Okay`, `None` if the field is not set or
652    /// holds a different branch.
653    pub fn okay(&self) -> std::option::Option<&std::boxed::Box<crate::model::Okay>> {
654        #[allow(unreachable_patterns)]
655        self.status.as_ref().and_then(|v| match v {
656            crate::model::stream_status::Status::Okay(v) => std::option::Option::Some(v),
657            _ => std::option::Option::None,
658        })
659    }
660
661    /// Sets the value of [status][crate::model::StreamStatus::status]
662    /// to hold a `Okay`.
663    ///
664    /// Note that all the setters affecting `status` are
665    /// mutually exclusive.
666    ///
667    /// # Example
668    /// ```ignore,no_run
669    /// # use google_cloud_devicestreaming_v1::model::StreamStatus;
670    /// use google_cloud_devicestreaming_v1::model::Okay;
671    /// let x = StreamStatus::new().set_okay(Okay::default()/* use setters */);
672    /// assert!(x.okay().is_some());
673    /// assert!(x.fail().is_none());
674    /// ```
675    pub fn set_okay<T: std::convert::Into<std::boxed::Box<crate::model::Okay>>>(
676        mut self,
677        v: T,
678    ) -> Self {
679        self.status =
680            std::option::Option::Some(crate::model::stream_status::Status::Okay(v.into()));
681        self
682    }
683
684    /// The value of [status][crate::model::StreamStatus::status]
685    /// if it holds a `Fail`, `None` if the field is not set or
686    /// holds a different branch.
687    pub fn fail(&self) -> std::option::Option<&std::boxed::Box<crate::model::Fail>> {
688        #[allow(unreachable_patterns)]
689        self.status.as_ref().and_then(|v| match v {
690            crate::model::stream_status::Status::Fail(v) => std::option::Option::Some(v),
691            _ => std::option::Option::None,
692        })
693    }
694
695    /// Sets the value of [status][crate::model::StreamStatus::status]
696    /// to hold a `Fail`.
697    ///
698    /// Note that all the setters affecting `status` are
699    /// mutually exclusive.
700    ///
701    /// # Example
702    /// ```ignore,no_run
703    /// # use google_cloud_devicestreaming_v1::model::StreamStatus;
704    /// use google_cloud_devicestreaming_v1::model::Fail;
705    /// let x = StreamStatus::new().set_fail(Fail::default()/* use setters */);
706    /// assert!(x.fail().is_some());
707    /// assert!(x.okay().is_none());
708    /// ```
709    pub fn set_fail<T: std::convert::Into<std::boxed::Box<crate::model::Fail>>>(
710        mut self,
711        v: T,
712    ) -> Self {
713        self.status =
714            std::option::Option::Some(crate::model::stream_status::Status::Fail(v.into()));
715        self
716    }
717}
718
719impl wkt::message::Message for StreamStatus {
720    fn typename() -> &'static str {
721        "type.googleapis.com/google.cloud.devicestreaming.v1.StreamStatus"
722    }
723}
724
725/// Defines additional types related to [StreamStatus].
726pub mod stream_status {
727    #[allow(unused_imports)]
728    use super::*;
729
730    /// The result of the stream. Either "Okay" for success or "Fail" for failure.
731    #[derive(Clone, Debug, PartialEq)]
732    #[non_exhaustive]
733    pub enum Status {
734        /// Okay for success.
735        Okay(std::boxed::Box<crate::model::Okay>),
736        /// Fail for failure.
737        Fail(std::boxed::Box<crate::model::Fail>),
738    }
739}
740
741/// Message for opening a new stream.
742#[derive(Clone, Default, PartialEq)]
743#[non_exhaustive]
744pub struct Open {
745    /// Required. The unique ID that will be used to talk to this stream. This
746    /// should probably just be a number that increments for each new Open request.
747    pub stream_id: i32,
748
749    /// Optional. An ADB service to use in the new stream.
750    pub service: std::string::String,
751
752    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
753}
754
755impl Open {
756    pub fn new() -> Self {
757        std::default::Default::default()
758    }
759
760    /// Sets the value of [stream_id][crate::model::Open::stream_id].
761    ///
762    /// # Example
763    /// ```ignore,no_run
764    /// # use google_cloud_devicestreaming_v1::model::Open;
765    /// let x = Open::new().set_stream_id(42);
766    /// ```
767    pub fn set_stream_id<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
768        self.stream_id = v.into();
769        self
770    }
771
772    /// Sets the value of [service][crate::model::Open::service].
773    ///
774    /// # Example
775    /// ```ignore,no_run
776    /// # use google_cloud_devicestreaming_v1::model::Open;
777    /// let x = Open::new().set_service("example");
778    /// ```
779    pub fn set_service<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
780        self.service = v.into();
781        self
782    }
783}
784
785impl wkt::message::Message for Open {
786    fn typename() -> &'static str {
787        "type.googleapis.com/google.cloud.devicestreaming.v1.Open"
788    }
789}
790
791/// Data for a stream.
792#[derive(Clone, Default, PartialEq)]
793#[non_exhaustive]
794pub struct StreamData {
795    /// Required. The unique ID of this stream, assigned by the client.
796    pub stream_id: i32,
797
798    /// The data of the stream, either bytes or "Close", indicating that the stream
799    /// is done.
800    pub contents: std::option::Option<crate::model::stream_data::Contents>,
801
802    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
803}
804
805impl StreamData {
806    pub fn new() -> Self {
807        std::default::Default::default()
808    }
809
810    /// Sets the value of [stream_id][crate::model::StreamData::stream_id].
811    ///
812    /// # Example
813    /// ```ignore,no_run
814    /// # use google_cloud_devicestreaming_v1::model::StreamData;
815    /// let x = StreamData::new().set_stream_id(42);
816    /// ```
817    pub fn set_stream_id<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
818        self.stream_id = v.into();
819        self
820    }
821
822    /// Sets the value of [contents][crate::model::StreamData::contents].
823    ///
824    /// Note that all the setters affecting `contents` are mutually
825    /// exclusive.
826    ///
827    /// # Example
828    /// ```ignore,no_run
829    /// # use google_cloud_devicestreaming_v1::model::StreamData;
830    /// use google_cloud_devicestreaming_v1::model::stream_data::Contents;
831    /// let x = StreamData::new().set_contents(Some(Contents::Data(bytes::Bytes::from_static(b"example"))));
832    /// ```
833    pub fn set_contents<
834        T: std::convert::Into<std::option::Option<crate::model::stream_data::Contents>>,
835    >(
836        mut self,
837        v: T,
838    ) -> Self {
839        self.contents = v.into();
840        self
841    }
842
843    /// The value of [contents][crate::model::StreamData::contents]
844    /// if it holds a `Data`, `None` if the field is not set or
845    /// holds a different branch.
846    pub fn data(&self) -> std::option::Option<&::bytes::Bytes> {
847        #[allow(unreachable_patterns)]
848        self.contents.as_ref().and_then(|v| match v {
849            crate::model::stream_data::Contents::Data(v) => std::option::Option::Some(v),
850            _ => std::option::Option::None,
851        })
852    }
853
854    /// Sets the value of [contents][crate::model::StreamData::contents]
855    /// to hold a `Data`.
856    ///
857    /// Note that all the setters affecting `contents` are
858    /// mutually exclusive.
859    ///
860    /// # Example
861    /// ```ignore,no_run
862    /// # use google_cloud_devicestreaming_v1::model::StreamData;
863    /// let x = StreamData::new().set_data(bytes::Bytes::from_static(b"example"));
864    /// assert!(x.data().is_some());
865    /// assert!(x.close().is_none());
866    /// ```
867    pub fn set_data<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
868        self.contents =
869            std::option::Option::Some(crate::model::stream_data::Contents::Data(v.into()));
870        self
871    }
872
873    /// The value of [contents][crate::model::StreamData::contents]
874    /// if it holds a `Close`, `None` if the field is not set or
875    /// holds a different branch.
876    pub fn close(&self) -> std::option::Option<&std::boxed::Box<crate::model::Close>> {
877        #[allow(unreachable_patterns)]
878        self.contents.as_ref().and_then(|v| match v {
879            crate::model::stream_data::Contents::Close(v) => std::option::Option::Some(v),
880            _ => std::option::Option::None,
881        })
882    }
883
884    /// Sets the value of [contents][crate::model::StreamData::contents]
885    /// to hold a `Close`.
886    ///
887    /// Note that all the setters affecting `contents` are
888    /// mutually exclusive.
889    ///
890    /// # Example
891    /// ```ignore,no_run
892    /// # use google_cloud_devicestreaming_v1::model::StreamData;
893    /// use google_cloud_devicestreaming_v1::model::Close;
894    /// let x = StreamData::new().set_close(Close::default()/* use setters */);
895    /// assert!(x.close().is_some());
896    /// assert!(x.data().is_none());
897    /// ```
898    pub fn set_close<T: std::convert::Into<std::boxed::Box<crate::model::Close>>>(
899        mut self,
900        v: T,
901    ) -> Self {
902        self.contents =
903            std::option::Option::Some(crate::model::stream_data::Contents::Close(v.into()));
904        self
905    }
906}
907
908impl wkt::message::Message for StreamData {
909    fn typename() -> &'static str {
910        "type.googleapis.com/google.cloud.devicestreaming.v1.StreamData"
911    }
912}
913
914/// Defines additional types related to [StreamData].
915pub mod stream_data {
916    #[allow(unused_imports)]
917    use super::*;
918
919    /// The data of the stream, either bytes or "Close", indicating that the stream
920    /// is done.
921    #[derive(Clone, Debug, PartialEq)]
922    #[non_exhaustive]
923    pub enum Contents {
924        /// Data in the stream.
925        Data(::bytes::Bytes),
926        /// The stream is closing. EOF.
927        Close(std::boxed::Box<crate::model::Close>),
928    }
929}
930
931/// Message signifying that the stream is open
932#[derive(Clone, Default, PartialEq)]
933#[non_exhaustive]
934pub struct Okay {
935    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
936}
937
938impl Okay {
939    pub fn new() -> Self {
940        std::default::Default::default()
941    }
942}
943
944impl wkt::message::Message for Okay {
945    fn typename() -> &'static str {
946        "type.googleapis.com/google.cloud.devicestreaming.v1.Okay"
947    }
948}
949
950/// Message signifying that the stream failed to open
951#[derive(Clone, Default, PartialEq)]
952#[non_exhaustive]
953pub struct Fail {
954    /// A user-displayable failure reason.
955    pub reason: std::string::String,
956
957    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
958}
959
960impl Fail {
961    pub fn new() -> Self {
962        std::default::Default::default()
963    }
964
965    /// Sets the value of [reason][crate::model::Fail::reason].
966    ///
967    /// # Example
968    /// ```ignore,no_run
969    /// # use google_cloud_devicestreaming_v1::model::Fail;
970    /// let x = Fail::new().set_reason("example");
971    /// ```
972    pub fn set_reason<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
973        self.reason = v.into();
974        self
975    }
976}
977
978impl wkt::message::Message for Fail {
979    fn typename() -> &'static str {
980        "type.googleapis.com/google.cloud.devicestreaming.v1.Fail"
981    }
982}
983
984/// Message signifying that the stream closed.
985#[derive(Clone, Default, PartialEq)]
986#[non_exhaustive]
987pub struct Close {
988    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
989}
990
991impl Close {
992    pub fn new() -> Self {
993        std::default::Default::default()
994    }
995}
996
997impl wkt::message::Message for Close {
998    fn typename() -> &'static str {
999        "type.googleapis.com/google.cloud.devicestreaming.v1.Close"
1000    }
1001}
1002
1003/// Request message for DirectAccessService.CreateDeviceSession.
1004#[derive(Clone, Default, PartialEq)]
1005#[non_exhaustive]
1006pub struct CreateDeviceSessionRequest {
1007    /// Required. The Compute Engine project under which this device will be
1008    /// allocated. "projects/{project_id}"
1009    pub parent: std::string::String,
1010
1011    /// Required. A DeviceSession to create.
1012    pub device_session: std::option::Option<crate::model::DeviceSession>,
1013
1014    /// Optional. The ID to use for the DeviceSession, which will become the final
1015    /// component of the DeviceSession's resource name.
1016    ///
1017    /// This value should be 4-63 characters, and valid characters
1018    /// are /[a-z][0-9]-/.
1019    pub device_session_id: std::string::String,
1020
1021    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1022}
1023
1024impl CreateDeviceSessionRequest {
1025    pub fn new() -> Self {
1026        std::default::Default::default()
1027    }
1028
1029    /// Sets the value of [parent][crate::model::CreateDeviceSessionRequest::parent].
1030    ///
1031    /// # Example
1032    /// ```ignore,no_run
1033    /// # use google_cloud_devicestreaming_v1::model::CreateDeviceSessionRequest;
1034    /// let x = CreateDeviceSessionRequest::new().set_parent("example");
1035    /// ```
1036    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1037        self.parent = v.into();
1038        self
1039    }
1040
1041    /// Sets the value of [device_session][crate::model::CreateDeviceSessionRequest::device_session].
1042    ///
1043    /// # Example
1044    /// ```ignore,no_run
1045    /// # use google_cloud_devicestreaming_v1::model::CreateDeviceSessionRequest;
1046    /// use google_cloud_devicestreaming_v1::model::DeviceSession;
1047    /// let x = CreateDeviceSessionRequest::new().set_device_session(DeviceSession::default()/* use setters */);
1048    /// ```
1049    pub fn set_device_session<T>(mut self, v: T) -> Self
1050    where
1051        T: std::convert::Into<crate::model::DeviceSession>,
1052    {
1053        self.device_session = std::option::Option::Some(v.into());
1054        self
1055    }
1056
1057    /// Sets or clears the value of [device_session][crate::model::CreateDeviceSessionRequest::device_session].
1058    ///
1059    /// # Example
1060    /// ```ignore,no_run
1061    /// # use google_cloud_devicestreaming_v1::model::CreateDeviceSessionRequest;
1062    /// use google_cloud_devicestreaming_v1::model::DeviceSession;
1063    /// let x = CreateDeviceSessionRequest::new().set_or_clear_device_session(Some(DeviceSession::default()/* use setters */));
1064    /// let x = CreateDeviceSessionRequest::new().set_or_clear_device_session(None::<DeviceSession>);
1065    /// ```
1066    pub fn set_or_clear_device_session<T>(mut self, v: std::option::Option<T>) -> Self
1067    where
1068        T: std::convert::Into<crate::model::DeviceSession>,
1069    {
1070        self.device_session = v.map(|x| x.into());
1071        self
1072    }
1073
1074    /// Sets the value of [device_session_id][crate::model::CreateDeviceSessionRequest::device_session_id].
1075    ///
1076    /// # Example
1077    /// ```ignore,no_run
1078    /// # use google_cloud_devicestreaming_v1::model::CreateDeviceSessionRequest;
1079    /// let x = CreateDeviceSessionRequest::new().set_device_session_id("example");
1080    /// ```
1081    pub fn set_device_session_id<T: std::convert::Into<std::string::String>>(
1082        mut self,
1083        v: T,
1084    ) -> Self {
1085        self.device_session_id = v.into();
1086        self
1087    }
1088}
1089
1090impl wkt::message::Message for CreateDeviceSessionRequest {
1091    fn typename() -> &'static str {
1092        "type.googleapis.com/google.cloud.devicestreaming.v1.CreateDeviceSessionRequest"
1093    }
1094}
1095
1096/// Request message for DirectAccessService.ListDeviceSessions.
1097#[derive(Clone, Default, PartialEq)]
1098#[non_exhaustive]
1099pub struct ListDeviceSessionsRequest {
1100    /// Required. The name of the parent to request, e.g. "projects/{project_id}"
1101    pub parent: std::string::String,
1102
1103    /// Optional. The maximum number of DeviceSessions to return.
1104    pub page_size: i32,
1105
1106    /// Optional. A continuation token for paging.
1107    pub page_token: std::string::String,
1108
1109    /// Optional. If specified, responses will be filtered by the given filter.
1110    /// Allowed fields are: session_state.
1111    pub filter: std::string::String,
1112
1113    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1114}
1115
1116impl ListDeviceSessionsRequest {
1117    pub fn new() -> Self {
1118        std::default::Default::default()
1119    }
1120
1121    /// Sets the value of [parent][crate::model::ListDeviceSessionsRequest::parent].
1122    ///
1123    /// # Example
1124    /// ```ignore,no_run
1125    /// # use google_cloud_devicestreaming_v1::model::ListDeviceSessionsRequest;
1126    /// let x = ListDeviceSessionsRequest::new().set_parent("example");
1127    /// ```
1128    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1129        self.parent = v.into();
1130        self
1131    }
1132
1133    /// Sets the value of [page_size][crate::model::ListDeviceSessionsRequest::page_size].
1134    ///
1135    /// # Example
1136    /// ```ignore,no_run
1137    /// # use google_cloud_devicestreaming_v1::model::ListDeviceSessionsRequest;
1138    /// let x = ListDeviceSessionsRequest::new().set_page_size(42);
1139    /// ```
1140    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1141        self.page_size = v.into();
1142        self
1143    }
1144
1145    /// Sets the value of [page_token][crate::model::ListDeviceSessionsRequest::page_token].
1146    ///
1147    /// # Example
1148    /// ```ignore,no_run
1149    /// # use google_cloud_devicestreaming_v1::model::ListDeviceSessionsRequest;
1150    /// let x = ListDeviceSessionsRequest::new().set_page_token("example");
1151    /// ```
1152    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1153        self.page_token = v.into();
1154        self
1155    }
1156
1157    /// Sets the value of [filter][crate::model::ListDeviceSessionsRequest::filter].
1158    ///
1159    /// # Example
1160    /// ```ignore,no_run
1161    /// # use google_cloud_devicestreaming_v1::model::ListDeviceSessionsRequest;
1162    /// let x = ListDeviceSessionsRequest::new().set_filter("example");
1163    /// ```
1164    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1165        self.filter = v.into();
1166        self
1167    }
1168}
1169
1170impl wkt::message::Message for ListDeviceSessionsRequest {
1171    fn typename() -> &'static str {
1172        "type.googleapis.com/google.cloud.devicestreaming.v1.ListDeviceSessionsRequest"
1173    }
1174}
1175
1176/// Response message for DirectAccessService.ListDeviceSessions.
1177#[derive(Clone, Default, PartialEq)]
1178#[non_exhaustive]
1179pub struct ListDeviceSessionsResponse {
1180    /// The sessions matching the specified filter in the given cloud project.
1181    pub device_sessions: std::vec::Vec<crate::model::DeviceSession>,
1182
1183    /// A token, which can be sent as `page_token` to retrieve the next page.
1184    /// If this field is omitted, there are no subsequent pages.
1185    pub next_page_token: std::string::String,
1186
1187    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1188}
1189
1190impl ListDeviceSessionsResponse {
1191    pub fn new() -> Self {
1192        std::default::Default::default()
1193    }
1194
1195    /// Sets the value of [device_sessions][crate::model::ListDeviceSessionsResponse::device_sessions].
1196    ///
1197    /// # Example
1198    /// ```ignore,no_run
1199    /// # use google_cloud_devicestreaming_v1::model::ListDeviceSessionsResponse;
1200    /// use google_cloud_devicestreaming_v1::model::DeviceSession;
1201    /// let x = ListDeviceSessionsResponse::new()
1202    ///     .set_device_sessions([
1203    ///         DeviceSession::default()/* use setters */,
1204    ///         DeviceSession::default()/* use (different) setters */,
1205    ///     ]);
1206    /// ```
1207    pub fn set_device_sessions<T, V>(mut self, v: T) -> Self
1208    where
1209        T: std::iter::IntoIterator<Item = V>,
1210        V: std::convert::Into<crate::model::DeviceSession>,
1211    {
1212        use std::iter::Iterator;
1213        self.device_sessions = v.into_iter().map(|i| i.into()).collect();
1214        self
1215    }
1216
1217    /// Sets the value of [next_page_token][crate::model::ListDeviceSessionsResponse::next_page_token].
1218    ///
1219    /// # Example
1220    /// ```ignore,no_run
1221    /// # use google_cloud_devicestreaming_v1::model::ListDeviceSessionsResponse;
1222    /// let x = ListDeviceSessionsResponse::new().set_next_page_token("example");
1223    /// ```
1224    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1225        self.next_page_token = v.into();
1226        self
1227    }
1228}
1229
1230impl wkt::message::Message for ListDeviceSessionsResponse {
1231    fn typename() -> &'static str {
1232        "type.googleapis.com/google.cloud.devicestreaming.v1.ListDeviceSessionsResponse"
1233    }
1234}
1235
1236#[doc(hidden)]
1237impl google_cloud_gax::paginator::internal::PageableResponse for ListDeviceSessionsResponse {
1238    type PageItem = crate::model::DeviceSession;
1239
1240    fn items(self) -> std::vec::Vec<Self::PageItem> {
1241        self.device_sessions
1242    }
1243
1244    fn next_page_token(&self) -> std::string::String {
1245        use std::clone::Clone;
1246        self.next_page_token.clone()
1247    }
1248}
1249
1250/// Request message for DirectAccessService.GetDeviceSession.
1251#[derive(Clone, Default, PartialEq)]
1252#[non_exhaustive]
1253pub struct GetDeviceSessionRequest {
1254    /// Required. Name of the DeviceSession, e.g.
1255    /// "projects/{project_id}/deviceSessions/{session_id}"
1256    pub name: std::string::String,
1257
1258    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1259}
1260
1261impl GetDeviceSessionRequest {
1262    pub fn new() -> Self {
1263        std::default::Default::default()
1264    }
1265
1266    /// Sets the value of [name][crate::model::GetDeviceSessionRequest::name].
1267    ///
1268    /// # Example
1269    /// ```ignore,no_run
1270    /// # use google_cloud_devicestreaming_v1::model::GetDeviceSessionRequest;
1271    /// let x = GetDeviceSessionRequest::new().set_name("example");
1272    /// ```
1273    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1274        self.name = v.into();
1275        self
1276    }
1277}
1278
1279impl wkt::message::Message for GetDeviceSessionRequest {
1280    fn typename() -> &'static str {
1281        "type.googleapis.com/google.cloud.devicestreaming.v1.GetDeviceSessionRequest"
1282    }
1283}
1284
1285/// Request message for DirectAccessService.CancelDeviceSession.
1286#[derive(Clone, Default, PartialEq)]
1287#[non_exhaustive]
1288pub struct CancelDeviceSessionRequest {
1289    /// Required. Name of the DeviceSession, e.g.
1290    /// "projects/{project_id}/deviceSessions/{session_id}"
1291    pub name: std::string::String,
1292
1293    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1294}
1295
1296impl CancelDeviceSessionRequest {
1297    pub fn new() -> Self {
1298        std::default::Default::default()
1299    }
1300
1301    /// Sets the value of [name][crate::model::CancelDeviceSessionRequest::name].
1302    ///
1303    /// # Example
1304    /// ```ignore,no_run
1305    /// # use google_cloud_devicestreaming_v1::model::CancelDeviceSessionRequest;
1306    /// let x = CancelDeviceSessionRequest::new().set_name("example");
1307    /// ```
1308    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1309        self.name = v.into();
1310        self
1311    }
1312}
1313
1314impl wkt::message::Message for CancelDeviceSessionRequest {
1315    fn typename() -> &'static str {
1316        "type.googleapis.com/google.cloud.devicestreaming.v1.CancelDeviceSessionRequest"
1317    }
1318}
1319
1320/// Request message for DirectAccessService.UpdateDeviceSession.
1321#[derive(Clone, Default, PartialEq)]
1322#[non_exhaustive]
1323pub struct UpdateDeviceSessionRequest {
1324    /// Required. DeviceSession to update.
1325    /// The DeviceSession's `name` field is used to identify the session to update
1326    /// "projects/{project_id}/deviceSessions/{session_id}"
1327    pub device_session: std::option::Option<crate::model::DeviceSession>,
1328
1329    /// Optional. The list of fields to update.
1330    pub update_mask: std::option::Option<wkt::FieldMask>,
1331
1332    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1333}
1334
1335impl UpdateDeviceSessionRequest {
1336    pub fn new() -> Self {
1337        std::default::Default::default()
1338    }
1339
1340    /// Sets the value of [device_session][crate::model::UpdateDeviceSessionRequest::device_session].
1341    ///
1342    /// # Example
1343    /// ```ignore,no_run
1344    /// # use google_cloud_devicestreaming_v1::model::UpdateDeviceSessionRequest;
1345    /// use google_cloud_devicestreaming_v1::model::DeviceSession;
1346    /// let x = UpdateDeviceSessionRequest::new().set_device_session(DeviceSession::default()/* use setters */);
1347    /// ```
1348    pub fn set_device_session<T>(mut self, v: T) -> Self
1349    where
1350        T: std::convert::Into<crate::model::DeviceSession>,
1351    {
1352        self.device_session = std::option::Option::Some(v.into());
1353        self
1354    }
1355
1356    /// Sets or clears the value of [device_session][crate::model::UpdateDeviceSessionRequest::device_session].
1357    ///
1358    /// # Example
1359    /// ```ignore,no_run
1360    /// # use google_cloud_devicestreaming_v1::model::UpdateDeviceSessionRequest;
1361    /// use google_cloud_devicestreaming_v1::model::DeviceSession;
1362    /// let x = UpdateDeviceSessionRequest::new().set_or_clear_device_session(Some(DeviceSession::default()/* use setters */));
1363    /// let x = UpdateDeviceSessionRequest::new().set_or_clear_device_session(None::<DeviceSession>);
1364    /// ```
1365    pub fn set_or_clear_device_session<T>(mut self, v: std::option::Option<T>) -> Self
1366    where
1367        T: std::convert::Into<crate::model::DeviceSession>,
1368    {
1369        self.device_session = v.map(|x| x.into());
1370        self
1371    }
1372
1373    /// Sets the value of [update_mask][crate::model::UpdateDeviceSessionRequest::update_mask].
1374    ///
1375    /// # Example
1376    /// ```ignore,no_run
1377    /// # use google_cloud_devicestreaming_v1::model::UpdateDeviceSessionRequest;
1378    /// use wkt::FieldMask;
1379    /// let x = UpdateDeviceSessionRequest::new().set_update_mask(FieldMask::default()/* use setters */);
1380    /// ```
1381    pub fn set_update_mask<T>(mut self, v: T) -> Self
1382    where
1383        T: std::convert::Into<wkt::FieldMask>,
1384    {
1385        self.update_mask = std::option::Option::Some(v.into());
1386        self
1387    }
1388
1389    /// Sets or clears the value of [update_mask][crate::model::UpdateDeviceSessionRequest::update_mask].
1390    ///
1391    /// # Example
1392    /// ```ignore,no_run
1393    /// # use google_cloud_devicestreaming_v1::model::UpdateDeviceSessionRequest;
1394    /// use wkt::FieldMask;
1395    /// let x = UpdateDeviceSessionRequest::new().set_or_clear_update_mask(Some(FieldMask::default()/* use setters */));
1396    /// let x = UpdateDeviceSessionRequest::new().set_or_clear_update_mask(None::<FieldMask>);
1397    /// ```
1398    pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
1399    where
1400        T: std::convert::Into<wkt::FieldMask>,
1401    {
1402        self.update_mask = v.map(|x| x.into());
1403        self
1404    }
1405}
1406
1407impl wkt::message::Message for UpdateDeviceSessionRequest {
1408    fn typename() -> &'static str {
1409        "type.googleapis.com/google.cloud.devicestreaming.v1.UpdateDeviceSessionRequest"
1410    }
1411}
1412
1413/// Protobuf message describing the device message, used from several RPCs.
1414#[derive(Clone, Default, PartialEq)]
1415#[non_exhaustive]
1416pub struct DeviceSession {
1417    /// Optional. Name of the DeviceSession, e.g.
1418    /// "projects/{project_id}/deviceSessions/{session_id}"
1419    pub name: std::string::String,
1420
1421    /// Output only. The title of the DeviceSession to be presented in the UI.
1422    pub display_name: std::string::String,
1423
1424    /// Output only. Current state of the DeviceSession.
1425    pub state: crate::model::device_session::SessionState,
1426
1427    /// Output only. The historical state transitions of the session_state message
1428    /// including the current session state.
1429    pub state_histories: std::vec::Vec<crate::model::device_session::SessionStateEvent>,
1430
1431    /// Output only. The interval of time that this device must be interacted with
1432    /// before it transitions from ACTIVE to TIMEOUT_INACTIVITY.
1433    pub inactivity_timeout: std::option::Option<wkt::Duration>,
1434
1435    /// Output only. The time that the Session was created.
1436    pub create_time: std::option::Option<wkt::Timestamp>,
1437
1438    /// Output only. The timestamp that the session first became ACTIVE.
1439    pub active_start_time: std::option::Option<wkt::Timestamp>,
1440
1441    /// Required. The requested device
1442    pub android_device: std::option::Option<crate::model::AndroidDevice>,
1443
1444    /// The amount of time that a device will be initially allocated for.
1445    pub expiration: std::option::Option<crate::model::device_session::Expiration>,
1446
1447    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1448}
1449
1450impl DeviceSession {
1451    pub fn new() -> Self {
1452        std::default::Default::default()
1453    }
1454
1455    /// Sets the value of [name][crate::model::DeviceSession::name].
1456    ///
1457    /// # Example
1458    /// ```ignore,no_run
1459    /// # use google_cloud_devicestreaming_v1::model::DeviceSession;
1460    /// let x = DeviceSession::new().set_name("example");
1461    /// ```
1462    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1463        self.name = v.into();
1464        self
1465    }
1466
1467    /// Sets the value of [display_name][crate::model::DeviceSession::display_name].
1468    ///
1469    /// # Example
1470    /// ```ignore,no_run
1471    /// # use google_cloud_devicestreaming_v1::model::DeviceSession;
1472    /// let x = DeviceSession::new().set_display_name("example");
1473    /// ```
1474    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1475        self.display_name = v.into();
1476        self
1477    }
1478
1479    /// Sets the value of [state][crate::model::DeviceSession::state].
1480    ///
1481    /// # Example
1482    /// ```ignore,no_run
1483    /// # use google_cloud_devicestreaming_v1::model::DeviceSession;
1484    /// use google_cloud_devicestreaming_v1::model::device_session::SessionState;
1485    /// let x0 = DeviceSession::new().set_state(SessionState::Requested);
1486    /// let x1 = DeviceSession::new().set_state(SessionState::Pending);
1487    /// let x2 = DeviceSession::new().set_state(SessionState::Active);
1488    /// ```
1489    pub fn set_state<T: std::convert::Into<crate::model::device_session::SessionState>>(
1490        mut self,
1491        v: T,
1492    ) -> Self {
1493        self.state = v.into();
1494        self
1495    }
1496
1497    /// Sets the value of [state_histories][crate::model::DeviceSession::state_histories].
1498    ///
1499    /// # Example
1500    /// ```ignore,no_run
1501    /// # use google_cloud_devicestreaming_v1::model::DeviceSession;
1502    /// use google_cloud_devicestreaming_v1::model::device_session::SessionStateEvent;
1503    /// let x = DeviceSession::new()
1504    ///     .set_state_histories([
1505    ///         SessionStateEvent::default()/* use setters */,
1506    ///         SessionStateEvent::default()/* use (different) setters */,
1507    ///     ]);
1508    /// ```
1509    pub fn set_state_histories<T, V>(mut self, v: T) -> Self
1510    where
1511        T: std::iter::IntoIterator<Item = V>,
1512        V: std::convert::Into<crate::model::device_session::SessionStateEvent>,
1513    {
1514        use std::iter::Iterator;
1515        self.state_histories = v.into_iter().map(|i| i.into()).collect();
1516        self
1517    }
1518
1519    /// Sets the value of [inactivity_timeout][crate::model::DeviceSession::inactivity_timeout].
1520    ///
1521    /// # Example
1522    /// ```ignore,no_run
1523    /// # use google_cloud_devicestreaming_v1::model::DeviceSession;
1524    /// use wkt::Duration;
1525    /// let x = DeviceSession::new().set_inactivity_timeout(Duration::default()/* use setters */);
1526    /// ```
1527    pub fn set_inactivity_timeout<T>(mut self, v: T) -> Self
1528    where
1529        T: std::convert::Into<wkt::Duration>,
1530    {
1531        self.inactivity_timeout = std::option::Option::Some(v.into());
1532        self
1533    }
1534
1535    /// Sets or clears the value of [inactivity_timeout][crate::model::DeviceSession::inactivity_timeout].
1536    ///
1537    /// # Example
1538    /// ```ignore,no_run
1539    /// # use google_cloud_devicestreaming_v1::model::DeviceSession;
1540    /// use wkt::Duration;
1541    /// let x = DeviceSession::new().set_or_clear_inactivity_timeout(Some(Duration::default()/* use setters */));
1542    /// let x = DeviceSession::new().set_or_clear_inactivity_timeout(None::<Duration>);
1543    /// ```
1544    pub fn set_or_clear_inactivity_timeout<T>(mut self, v: std::option::Option<T>) -> Self
1545    where
1546        T: std::convert::Into<wkt::Duration>,
1547    {
1548        self.inactivity_timeout = v.map(|x| x.into());
1549        self
1550    }
1551
1552    /// Sets the value of [create_time][crate::model::DeviceSession::create_time].
1553    ///
1554    /// # Example
1555    /// ```ignore,no_run
1556    /// # use google_cloud_devicestreaming_v1::model::DeviceSession;
1557    /// use wkt::Timestamp;
1558    /// let x = DeviceSession::new().set_create_time(Timestamp::default()/* use setters */);
1559    /// ```
1560    pub fn set_create_time<T>(mut self, v: T) -> Self
1561    where
1562        T: std::convert::Into<wkt::Timestamp>,
1563    {
1564        self.create_time = std::option::Option::Some(v.into());
1565        self
1566    }
1567
1568    /// Sets or clears the value of [create_time][crate::model::DeviceSession::create_time].
1569    ///
1570    /// # Example
1571    /// ```ignore,no_run
1572    /// # use google_cloud_devicestreaming_v1::model::DeviceSession;
1573    /// use wkt::Timestamp;
1574    /// let x = DeviceSession::new().set_or_clear_create_time(Some(Timestamp::default()/* use setters */));
1575    /// let x = DeviceSession::new().set_or_clear_create_time(None::<Timestamp>);
1576    /// ```
1577    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
1578    where
1579        T: std::convert::Into<wkt::Timestamp>,
1580    {
1581        self.create_time = v.map(|x| x.into());
1582        self
1583    }
1584
1585    /// Sets the value of [active_start_time][crate::model::DeviceSession::active_start_time].
1586    ///
1587    /// # Example
1588    /// ```ignore,no_run
1589    /// # use google_cloud_devicestreaming_v1::model::DeviceSession;
1590    /// use wkt::Timestamp;
1591    /// let x = DeviceSession::new().set_active_start_time(Timestamp::default()/* use setters */);
1592    /// ```
1593    pub fn set_active_start_time<T>(mut self, v: T) -> Self
1594    where
1595        T: std::convert::Into<wkt::Timestamp>,
1596    {
1597        self.active_start_time = std::option::Option::Some(v.into());
1598        self
1599    }
1600
1601    /// Sets or clears the value of [active_start_time][crate::model::DeviceSession::active_start_time].
1602    ///
1603    /// # Example
1604    /// ```ignore,no_run
1605    /// # use google_cloud_devicestreaming_v1::model::DeviceSession;
1606    /// use wkt::Timestamp;
1607    /// let x = DeviceSession::new().set_or_clear_active_start_time(Some(Timestamp::default()/* use setters */));
1608    /// let x = DeviceSession::new().set_or_clear_active_start_time(None::<Timestamp>);
1609    /// ```
1610    pub fn set_or_clear_active_start_time<T>(mut self, v: std::option::Option<T>) -> Self
1611    where
1612        T: std::convert::Into<wkt::Timestamp>,
1613    {
1614        self.active_start_time = v.map(|x| x.into());
1615        self
1616    }
1617
1618    /// Sets the value of [android_device][crate::model::DeviceSession::android_device].
1619    ///
1620    /// # Example
1621    /// ```ignore,no_run
1622    /// # use google_cloud_devicestreaming_v1::model::DeviceSession;
1623    /// use google_cloud_devicestreaming_v1::model::AndroidDevice;
1624    /// let x = DeviceSession::new().set_android_device(AndroidDevice::default()/* use setters */);
1625    /// ```
1626    pub fn set_android_device<T>(mut self, v: T) -> Self
1627    where
1628        T: std::convert::Into<crate::model::AndroidDevice>,
1629    {
1630        self.android_device = std::option::Option::Some(v.into());
1631        self
1632    }
1633
1634    /// Sets or clears the value of [android_device][crate::model::DeviceSession::android_device].
1635    ///
1636    /// # Example
1637    /// ```ignore,no_run
1638    /// # use google_cloud_devicestreaming_v1::model::DeviceSession;
1639    /// use google_cloud_devicestreaming_v1::model::AndroidDevice;
1640    /// let x = DeviceSession::new().set_or_clear_android_device(Some(AndroidDevice::default()/* use setters */));
1641    /// let x = DeviceSession::new().set_or_clear_android_device(None::<AndroidDevice>);
1642    /// ```
1643    pub fn set_or_clear_android_device<T>(mut self, v: std::option::Option<T>) -> Self
1644    where
1645        T: std::convert::Into<crate::model::AndroidDevice>,
1646    {
1647        self.android_device = v.map(|x| x.into());
1648        self
1649    }
1650
1651    /// Sets the value of [expiration][crate::model::DeviceSession::expiration].
1652    ///
1653    /// Note that all the setters affecting `expiration` are mutually
1654    /// exclusive.
1655    ///
1656    /// # Example
1657    /// ```ignore,no_run
1658    /// # use google_cloud_devicestreaming_v1::model::DeviceSession;
1659    /// use wkt::Duration;
1660    /// let x = DeviceSession::new().set_expiration(Some(
1661    ///     google_cloud_devicestreaming_v1::model::device_session::Expiration::Ttl(Duration::default().into())));
1662    /// ```
1663    pub fn set_expiration<
1664        T: std::convert::Into<std::option::Option<crate::model::device_session::Expiration>>,
1665    >(
1666        mut self,
1667        v: T,
1668    ) -> Self {
1669        self.expiration = v.into();
1670        self
1671    }
1672
1673    /// The value of [expiration][crate::model::DeviceSession::expiration]
1674    /// if it holds a `Ttl`, `None` if the field is not set or
1675    /// holds a different branch.
1676    pub fn ttl(&self) -> std::option::Option<&std::boxed::Box<wkt::Duration>> {
1677        #[allow(unreachable_patterns)]
1678        self.expiration.as_ref().and_then(|v| match v {
1679            crate::model::device_session::Expiration::Ttl(v) => std::option::Option::Some(v),
1680            _ => std::option::Option::None,
1681        })
1682    }
1683
1684    /// Sets the value of [expiration][crate::model::DeviceSession::expiration]
1685    /// to hold a `Ttl`.
1686    ///
1687    /// Note that all the setters affecting `expiration` are
1688    /// mutually exclusive.
1689    ///
1690    /// # Example
1691    /// ```ignore,no_run
1692    /// # use google_cloud_devicestreaming_v1::model::DeviceSession;
1693    /// use wkt::Duration;
1694    /// let x = DeviceSession::new().set_ttl(Duration::default()/* use setters */);
1695    /// assert!(x.ttl().is_some());
1696    /// assert!(x.expire_time().is_none());
1697    /// ```
1698    pub fn set_ttl<T: std::convert::Into<std::boxed::Box<wkt::Duration>>>(mut self, v: T) -> Self {
1699        self.expiration =
1700            std::option::Option::Some(crate::model::device_session::Expiration::Ttl(v.into()));
1701        self
1702    }
1703
1704    /// The value of [expiration][crate::model::DeviceSession::expiration]
1705    /// if it holds a `ExpireTime`, `None` if the field is not set or
1706    /// holds a different branch.
1707    pub fn expire_time(&self) -> std::option::Option<&std::boxed::Box<wkt::Timestamp>> {
1708        #[allow(unreachable_patterns)]
1709        self.expiration.as_ref().and_then(|v| match v {
1710            crate::model::device_session::Expiration::ExpireTime(v) => std::option::Option::Some(v),
1711            _ => std::option::Option::None,
1712        })
1713    }
1714
1715    /// Sets the value of [expiration][crate::model::DeviceSession::expiration]
1716    /// to hold a `ExpireTime`.
1717    ///
1718    /// Note that all the setters affecting `expiration` are
1719    /// mutually exclusive.
1720    ///
1721    /// # Example
1722    /// ```ignore,no_run
1723    /// # use google_cloud_devicestreaming_v1::model::DeviceSession;
1724    /// use wkt::Timestamp;
1725    /// let x = DeviceSession::new().set_expire_time(Timestamp::default()/* use setters */);
1726    /// assert!(x.expire_time().is_some());
1727    /// assert!(x.ttl().is_none());
1728    /// ```
1729    pub fn set_expire_time<T: std::convert::Into<std::boxed::Box<wkt::Timestamp>>>(
1730        mut self,
1731        v: T,
1732    ) -> Self {
1733        self.expiration = std::option::Option::Some(
1734            crate::model::device_session::Expiration::ExpireTime(v.into()),
1735        );
1736        self
1737    }
1738}
1739
1740impl wkt::message::Message for DeviceSession {
1741    fn typename() -> &'static str {
1742        "type.googleapis.com/google.cloud.devicestreaming.v1.DeviceSession"
1743    }
1744}
1745
1746/// Defines additional types related to [DeviceSession].
1747pub mod device_session {
1748    #[allow(unused_imports)]
1749    use super::*;
1750
1751    /// A message encapsulating a series of Session states and the time that the
1752    /// DeviceSession first entered those states.
1753    #[derive(Clone, Default, PartialEq)]
1754    #[non_exhaustive]
1755    pub struct SessionStateEvent {
1756        /// Output only. The session_state tracked by this event
1757        pub session_state: crate::model::device_session::SessionState,
1758
1759        /// Output only. The time that the session_state first encountered that
1760        /// state.
1761        pub event_time: std::option::Option<wkt::Timestamp>,
1762
1763        /// Output only. A human-readable message to explain the state.
1764        pub state_message: std::string::String,
1765
1766        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1767    }
1768
1769    impl SessionStateEvent {
1770        pub fn new() -> Self {
1771            std::default::Default::default()
1772        }
1773
1774        /// Sets the value of [session_state][crate::model::device_session::SessionStateEvent::session_state].
1775        ///
1776        /// # Example
1777        /// ```ignore,no_run
1778        /// # use google_cloud_devicestreaming_v1::model::device_session::SessionStateEvent;
1779        /// use google_cloud_devicestreaming_v1::model::device_session::SessionState;
1780        /// let x0 = SessionStateEvent::new().set_session_state(SessionState::Requested);
1781        /// let x1 = SessionStateEvent::new().set_session_state(SessionState::Pending);
1782        /// let x2 = SessionStateEvent::new().set_session_state(SessionState::Active);
1783        /// ```
1784        pub fn set_session_state<
1785            T: std::convert::Into<crate::model::device_session::SessionState>,
1786        >(
1787            mut self,
1788            v: T,
1789        ) -> Self {
1790            self.session_state = v.into();
1791            self
1792        }
1793
1794        /// Sets the value of [event_time][crate::model::device_session::SessionStateEvent::event_time].
1795        ///
1796        /// # Example
1797        /// ```ignore,no_run
1798        /// # use google_cloud_devicestreaming_v1::model::device_session::SessionStateEvent;
1799        /// use wkt::Timestamp;
1800        /// let x = SessionStateEvent::new().set_event_time(Timestamp::default()/* use setters */);
1801        /// ```
1802        pub fn set_event_time<T>(mut self, v: T) -> Self
1803        where
1804            T: std::convert::Into<wkt::Timestamp>,
1805        {
1806            self.event_time = std::option::Option::Some(v.into());
1807            self
1808        }
1809
1810        /// Sets or clears the value of [event_time][crate::model::device_session::SessionStateEvent::event_time].
1811        ///
1812        /// # Example
1813        /// ```ignore,no_run
1814        /// # use google_cloud_devicestreaming_v1::model::device_session::SessionStateEvent;
1815        /// use wkt::Timestamp;
1816        /// let x = SessionStateEvent::new().set_or_clear_event_time(Some(Timestamp::default()/* use setters */));
1817        /// let x = SessionStateEvent::new().set_or_clear_event_time(None::<Timestamp>);
1818        /// ```
1819        pub fn set_or_clear_event_time<T>(mut self, v: std::option::Option<T>) -> Self
1820        where
1821            T: std::convert::Into<wkt::Timestamp>,
1822        {
1823            self.event_time = v.map(|x| x.into());
1824            self
1825        }
1826
1827        /// Sets the value of [state_message][crate::model::device_session::SessionStateEvent::state_message].
1828        ///
1829        /// # Example
1830        /// ```ignore,no_run
1831        /// # use google_cloud_devicestreaming_v1::model::device_session::SessionStateEvent;
1832        /// let x = SessionStateEvent::new().set_state_message("example");
1833        /// ```
1834        pub fn set_state_message<T: std::convert::Into<std::string::String>>(
1835            mut self,
1836            v: T,
1837        ) -> Self {
1838            self.state_message = v.into();
1839            self
1840        }
1841    }
1842
1843    impl wkt::message::Message for SessionStateEvent {
1844        fn typename() -> &'static str {
1845            "type.googleapis.com/google.cloud.devicestreaming.v1.DeviceSession.SessionStateEvent"
1846        }
1847    }
1848
1849    /// The state that the DeviceSession resides.
1850    ///
1851    /// # Working with unknown values
1852    ///
1853    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1854    /// additional enum variants at any time. Adding new variants is not considered
1855    /// a breaking change. Applications should write their code in anticipation of:
1856    ///
1857    /// - New values appearing in future releases of the client library, **and**
1858    /// - New values received dynamically, without application changes.
1859    ///
1860    /// Please consult the [Working with enums] section in the user guide for some
1861    /// guidelines.
1862    ///
1863    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
1864    #[derive(Clone, Debug, PartialEq)]
1865    #[non_exhaustive]
1866    pub enum SessionState {
1867        /// Default value. This value is unused.
1868        Unspecified,
1869        /// Initial state of a session request. The session is being validated for
1870        /// correctness and a device is not yet requested.
1871        Requested,
1872        /// The session has been validated and is in the queue for a device.
1873        Pending,
1874        /// The session has been granted and the device is accepting
1875        /// connections.
1876        Active,
1877        /// The session duration exceeded the device's reservation time period and
1878        /// timed out automatically.
1879        Expired,
1880        /// The user is finished with the session and it was canceled by the user
1881        /// while the request was still getting allocated or after allocation and
1882        /// during device usage period.
1883        Finished,
1884        /// Unable to complete the session because the device was unavailable and
1885        /// it failed to allocate through the scheduler. For example, a device not
1886        /// in the catalog was requested or the request expired in the allocation
1887        /// queue.
1888        Unavailable,
1889        /// Unable to complete the session for an internal reason, such as an
1890        /// infrastructure failure.
1891        Error,
1892        /// If set, the enum was initialized with an unknown value.
1893        ///
1894        /// Applications can examine the value using [SessionState::value] or
1895        /// [SessionState::name].
1896        UnknownValue(session_state::UnknownValue),
1897    }
1898
1899    #[doc(hidden)]
1900    pub mod session_state {
1901        #[allow(unused_imports)]
1902        use super::*;
1903        #[derive(Clone, Debug, PartialEq)]
1904        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1905    }
1906
1907    impl SessionState {
1908        /// Gets the enum value.
1909        ///
1910        /// Returns `None` if the enum contains an unknown value deserialized from
1911        /// the string representation of enums.
1912        pub fn value(&self) -> std::option::Option<i32> {
1913            match self {
1914                Self::Unspecified => std::option::Option::Some(0),
1915                Self::Requested => std::option::Option::Some(1),
1916                Self::Pending => std::option::Option::Some(2),
1917                Self::Active => std::option::Option::Some(3),
1918                Self::Expired => std::option::Option::Some(4),
1919                Self::Finished => std::option::Option::Some(5),
1920                Self::Unavailable => std::option::Option::Some(6),
1921                Self::Error => std::option::Option::Some(7),
1922                Self::UnknownValue(u) => u.0.value(),
1923            }
1924        }
1925
1926        /// Gets the enum value as a string.
1927        ///
1928        /// Returns `None` if the enum contains an unknown value deserialized from
1929        /// the integer representation of enums.
1930        pub fn name(&self) -> std::option::Option<&str> {
1931            match self {
1932                Self::Unspecified => std::option::Option::Some("SESSION_STATE_UNSPECIFIED"),
1933                Self::Requested => std::option::Option::Some("REQUESTED"),
1934                Self::Pending => std::option::Option::Some("PENDING"),
1935                Self::Active => std::option::Option::Some("ACTIVE"),
1936                Self::Expired => std::option::Option::Some("EXPIRED"),
1937                Self::Finished => std::option::Option::Some("FINISHED"),
1938                Self::Unavailable => std::option::Option::Some("UNAVAILABLE"),
1939                Self::Error => std::option::Option::Some("ERROR"),
1940                Self::UnknownValue(u) => u.0.name(),
1941            }
1942        }
1943    }
1944
1945    impl std::default::Default for SessionState {
1946        fn default() -> Self {
1947            use std::convert::From;
1948            Self::from(0)
1949        }
1950    }
1951
1952    impl std::fmt::Display for SessionState {
1953        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1954            wkt::internal::display_enum(f, self.name(), self.value())
1955        }
1956    }
1957
1958    impl std::convert::From<i32> for SessionState {
1959        fn from(value: i32) -> Self {
1960            match value {
1961                0 => Self::Unspecified,
1962                1 => Self::Requested,
1963                2 => Self::Pending,
1964                3 => Self::Active,
1965                4 => Self::Expired,
1966                5 => Self::Finished,
1967                6 => Self::Unavailable,
1968                7 => Self::Error,
1969                _ => Self::UnknownValue(session_state::UnknownValue(
1970                    wkt::internal::UnknownEnumValue::Integer(value),
1971                )),
1972            }
1973        }
1974    }
1975
1976    impl std::convert::From<&str> for SessionState {
1977        fn from(value: &str) -> Self {
1978            use std::string::ToString;
1979            match value {
1980                "SESSION_STATE_UNSPECIFIED" => Self::Unspecified,
1981                "REQUESTED" => Self::Requested,
1982                "PENDING" => Self::Pending,
1983                "ACTIVE" => Self::Active,
1984                "EXPIRED" => Self::Expired,
1985                "FINISHED" => Self::Finished,
1986                "UNAVAILABLE" => Self::Unavailable,
1987                "ERROR" => Self::Error,
1988                _ => Self::UnknownValue(session_state::UnknownValue(
1989                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1990                )),
1991            }
1992        }
1993    }
1994
1995    impl serde::ser::Serialize for SessionState {
1996        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1997        where
1998            S: serde::Serializer,
1999        {
2000            match self {
2001                Self::Unspecified => serializer.serialize_i32(0),
2002                Self::Requested => serializer.serialize_i32(1),
2003                Self::Pending => serializer.serialize_i32(2),
2004                Self::Active => serializer.serialize_i32(3),
2005                Self::Expired => serializer.serialize_i32(4),
2006                Self::Finished => serializer.serialize_i32(5),
2007                Self::Unavailable => serializer.serialize_i32(6),
2008                Self::Error => serializer.serialize_i32(7),
2009                Self::UnknownValue(u) => u.0.serialize(serializer),
2010            }
2011        }
2012    }
2013
2014    impl<'de> serde::de::Deserialize<'de> for SessionState {
2015        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2016        where
2017            D: serde::Deserializer<'de>,
2018        {
2019            deserializer.deserialize_any(wkt::internal::EnumVisitor::<SessionState>::new(
2020                ".google.cloud.devicestreaming.v1.DeviceSession.SessionState",
2021            ))
2022        }
2023    }
2024
2025    /// The amount of time that a device will be initially allocated for.
2026    #[derive(Clone, Debug, PartialEq)]
2027    #[non_exhaustive]
2028    pub enum Expiration {
2029        /// Optional. The amount of time that a device will be initially allocated
2030        /// for. This can eventually be extended with the UpdateDeviceSession RPC.
2031        /// Default: 15 minutes.
2032        Ttl(std::boxed::Box<wkt::Duration>),
2033        /// Optional. If the device is still in use at this time, any connections
2034        /// will be ended and the SessionState will transition from ACTIVE to
2035        /// FINISHED.
2036        ExpireTime(std::boxed::Box<wkt::Timestamp>),
2037    }
2038}
2039
2040/// A single Android device.
2041#[derive(Clone, Default, PartialEq)]
2042#[non_exhaustive]
2043pub struct AndroidDevice {
2044    /// Required. The id of the Android device to be used.
2045    /// Use the TestEnvironmentDiscoveryService to get supported options.
2046    pub android_model_id: std::string::String,
2047
2048    /// Required. The id of the Android OS version to be used.
2049    /// Use the TestEnvironmentDiscoveryService to get supported options.
2050    pub android_version_id: std::string::String,
2051
2052    /// Optional. The locale the test device used for testing.
2053    /// Use the TestEnvironmentDiscoveryService to get supported options.
2054    pub locale: std::string::String,
2055
2056    /// Optional. How the device is oriented during the test.
2057    /// Use the TestEnvironmentDiscoveryService to get supported options.
2058    pub orientation: std::string::String,
2059
2060    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2061}
2062
2063impl AndroidDevice {
2064    pub fn new() -> Self {
2065        std::default::Default::default()
2066    }
2067
2068    /// Sets the value of [android_model_id][crate::model::AndroidDevice::android_model_id].
2069    ///
2070    /// # Example
2071    /// ```ignore,no_run
2072    /// # use google_cloud_devicestreaming_v1::model::AndroidDevice;
2073    /// let x = AndroidDevice::new().set_android_model_id("example");
2074    /// ```
2075    pub fn set_android_model_id<T: std::convert::Into<std::string::String>>(
2076        mut self,
2077        v: T,
2078    ) -> Self {
2079        self.android_model_id = v.into();
2080        self
2081    }
2082
2083    /// Sets the value of [android_version_id][crate::model::AndroidDevice::android_version_id].
2084    ///
2085    /// # Example
2086    /// ```ignore,no_run
2087    /// # use google_cloud_devicestreaming_v1::model::AndroidDevice;
2088    /// let x = AndroidDevice::new().set_android_version_id("example");
2089    /// ```
2090    pub fn set_android_version_id<T: std::convert::Into<std::string::String>>(
2091        mut self,
2092        v: T,
2093    ) -> Self {
2094        self.android_version_id = v.into();
2095        self
2096    }
2097
2098    /// Sets the value of [locale][crate::model::AndroidDevice::locale].
2099    ///
2100    /// # Example
2101    /// ```ignore,no_run
2102    /// # use google_cloud_devicestreaming_v1::model::AndroidDevice;
2103    /// let x = AndroidDevice::new().set_locale("example");
2104    /// ```
2105    pub fn set_locale<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2106        self.locale = v.into();
2107        self
2108    }
2109
2110    /// Sets the value of [orientation][crate::model::AndroidDevice::orientation].
2111    ///
2112    /// # Example
2113    /// ```ignore,no_run
2114    /// # use google_cloud_devicestreaming_v1::model::AndroidDevice;
2115    /// let x = AndroidDevice::new().set_orientation("example");
2116    /// ```
2117    pub fn set_orientation<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2118        self.orientation = v.into();
2119        self
2120    }
2121}
2122
2123impl wkt::message::Message for AndroidDevice {
2124    fn typename() -> &'static str {
2125        "type.googleapis.com/google.cloud.devicestreaming.v1.AndroidDevice"
2126    }
2127}