forked from Proxmox/proxmox
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>
This commit is contained in:
parent
510d410b7a
commit
973e7ccef0
@ -45,7 +45,7 @@ pub fn handle_method(mut attribs: JSONObject, mut func: syn::ItemFn) -> Result<T
|
||||
let description: syn::LitStr = access.description.try_into()?;
|
||||
let permission: syn::Expr = access.permission.try_into()?;
|
||||
quote_spanned! { access.span =>
|
||||
.permissions(#description, #permission)
|
||||
.access(#description, #permission)
|
||||
}
|
||||
}
|
||||
None => TokenStream::new(),
|
||||
|
@ -108,7 +108,7 @@ fn create_ticket_schema_check() {
|
||||
)
|
||||
.schema(),
|
||||
)
|
||||
.permissions("Only root can access this.", &Permission::Superuser)
|
||||
.access("Only root can access this.", &Permission::Superuser)
|
||||
.protected(true);
|
||||
assert_eq!(TEST_METHOD, API_METHOD_CREATE_TICKET);
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ const DUMMY_HANDLER: ApiHandler = ApiHandler::Sync(&dummy_handler_fn);
|
||||
|
||||
/// Access permission with description
|
||||
#[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))]
|
||||
pub struct ApiAccessPermissions {
|
||||
pub struct ApiAccess {
|
||||
pub description: &'static str,
|
||||
pub permission: &'static Permission,
|
||||
}
|
||||
@ -408,7 +408,7 @@ pub struct ApiMethod {
|
||||
/// Handler function
|
||||
pub handler: &'static ApiHandler,
|
||||
/// Access Permissions
|
||||
pub access: ApiAccessPermissions,
|
||||
pub access: ApiAccess,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for ApiMethod {
|
||||
@ -430,9 +430,9 @@ impl ApiMethod {
|
||||
returns: &NULL_SCHEMA,
|
||||
protected: false,
|
||||
reload_timezone: false,
|
||||
access: ApiAccessPermissions {
|
||||
access: ApiAccess {
|
||||
description: "Default access permissions (superuser only).",
|
||||
permission: &Permission::Superuser
|
||||
permission: &Permission::Superuser,
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -444,9 +444,9 @@ impl ApiMethod {
|
||||
returns: &NULL_SCHEMA,
|
||||
protected: false,
|
||||
reload_timezone: false,
|
||||
access: ApiAccessPermissions {
|
||||
access: ApiAccess {
|
||||
description: "Default access permissions (superuser only).",
|
||||
permission: &Permission::Superuser
|
||||
permission: &Permission::Superuser,
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -469,8 +469,15 @@ impl ApiMethod {
|
||||
self
|
||||
}
|
||||
|
||||
pub const fn permissions(mut self, description: &'static str, permission: &'static Permission) -> Self {
|
||||
self.access = ApiAccessPermissions { description, permission };
|
||||
pub const fn access(
|
||||
mut self,
|
||||
description: &'static str,
|
||||
permission: &'static Permission,
|
||||
) -> Self {
|
||||
self.access = ApiAccess {
|
||||
description,
|
||||
permission,
|
||||
};
|
||||
|
||||
self
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user