Wolfgang Bumiller
dc3b88f50c
start command resolution
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-17 12:31:29 +02:00
Wolfgang Bumiller
3182df96c0
api: started CLI layout
...
The CLI part itself needs much less info now as we'll take
as much as we can from the api methods themselves. Note that
we may still want to be able to add extra info to a cli
command in particular, for instance, for the completion
callbacks. For now this is all part of the method itself.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-17 12:31:29 +02:00
Dietmar Maurer
64d9e81c76
src/lib.rs: add hex_to_bin and bin_to_hex
2019-06-17 10:59:59 +02:00
Dietmar Maurer
f2716a0d26
add hex_to_digest and digest_to_hex
2019-06-14 11:27:40 +02:00
Dietmar Maurer
d7fbee66e3
proxmox-tools/src/lib.rs: implement offsetof
2019-06-14 09:57:18 +02:00
Wolfgang Bumiller
b243d9664d
macro: implement minimum and maximum verification
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-13 14:29:09 +02:00
Wolfgang Bumiller
b1e3a9f0d2
impl ApiType for bool
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-13 14:19:01 +02:00
Wolfgang Bumiller
0d133c4d2c
add 'returns' member to method info dump
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 17:26:02 +02:00
Wolfgang Bumiller
a64832aac2
testing a Router::api_dump method
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 17:24:59 +02:00
Wolfgang Bumiller
536072c712
cleanup
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 17:06:57 +02:00
Wolfgang Bumiller
23d8e1d4e0
api: Parameter::type_info must be an fn
...
while filling the Parameter fields as &'static we cannot
really make use of the get_type_info() yet because it would
need to be a `const fn` (possible via #!feature(const_fn)),
so for now we store the method pointer until `const_fn` is
stable
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 16:43:24 +02:00
Wolfgang Bumiller
1a279f54a9
formatting fixup
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 16:33:27 +02:00
Wolfgang Bumiller
41884a622e
macro: check function parameters
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 16:33:12 +02:00
Wolfgang Bumiller
fe46b11152
add an api-test module
...
Run with:
cargo run -p api-test -- SomeDirectory/
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 15:54:52 +02:00
Wolfgang Bumiller
11b09e578c
router: parse an optional visibility
...
The 'pub' in `pub static ROUTER: ...`
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 15:31:19 +02:00
Wolfgang Bumiller
841799d882
fixup add missing question mark
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
22f4d076e2
api: ApiMethodInfo should be Send + Sync
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
6488a5cddb
api: ApiFutures need to be Send
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
1c1c8530c5
formatting cleanup
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
7db28deaff
macro: body type support for router and api macros
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
10451f65eb
rewrite parse_object
...
This should support arbitrary expresion, so gobble up
elements up to the next comma and then run it through
syn::parse2.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
1791c089b6
macro: need to allow specifying the body type now
...
TODO:
- change parse_object to use Punctuated for the fields to
support longer value types (so we can use actual types
as fields)
- allow adding a body type to methods
- allow adding a body type to routers explicitly
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
ff2767129f
rename reload_timezone -> reload-timezone
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
7d2c13da95
api: add generic Body parameter
...
Since we already know we'll want to be using hyper::Body and
bytes::Bytes as API output, we need to allow making routers
for each kind.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
b82b14d947
macro: add wildcard matching to router macro
...
router!{
/path/{parameter}*: {
methods...
}
}
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
8036941977
router: implement 'rest of the path' wildcard matching
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
60df564f73
api: move router to router.rs
...
We'll have a separate router for the command line, so the
http router won't live in the root module.
It is still exported at the root level, though, via
proxmox::api::Router.
Also move ApiType into api_type.rs, makes more sense.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
dcfa3ca9a2
allow async api methods to return Response<Bytes>
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
3f7e4c0eda
router: add remaining missing ::proxmox::api:: prefixes
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
2b577c9c17
cleanup
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
1993460d4a
allow integer literals as subdirectories
...
eg: /api/2/ should be legal
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
f3e2e672be
use 'quote' in router macro
...
get rid of a lot of unreadable TokenTree entries
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
7155689724
fix missing proxmox_api -> proxmox::api replacement
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
cd23e0956a
macro: switch to using proxmox::api
...
and fixup a `bail!` -> `::failure::bail!`
Signed-off-by: Wolfgang Bumiller <wry.git@bumiller.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
024930f63c
cargo fmt --all
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Dietmar Maurer
71f2d48c2e
start proxmox-sys module
2019-06-07 18:03:07 +02:00
Wolfgang Bumiller
3dd6cd3fe0
formatting fixup
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-07 12:03:17 +02:00
Wolfgang Bumiller
b5c05fc85c
import proxmox-api-macro crate
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-06 15:25:47 +02:00
Wolfgang Bumiller
671a56c545
typo fixup
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-06 14:47:02 +02:00
Wolfgang Bumiller
5bda38830c
Add more documentation
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-06 14:45:05 +02:00
Wolfgang Bumiller
b873e5e2a5
api: router test file
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-06 14:07:26 +02:00
Wolfgang Bumiller
fa2ba562ce
add proxmox-api crate
...
This contains the router and will get helpers for
generating documentation, and for parsing command line
parameters for api methods.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-06 14:06:21 +02:00
Wolfgang Bumiller
2e6520a987
initial import, starting with vec & io helpers
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-06 14:00:25 +02:00