proxmox_api/generated/nodes/node/lxc/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) -> Self {
31 Self {
32 hasfeature,
33 additional_properties: ::std::default::Default::default(),
34 }
35 }
36}
37#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
38pub struct GetOutput {
39 #[serde(rename = "hasFeature")]
40 #[serde(
41 serialize_with = "crate::types::serialize_bool",
42 deserialize_with = "crate::types::deserialize_bool"
43 )]
44 pub hasfeature: bool,
45 #[serde(
46 flatten,
47 default,
48 skip_serializing_if = "::std::collections::HashMap::is_empty"
49 )]
50 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
51}
52impl GetParams {
53 pub fn new(feature: Feature) -> Self {
54 Self {
55 feature,
56 snapname: ::std::default::Default::default(),
57 additional_properties: ::std::default::Default::default(),
58 }
59 }
60}
61#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
62pub struct GetParams {
63 #[doc = "Feature to check."]
64 #[doc = ""]
65 pub feature: Feature,
66 #[serde(skip_serializing_if = "Option::is_none", default)]
67 #[doc = "The name of the snapshot."]
68 #[doc = ""]
69 pub snapname: Option<SnapnameStr>,
70 #[serde(
71 flatten,
72 default,
73 skip_serializing_if = "::std::collections::HashMap::is_empty"
74 )]
75 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
76}
77#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
78#[doc = "Feature to check."]
79#[doc = ""]
80pub enum Feature {
81 #[serde(rename = "clone")]
82 Clone,
83 #[serde(rename = "copy")]
84 Copy,
85 #[serde(rename = "snapshot")]
86 Snapshot,
87}
88impl TryFrom<&str> for Feature {
89 type Error = String;
90 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
91 match value {
92 "clone" => Ok(Self::Clone),
93 "copy" => Ok(Self::Copy),
94 "snapshot" => Ok(Self::Snapshot),
95 v => Err(format!("Unknown variant {v}")),
96 }
97 }
98}
99#[derive(Debug, Clone, PartialEq, PartialOrd)]
100pub struct SnapnameStr {
101 value: String,
102}
103impl crate::types::bounded_string::BoundedString for SnapnameStr {
104 const MIN_LENGTH: Option<usize> = None::<usize>;
105 const MAX_LENGTH: Option<usize> = Some(40usize);
106 const DEFAULT: Option<&'static str> = None::<&'static str>;
107 const PATTERN: Option<&'static str> = None::<&'static str>;
108 const TYPE_DESCRIPTION: &'static str = "a string with length at most 40";
109 fn get_value(&self) -> &str {
110 &self.value
111 }
112 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
113 Self::validate(&value)?;
114 Ok(Self { value })
115 }
116}
117impl std::convert::TryFrom<String> for SnapnameStr {
118 type Error = crate::types::bounded_string::BoundedStringError;
119 fn try_from(value: String) -> Result<Self, Self::Error> {
120 crate::types::bounded_string::BoundedString::new(value)
121 }
122}
123impl ::serde::Serialize for SnapnameStr {
124 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
125 where
126 S: ::serde::Serializer,
127 {
128 crate::types::bounded_string::serialize_bounded_string(self, serializer)
129 }
130}
131impl<'de> ::serde::Deserialize<'de> for SnapnameStr {
132 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
133 where
134 D: ::serde::Deserializer<'de>,
135 {
136 crate::types::bounded_string::deserialize_bounded_string(deserializer)
137 }
138}