Skip to main content

proxmox_api/generated/cluster/mapping/
usb.rs

1pub mod id;
2#[derive(Debug, Clone)]
3pub struct UsbClient<T> {
4    client: T,
5    path: String,
6}
7impl<T> UsbClient<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, "/usb"),
15        }
16    }
17}
18impl<T> UsbClient<T>
19where
20    T: crate::client::Client,
21{
22    #[doc = "List USB Hardware Mappings"]
23    #[doc = ""]
24    #[doc = "Only lists entries where you have 'Mapping.Modify', 'Mapping.Use' or 'Mapping.Audit' permissions on '/mapping/usb/\\<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, &params).await?;
28        Ok(optional_vec.unwrap_or_default())
29    }
30}
31impl<T> UsbClient<T>
32where
33    T: crate::client::Client,
34{
35    #[doc = "Create a new hardware mapping."]
36    #[doc = ""]
37    #[doc = "Permission check: perm(\"/mapping/usb\", [\"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, &params).await
41    }
42}
43impl GetOutputItems {
44    pub fn new(description: String, id: String, map: Vec<String>) -> Self {
45        Self {
46            description,
47            id,
48            map,
49            additional_properties: ::std::default::Default::default(),
50        }
51    }
52}
53#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
54pub struct GetOutputItems {
55    #[doc = "A description of the logical mapping."]
56    #[doc = ""]
57    pub description: String,
58    #[doc = "The logical ID of the mapping."]
59    #[doc = ""]
60    pub id: String,
61    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
62    #[doc = "The entries of the mapping."]
63    #[doc = ""]
64    pub map: Vec<String>,
65    #[serde(
66        flatten,
67        default,
68        skip_serializing_if = "::std::collections::HashMap::is_empty"
69    )]
70    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
71}
72#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
73pub struct GetParams {
74    #[serde(rename = "check-node")]
75    #[serde(skip_serializing_if = "Option::is_none", default)]
76    #[doc = "If given, checks the configurations on the given node for correctness, and adds relevant errors to the devices."]
77    #[doc = ""]
78    pub check_node: Option<String>,
79    #[serde(
80        flatten,
81        default,
82        skip_serializing_if = "::std::collections::HashMap::is_empty"
83    )]
84    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
85}
86impl PostParams {
87    pub fn new(id: String, map: Vec<String>) -> Self {
88        Self {
89            id,
90            map,
91            description: ::std::default::Default::default(),
92            additional_properties: ::std::default::Default::default(),
93        }
94    }
95}
96#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
97pub struct PostParams {
98    #[serde(skip_serializing_if = "Option::is_none", default)]
99    #[doc = "Description of the logical USB device."]
100    #[doc = ""]
101    pub description: Option<DescriptionStr>,
102    #[doc = "The ID of the logical USB mapping."]
103    #[doc = ""]
104    pub id: String,
105    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
106    #[doc = "A list of maps for the cluster nodes."]
107    #[doc = ""]
108    pub map: Vec<String>,
109    #[serde(
110        flatten,
111        default,
112        skip_serializing_if = "::std::collections::HashMap::is_empty"
113    )]
114    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
115}
116#[derive(Debug, Clone, PartialEq, PartialOrd)]
117pub struct DescriptionStr {
118    value: String,
119}
120impl crate::types::bounded_string::BoundedString for DescriptionStr {
121    const MIN_LENGTH: Option<usize> = None::<usize>;
122    const MAX_LENGTH: Option<usize> = Some(4096usize);
123    const DEFAULT: Option<&'static str> = None::<&'static str>;
124    const PATTERN: Option<&'static str> = None::<&'static str>;
125    const TYPE_DESCRIPTION: &'static str = "a string with length at most 4096";
126    fn get_value(&self) -> &str {
127        &self.value
128    }
129    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
130        Self::validate(&value)?;
131        Ok(Self { value })
132    }
133}
134impl std::convert::TryFrom<String> for DescriptionStr {
135    type Error = crate::types::bounded_string::BoundedStringError;
136    fn try_from(value: String) -> Result<Self, Self::Error> {
137        crate::types::bounded_string::BoundedString::new(value)
138    }
139}
140impl ::serde::Serialize for DescriptionStr {
141    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
142    where
143        S: ::serde::Serializer,
144    {
145        crate::types::bounded_string::serialize_bounded_string(self, serializer)
146    }
147}
148impl<'de> ::serde::Deserialize<'de> for DescriptionStr {
149    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
150    where
151        D: ::serde::Deserializer<'de>,
152    {
153        crate::types::bounded_string::deserialize_bounded_string(deserializer)
154    }
155}
156impl<T> UsbClient<T>
157where
158    T: crate::client::Client,
159{
160    pub fn id(&self, id: &str) -> id::IdClient<T> {
161        id::IdClient::<T>::new(self.client.clone(), &self.path, id)
162    }
163}