proxmox_api/generated/nodes/node/storage/storage/
download_url.rs1#[derive(Debug, Clone)]
2pub struct DownloadUrlClient<T> {
3 client: T,
4 path: String,
5}
6impl<T> DownloadUrlClient<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, "/download-url"),
14 }
15 }
16}
17impl<T> DownloadUrlClient<T>
18where
19 T: crate::client::Client,
20{
21 #[doc = "Download templates, ISO images, OVAs and VM images by using an URL."]
22 #[doc = ""]
23 #[doc = "Permission check: and(perm(\"/storage/{storage}\", [\"Datastore.AllocateTemplate\"]), or(perm(\"/\", [\"Sys.Audit\", \"Sys.Modify\"]), perm(\"/nodes/{node}\", [\"Sys.AccessNetwork\"])))"]
24 #[doc = "Requires allocation access on the storage and as this allows one to probe the (local!) host network indirectly it also requires one of Sys.Modify on / (for backwards compatibility) or the newer Sys.AccessNetwork privilege on the node."]
25 pub async fn post(&self, params: PostParams) -> Result<String, T::Error> {
26 let path = self.path.to_string();
27 self.client.post(&path, ¶ms).await
28 }
29}
30impl PostParams {
31 pub fn new(content: Content, filename: FilenameStr, url: UrlStr) -> Self {
32 Self {
33 content,
34 filename,
35 url,
36 checksum: ::std::default::Default::default(),
37 checksum_algorithm: ::std::default::Default::default(),
38 compression: ::std::default::Default::default(),
39 verify_certificates: ::std::default::Default::default(),
40 additional_properties: ::std::default::Default::default(),
41 }
42 }
43}
44#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
45pub struct PostParams {
46 #[serde(skip_serializing_if = "Option::is_none", default)]
47 #[doc = "The expected checksum of the file."]
48 #[doc = ""]
49 pub checksum: Option<String>,
50 #[serde(rename = "checksum-algorithm")]
51 #[serde(skip_serializing_if = "Option::is_none", default)]
52 #[doc = "The algorithm to calculate the checksum of the file."]
53 #[doc = ""]
54 pub checksum_algorithm: Option<ChecksumAlgorithm>,
55 #[serde(skip_serializing_if = "Option::is_none", default)]
56 #[doc = "Decompress the downloaded file using the specified compression algorithm."]
57 #[doc = ""]
58 pub compression: Option<String>,
59 #[doc = "Content type."]
60 #[doc = ""]
61 pub content: Content,
62 #[doc = "The name of the file to create. Caution: This will be normalized!"]
63 #[doc = ""]
64 pub filename: FilenameStr,
65 #[doc = "The URL to download the file from."]
66 #[doc = ""]
67 pub url: UrlStr,
68 #[serde(rename = "verify-certificates")]
69 #[serde(
70 serialize_with = "crate::types::serialize_bool_optional",
71 deserialize_with = "crate::types::deserialize_bool_optional"
72 )]
73 #[serde(skip_serializing_if = "Option::is_none", default)]
74 #[doc = "If false, no SSL/TLS certificates will be verified."]
75 #[doc = ""]
76 pub verify_certificates: Option<bool>,
77 #[serde(
78 flatten,
79 default,
80 skip_serializing_if = "::std::collections::HashMap::is_empty"
81 )]
82 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
83}
84#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
85#[doc = "The algorithm to calculate the checksum of the file."]
86#[doc = ""]
87pub enum ChecksumAlgorithm {
88 #[serde(rename = "md5")]
89 Md5,
90 #[serde(rename = "sha1")]
91 Sha1,
92 #[serde(rename = "sha224")]
93 Sha224,
94 #[serde(rename = "sha256")]
95 Sha256,
96 #[serde(rename = "sha384")]
97 Sha384,
98 #[serde(rename = "sha512")]
99 Sha512,
100}
101impl TryFrom<&str> for ChecksumAlgorithm {
102 type Error = String;
103 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
104 match value {
105 "md5" => Ok(Self::Md5),
106 "sha1" => Ok(Self::Sha1),
107 "sha224" => Ok(Self::Sha224),
108 "sha256" => Ok(Self::Sha256),
109 "sha384" => Ok(Self::Sha384),
110 "sha512" => Ok(Self::Sha512),
111 v => Err(format!("Unknown variant {v}")),
112 }
113 }
114}
115#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
116#[doc = "Content type."]
117#[doc = ""]
118pub enum Content {
119 #[serde(rename = "import")]
120 Import,
121 #[serde(rename = "iso")]
122 Iso,
123 #[serde(rename = "vztmpl")]
124 Vztmpl,
125}
126impl TryFrom<&str> for Content {
127 type Error = String;
128 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
129 match value {
130 "import" => Ok(Self::Import),
131 "iso" => Ok(Self::Iso),
132 "vztmpl" => Ok(Self::Vztmpl),
133 v => Err(format!("Unknown variant {v}")),
134 }
135 }
136}
137#[derive(Debug, Clone, PartialEq, PartialOrd)]
138pub struct FilenameStr {
139 value: String,
140}
141impl crate::types::bounded_string::BoundedString for FilenameStr {
142 const MIN_LENGTH: Option<usize> = None::<usize>;
143 const MAX_LENGTH: Option<usize> = Some(255usize);
144 const DEFAULT: Option<&'static str> = None::<&'static str>;
145 const PATTERN: Option<&'static str> = None::<&'static str>;
146 const TYPE_DESCRIPTION: &'static str = "a string with length at most 255";
147 fn get_value(&self) -> &str {
148 &self.value
149 }
150 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
151 Self::validate(&value)?;
152 Ok(Self { value })
153 }
154}
155impl std::convert::TryFrom<String> for FilenameStr {
156 type Error = crate::types::bounded_string::BoundedStringError;
157 fn try_from(value: String) -> Result<Self, Self::Error> {
158 crate::types::bounded_string::BoundedString::new(value)
159 }
160}
161impl ::serde::Serialize for FilenameStr {
162 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
163 where
164 S: ::serde::Serializer,
165 {
166 crate::types::bounded_string::serialize_bounded_string(self, serializer)
167 }
168}
169impl<'de> ::serde::Deserialize<'de> for FilenameStr {
170 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
171 where
172 D: ::serde::Deserializer<'de>,
173 {
174 crate::types::bounded_string::deserialize_bounded_string(deserializer)
175 }
176}
177#[derive(Debug, Clone, PartialEq, PartialOrd)]
178pub struct UrlStr {
179 value: String,
180}
181impl crate::types::bounded_string::BoundedString for UrlStr {
182 const MIN_LENGTH: Option<usize> = None::<usize>;
183 const MAX_LENGTH: Option<usize> = None::<usize>;
184 const DEFAULT: Option<&'static str> = None::<&'static str>;
185 const PATTERN: Option<&'static str> = Some("https?://.*");
186 const TYPE_DESCRIPTION: &'static str =
187 "a string with pattern r\"https?://.*\" and no length constraints";
188 fn get_value(&self) -> &str {
189 &self.value
190 }
191 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
192 Self::validate(&value)?;
193 Ok(Self { value })
194 }
195}
196impl std::convert::TryFrom<String> for UrlStr {
197 type Error = crate::types::bounded_string::BoundedStringError;
198 fn try_from(value: String) -> Result<Self, Self::Error> {
199 crate::types::bounded_string::BoundedString::new(value)
200 }
201}
202impl ::serde::Serialize for UrlStr {
203 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
204 where
205 S: ::serde::Serializer,
206 {
207 crate::types::bounded_string::serialize_bounded_string(self, serializer)
208 }
209}
210impl<'de> ::serde::Deserialize<'de> for UrlStr {
211 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
212 where
213 D: ::serde::Deserializer<'de>,
214 {
215 crate::types::bounded_string::deserialize_bounded_string(deserializer)
216 }
217}