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