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
use std::sync::Arc;
use crate::core::client::{VimClient, Result};
/// The VsanCapabilitySystem exposes interfaces to retrieve the supported
/// capabilities on the current system.
///
/// The Managed Entity can be accessed
/// through MOID of vsan-vc-capability-system at vCenter server side or
/// vsan-capability-system at ESXi server side.
#[derive(Clone)]
pub struct VsanCapabilitySystem {
client: Arc<dyn VimClient>,
mo_id: String,
}
impl VsanCapabilitySystem {
pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self {
Self {
client,
mo_id: mo_id.to_string(),
}
}
/// Retrieves the supported capabilities on the current system.
///
/// The calculation
/// is based on the available APIs and registered managed objects. This way the
/// client can be sure if a certain feature is supported on the system or not.
/// For scenarios like disconnected hosts, older version hosts than ESXi 6.0 U1,
/// or unable to retrieve capabilities due to other reasons, along with empty
/// capability set, status of target managed object at the retrieving time is
/// also returned to explain the reason. For a host whose capabilities are
/// calculated according to host version, a 'calculated' capability status is
/// returned. For other cases, the statuses field in
/// *VsanCapability*
/// is omitted.
///
/// ## Parameters:
///
/// ### targets
/// An optional list of targeted managed objects. The supported
/// targets are HostSystem and ClusterComputeResource instances. If a HostSystem
/// is given, the result contains information about the capabilities of this
/// certain host. If a cluster is passed, the result contains information about
/// the capabilities of all hosts that reside in the cluster and the capabilities
/// of the vCenter. If the targets parameter is empty, the result contains only
/// the capabilities of the current vCenter.
///
/// ***Required privileges:*** System.Read
///
/// ## Returns:
///
/// A list of vim.cluster.VsanCapability.
///
/// ## Errors:
///
/// Failure
pub async fn vsan_get_capabilities(&self, targets: Option<&[crate::types::structs::ManagedObjectReference]>) -> Result<Vec<crate::types::structs::VsanCapability>> {
let input = VsanGetCapabilitiesRequestType {targets, };
let bytes = self.client.invoke("vsan", "VsanCapabilitySystem", &self.mo_id, "VsanGetCapabilities", Some(&input)).await?;
let result: Vec<crate::types::structs::VsanCapability> = crate::core::client::unmarshal_array(self.client.transport(), &bytes)?;
Ok(result)
}
}
struct VsanGetCapabilitiesRequestType<'a> {
targets: Option<&'a [crate::types::structs::ManagedObjectReference]>,
}
impl<'a> miniserde::Serialize for VsanGetCapabilitiesRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(VsanGetCapabilitiesRequestTypeSer { data: self, seq: 0 }))
}
}
struct VsanGetCapabilitiesRequestTypeSer<'b, 'a> {
data: &'b VsanGetCapabilitiesRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for VsanGetCapabilitiesRequestTypeSer<'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"), &"VsanGetCapabilitiesRequestType")),
1 => {
let Some(ref val) = self.data.targets else { continue; };
return Some((std::borrow::Cow::Borrowed("targets"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}