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
use std::sync::Arc;
use crate::core::client::{VimClient, Result};
/// The *PbmComplianceManager* provides methods to verify the compliance
/// of virtual machine and virtual disk requirement profiles.
///
/// When you provision
/// a virtual machine on a matching datastore, the Server sends the profile
/// to the storage provider. When you perform a compliance check, the storage
/// provider compares the requirements with its capabilities,
/// returns the results to the Server, and the Server returns the results
/// to your client. The Server maintains the compliance results for retrieval
/// at a later time.
///
/// You can check the compliance of one or more virtual machines and/or virtual disks.
/// You can also perform a rollup compliance check, in which the Server checks the
/// compliance of a virtual machine and all of its virtual disks.
#[derive(Clone)]
pub struct PbmComplianceManager {
client: Arc<dyn VimClient>,
mo_id: String,
}
impl PbmComplianceManager {
pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self {
Self {
client,
mo_id: mo_id.to_string(),
}
}
/// Checks compliance of the profiles associated with one or more
/// virtual machines and/or virtual disks.
///
/// The Server stores the compliance results for all of the storage entities
/// associated with the virtual machines and disks. You can call the
/// *PbmComplianceManager.PbmFetchComplianceResult* method
/// to retrieve the stored results. However, for storage entities placed on vSAN,
/// both fetchComplianceResult and checkCompliance methods have the same
/// behaviour of recomputing the compliance.
///
/// ***Required privileges:*** StorageProfile.View
///
/// ## Parameters:
///
/// ### entities
/// One or more references to storage entities.
/// You can specify virtual machines and virtual disks
/// A maximum of 1000 virtual machines and/or virtual disks can be specified
/// in a call. The results of calling the checkCompliance API with
/// more than a 1000 entities is undefined.
/// - If the list of entities also contains datastores, the Server
/// will ignore the datastores.
/// - If the list contains valid and invalid entities, the Server ignores
/// the invalid entities and returns results for the valid entities.
/// Invalid entities are entities that are not in the vCenter inventory.
/// - If the list contains only datastores, the method throws
/// an <code>InvalidArgument</code> fault.
/// - If the list contains virtual machines and disks and the entities
/// are invalid or have been deleted by the time of the request, the method
/// throws an <code>InvalidArgument</code> fault.
///
/// If an entity does not have an associated storage profile, the entity
/// is removed from the list.
///
/// ### profile
/// Not used. If specified, the Server ignores the value.
/// The Server uses the profiles associated with the specified entities.
///
/// ## Returns:
///
/// Result of the compliance check. The returned array contains one
/// result object for each entity specified in the method call.
///
/// ## Errors:
///
/// ***InvalidArgument***: If one of the following situations occurs:
/// - You do not specify an entity.
/// - You specify only datastores.
/// - All of the specified storage entities are invalid.
///
/// ***PbmFault***: If there is an internal server error.
pub async fn pbm_check_compliance(&self, entities: &[crate::types::structs::PbmServerObjectRef], profile: Option<&crate::types::structs::PbmProfileId>) -> Result<Option<Vec<crate::types::structs::PbmComplianceResult>>> {
let input = PbmCheckComplianceRequestType {entities, profile, };
let bytes_opt = self.client.invoke_optional("pbm", "PbmComplianceManager", &self.mo_id, "PbmCheckCompliance", Some(&input)).await?;
match bytes_opt {
Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
None => Ok(None),
}
}
/// Checks rollup compliance of virtual machines and returns the results to your
/// client.
///
/// For a specified virtual machine, a rollup compliance check verifies
/// the storage requirements of the virtual machine and its virtual disks as
/// compared with the storage provider capabilities.
///
/// The Server stores the compliance results for all of the storage entities
/// associated with the virtual machines. You can call the
/// *PbmComplianceManager.PbmFetchRollupComplianceResult* method
/// to retrieve the stored results. However, for storage entities placed on vSAN,
/// both fetchRollupComplianceResult and checkRollupCompliance methods have the
/// same behaviour of recomputing the compliance.
///
/// ***Required privileges:*** StorageProfile.View
///
/// ## Parameters:
///
/// ### entity
/// One or more references to virtual machines.
/// A maximum of 1000 virtual machines can be specified
/// in a call. The results of calling the checkRollupCompliance API with
/// more than a 1000 entities is undefined.
///
/// ## Returns:
///
/// Result of the rollup compliance check. The returned array
/// contains one rollup compliance result for each virtual machine.
/// A rollup compliance result object includes the overall compliance
/// status that represents the collective compliance status for the
/// virtual machine and its virtual disks.
///
/// ## Errors:
///
/// ***InvalidArgument***: If one of the following situations occurs:
/// - You do not specify any entities.
/// - You specify only datastores or virtual disks.
/// - All of the specified virtual machines are invalid.
///
/// ***PbmFault***: If there is an internal server error.
pub async fn pbm_check_rollup_compliance(&self, entity: &[crate::types::structs::PbmServerObjectRef]) -> Result<Option<Vec<crate::types::structs::PbmRollupComplianceResult>>> {
let input = PbmCheckRollupComplianceRequestType {entity, };
let bytes_opt = self.client.invoke_optional("pbm", "PbmComplianceManager", &self.mo_id, "PbmCheckRollupCompliance", Some(&input)).await?;
match bytes_opt {
Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
None => Ok(None),
}
}
/// Retrieves the latest version of *PbmComplianceResult* objects that are
/// available for the specified entities.
///
/// ***Required privileges:*** StorageProfile.View
///
/// ## Parameters:
///
/// ### entities
/// One or more references to storage entities.
/// A maximum of 1000 virtual machines and/or virtual disks can be specified
/// in a call. The results of calling the fetchComplianceResult API with
/// more than a 1000 entities is undefined.
/// - If the list of entities also contains datastores, the Server
/// will ignore the datastores.
/// - If the list contains valid and invalid entities, the Server ignores
/// the invalid entities and returns results for the valid entities.
/// Invalid entities are entities that are not in the vCenter inventory.
/// - If the list contains only datastores, the method throws
/// an <code>InvalidArgument</code> fault.
///
/// ### profile
/// Not used. if specified, the Server ignores the value.
/// The Server uses the profiles associated with the specified entities.
///
/// ## Returns:
///
/// Array of compliance results. The returned array contains
/// one result object for each entity specified in the method call.
///
/// ## Errors:
///
/// ***InvalidArgument***: If one of the following situations occurs:
/// - You do not specify an entity.
/// - You specify only datastores.
/// - All of the specified storage entities are invalid.
///
/// ***PbmFault***: If there is an internal server error.
pub async fn pbm_fetch_compliance_result(&self, entities: &[crate::types::structs::PbmServerObjectRef], profile: Option<&crate::types::structs::PbmProfileId>) -> Result<Option<Vec<crate::types::structs::PbmComplianceResult>>> {
let input = PbmFetchComplianceResultRequestType {entities, profile, };
let bytes_opt = self.client.invoke_optional("pbm", "PbmComplianceManager", &self.mo_id, "PbmFetchComplianceResult", Some(&input)).await?;
match bytes_opt {
Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
None => Ok(None),
}
}
/// Retrieves the rollup compliance (*PbmRollupComplianceResult*)
/// of the given virtual machines if present.
///
/// The returned rollup compliance
/// result may be old. Invoke checkRollupCompliance API to compute and retrieve the
/// latest rollup compliance result. For storage entities placed on vSAN the
/// returned compliance is always the latest.
///
/// ***Required privileges:*** StorageProfile.View
///
/// ## Parameters:
///
/// ### entity
/// One or more virtual machines.
/// A maximum of 1000 virtual machines can be specified
/// in a call. The results of calling the fetchRollupComplianceResult API with
/// more than a 1000 entity objects is undefined.
///
/// ## Returns:
///
/// Rollup compliance results for the given virtual machines.
///
/// ## Errors:
///
/// ***InvalidArgument***: If one of the following situations occurs:
/// - There is no profile associated with the virtual machine
/// or its virtual disks.
/// - You specify only datastores or virtual disks.
/// - All of the specified virtual machines are invalid.
///
/// ***PbmFault***: If there is an internal server error.
pub async fn pbm_fetch_rollup_compliance_result(&self, entity: &[crate::types::structs::PbmServerObjectRef]) -> Result<Option<Vec<crate::types::structs::PbmRollupComplianceResult>>> {
let input = PbmFetchRollupComplianceResultRequestType {entity, };
let bytes_opt = self.client.invoke_optional("pbm", "PbmComplianceManager", &self.mo_id, "PbmFetchRollupComplianceResult", Some(&input)).await?;
match bytes_opt {
Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
None => Ok(None),
}
}
/// Returns the virtual machines for the given rollup compliance status.
///
/// ***Required privileges:*** StorageProfile.View
///
/// ## Parameters:
///
/// ### status
/// *PbmComplianceStatus_enum*
///
/// ## Returns:
///
/// Array of VirtualMachine entities
///
/// ## Errors:
///
/// ***InvalidArgument***: If the given status parameter is invalid or incorrect format.
///
/// ***PbmFault***: If there is an internal service error.
pub async fn pbm_query_by_rollup_compliance_status(&self, status: &str) -> Result<Option<Vec<crate::types::structs::PbmServerObjectRef>>> {
let input = PbmQueryByRollupComplianceStatusRequestType {status, };
let bytes_opt = self.client.invoke_optional("pbm", "PbmComplianceManager", &self.mo_id, "PbmQueryByRollupComplianceStatus", Some(&input)).await?;
match bytes_opt {
Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
None => Ok(None),
}
}
}
struct PbmCheckComplianceRequestType<'a> {
entities: &'a [crate::types::structs::PbmServerObjectRef],
profile: Option<&'a crate::types::structs::PbmProfileId>,
}
impl<'a> miniserde::Serialize for PbmCheckComplianceRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(PbmCheckComplianceRequestTypeSer { data: self, seq: 0 }))
}
}
struct PbmCheckComplianceRequestTypeSer<'b, 'a> {
data: &'b PbmCheckComplianceRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for PbmCheckComplianceRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
loop {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"PbmCheckComplianceRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("entities"), &self.data.entities as &dyn miniserde::Serialize)),
2 => {
let Some(ref val) = self.data.profile else { continue; };
return Some((std::borrow::Cow::Borrowed("profile"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct PbmCheckRollupComplianceRequestType<'a> {
entity: &'a [crate::types::structs::PbmServerObjectRef],
}
impl<'a> miniserde::Serialize for PbmCheckRollupComplianceRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(PbmCheckRollupComplianceRequestTypeSer { data: self, seq: 0 }))
}
}
struct PbmCheckRollupComplianceRequestTypeSer<'b, 'a> {
data: &'b PbmCheckRollupComplianceRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for PbmCheckRollupComplianceRequestTypeSer<'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"), &"PbmCheckRollupComplianceRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("entity"), &self.data.entity as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct PbmFetchComplianceResultRequestType<'a> {
entities: &'a [crate::types::structs::PbmServerObjectRef],
profile: Option<&'a crate::types::structs::PbmProfileId>,
}
impl<'a> miniserde::Serialize for PbmFetchComplianceResultRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(PbmFetchComplianceResultRequestTypeSer { data: self, seq: 0 }))
}
}
struct PbmFetchComplianceResultRequestTypeSer<'b, 'a> {
data: &'b PbmFetchComplianceResultRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for PbmFetchComplianceResultRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
loop {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"PbmFetchComplianceResultRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("entities"), &self.data.entities as &dyn miniserde::Serialize)),
2 => {
let Some(ref val) = self.data.profile else { continue; };
return Some((std::borrow::Cow::Borrowed("profile"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct PbmFetchRollupComplianceResultRequestType<'a> {
entity: &'a [crate::types::structs::PbmServerObjectRef],
}
impl<'a> miniserde::Serialize for PbmFetchRollupComplianceResultRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(PbmFetchRollupComplianceResultRequestTypeSer { data: self, seq: 0 }))
}
}
struct PbmFetchRollupComplianceResultRequestTypeSer<'b, 'a> {
data: &'b PbmFetchRollupComplianceResultRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for PbmFetchRollupComplianceResultRequestTypeSer<'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"), &"PbmFetchRollupComplianceResultRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("entity"), &self.data.entity as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct PbmQueryByRollupComplianceStatusRequestType<'a> {
status: &'a str,
}
impl<'a> miniserde::Serialize for PbmQueryByRollupComplianceStatusRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(PbmQueryByRollupComplianceStatusRequestTypeSer { data: self, seq: 0 }))
}
}
struct PbmQueryByRollupComplianceStatusRequestTypeSer<'b, 'a> {
data: &'b PbmQueryByRollupComplianceStatusRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for PbmQueryByRollupComplianceStatusRequestTypeSer<'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"), &"PbmQueryByRollupComplianceStatusRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("status"), &self.data.status as &dyn miniserde::Serialize)),
_ => return None,
}
}
}