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