feat: add host id allocation

Signed-off-by: sisungo <[email protected]>
This commit is contained in:
2026-07-19 13:05:26 +08:00
parent bfcc98b50e
commit c72134a89e
8 changed files with 124 additions and 9 deletions
+4
View File
@@ -92,4 +92,8 @@ impl Client {
pub fn create_user(&mut self, args: CreateUserArgs) -> Result<(), Error> {
self.invoke(CREATE_USER.into(), args)
}
pub fn create_group(&mut self, args: CreateGroupArgs) -> Result<(), Error> {
self.invoke(CREATE_GROUP.into(), args)
}
}
+4
View File
@@ -44,6 +44,10 @@ pub enum Error {
#[error("the specified auth method is not activated for the user")]
NotActivatedAuthMethod,
/// Cannot allocate host ID
#[error("cannot allocate host id")]
AllocHostId,
/// TODO
#[error("already exists")]
AlreadyExists,
+10 -2
View File
@@ -184,7 +184,7 @@ pub struct CreateUserArgs {
pub fullname: Option<String>,
/// Specify a host UID.
pub host_uid: Option<HostUid>,
pub host_uid: HostIdRule<HostUid>,
/// User description.
#[serde(default)]
@@ -225,7 +225,7 @@ pub struct CreateGroupArgs {
pub fullname: Option<String>,
/// Group ID on current host.
pub host_gid: Option<HostGid>,
pub host_gid: HostIdRule<HostGid>,
/// Group description.
#[serde(default)]
@@ -238,6 +238,14 @@ pub struct RemoveGroupArgs {
pub uuid: Uuid,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum HostIdRule<T> {
Unallocated,
Auto(T, T),
Manual(T),
}
// ==- Methods: Authentication -==
pub const GET_USER_AUTH_METHODS: &str = "GetUserAuthMethods";