google_cloud_oslogin_common/
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 bytes;
21extern crate serde;
22extern crate serde_json;
23extern crate serde_with;
24extern crate std;
25extern crate wkt;
26
27mod debug;
28mod deserialize;
29mod serialize;
30
31/// The POSIX account information associated with a Google account.
32#[derive(Clone, Default, PartialEq)]
33#[non_exhaustive]
34pub struct PosixAccount {
35    /// Only one POSIX account can be marked as primary.
36    pub primary: bool,
37
38    /// The username of the POSIX account.
39    pub username: std::string::String,
40
41    /// The user ID.
42    pub uid: i64,
43
44    /// The default group ID.
45    pub gid: i64,
46
47    /// The path to the home directory for this account.
48    pub home_directory: std::string::String,
49
50    /// The path to the logic shell for this account.
51    pub shell: std::string::String,
52
53    /// The GECOS (user information) entry for this account.
54    pub gecos: std::string::String,
55
56    /// System identifier for which account the username or uid applies to.
57    /// By default, the empty value is used.
58    pub system_id: std::string::String,
59
60    /// Output only. A POSIX account identifier.
61    pub account_id: std::string::String,
62
63    /// The operating system type where this account applies.
64    pub operating_system_type: crate::model::OperatingSystemType,
65
66    /// Output only. The canonical resource name.
67    pub name: std::string::String,
68
69    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
70}
71
72impl PosixAccount {
73    pub fn new() -> Self {
74        std::default::Default::default()
75    }
76
77    /// Sets the value of [primary][crate::model::PosixAccount::primary].
78    ///
79    /// # Example
80    /// ```ignore,no_run
81    /// # use google_cloud_oslogin_common::model::PosixAccount;
82    /// let x = PosixAccount::new().set_primary(true);
83    /// ```
84    pub fn set_primary<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
85        self.primary = v.into();
86        self
87    }
88
89    /// Sets the value of [username][crate::model::PosixAccount::username].
90    ///
91    /// # Example
92    /// ```ignore,no_run
93    /// # use google_cloud_oslogin_common::model::PosixAccount;
94    /// let x = PosixAccount::new().set_username("example");
95    /// ```
96    pub fn set_username<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
97        self.username = v.into();
98        self
99    }
100
101    /// Sets the value of [uid][crate::model::PosixAccount::uid].
102    ///
103    /// # Example
104    /// ```ignore,no_run
105    /// # use google_cloud_oslogin_common::model::PosixAccount;
106    /// let x = PosixAccount::new().set_uid(42);
107    /// ```
108    pub fn set_uid<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
109        self.uid = v.into();
110        self
111    }
112
113    /// Sets the value of [gid][crate::model::PosixAccount::gid].
114    ///
115    /// # Example
116    /// ```ignore,no_run
117    /// # use google_cloud_oslogin_common::model::PosixAccount;
118    /// let x = PosixAccount::new().set_gid(42);
119    /// ```
120    pub fn set_gid<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
121        self.gid = v.into();
122        self
123    }
124
125    /// Sets the value of [home_directory][crate::model::PosixAccount::home_directory].
126    ///
127    /// # Example
128    /// ```ignore,no_run
129    /// # use google_cloud_oslogin_common::model::PosixAccount;
130    /// let x = PosixAccount::new().set_home_directory("example");
131    /// ```
132    pub fn set_home_directory<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
133        self.home_directory = v.into();
134        self
135    }
136
137    /// Sets the value of [shell][crate::model::PosixAccount::shell].
138    ///
139    /// # Example
140    /// ```ignore,no_run
141    /// # use google_cloud_oslogin_common::model::PosixAccount;
142    /// let x = PosixAccount::new().set_shell("example");
143    /// ```
144    pub fn set_shell<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
145        self.shell = v.into();
146        self
147    }
148
149    /// Sets the value of [gecos][crate::model::PosixAccount::gecos].
150    ///
151    /// # Example
152    /// ```ignore,no_run
153    /// # use google_cloud_oslogin_common::model::PosixAccount;
154    /// let x = PosixAccount::new().set_gecos("example");
155    /// ```
156    pub fn set_gecos<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
157        self.gecos = v.into();
158        self
159    }
160
161    /// Sets the value of [system_id][crate::model::PosixAccount::system_id].
162    ///
163    /// # Example
164    /// ```ignore,no_run
165    /// # use google_cloud_oslogin_common::model::PosixAccount;
166    /// let x = PosixAccount::new().set_system_id("example");
167    /// ```
168    pub fn set_system_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
169        self.system_id = v.into();
170        self
171    }
172
173    /// Sets the value of [account_id][crate::model::PosixAccount::account_id].
174    ///
175    /// # Example
176    /// ```ignore,no_run
177    /// # use google_cloud_oslogin_common::model::PosixAccount;
178    /// let x = PosixAccount::new().set_account_id("example");
179    /// ```
180    pub fn set_account_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
181        self.account_id = v.into();
182        self
183    }
184
185    /// Sets the value of [operating_system_type][crate::model::PosixAccount::operating_system_type].
186    ///
187    /// # Example
188    /// ```ignore,no_run
189    /// # use google_cloud_oslogin_common::model::PosixAccount;
190    /// use google_cloud_oslogin_common::model::OperatingSystemType;
191    /// let x0 = PosixAccount::new().set_operating_system_type(OperatingSystemType::Linux);
192    /// let x1 = PosixAccount::new().set_operating_system_type(OperatingSystemType::Windows);
193    /// ```
194    pub fn set_operating_system_type<T: std::convert::Into<crate::model::OperatingSystemType>>(
195        mut self,
196        v: T,
197    ) -> Self {
198        self.operating_system_type = v.into();
199        self
200    }
201
202    /// Sets the value of [name][crate::model::PosixAccount::name].
203    ///
204    /// # Example
205    /// ```ignore,no_run
206    /// # use google_cloud_oslogin_common::model::PosixAccount;
207    /// let x = PosixAccount::new().set_name("example");
208    /// ```
209    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
210        self.name = v.into();
211        self
212    }
213}
214
215impl wkt::message::Message for PosixAccount {
216    fn typename() -> &'static str {
217        "type.googleapis.com/google.cloud.oslogin.common.PosixAccount"
218    }
219}
220
221/// The SSH public key information associated with a Google account.
222#[derive(Clone, Default, PartialEq)]
223#[non_exhaustive]
224pub struct SshPublicKey {
225    /// Public key text in SSH format, defined by
226    /// [RFC4253](https://www.ietf.org/rfc/rfc4253.txt) section 6.6.
227    pub key: std::string::String,
228
229    /// An expiration time in microseconds since epoch.
230    pub expiration_time_usec: i64,
231
232    /// Output only. The SHA-256 fingerprint of the SSH public key.
233    pub fingerprint: std::string::String,
234
235    /// Output only. The canonical resource name.
236    pub name: std::string::String,
237
238    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
239}
240
241impl SshPublicKey {
242    pub fn new() -> Self {
243        std::default::Default::default()
244    }
245
246    /// Sets the value of [key][crate::model::SshPublicKey::key].
247    ///
248    /// # Example
249    /// ```ignore,no_run
250    /// # use google_cloud_oslogin_common::model::SshPublicKey;
251    /// let x = SshPublicKey::new().set_key("example");
252    /// ```
253    pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
254        self.key = v.into();
255        self
256    }
257
258    /// Sets the value of [expiration_time_usec][crate::model::SshPublicKey::expiration_time_usec].
259    ///
260    /// # Example
261    /// ```ignore,no_run
262    /// # use google_cloud_oslogin_common::model::SshPublicKey;
263    /// let x = SshPublicKey::new().set_expiration_time_usec(42);
264    /// ```
265    pub fn set_expiration_time_usec<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
266        self.expiration_time_usec = v.into();
267        self
268    }
269
270    /// Sets the value of [fingerprint][crate::model::SshPublicKey::fingerprint].
271    ///
272    /// # Example
273    /// ```ignore,no_run
274    /// # use google_cloud_oslogin_common::model::SshPublicKey;
275    /// let x = SshPublicKey::new().set_fingerprint("example");
276    /// ```
277    pub fn set_fingerprint<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
278        self.fingerprint = v.into();
279        self
280    }
281
282    /// Sets the value of [name][crate::model::SshPublicKey::name].
283    ///
284    /// # Example
285    /// ```ignore,no_run
286    /// # use google_cloud_oslogin_common::model::SshPublicKey;
287    /// let x = SshPublicKey::new().set_name("example");
288    /// ```
289    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
290        self.name = v.into();
291        self
292    }
293}
294
295impl wkt::message::Message for SshPublicKey {
296    fn typename() -> &'static str {
297        "type.googleapis.com/google.cloud.oslogin.common.SshPublicKey"
298    }
299}
300
301/// The operating system options for account entries.
302///
303/// # Working with unknown values
304///
305/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
306/// additional enum variants at any time. Adding new variants is not considered
307/// a breaking change. Applications should write their code in anticipation of:
308///
309/// - New values appearing in future releases of the client library, **and**
310/// - New values received dynamically, without application changes.
311///
312/// Please consult the [Working with enums] section in the user guide for some
313/// guidelines.
314///
315/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
316#[derive(Clone, Debug, PartialEq)]
317#[non_exhaustive]
318pub enum OperatingSystemType {
319    /// The operating system type associated with the user account information is
320    /// unspecified.
321    Unspecified,
322    /// Linux user account information.
323    Linux,
324    /// Windows user account information.
325    Windows,
326    /// If set, the enum was initialized with an unknown value.
327    ///
328    /// Applications can examine the value using [OperatingSystemType::value] or
329    /// [OperatingSystemType::name].
330    UnknownValue(operating_system_type::UnknownValue),
331}
332
333#[doc(hidden)]
334pub mod operating_system_type {
335    #[allow(unused_imports)]
336    use super::*;
337    #[derive(Clone, Debug, PartialEq)]
338    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
339}
340
341impl OperatingSystemType {
342    /// Gets the enum value.
343    ///
344    /// Returns `None` if the enum contains an unknown value deserialized from
345    /// the string representation of enums.
346    pub fn value(&self) -> std::option::Option<i32> {
347        match self {
348            Self::Unspecified => std::option::Option::Some(0),
349            Self::Linux => std::option::Option::Some(1),
350            Self::Windows => std::option::Option::Some(2),
351            Self::UnknownValue(u) => u.0.value(),
352        }
353    }
354
355    /// Gets the enum value as a string.
356    ///
357    /// Returns `None` if the enum contains an unknown value deserialized from
358    /// the integer representation of enums.
359    pub fn name(&self) -> std::option::Option<&str> {
360        match self {
361            Self::Unspecified => std::option::Option::Some("OPERATING_SYSTEM_TYPE_UNSPECIFIED"),
362            Self::Linux => std::option::Option::Some("LINUX"),
363            Self::Windows => std::option::Option::Some("WINDOWS"),
364            Self::UnknownValue(u) => u.0.name(),
365        }
366    }
367}
368
369impl std::default::Default for OperatingSystemType {
370    fn default() -> Self {
371        use std::convert::From;
372        Self::from(0)
373    }
374}
375
376impl std::fmt::Display for OperatingSystemType {
377    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
378        wkt::internal::display_enum(f, self.name(), self.value())
379    }
380}
381
382impl std::convert::From<i32> for OperatingSystemType {
383    fn from(value: i32) -> Self {
384        match value {
385            0 => Self::Unspecified,
386            1 => Self::Linux,
387            2 => Self::Windows,
388            _ => Self::UnknownValue(operating_system_type::UnknownValue(
389                wkt::internal::UnknownEnumValue::Integer(value),
390            )),
391        }
392    }
393}
394
395impl std::convert::From<&str> for OperatingSystemType {
396    fn from(value: &str) -> Self {
397        use std::string::ToString;
398        match value {
399            "OPERATING_SYSTEM_TYPE_UNSPECIFIED" => Self::Unspecified,
400            "LINUX" => Self::Linux,
401            "WINDOWS" => Self::Windows,
402            _ => Self::UnknownValue(operating_system_type::UnknownValue(
403                wkt::internal::UnknownEnumValue::String(value.to_string()),
404            )),
405        }
406    }
407}
408
409impl serde::ser::Serialize for OperatingSystemType {
410    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
411    where
412        S: serde::Serializer,
413    {
414        match self {
415            Self::Unspecified => serializer.serialize_i32(0),
416            Self::Linux => serializer.serialize_i32(1),
417            Self::Windows => serializer.serialize_i32(2),
418            Self::UnknownValue(u) => u.0.serialize(serializer),
419        }
420    }
421}
422
423impl<'de> serde::de::Deserialize<'de> for OperatingSystemType {
424    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
425    where
426        D: serde::Deserializer<'de>,
427    {
428        deserializer.deserialize_any(wkt::internal::EnumVisitor::<OperatingSystemType>::new(
429            ".google.cloud.oslogin.common.OperatingSystemType",
430        ))
431    }
432}