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