src/api2/admin/datastore.rs: imp delete_snapshot

This commit is contained in:
Dietmar Maurer
2019-03-03 11:29:00 +01:00
parent af926291e0
commit 6f62c9240a
4 changed files with 128 additions and 10 deletions

View File

@ -121,6 +121,26 @@ impl HttpClient {
Self::run_request(request)
}
pub fn delete(&mut self, path: &str) -> Result<Value, Error> {
let path = path.trim_matches('/');
let url: Uri = format!("https://{}:8007/{}", self.server, path).parse()?;
let (ticket, token) = self.login()?;
let enc_ticket = percent_encode(ticket.as_bytes(), DEFAULT_ENCODE_SET).to_string();
let request = Request::builder()
.method("DELETE")
.uri(url)
.header("User-Agent", "proxmox-backup-client/1.0")
.header("Cookie", format!("PBSAuthCookie={}", enc_ticket))
.header("CSRFPreventionToken", token)
.body(Body::empty())?;
Self::run_request(request)
}
pub fn post(&mut self, path: &str) -> Result<Value, Error> {
let path = path.trim_matches('/');