496 Commits

Author SHA1 Message Date
Wolfgang Bumiller
49fb5e127c bump proxmox-sortable-macro to 0.1.1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-17 18:37:46 +02:00
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
6976fc4a35 bump rust-proxmox version to 0.1.21-1 2020-04-16 08:43:29 +02:00
Dietmar Maurer
076501e17e proxmox-api-macro/tests/api1.rs: fix test case 2020-04-16 08:42:05 +02:00
Dietmar Maurer
382eb665c4 proxmox/src/api/permission.rs: pass parameters as HashMap
- to make it suitable for our rest server...
- also avoid repeated is_superuser() checks
- fix privilege test (add check for 0)
2020-04-16 08:07:03 +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
Dietmar Maurer
9c523a4de6 list_subdirs_api_method: allow access for Anybody 2020-04-15 09:26:56 +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
b67e2f7214 api/permissions: support test-harness
(Api-macro tests want to use `==` to compare generated
schemas against hardcoded schemas.)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-14 11:25:40 +02:00
Wolfgang Bumiller
5aeebdab44 api/permissions: cleanup & formatting
Use the `write!` macro as a shortcut for
   f.write_fmt(format_args!(...))

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-14 10:56:39 +02:00
Dietmar Maurer
5d73e4b8e8 flatten use hierarchy for api::Permissions 2020-04-10 15:43:49 +02:00
Dietmar Maurer
7ec6448db8 implement access permission system 2020-04-10 11:24:24 +02:00
Dietmar Maurer
89e71adfeb bump proxmox crate to 0.1.20-1 2020-03-25 10:56:46 +01:00
Dietmar Maurer
75e4c4a205 improve command line completion with optional argument parameters 2020-03-25 10:52:13 +01: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
832dd021c2 bump proxmox crate to 0.1.19-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-19 10:00:50 +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
Dominik Csapak
d1bfafe157 make cli format a bit saner
this looks more like pve/pmg cli tools now
without double the empty lines

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-19 09:50:47 +01:00
Wolfgang Bumiller
d84f563d5b buildsys: drop format check in check target
rename 'checkfmt' target to 'fmt'
there's no "apply formatting" target anymore now, this has
to be done manually to not do this by accident

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-16 12:21:14 +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
Fabian Grünbichler
0e9eb37ea0 build: add -upload target
requires 'dcmd' from devscripts to extract binary package file names
from .changes file

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-03-03 11:50:31 +01:00
Dietmar Maurer
5c188c7340 Revert "add proxmox/src/sys/linux/fs.rs"
This reverts the previous commit 21b9321cf81409cb07ef332076f54dc4f32141ce.

Turn out we only need this for pxar, so this will get moved into the pxar crate.
2020-03-02 14:07:35 +01:00
Dietmar Maurer
21b9321cf8 add proxmox/src/sys/linux/fs.rs 2020-03-02 13:59:39 +01:00
Dietmar Maurer
bff0791307 bump rust-proxmox version 0.1.18-1 2020-03-02 12:48:31 +01:00
Dietmar Maurer
59bd5bcad6 src/api/section_config.rs: moved SectionConfig from proxmox-backup 2020-03-02 10:56:40 +01:00
Dietmar Maurer
18b53d0fa6 fix typo in doc comment 2020-02-28 10:10:35 +01:00
Dietmar Maurer
ccc4d2ddd4 bump rust-proxmox version 0.1.17-1 2020-02-28 10:08:24 +01:00
Dietmar Maurer
9d9ab22128 text_table.rs: fix max column width when displaying without header 2020-02-28 10:05:59 +01:00