proxmox-client: add post_without_body

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
Dietmar Maurer 2023-08-27 16:16:37 +02:00
parent d49fc1aa2f
commit 022fdacb25
3 changed files with 26 additions and 100 deletions

View File

@ -1,100 +0,0 @@
Source: rust-proxmox-client
Section: rust
Priority: optional
Build-Depends: debhelper (>= 12),
dh-cargo (>= 25),
cargo:native <!nocheck>,
rustc:native <!nocheck>,
libstd-rust-dev <!nocheck>,
librust-anyhow-1+default-dev <!nocheck>,
librust-base64-0.13+default-dev <!nocheck>,
librust-hex-0.4+default-dev <!nocheck>,
librust-http-0.2+default-dev <!nocheck>,
librust-once-cell-1+default-dev (>= 1.3.1-~~) <!nocheck>,
librust-percent-encoding-2+default-dev (>= 2.1-~~) <!nocheck>,
librust-proxmox-login-0.1+default-dev <!nocheck>,
librust-proxmox-login-0.1+http-dev <!nocheck>,
librust-proxmox-schema-2+api-macro-dev <!nocheck>,
librust-proxmox-schema-2+default-dev <!nocheck>,
librust-proxmox-section-config-2+default-dev <!nocheck>,
librust-regex-1+default-dev (>= 1.5-~~) <!nocheck>,
librust-serde-1+default-dev <!nocheck>,
librust-serde-json-1+default-dev <!nocheck>,
librust-serde-plain-1+default-dev <!nocheck>
Maintainer: Proxmox Support Team <support@proxmox.com>
Standards-Version: 4.6.1
Vcs-Git: git://git.proxmox.com/git/proxmox.git
Vcs-Browser: https://git.proxmox.com/?p=proxmox.git
X-Cargo-Crate: proxmox-client
Rules-Requires-Root: no
Package: librust-proxmox-client-dev
Architecture: any
Multi-Arch: same
Depends:
${misc:Depends},
librust-anyhow-1+default-dev,
librust-base64-0.13+default-dev,
librust-hex-0.4+default-dev,
librust-http-0.2+default-dev,
librust-once-cell-1+default-dev (>= 1.3.1-~~),
librust-percent-encoding-2+default-dev (>= 2.1-~~),
librust-proxmox-login-0.1+default-dev,
librust-proxmox-login-0.1+http-dev,
librust-proxmox-schema-2+api-macro-dev,
librust-proxmox-schema-2+default-dev,
librust-proxmox-section-config-2+default-dev,
librust-regex-1+default-dev (>= 1.5-~~),
librust-serde-1+default-dev,
librust-serde-json-1+default-dev,
librust-serde-plain-1+default-dev
Suggests:
librust-proxmox-client+hyper-client-dev (= ${binary:Version}),
librust-proxmox-client+webauthn-dev (= ${binary:Version})
Provides:
librust-proxmox-client+default-dev (= ${binary:Version}),
librust-proxmox-client-0-dev (= ${binary:Version}),
librust-proxmox-client-0+default-dev (= ${binary:Version}),
librust-proxmox-client-0.2-dev (= ${binary:Version}),
librust-proxmox-client-0.2+default-dev (= ${binary:Version}),
librust-proxmox-client-0.2.3-dev (= ${binary:Version}),
librust-proxmox-client-0.2.3+default-dev (= ${binary:Version})
Description: Base client for proxmox APIs for handling login and ticket renewal - Rust source code
This package contains the source for the Rust proxmox-client crate, packaged by
debcargo for use with cargo and dh-cargo.
Package: librust-proxmox-client+hyper-client-dev
Architecture: any
Multi-Arch: same
Depends:
${misc:Depends},
librust-proxmox-client-dev (= ${binary:Version}),
librust-hyper-0.14+default-dev (>= 0.14.5-~~),
librust-log-0.4+default-dev (>= 0.4.17-~~),
librust-openssl-0.10+default-dev,
librust-proxmox-http-0.9+client-dev,
librust-proxmox-http-0.9+default-dev
Provides:
librust-proxmox-client-0+hyper-client-dev (= ${binary:Version}),
librust-proxmox-client-0.2+hyper-client-dev (= ${binary:Version}),
librust-proxmox-client-0.2.3+hyper-client-dev (= ${binary:Version})
Description: Base client for proxmox APIs for handling login and ticket renewal - feature "hyper-client"
This metapackage enables feature "hyper-client" for the Rust proxmox-client
crate, by pulling in any additional dependencies needed by that feature.
Package: librust-proxmox-client+webauthn-dev
Architecture: any
Multi-Arch: same
Depends:
${misc:Depends},
librust-proxmox-client-dev (= ${binary:Version}),
librust-proxmox-login-0.1+http-dev,
librust-proxmox-login-0.1+webauthn-dev,
librust-webauthn-rs-0.3+default-dev
Provides:
librust-proxmox-client-0+webauthn-dev (= ${binary:Version}),
librust-proxmox-client-0.2+webauthn-dev (= ${binary:Version}),
librust-proxmox-client-0.2.3+webauthn-dev (= ${binary:Version})
Description: Base client for proxmox APIs for handling login and ticket renewal - feature "webauthn"
This metapackage enables feature "webauthn" for the Rust proxmox-client crate,
by pulling in any additional dependencies needed by that feature.

View File

@ -409,6 +409,15 @@ impl HttpApiClient for Client {
})
}
fn post_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 put<'a, T>(&'a self, path_and_query: &'a str, params: &T) -> Self::ResponseFuture<'a>
where
T: ?Sized + Serialize,

View File

@ -41,6 +41,11 @@ pub trait HttpApiClient {
where
T: ?Sized + Serialize;
/// `POST` request with a path and query component (no hostname), no request body.
///
/// For this request, authentication headers should be set!
fn post_without_body<'a>(&'a self, path_and_query: &'a str) -> Self::ResponseFuture<'a>;
/// `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`.
@ -195,6 +200,10 @@ where
C::post(self, path_and_query, params)
}
fn post_without_body<'a>(&'a self, path_and_query: &'a str) -> Self::ResponseFuture<'a> {
C::post_without_body(self, path_and_query)
}
fn put<'a, T>(&'a self, path_and_query: &'a str, params: &T) -> Self::ResponseFuture<'a>
where
T: ?Sized + Serialize,
@ -230,6 +239,10 @@ where
C::post(self, path_and_query, params)
}
fn post_without_body<'a>(&'a self, path_and_query: &'a str) -> Self::ResponseFuture<'a> {
C::post_without_body(self, path_and_query)
}
fn put<'a, T>(&'a self, path_and_query: &'a str, params: &T) -> Self::ResponseFuture<'a>
where
T: ?Sized + Serialize,
@ -265,6 +278,10 @@ where
C::post(self, path_and_query, params)
}
fn post_without_body<'a>(&'a self, path_and_query: &'a str) -> Self::ResponseFuture<'a> {
C::post_without_body(self, path_and_query)
}
fn put<'a, T>(&'a self, path_and_query: &'a str, params: &T) -> Self::ResponseFuture<'a>
where
T: ?Sized + Serialize,