proxmox_api/generated/nodes/node/
hosts.rs1#[derive(Debug, Clone)]
2pub struct HostsClient<T> {
3 client: T,
4 path: String,
5}
6impl<T> HostsClient<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, "/hosts"),
14 }
15 }
16}
17impl<T> HostsClient<T>
18where
19 T: crate::client::Client,
20{
21 #[doc = "Get the content of /etc/hosts."]
22 #[doc = ""]
23 #[doc = "Permission check: perm(\"/\", [\"Sys.Audit\"])"]
24 pub async fn get(&self) -> Result<GetOutput, T::Error> {
25 let path = self.path.to_string();
26 self.client.get(&path, &()).await
27 }
28}
29impl<T> HostsClient<T>
30where
31 T: crate::client::Client,
32{
33 #[doc = "Write /etc/hosts."]
34 #[doc = ""]
35 #[doc = "Permission check: perm(\"/nodes/{node}\", [\"Sys.Modify\"])"]
36 pub async fn post(&self, params: PostParams) -> Result<(), T::Error> {
37 let path = self.path.to_string();
38 self.client.post(&path, ¶ms).await
39 }
40}
41impl GetOutput {
42 pub fn new(data: String) -> Self {
43 Self {
44 data,
45 digest: ::std::default::Default::default(),
46 additional_properties: ::std::default::Default::default(),
47 }
48 }
49}
50#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
51pub struct GetOutput {
52 #[doc = "The content of /etc/hosts."]
53 #[doc = ""]
54 pub data: String,
55 #[serde(skip_serializing_if = "Option::is_none", default)]
56 #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
57 #[doc = ""]
58 pub digest: Option<DigestStr>,
59 #[serde(
60 flatten,
61 default,
62 skip_serializing_if = "::std::collections::HashMap::is_empty"
63 )]
64 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
65}
66impl PostParams {
67 pub fn new(data: String) -> Self {
68 Self {
69 data,
70 digest: ::std::default::Default::default(),
71 additional_properties: ::std::default::Default::default(),
72 }
73 }
74}
75#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
76pub struct PostParams {
77 #[doc = "The target content of /etc/hosts."]
78 #[doc = ""]
79 pub data: String,
80 #[serde(skip_serializing_if = "Option::is_none", default)]
81 #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
82 #[doc = ""]
83 pub digest: Option<DigestStr>,
84 #[serde(
85 flatten,
86 default,
87 skip_serializing_if = "::std::collections::HashMap::is_empty"
88 )]
89 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
90}
91#[derive(Debug, Clone, PartialEq, PartialOrd)]
92pub struct DigestStr {
93 value: String,
94}
95impl crate::types::bounded_string::BoundedString for DigestStr {
96 const MIN_LENGTH: Option<usize> = None::<usize>;
97 const MAX_LENGTH: Option<usize> = Some(64usize);
98 const DEFAULT: Option<&'static str> = None::<&'static str>;
99 const PATTERN: Option<&'static str> = None::<&'static str>;
100 const TYPE_DESCRIPTION: &'static str = "a string with length at most 64";
101 fn get_value(&self) -> &str {
102 &self.value
103 }
104 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
105 Self::validate(&value)?;
106 Ok(Self { value })
107 }
108}
109impl std::convert::TryFrom<String> for DigestStr {
110 type Error = crate::types::bounded_string::BoundedStringError;
111 fn try_from(value: String) -> Result<Self, Self::Error> {
112 crate::types::bounded_string::BoundedString::new(value)
113 }
114}
115impl ::serde::Serialize for DigestStr {
116 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
117 where
118 S: ::serde::Serializer,
119 {
120 crate::types::bounded_string::serialize_bounded_string(self, serializer)
121 }
122}
123impl<'de> ::serde::Deserialize<'de> for DigestStr {
124 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
125 where
126 D: ::serde::Deserializer<'de>,
127 {
128 crate::types::bounded_string::deserialize_bounded_string(deserializer)
129 }
130}