vim_rs 0.4.4

Rust Bindings for the VMware by Broadcom vCenter VI JSON API
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
435
436
437
438
439
440
441
442
443
444
445
446
use std::sync::Arc;
use crate::core::client::{VimClient, Result};
/// This managed object type provides an interface
/// through which local accounts on a host are managed.
/// 
/// Note that this
/// managed object applies only to applications that use a local account
/// database on the host to provide authentication (ESX Server, for example).
/// POSIX and win32 hosts may impose different restrictions on the password,
/// ID, and description formats. POSIX host implementation may restrict the
/// user or group name to be lower case letters and less than 16 characters in
/// total. It may also disallow characters such as
/// ";", "\\n", and so on. In short, all the platform dependent rules and
/// restrictions regarding naming of users/groups and password apply here.
/// An InvalidArgument fault is thrown if any of these rules are not obeyed.
#[derive(Clone)]
pub struct HostLocalAccountManager {
    client: Arc<dyn VimClient>,
    mo_id: String,
}
impl HostLocalAccountManager {
    pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self {
        Self {
            client,
            mo_id: mo_id.to_string(),
        }
    }
    /// Deprecated as of vSphere API 5.1, local user groups are not supported
    /// and group specific methods will throw NotSupported.
    /// 
    /// Assigns a user to a group.
    /// 
    /// ***Required privileges:*** Host.Local.ManageUserGroups
    ///
    /// ## Parameters:
    ///
    /// ### user
    /// User ID of the account whose group membership is
    /// being assigned.
    ///
    /// ### group
    /// Destination group account to which the user is
    /// being assigned.
    ///
    /// ## Errors:
    ///
    /// ***UserNotFound***: if the specified user or group does not exist.
    /// 
    /// ***AlreadyExists***: if the user is already a member of the target group.
    pub async fn assign_user_to_group(&self, user: &str, group: &str) -> Result<()> {
        let input = AssignUserToGroupRequestType {user, group, };
        self.client.invoke_void("", "HostLocalAccountManager", &self.mo_id, "AssignUserToGroup", Some(&input)).await
    }
    /// Updates the password of a local user account.
    /// 
    /// ***Required privileges:*** System.Anonymous
    ///
    /// ## Parameters:
    ///
    /// ### user
    /// the user whose password will be changed.
    ///
    /// ### old_password
    /// the user's current (old) password.
    ///
    /// ### new_password
    /// the user's new password.
    ///
    /// ## Errors:
    ///
    /// ***InvalidArgument***: if newPassword has an invalid format.
    /// 
    /// ***InvalidLogin***: if the user and oldPassword combination is not valid.
    pub async fn change_password(&self, user: &str, old_password: &str, new_password: &str) -> Result<()> {
        let input = ChangePasswordRequestType {user, old_password, new_password, };
        self.client.invoke_void("", "HostLocalAccountManager", &self.mo_id, "ChangePassword", Some(&input)).await
    }
    /// Deprecated as of vSphere API 5.1, local user groups are not supported
    /// and group specific methods will throw NotSupported.
    /// 
    /// Creates a local group account using the parameters defined in the
    /// *HostLocalAccountManagerAccountSpecification*
    /// data object type.
    /// 
    /// For POSIX hosts, passing the
    /// *HostLocalAccountManagerPosixAccountSpecification* data object
    /// type allows you to control
    /// the group ID format of the group account being created.
    /// 
    /// ***Required privileges:*** Host.Local.ManageUserGroups
    ///
    /// ## Parameters:
    ///
    /// ### group
    /// Specification of group being created.
    ///
    /// ## Errors:
    ///
    /// ***AlreadyExists***: if specified local group already exists.
    /// 
    /// ***InvalidArgument***: if group name is in invalid format.
    pub async fn create_group(&self, group: &dyn crate::types::traits::HostAccountSpecTrait) -> Result<()> {
        let input = CreateGroupRequestType {group, };
        self.client.invoke_void("", "HostLocalAccountManager", &self.mo_id, "CreateGroup", Some(&input)).await
    }
    /// Creates a local user account using the parameters defined in the
    /// *HostLocalAccountManagerAccountSpecification*
    /// data object type.
    /// 
    /// For POSIX hosts,
    /// passing *HostLocalAccountManagerPosixAccountSpecification* data object
    /// type allows you to control the
    /// format of the user ID of the user account being created.
    /// 
    /// ***Required privileges:*** Host.Local.ManageUserGroups
    ///
    /// ## Parameters:
    ///
    /// ### user
    /// Specification of user being created.
    ///
    /// ## Errors:
    ///
    /// ***AlreadyExists***: if the specified local user account
    /// already exists.
    /// 
    /// ***InvalidArgument***: if the user name or password has an
    /// invalid format.
    pub async fn create_user(&self, user: &dyn crate::types::traits::HostAccountSpecTrait) -> Result<()> {
        let input = CreateUserRequestType {user, };
        self.client.invoke_void("", "HostLocalAccountManager", &self.mo_id, "CreateUser", Some(&input)).await
    }
    /// Deprecated as of vSphere API 5.1, local user groups are not supported
    /// and group specific methods will throw NotSupported.
    /// 
    /// Removes a local group account.
    /// 
    /// ***Required privileges:*** Host.Local.ManageUserGroups
    ///
    /// ## Parameters:
    ///
    /// ### group_name
    /// Group ID of the group account being removed.
    ///
    /// ## Errors:
    ///
    /// ***UserNotFound***: if the specified groupName does not exist.
    pub async fn remove_group(&self, group_name: &str) -> Result<()> {
        let input = RemoveGroupRequestType {group_name, };
        self.client.invoke_void("", "HostLocalAccountManager", &self.mo_id, "RemoveGroup", Some(&input)).await
    }
    /// Removes a local user account.
    /// 
    /// As of vSphere API 5.1, this operation will first try to remove all
    /// permissions associated with the specified account. The permissions of
    /// the user are removed one by one, not atomically, and the operation
    /// is not rolled back if the removal of some permission fails.
    /// 
    /// ***Required privileges:*** Host.Local.ManageUserGroups
    ///
    /// ## Parameters:
    ///
    /// ### user_name
    /// User ID of the user account being removed.
    ///
    /// ## Errors:
    ///
    /// ***SecurityError***: if trying to remove the last local user with
    /// DCUI access,
    /// or if trying to remove the last local
    /// user with full administrative privileges,
    /// or if the system has encountered an error while
    /// trying to remove user's permissions.
    /// or if the account cannot be removed due to
    /// permission issues.
    /// 
    /// ***UserNotFound***: if the specified userName does not exist.
    pub async fn remove_user(&self, user_name: &str) -> Result<()> {
        let input = RemoveUserRequestType {user_name, };
        self.client.invoke_void("", "HostLocalAccountManager", &self.mo_id, "RemoveUser", Some(&input)).await
    }
    /// Deprecated as of vSphere API 5.1, local user groups are not supported
    /// and group specific methods will throw NotSupported.
    /// 
    /// Unassigns a user from a group.
    /// 
    /// ***Required privileges:*** Host.Local.ManageUserGroups
    ///
    /// ## Parameters:
    ///
    /// ### user
    /// User being unassigned from group.
    ///
    /// ### group
    /// Group from which the user is being removed.
    ///
    /// ## Errors:
    ///
    /// ***UserNotFound***: if the specified user or group does not exist.
    /// 
    /// ***NoPermission***: if the group is the only group to which the
    /// user belongs.
    pub async fn unassign_user_from_group(&self, user: &str, group: &str) -> Result<()> {
        let input = UnassignUserFromGroupRequestType {user, group, };
        self.client.invoke_void("", "HostLocalAccountManager", &self.mo_id, "UnassignUserFromGroup", Some(&input)).await
    }
    /// Updates a local user account using the parameters defined in the
    /// *HostLocalAccountManagerAccountSpecification*
    /// data object type.
    /// 
    /// ***Required privileges:*** Host.Local.ManageUserGroups
    ///
    /// ## Parameters:
    ///
    /// ### user
    /// Specification of user being updated.
    ///
    /// ## Errors:
    ///
    /// ***UserNotFound***: if user is not found.
    /// 
    /// ***AlreadyExists***: if new account specification specifies an existing
    /// user's ID.
    /// 
    /// ***InvalidArgument***: if new password or description has an invalid format.
    pub async fn update_user(&self, user: &dyn crate::types::traits::HostAccountSpecTrait) -> Result<()> {
        let input = UpdateUserRequestType {user, };
        self.client.invoke_void("", "HostLocalAccountManager", &self.mo_id, "UpdateUser", Some(&input)).await
    }
}
struct AssignUserToGroupRequestType<'a> {
    user: &'a str,
    group: &'a str,
}

impl<'a> miniserde::Serialize for AssignUserToGroupRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(AssignUserToGroupRequestTypeSer { data: self, seq: 0 }))
    }
}

struct AssignUserToGroupRequestTypeSer<'b, 'a> {
    data: &'b AssignUserToGroupRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for AssignUserToGroupRequestTypeSer<'b, 'a> {
    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
        let seq = self.seq;
        self.seq += 1;
        match seq {
            0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"AssignUserToGroupRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("user"), &self.data.user as &dyn miniserde::Serialize)),
            2 => return Some((std::borrow::Cow::Borrowed("group"), &self.data.group as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}
struct ChangePasswordRequestType<'a> {
    user: &'a str,
    old_password: &'a str,
    new_password: &'a str,
}

impl<'a> miniserde::Serialize for ChangePasswordRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(ChangePasswordRequestTypeSer { data: self, seq: 0 }))
    }
}

struct ChangePasswordRequestTypeSer<'b, 'a> {
    data: &'b ChangePasswordRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for ChangePasswordRequestTypeSer<'b, 'a> {
    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
        let seq = self.seq;
        self.seq += 1;
        match seq {
            0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"ChangePasswordRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("user"), &self.data.user as &dyn miniserde::Serialize)),
            2 => return Some((std::borrow::Cow::Borrowed("oldPassword"), &self.data.old_password as &dyn miniserde::Serialize)),
            3 => return Some((std::borrow::Cow::Borrowed("newPassword"), &self.data.new_password as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}
struct CreateGroupRequestType<'a> {
    group: &'a dyn crate::types::traits::HostAccountSpecTrait,
}

impl<'a> miniserde::Serialize for CreateGroupRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(CreateGroupRequestTypeSer { data: self, seq: 0 }))
    }
}

struct CreateGroupRequestTypeSer<'b, 'a> {
    data: &'b CreateGroupRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for CreateGroupRequestTypeSer<'b, 'a> {
    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
        let seq = self.seq;
        self.seq += 1;
        match seq {
            0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"CreateGroupRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("group"), &self.data.group as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}
struct CreateUserRequestType<'a> {
    user: &'a dyn crate::types::traits::HostAccountSpecTrait,
}

impl<'a> miniserde::Serialize for CreateUserRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(CreateUserRequestTypeSer { data: self, seq: 0 }))
    }
}

struct CreateUserRequestTypeSer<'b, 'a> {
    data: &'b CreateUserRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for CreateUserRequestTypeSer<'b, 'a> {
    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
        let seq = self.seq;
        self.seq += 1;
        match seq {
            0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"CreateUserRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("user"), &self.data.user as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}
struct RemoveGroupRequestType<'a> {
    group_name: &'a str,
}

impl<'a> miniserde::Serialize for RemoveGroupRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(RemoveGroupRequestTypeSer { data: self, seq: 0 }))
    }
}

struct RemoveGroupRequestTypeSer<'b, 'a> {
    data: &'b RemoveGroupRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for RemoveGroupRequestTypeSer<'b, 'a> {
    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
        let seq = self.seq;
        self.seq += 1;
        match seq {
            0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"RemoveGroupRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("groupName"), &self.data.group_name as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}
struct RemoveUserRequestType<'a> {
    user_name: &'a str,
}

impl<'a> miniserde::Serialize for RemoveUserRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(RemoveUserRequestTypeSer { data: self, seq: 0 }))
    }
}

struct RemoveUserRequestTypeSer<'b, 'a> {
    data: &'b RemoveUserRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for RemoveUserRequestTypeSer<'b, 'a> {
    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
        let seq = self.seq;
        self.seq += 1;
        match seq {
            0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"RemoveUserRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("userName"), &self.data.user_name as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}
struct UnassignUserFromGroupRequestType<'a> {
    user: &'a str,
    group: &'a str,
}

impl<'a> miniserde::Serialize for UnassignUserFromGroupRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(UnassignUserFromGroupRequestTypeSer { data: self, seq: 0 }))
    }
}

struct UnassignUserFromGroupRequestTypeSer<'b, 'a> {
    data: &'b UnassignUserFromGroupRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for UnassignUserFromGroupRequestTypeSer<'b, 'a> {
    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
        let seq = self.seq;
        self.seq += 1;
        match seq {
            0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"UnassignUserFromGroupRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("user"), &self.data.user as &dyn miniserde::Serialize)),
            2 => return Some((std::borrow::Cow::Borrowed("group"), &self.data.group as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}
struct UpdateUserRequestType<'a> {
    user: &'a dyn crate::types::traits::HostAccountSpecTrait,
}

impl<'a> miniserde::Serialize for UpdateUserRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(UpdateUserRequestTypeSer { data: self, seq: 0 }))
    }
}

struct UpdateUserRequestTypeSer<'b, 'a> {
    data: &'b UpdateUserRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for UpdateUserRequestTypeSer<'b, 'a> {
    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
        let seq = self.seq;
        self.seq += 1;
        match seq {
            0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"UpdateUserRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("user"), &self.data.user as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}