client: put requests
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
ffe908f636
commit
a3322e49b9
@ -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()?;
|
||||
|
@ -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!
|
||||
|
Loading…
Reference in New Issue
Block a user