proxmox_api/generated/nodes/node/qemu/vmid/
feature.rs1#[derive(Debug, Clone)]
2pub struct FeatureClient<T> {
3 client: T,
4 path: String,
5}
6impl<T> FeatureClient<T>
7where
8 T: crate::client::Client,
9{
10 pub fn new(client: T, parent_path: &str) -> Self {
11 Self {
12 client,
13 path: format!("{}{}", parent_path, "/feature"),
14 }
15 }
16}
17impl<T> FeatureClient<T>
18where
19 T: crate::client::Client,
20{
21 #[doc = "Check if feature for virtual machine is available."]
22 #[doc = ""]
23 #[doc = "Permission check: perm(\"/vms/{vmid}\", [\"VM.Audit\"])"]
24 pub async fn get(&self, params: GetParams) -> Result<GetOutput, T::Error> {
25 let path = self.path.to_string();
26 self.client.get(&path, ¶ms).await
27 }
28}
29impl GetOutput {
30 pub fn new(hasfeature: bool, nodes: Vec<String>) -> Self {
31 Self {
32 hasfeature,
33 nodes,
34 additional_properties: ::std::default::Default::default(),
35 }
36 }
37}
38#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
39pub struct GetOutput {
40 #[serde(rename = "hasFeature")]
41 #[serde(
42 serialize_with = "crate::types::serialize_bool",
43 deserialize_with = "crate::types::deserialize_bool"
44 )]
45 pub hasfeature: bool,
46 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
47 pub nodes: Vec<String>,
48 #[serde(
49 flatten,
50 default,
51 skip_serializing_if = "::std::collections::HashMap::is_empty"
52 )]
53 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
54}
55impl GetParams {
56 pub fn new(feature: Feature) -> Self {
57 Self {
58 feature,
59 snapname: ::std::default::Default::default(),
60 additional_properties: ::std::default::Default::default(),
61 }
62 }
63}
64#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
65pub struct GetParams {
66 #[doc = "Feature to check."]
67 #[doc = ""]
68 pub feature: Feature,
69 #[serde(skip_serializing_if = "Option::is_none", default)]
70 #[doc = "The name of the snapshot."]
71 #[doc = ""]
72 pub snapname: Option<SnapnameStr>,
73 #[serde(
74 flatten,
75 default,
76 skip_serializing_if = "::std::collections::HashMap::is_empty"
77 )]
78 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
79}
80#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
81#[doc = "Feature to check."]
82#[doc = ""]
83pub enum Feature {
84 #[serde(rename = "clone")]
85 Clone,
86 #[serde(rename = "copy")]
87 Copy,
88 #[serde(rename = "snapshot")]
89 Snapshot,
90}
91impl TryFrom<&str> for Feature {
92 type Error = String;
93 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
94 match value {
95 "clone" => Ok(Self::Clone),
96 "copy" => Ok(Self::Copy),
97 "snapshot" => Ok(Self::Snapshot),
98 v => Err(format!("Unknown variant {v}")),
99 }
100 }
101}
102#[derive(Debug, Clone, PartialEq, PartialOrd)]
103pub struct SnapnameStr {
104 value: String,
105}
106impl crate::types::bounded_string::BoundedString for SnapnameStr {
107 const MIN_LENGTH: Option<usize> = None::<usize>;
108 const MAX_LENGTH: Option<usize> = Some(40usize);
109 const DEFAULT: Option<&'static str> = None::<&'static str>;
110 const PATTERN: Option<&'static str> = None::<&'static str>;
111 const TYPE_DESCRIPTION: &'static str = "a string with length at most 40";
112 fn get_value(&self) -> &str {
113 &self.value
114 }
115 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
116 Self::validate(&value)?;
117 Ok(Self { value })
118 }
119}
120impl std::convert::TryFrom<String> for SnapnameStr {
121 type Error = crate::types::bounded_string::BoundedStringError;
122 fn try_from(value: String) -> Result<Self, Self::Error> {
123 crate::types::bounded_string::BoundedString::new(value)
124 }
125}
126impl ::serde::Serialize for SnapnameStr {
127 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
128 where
129 S: ::serde::Serializer,
130 {
131 crate::types::bounded_string::serialize_bounded_string(self, serializer)
132 }
133}
134impl<'de> ::serde::Deserialize<'de> for SnapnameStr {
135 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
136 where
137 D: ::serde::Deserializer<'de>,
138 {
139 crate::types::bounded_string::deserialize_bounded_string(deserializer)
140 }
141}