Commit Graph

39 Commits

Author SHA1 Message Date
Wolfgang Bumiller
cb509a1e6a client: bump to 0.4.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-13 15:45:20 +02:00
Wolfgang Bumiller
c54d5e06e6 client: change Token struct
API tokens between rust & perl code bases are inconsistent... this
needs fixing, but for now this is faster and more compatible.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-13 15:45:20 +02:00
Maximiliano Sandoval
c8b975799b fix typos in strings
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-07-22 08:49:42 +02:00
Maximiliano Sandoval
72ab48eb55 fix typos in rust api documentation
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-07-22 08:49:42 +02:00
Wolfgang Bumiller
0652d81977 tree-wide: enable doc_cfg and doc_auto_cfg for docs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-07-02 11:59:53 +02:00
Wolfgang Bumiller
635c8bcbed client: clippy: factor out complex type
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-06-28 11:38:59 +02:00
Maximiliano Sandoval
aff76f9e0e remove needless borrows
Fixes the following clippy warnings:

warning: the borrowed expression implements the required traits
  --> proxmox-tfa/src/api/recovery.rs:86:24
   |
86 |         Ok(hex::encode(&hmac))
   |                        ^^^^^ help: change this to: `hmac`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args

and

warning: this expression creates a reference which is immediately dereferenced by the compiler
   --> proxmox-network-api/src/api_impl.rs:108:47
    |
108 |                 interface.set_bond_slave_list(&slaves)?;
    |                                               ^^^^^^^ help: change this to: `slaves`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
    = note: `#[warn(clippy::needless_borrow)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-06-28 10:22:58 +02:00
Fabian Grünbichler
a17430b38f run cargo fmt
(again)

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-06-05 13:31:06 +02:00
Wolfgang Bumiller
77672b1253 bump proxmox-client to 0.3.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-02-02 14:06:08 +01:00
Lukas Wagner
228ce9d69c client: do a POST instead of PUT in post_without_body
Probably a copy-paste mistake.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2024-01-04 08:15:01 +01:00
Wolfgang Bumiller
45152c5e3e bump proxmox-client to 0.3.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-10-16 13:27:13 +02:00
Dominik Csapak
9fa4185196 client: fix optional data for errors
previously we changed the internal type of the 'data' property
from Option<T> to T in the assumption the api always returns
'data:null'.

this is actually only the case when the api call succeeds. in an error
case there is no data property at all.

to fix this issue while behaving the same for 'data:null' we have to
revert to Option<T> for RawApiResponse but instead of always throwing an
error for 'data:null' in 'check' we now try there to deserialize from
Value::Null for T if there was no data. This will succeed for the Type
'()' which was the motivation for the original change.

The only downside is that the RawApiResponse now has a trait bound that
T is deserializeable, but was a requirement for using it anyway
(as there was no other way of constructing it)

Fixes: 271a55f ("client: remove option from inner RawApiResponse")
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2023-09-27 11:27:47 +02:00
Dominik Csapak
271a55f187 client: remove option from inner RawApiResponse
when using the client for an api call that does not return any data
(it returns '{"data":null}'), we would always get an error 'api returned
no data'. The message is technically correct, but it should not be an
error when we expect no data (e.g. most of our CRUD PUT/POST calls)

instead of having the Option<T> in the RawApiResponse type itself, move
it into to the 'nodata' function intended for api calls where we don't
expect any data.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2023-08-29 14:14:52 +02:00
Dietmar Maurer
022fdacb25 proxmox-client: add post_without_body
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-08-27 16:19:31 +02:00
Wolfgang Bumiller
c81068097b bump proxmox-client to 0.2.3-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-25 09:03:00 +02:00
Wolfgang Bumiller
8617442560 client: fixup checks for api calls not returning data
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-25 09:03:00 +02:00
Wolfgang Bumiller
f20f9bb9f7 client: set content type header on requests
this got lost with the recent refactoring

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-25 08:56:41 +02:00
Wolfgang Bumiller
6286ff4eeb bump proxmox-client to 0.2.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-25 08:37:25 +02:00
Wolfgang Bumiller
d7f6fc4db5 client: fix content type parsing with included charset
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-25 08:36:19 +02:00
Max Carrara
ede73a6561 client/login: clippy fixes
Signed-off-by: Max Carrara <m.carrara@proxmox.com>
2023-08-22 10:04:16 +02:00
Wolfgang Bumiller
68fe8baf95 bump proxmox-client to 0.2.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-16 14:33:01 +02:00
Wolfgang Bumiller
a909d5789c client: convenience helper to get a serialized ticket
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-10 14:33:55 +02:00
Wolfgang Bumiller
490008d596 client: expose AuthenticationKind
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-10 14:27:31 +02:00
Wolfgang Bumiller
bea97ccce1 client: add Client::set_authentication method
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-10 14:14:06 +02:00
Wolfgang Bumiller
2fd5502321 bump proxmox-client to 0.2.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-10 11:15:36 +02:00
Wolfgang Bumiller
604e467684 client: add TlsOptions::parse_fingerprint
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-10 10:44:04 +02:00
Wolfgang Bumiller
dff830ba04 client: impl HttpApiClient for refs, Arcs and Rcs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-09 15:29:38 +02:00
Wolfgang Bumiller
a3322e49b9 client: put requests
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-09 15:29:38 +02:00
Wolfgang Bumiller
ffe908f636 client: handle response data
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-09 13:21:02 +02:00
Wolfgang Bumiller
1c96afd0ec client: turn Client inside out
Since the WASM client cannot actually use a `http::Request` the way we
expect it to, that is, it cannot manually along cookies, we turn the
client bit inside out:

This crate mainly defines the `HttpApiClient` trait which expects the
http client to perform *authenticated* API calls, that is, the
handling of API tokens and tickets should happen at the *implementor*
side.

The product clients will require *this* trait to be implemented, and
will not themselves offer a way to login.

As for the `Client` struct, this will now instead *implement* this
trait and will *not* be used in the `wasm` ecosystem. Rather, this is
the ticket handling http client that already exists in the PWT based
ui code.

The PVE client in `pve-api-types` will not *contain* a `Client`
anymore, but rather, it will provide PVE api call implementations for
something implementing `HttpApiClient`.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-09 13:21:02 +02:00
Wolfgang Bumiller
0f19f2125f client: drop environment and login methods
The environment trait was useful on the CLI, but does not really
translate well to eg. the wasm ui (or pdm for that matter), so drop it
and instead have `.login` and `.login_tfa` just take the
`proxmox_login` type and handle the updating of authentication data.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-09 13:21:02 +02:00
Wolfgang Bumiller
a9a267f04f client: replace Error trait with a type
Because we ultimately also want to drop the `Environment` trait since
it is not suitable for all use cases (eg. wasm ui)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-09 13:21:02 +02:00
Wolfgang Bumiller
e0b102d932 client: prepare to get rid of Error trait
First rename it so it's clear what "Error" refers to in the following
patches.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-09 13:21:02 +02:00
Wolfgang Bumiller
17f5eac57a client: drop Send for non-wasm as well on response future
To see if it is even still necessary given that it's not a trait
object type where auto traits would need to be explicit...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-07 11:06:10 +02:00
Wolfgang Bumiller
1531a619ab client: rename response future to ResponseFuture
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-07 10:59:07 +02:00
Wolfgang Bumiller
a7435e757b client: drop retry logic
This should be moved to where we actually need it, not be part of the
generic product client.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-07 10:57:39 +02:00
Dietmar Maurer
2b212cf4e3 proxmox-client: do not require Send for wasm32 target
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-08-05 09:10:28 +02:00
Wolfgang Bumiller
ba6a628601 client: getters for the inner client
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-03 08:22:45 +02:00
Wolfgang Bumiller
25024fa687 import proxmox-client crate
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-01 15:49:43 +02:00