Wolfgang Bumiller
5dd21ee89b
switch from failure to anyhow
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-17 18:34:21 +02:00
Dietmar Maurer
5affb691b5
proxmox-api-macro/src/api/method.rs: fix error message
2020-04-17 15:28:49 +02:00
Wolfgang Bumiller
5ae320f577
api-macro: add test for access w/o a description
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-16 09:26:24 +02:00
Wolfgang Bumiller
62f3c7d2d9
api-macro: avoid duplicate output code
...
While this is a tiny piece of code, having only one output
code consisting of prepared parts is nicer to keep up to
date.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-16 09:26:24 +02:00
Wolfgang Bumiller
6d831e36dd
api-macro: cleanup & test fixup
...
remove unnecessary types, they were already in the struct
update test to use Option for access description
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-16 09:26:24 +02:00
Dietmar Maurer
b07d592597
bump rust-proxmox-api-macro version to 0.1.6-1
2020-04-16 08:44:17 +02:00
Dietmar Maurer
076501e17e
proxmox-api-macro/tests/api1.rs: fix test case
2020-04-16 08:42:05 +02:00
Dietmar Maurer
e78e31ab4c
make access description optional
2020-04-16 07:20:29 +02:00
Dietmar Maurer
25dbb0ebab
api macro: support reload_timezone
2020-04-15 17:26:43 +02:00
Wolfgang Bumiller
da01ff1a72
style cleanup
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-15 09:21:04 +02:00
Wolfgang Bumiller
973e7ccef0
rename some permission/access items
...
router.permissions(...) -> router.access(...)
to be more consistent with the other builder methods and
struct member names
ApiAccessPermissions -> ApiAccess
shorter, not necessarily with defined permissions, and
gets rid of a singular/plural confusion
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-15 09:19:25 +02:00
Wolfgang Bumiller
510d410b7a
api-macro: support 'access' specification for methods
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-14 14:28:12 +02:00
Wolfgang Bumiller
19ad65ac84
api-macro: error on unexpected keys
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-14 13:48:09 +02:00
Wolfgang Bumiller
2c83d55cb0
api-macro: util: add join and join_debug helper
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-14 13:27:36 +02:00
Wolfgang Bumiller
0b2c9b95b4
api-macro: minor cleanup
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-14 11:45:50 +02:00
Wolfgang Bumiller
ab8a6120ca
api-macro: started with some more documentation
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-23 15:55:18 +01:00
Wolfgang Bumiller
176e208caf
api-macro: add consts for defaults
...
Not sure how we want to actually handle default values yet.
For now we need to figure out what "feels best".
This adds default values as publicly available consts so
they can be accessed from anywhere as
`API_METHOD_<METHOD_NAME>_PARAM_DEFAULT_<PARAM_NAME>`.
This is quite a handful to type, but I'm not sure how to
make this better.
Within the function body we also have the
`api_get_default!(param_name)` macro which is more
convenient, but not available outside the `#[api]` tagged
function.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-23 09:15:54 +01:00
Fabian Grünbichler
6a21867d87
api-macro: explicitly enable syn's visit-mut feature
...
otherwise the build fails because the module is not visible
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-03-23 08:04:26 +01:00
Wolfgang Bumiller
f5d15872f4
api-macro: add api_get_default!() macro
...
When writing an #[api] function, one can now access default
values by parameter name (see test_default_option in
tests/options.rs):
#[api(...)]
pub fn func(value: Option<isize>) {
println!(
"value: {}",
value.unwrap_or(api_get_default!("value")),
);
}
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-19 15:49:34 +01:00
Wolfgang Bumiller
8beec0d6e6
api-macro: tests for optional non-Option parameters
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-19 12:08:38 +01:00
Wolfgang Bumiller
83b6d082db
api-macro: allow optional types without Option<T>
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-19 12:08:10 +01:00
Wolfgang Bumiller
2065bcb136
bump api-macro to 0.1.5
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-19 09:58:02 +01:00
Wolfgang Bumiller
c5c82abc7d
api-macro: cleanup: warnings
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-06 13:50:39 +01:00
Wolfgang Bumiller
8e1ace59b1
api-macro: cleanup: don't use try_fold for a Vec
...
`collect()` uses `FromIterator` which is also implemented
for `Result<Vec, Err>` from `Result<Item, Err>` doing the
same thing.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-06 13:37:59 +01:00
Wolfgang Bumiller
2edd8da965
api-macro: add integer limit test cases
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-06 12:02:32 +01:00
Wolfgang Bumiller
723500dbfc
api-macro: include default minimum/maximum for integer types
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-06 11:59:08 +01:00
Wolfgang Bumiller
f4e88aab6c
api-macro: replace unreachable with a panic
...
(we're not running into this, but ran into an unreachable in
`syn` during development, and I needed to make sure it's not
one of ours...)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-06 11:56:48 +01:00
Wolfgang Bumiller
dc4ec65723
api-macro: correctly infer newtype types
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-06 11:10:22 +01:00
Wolfgang Bumiller
67949bf8f0
api-macro: factor handle_struct differently
...
Don't assume an empty object schema for all cases as
newtypes shouldn't use an object schema at all actually!
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-06 10:53:59 +01:00
Wolfgang Bumiller
d7be7df86c
bump proxmox-api-macro to 0.1.4
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-02-27 13:10:40 +01:00
Wolfgang Bumiller
dd8ccd80d9
api-macro: make API_{RETURN,PARAMETER}_SCHEMA_... public
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-02-27 13:08:59 +01:00
Wolfgang Bumiller
39566afb15
formatting fixup
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-30 12:37:26 +01:00
Wolfgang Bumiller
db741bfb81
bump api-macro to 0.1.3
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-30 12:35:28 +01:00
Wolfgang Bumiller
eadffcfc16
expose parameter schema as API_PARAMETER_SCHEMA_<methodname>
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-30 12:32:22 +01:00
Wolfgang Bumiller
2c7b786cef
expose return schema as API_RETURN_SCHEMA_<methodname>
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-30 12:28:19 +01:00
Wolfgang Bumiller
a5373a9679
bump api-macro
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-23 13:16:50 +01:00
Wolfgang Bumiller
edebbf920a
fix property sorting
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-23 13:15:59 +01:00
Wolfgang Bumiller
436bf05e0b
merge api, sys and tools into proxmox directly
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-21 12:15:42 +01:00
Wolfgang Bumiller
f22b693800
macro: silence some warnings in tests
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-15 14:10:58 +01:00
Fabian Grünbichler
a94de245f0
build: switch to debcargo
...
to autogenerate crate (build)-dependencies, and correct Provides
statements.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-15 12:02:47 +01:00
Wolfgang Bumiller
66d9d43cd4
bump api-macro to 0.1.1
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 11:29:15 +01:00
Wolfgang Bumiller
1992abf96e
api-macro: even more documentation
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 11:28:00 +01:00
Wolfgang Bumiller
0f630a4cb8
api-macro: more documentation
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 11:23:48 +01:00
Wolfgang Bumiller
5b652dbad8
api-macro: schema tests for async fns
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 11:01:55 +01:00
Wolfgang Bumiller
943bc4de52
api-macro: more tests
...
Note that this one tests the fact that we do not do output
schema validation!
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:58:27 +01:00
Wolfgang Bumiller
58158b495e
api-macro: more invocation tests for api methods
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:56:45 +01:00
Wolfgang Bumiller
679ad01c03
api-macro: add expanded data to tests for verification
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:51:00 +01:00
Wolfgang Bumiller
08e1cf3c2f
api-macro: support empty api macro on structs
...
The description comes from the doc comment, the field types
and description from field doc comments and types.
Previously we needed to add at least the hint that the
schema is an object schema. Now we support an empty #[api]
attribute as well.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:09:42 +01:00
Wolfgang Bumiller
7c6ebbdbf3
api-macro: support renamed struct fields
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:06:48 +01:00
Wolfgang Bumiller
2e63bf8422
api-macro: support rename_all in enums
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 15:29:56 +01:00