proxmox_api/generated/cluster/mapping/
pci.rs1pub mod id;
2#[derive(Debug, Clone)]
3pub struct PciClient<T> {
4 client: T,
5 path: String,
6}
7impl<T> PciClient<T>
8where
9 T: crate::client::Client,
10{
11 pub fn new(client: T, parent_path: &str) -> Self {
12 Self {
13 client,
14 path: format!("{}{}", parent_path, "/pci"),
15 }
16 }
17}
18impl<T> PciClient<T>
19where
20 T: crate::client::Client,
21{
22 #[doc = "List PCI Hardware Mapping"]
23 #[doc = ""]
24 #[doc = "Only lists entries where you have 'Mapping.Modify', 'Mapping.Use' or 'Mapping.Audit' permissions on '/mapping/pci/\\<id\\>'."]
25 pub async fn get(&self, params: GetParams) -> Result<Vec<GetOutputItems>, T::Error> {
26 let path = self.path.to_string();
27 let optional_vec: Option<Vec<GetOutputItems>> = self.client.get(&path, ¶ms).await?;
28 Ok(optional_vec.unwrap_or_default())
29 }
30}
31impl<T> PciClient<T>
32where
33 T: crate::client::Client,
34{
35 #[doc = "Create a new hardware mapping."]
36 #[doc = ""]
37 #[doc = "Permission check: perm(\"/mapping/pci\", [\"Mapping.Modify\"])"]
38 pub async fn post(&self, params: PostParams) -> Result<(), T::Error> {
39 let path = self.path.to_string();
40 self.client.post(&path, ¶ms).await
41 }
42}
43impl ChecksGetOutputItemsChecksItems {
44 pub fn new(message: String, severity: Severity) -> Self {
45 Self {
46 message,
47 severity,
48 additional_properties: ::std::default::Default::default(),
49 }
50 }
51}
52#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
53pub struct ChecksGetOutputItemsChecksItems {
54 #[doc = "The message of the error"]
55 #[doc = ""]
56 pub message: String,
57 #[doc = "The severity of the error"]
58 #[doc = ""]
59 pub severity: Severity,
60 #[serde(
61 flatten,
62 default,
63 skip_serializing_if = "::std::collections::HashMap::is_empty"
64 )]
65 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
66}
67impl GetOutputItems {
68 pub fn new(description: String, id: String, map: Vec<String>) -> Self {
69 Self {
70 description,
71 id,
72 map,
73 checks: ::std::default::Default::default(),
74 additional_properties: ::std::default::Default::default(),
75 }
76 }
77}
78#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
79pub struct GetOutputItems {
80 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
81 #[doc = "A list of checks, only present if 'check_node' is set."]
82 #[doc = ""]
83 pub checks: Vec<ChecksGetOutputItemsChecksItems>,
84 #[doc = "A description of the logical mapping."]
85 #[doc = ""]
86 pub description: String,
87 #[doc = "The logical ID of the mapping."]
88 #[doc = ""]
89 pub id: String,
90 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
91 #[doc = "The entries of the mapping."]
92 #[doc = ""]
93 pub map: Vec<String>,
94 #[serde(
95 flatten,
96 default,
97 skip_serializing_if = "::std::collections::HashMap::is_empty"
98 )]
99 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
100}
101#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
102pub struct GetParams {
103 #[serde(rename = "check-node")]
104 #[serde(skip_serializing_if = "Option::is_none", default)]
105 #[doc = "If given, checks the configurations on the given node for correctness, and adds relevant diagnostics for the devices to the response."]
106 #[doc = ""]
107 pub check_node: Option<String>,
108 #[serde(
109 flatten,
110 default,
111 skip_serializing_if = "::std::collections::HashMap::is_empty"
112 )]
113 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
114}
115impl PostParams {
116 pub fn new(id: String, map: Vec<String>) -> Self {
117 Self {
118 id,
119 map,
120 description: ::std::default::Default::default(),
121 live_migration_capable: ::std::default::Default::default(),
122 mdev: ::std::default::Default::default(),
123 additional_properties: ::std::default::Default::default(),
124 }
125 }
126}
127#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
128pub struct PostParams {
129 #[serde(skip_serializing_if = "Option::is_none", default)]
130 #[doc = "Description of the logical PCI device."]
131 #[doc = ""]
132 pub description: Option<DescriptionStr>,
133 #[doc = "The ID of the logical PCI mapping."]
134 #[doc = ""]
135 pub id: String,
136 #[serde(rename = "live-migration-capable")]
137 #[serde(
138 serialize_with = "crate::types::serialize_bool_optional",
139 deserialize_with = "crate::types::deserialize_bool_optional"
140 )]
141 #[serde(skip_serializing_if = "Option::is_none", default)]
142 #[doc = "Marks the device(s) as being able to be live-migrated (Experimental). This needs hardware and driver support to work."]
143 #[doc = ""]
144 pub live_migration_capable: Option<bool>,
145 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
146 #[doc = "A list of maps for the cluster nodes."]
147 #[doc = ""]
148 pub map: Vec<String>,
149 #[serde(
150 serialize_with = "crate::types::serialize_bool_optional",
151 deserialize_with = "crate::types::deserialize_bool_optional"
152 )]
153 #[serde(skip_serializing_if = "Option::is_none", default)]
154 #[doc = "Marks the device(s) as being capable of providing mediated devices."]
155 #[doc = ""]
156 pub mdev: Option<bool>,
157 #[serde(
158 flatten,
159 default,
160 skip_serializing_if = "::std::collections::HashMap::is_empty"
161 )]
162 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
163}
164#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
165#[doc = "The severity of the error"]
166#[doc = ""]
167pub enum Severity {
168 #[serde(rename = "error")]
169 Error,
170 #[serde(rename = "warning")]
171 Warning,
172}
173impl TryFrom<&str> for Severity {
174 type Error = String;
175 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
176 match value {
177 "error" => Ok(Self::Error),
178 "warning" => Ok(Self::Warning),
179 v => Err(format!("Unknown variant {v}")),
180 }
181 }
182}
183#[derive(Debug, Clone, PartialEq, PartialOrd)]
184pub struct DescriptionStr {
185 value: String,
186}
187impl crate::types::bounded_string::BoundedString for DescriptionStr {
188 const MIN_LENGTH: Option<usize> = None::<usize>;
189 const MAX_LENGTH: Option<usize> = Some(4096usize);
190 const DEFAULT: Option<&'static str> = None::<&'static str>;
191 const PATTERN: Option<&'static str> = None::<&'static str>;
192 const TYPE_DESCRIPTION: &'static str = "a string with length at most 4096";
193 fn get_value(&self) -> &str {
194 &self.value
195 }
196 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
197 Self::validate(&value)?;
198 Ok(Self { value })
199 }
200}
201impl std::convert::TryFrom<String> for DescriptionStr {
202 type Error = crate::types::bounded_string::BoundedStringError;
203 fn try_from(value: String) -> Result<Self, Self::Error> {
204 crate::types::bounded_string::BoundedString::new(value)
205 }
206}
207impl ::serde::Serialize for DescriptionStr {
208 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
209 where
210 S: ::serde::Serializer,
211 {
212 crate::types::bounded_string::serialize_bounded_string(self, serializer)
213 }
214}
215impl<'de> ::serde::Deserialize<'de> for DescriptionStr {
216 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
217 where
218 D: ::serde::Deserializer<'de>,
219 {
220 crate::types::bounded_string::deserialize_bounded_string(deserializer)
221 }
222}
223impl<T> PciClient<T>
224where
225 T: crate::client::Client,
226{
227 pub fn id(&self, id: &str) -> id::IdClient<T> {
228 id::IdClient::<T>::new(self.client.clone(), &self.path, id)
229 }
230}