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