diff --git a/proxmox-client/src/client.rs b/proxmox-client/src/client.rs index 48b1a7a4..27d07028 100644 --- a/proxmox-client/src/client.rs +++ b/proxmox-client/src/client.rs @@ -363,6 +363,31 @@ impl HttpApiClient for Client { }) } + fn put<'a, T>(&'a self, path_and_query: &'a str, params: &T) -> Self::ResponseFuture<'a> + where + T: ?Sized + Serialize, + { + let params = serde_json::to_string(params) + .map_err(|err| Error::internal("failed to serialize parametres", err)); + + Box::pin(async move { + let params = params?; + let auth = self.login_auth()?; + let uri = self.build_uri(path_and_query)?; + let client = Arc::clone(&self.client); + Self::authenticated_request(client, auth, http::Method::PUT, uri, Some(params)).await + }) + } + + fn put_without_body<'a>(&'a self, path_and_query: &'a str) -> Self::ResponseFuture<'a> { + Box::pin(async move { + let auth = self.login_auth()?; + let uri = self.build_uri(path_and_query)?; + let client = Arc::clone(&self.client); + Self::authenticated_request(client, auth, http::Method::PUT, uri, None).await + }) + } + fn delete<'a>(&'a self, path_and_query: &'a str) -> Self::ResponseFuture<'a> { Box::pin(async move { let auth = self.login_auth()?; diff --git a/proxmox-client/src/lib.rs b/proxmox-client/src/lib.rs index 54e655ae..f8fa273e 100644 --- a/proxmox-client/src/lib.rs +++ b/proxmox-client/src/lib.rs @@ -41,6 +41,20 @@ pub trait HttpApiClient: Send + Sync { where T: ?Sized + Serialize; + /// `PUT` request with a path and query component (no hostname), and a serializable body. + /// + /// The body should be serialized to json and sent with `Content-type: applicaion/json`. + /// + /// For this request, authentication headers should be set! + fn put<'a, T>(&'a self, path_and_query: &'a str, params: &T) -> Self::ResponseFuture<'a> + where + T: ?Sized + Serialize; + + /// `PUT` request with a path and query component (no hostname), no request body. + /// + /// For this request, authentication headers should be set! + fn put_without_body<'a>(&'a self, path_and_query: &'a str) -> Self::ResponseFuture<'a>; + /// `DELETE` request with a path and query component (no hostname). /// /// For this request, authentication headers should be set!