Skip to main content

proxmox_api/generated/nodes/node/
query_url_metadata.rs

1#[derive(Debug, Clone)]
2pub struct QueryUrlMetadataClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> QueryUrlMetadataClient<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, "/query-url-metadata"),
14        }
15    }
16}
17impl<T> QueryUrlMetadataClient<T>
18where
19    T: crate::client::Client,
20{
21    #[doc = "Query metadata of an URL: file size, file name and mime type."]
22    #[doc = ""]
23    #[doc = "Permission check: or(perm(\"/\", [\"Sys.Audit\", \"Sys.Modify\"]), perm(\"/nodes/{node}\", [\"Sys.AccessNetwork\"]))"]
24    pub async fn get(&self, params: GetParams) -> Result<GetOutput, T::Error> {
25        let path = self.path.to_string();
26        self.client.get(&path, &params).await
27    }
28}
29#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
30pub struct GetOutput {
31    #[serde(skip_serializing_if = "Option::is_none", default)]
32    pub filename: Option<String>,
33    #[serde(skip_serializing_if = "Option::is_none", default)]
34    pub mimetype: Option<String>,
35    #[serde(
36        serialize_with = "crate::types::serialize_int_optional",
37        deserialize_with = "crate::types::deserialize_int_optional"
38    )]
39    #[serde(skip_serializing_if = "Option::is_none", default)]
40    pub size: Option<i64>,
41    #[serde(
42        flatten,
43        default,
44        skip_serializing_if = "::std::collections::HashMap::is_empty"
45    )]
46    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
47}
48impl GetParams {
49    pub fn new(url: UrlStr) -> Self {
50        Self {
51            url,
52            verify_certificates: ::std::default::Default::default(),
53            additional_properties: ::std::default::Default::default(),
54        }
55    }
56}
57#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
58pub struct GetParams {
59    #[doc = "The URL to query the metadata from."]
60    #[doc = ""]
61    pub url: UrlStr,
62    #[serde(rename = "verify-certificates")]
63    #[serde(
64        serialize_with = "crate::types::serialize_bool_optional",
65        deserialize_with = "crate::types::deserialize_bool_optional"
66    )]
67    #[serde(skip_serializing_if = "Option::is_none", default)]
68    #[doc = "If false, no SSL/TLS certificates will be verified."]
69    #[doc = ""]
70    pub verify_certificates: Option<bool>,
71    #[serde(
72        flatten,
73        default,
74        skip_serializing_if = "::std::collections::HashMap::is_empty"
75    )]
76    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
77}
78#[derive(Debug, Clone, PartialEq, PartialOrd)]
79pub struct UrlStr {
80    value: String,
81}
82impl crate::types::bounded_string::BoundedString for UrlStr {
83    const MIN_LENGTH: Option<usize> = None::<usize>;
84    const MAX_LENGTH: Option<usize> = None::<usize>;
85    const DEFAULT: Option<&'static str> = None::<&'static str>;
86    const PATTERN: Option<&'static str> = Some("https?://.*");
87    const TYPE_DESCRIPTION: &'static str =
88        "a string with pattern r\"https?://.*\" and no length constraints";
89    fn get_value(&self) -> &str {
90        &self.value
91    }
92    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
93        Self::validate(&value)?;
94        Ok(Self { value })
95    }
96}
97impl std::convert::TryFrom<String> for UrlStr {
98    type Error = crate::types::bounded_string::BoundedStringError;
99    fn try_from(value: String) -> Result<Self, Self::Error> {
100        crate::types::bounded_string::BoundedString::new(value)
101    }
102}
103impl ::serde::Serialize for UrlStr {
104    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
105    where
106        S: ::serde::Serializer,
107    {
108        crate::types::bounded_string::serialize_bounded_string(self, serializer)
109    }
110}
111impl<'de> ::serde::Deserialize<'de> for UrlStr {
112    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
113    where
114        D: ::serde::Deserializer<'de>,
115    {
116        crate::types::bounded_string::deserialize_bounded_string(deserializer)
117    }
118}