From 022fdacb25f35730bd2320b4a65f8222a11fad5a Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Sun, 27 Aug 2023 16:16:37 +0200 Subject: [PATCH] proxmox-client: add post_without_body Signed-off-by: Dietmar Maurer --- proxmox-client/debian/control | 100 ---------------------------------- proxmox-client/src/client.rs | 9 +++ proxmox-client/src/lib.rs | 17 ++++++ 3 files changed, 26 insertions(+), 100 deletions(-) delete mode 100644 proxmox-client/debian/control diff --git a/proxmox-client/debian/control b/proxmox-client/debian/control deleted file mode 100644 index 6163358b..00000000 --- a/proxmox-client/debian/control +++ /dev/null @@ -1,100 +0,0 @@ -Source: rust-proxmox-client -Section: rust -Priority: optional -Build-Depends: debhelper (>= 12), - dh-cargo (>= 25), - cargo:native , - rustc:native , - libstd-rust-dev , - 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 -Maintainer: Proxmox Support Team -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. diff --git a/proxmox-client/src/client.rs b/proxmox-client/src/client.rs index 8dad2d62..bd8d45cb 100644 --- a/proxmox-client/src/client.rs +++ b/proxmox-client/src/client.rs @@ -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, diff --git a/proxmox-client/src/lib.rs b/proxmox-client/src/lib.rs index fb7b4b20..6039ae5e 100644 --- a/proxmox-client/src/lib.rs +++ b/proxmox-client/src/lib.rs @@ -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,