pve/nodes/node/
execute.rs

1#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
2pub struct PostParameters {
3    #[doc = "JSON encoded array of commands."]
4    pub commands: String,
5}
6
7#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, Default)]
8pub struct PostResponseItem {}
9
10#[derive(Debug, Clone)]
11pub struct ExecuteClient<T> {
12    client: T,
13    path: String,
14}
15
16impl<T> ExecuteClient<T>
17where
18    T: Clone,
19{
20    pub fn new(client: T, parent_path: &str) -> Self {
21        Self {
22            client,
23            path: format!("{}/{}", parent_path, "execute"),
24        }
25    }
26}
27impl<T> ExecuteClient<T>
28where
29    T: crate::client::HttpClient,
30{
31    #[doc = "Execute multiple commands in order."]
32    pub fn post(&self, parameters: PostParameters) -> Result<Vec<PostResponseItem>, T::Error> {
33        self.client.post(&self.path, &parameters)
34    }
35}
36#[derive(Debug, Clone)]
37pub struct AsyncExecuteClient<T> {
38    client: T,
39    path: String,
40}
41
42impl<T> AsyncExecuteClient<T>
43where
44    T: Clone,
45{
46    pub fn new(client: T, parent_path: &str) -> Self {
47        Self {
48            client,
49            path: format!("{}/{}", parent_path, "execute"),
50        }
51    }
52}
53impl<T> AsyncExecuteClient<T>
54where
55    T: crate::client::AsyncHttpClient,
56{
57    #[doc = "Execute multiple commands in order."]
58    pub async fn post(
59        &self,
60        parameters: PostParameters,
61    ) -> Result<Vec<PostResponseItem>, T::Error> {
62        self.client.post(&self.path, &parameters).await
63    }
64}