google-cloud-oslogin-common 1.5.0

Google Cloud Client Libraries for Rust - Cloud OS Login Common Types
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate bytes;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// The POSIX account information associated with a Google account.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct PosixAccount {
    /// Only one POSIX account can be marked as primary.
    pub primary: bool,

    /// The username of the POSIX account.
    pub username: std::string::String,

    /// The user ID.
    pub uid: i64,

    /// The default group ID.
    pub gid: i64,

    /// The path to the home directory for this account.
    pub home_directory: std::string::String,

    /// The path to the logic shell for this account.
    pub shell: std::string::String,

    /// The GECOS (user information) entry for this account.
    pub gecos: std::string::String,

    /// System identifier for which account the username or uid applies to.
    /// By default, the empty value is used.
    pub system_id: std::string::String,

    /// Output only. A POSIX account identifier.
    pub account_id: std::string::String,

    /// The operating system type where this account applies.
    pub operating_system_type: crate::model::OperatingSystemType,

    /// Output only. The canonical resource name.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl PosixAccount {
    /// Creates a new default instance.
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [primary][crate::model::PosixAccount::primary].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_oslogin_common::model::PosixAccount;
    /// let x = PosixAccount::new().set_primary(true);
    /// ```
    pub fn set_primary<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.primary = v.into();
        self
    }

    /// Sets the value of [username][crate::model::PosixAccount::username].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_oslogin_common::model::PosixAccount;
    /// let x = PosixAccount::new().set_username("example");
    /// ```
    pub fn set_username<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.username = v.into();
        self
    }

    /// Sets the value of [uid][crate::model::PosixAccount::uid].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_oslogin_common::model::PosixAccount;
    /// let x = PosixAccount::new().set_uid(42);
    /// ```
    pub fn set_uid<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.uid = v.into();
        self
    }

    /// Sets the value of [gid][crate::model::PosixAccount::gid].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_oslogin_common::model::PosixAccount;
    /// let x = PosixAccount::new().set_gid(42);
    /// ```
    pub fn set_gid<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.gid = v.into();
        self
    }

    /// Sets the value of [home_directory][crate::model::PosixAccount::home_directory].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_oslogin_common::model::PosixAccount;
    /// let x = PosixAccount::new().set_home_directory("example");
    /// ```
    pub fn set_home_directory<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.home_directory = v.into();
        self
    }

    /// Sets the value of [shell][crate::model::PosixAccount::shell].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_oslogin_common::model::PosixAccount;
    /// let x = PosixAccount::new().set_shell("example");
    /// ```
    pub fn set_shell<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.shell = v.into();
        self
    }

    /// Sets the value of [gecos][crate::model::PosixAccount::gecos].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_oslogin_common::model::PosixAccount;
    /// let x = PosixAccount::new().set_gecos("example");
    /// ```
    pub fn set_gecos<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.gecos = v.into();
        self
    }

    /// Sets the value of [system_id][crate::model::PosixAccount::system_id].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_oslogin_common::model::PosixAccount;
    /// let x = PosixAccount::new().set_system_id("example");
    /// ```
    pub fn set_system_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.system_id = v.into();
        self
    }

    /// Sets the value of [account_id][crate::model::PosixAccount::account_id].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_oslogin_common::model::PosixAccount;
    /// let x = PosixAccount::new().set_account_id("example");
    /// ```
    pub fn set_account_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.account_id = v.into();
        self
    }

    /// Sets the value of [operating_system_type][crate::model::PosixAccount::operating_system_type].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_oslogin_common::model::PosixAccount;
    /// use google_cloud_oslogin_common::model::OperatingSystemType;
    /// let x0 = PosixAccount::new().set_operating_system_type(OperatingSystemType::Linux);
    /// let x1 = PosixAccount::new().set_operating_system_type(OperatingSystemType::Windows);
    /// ```
    pub fn set_operating_system_type<T: std::convert::Into<crate::model::OperatingSystemType>>(
        mut self,
        v: T,
    ) -> Self {
        self.operating_system_type = v.into();
        self
    }

    /// Sets the value of [name][crate::model::PosixAccount::name].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_oslogin_common::model::PosixAccount;
    /// let x = PosixAccount::new().set_name("example");
    /// ```
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for PosixAccount {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.oslogin.common.PosixAccount"
    }
}

/// The SSH public key information associated with a Google account.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SshPublicKey {
    /// Public key text in SSH format, defined by
    /// [RFC4253](https://www.ietf.org/rfc/rfc4253.txt) section 6.6.
    pub key: std::string::String,

    /// An expiration time in microseconds since epoch.
    pub expiration_time_usec: i64,

    /// Output only. The SHA-256 fingerprint of the SSH public key.
    pub fingerprint: std::string::String,

    /// Output only. The canonical resource name.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl SshPublicKey {
    /// Creates a new default instance.
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [key][crate::model::SshPublicKey::key].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_oslogin_common::model::SshPublicKey;
    /// let x = SshPublicKey::new().set_key("example");
    /// ```
    pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.key = v.into();
        self
    }

    /// Sets the value of [expiration_time_usec][crate::model::SshPublicKey::expiration_time_usec].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_oslogin_common::model::SshPublicKey;
    /// let x = SshPublicKey::new().set_expiration_time_usec(42);
    /// ```
    pub fn set_expiration_time_usec<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.expiration_time_usec = v.into();
        self
    }

    /// Sets the value of [fingerprint][crate::model::SshPublicKey::fingerprint].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_oslogin_common::model::SshPublicKey;
    /// let x = SshPublicKey::new().set_fingerprint("example");
    /// ```
    pub fn set_fingerprint<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.fingerprint = v.into();
        self
    }

    /// Sets the value of [name][crate::model::SshPublicKey::name].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_oslogin_common::model::SshPublicKey;
    /// let x = SshPublicKey::new().set_name("example");
    /// ```
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for SshPublicKey {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.oslogin.common.SshPublicKey"
    }
}

/// The operating system options for account entries.
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum OperatingSystemType {
    /// The operating system type associated with the user account information is
    /// unspecified.
    Unspecified,
    /// Linux user account information.
    Linux,
    /// Windows user account information.
    Windows,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [OperatingSystemType::value] or
    /// [OperatingSystemType::name].
    UnknownValue(operating_system_type::UnknownValue),
}

#[doc(hidden)]
pub mod operating_system_type {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl OperatingSystemType {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::Linux => std::option::Option::Some(1),
            Self::Windows => std::option::Option::Some(2),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => std::option::Option::Some("OPERATING_SYSTEM_TYPE_UNSPECIFIED"),
            Self::Linux => std::option::Option::Some("LINUX"),
            Self::Windows => std::option::Option::Some("WINDOWS"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for OperatingSystemType {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for OperatingSystemType {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for OperatingSystemType {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            1 => Self::Linux,
            2 => Self::Windows,
            _ => Self::UnknownValue(operating_system_type::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for OperatingSystemType {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "OPERATING_SYSTEM_TYPE_UNSPECIFIED" => Self::Unspecified,
            "LINUX" => Self::Linux,
            "WINDOWS" => Self::Windows,
            _ => Self::UnknownValue(operating_system_type::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for OperatingSystemType {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::Linux => serializer.serialize_i32(1),
            Self::Windows => serializer.serialize_i32(2),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for OperatingSystemType {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<OperatingSystemType>::new(
            ".google.cloud.oslogin.common.OperatingSystemType",
        ))
    }
}