From 473c5762c6665003e26df28daeea11bd528a5435 Mon Sep 17 00:00:00 2001 From: axolotle Date: Mon, 22 Mar 2021 18:41:18 +0100 Subject: [PATCH] replace api action group.update with group.add and group.remove --- data/actionsmap/yunohost.yml | 56 ++++++++++++++++++++---------------- src/yunohost/user.py | 28 ++++++++++++++++++ 2 files changed, 60 insertions(+), 24 deletions(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 38c7b4918..7fcf9e51b 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -252,30 +252,6 @@ user: extra: pattern: *pattern_groupname - ### user_group_update() - update: - action_help: Update group - api: PUT /users/groups/ - arguments: - groupname: - help: Name of the group to be updated - extra: - pattern: *pattern_groupname - -a: - full: --add - help: User(s) to add in the group - nargs: "*" - metavar: USERNAME - extra: - pattern: *pattern_username - -r: - full: --remove - help: User(s) to remove in the group - nargs: "*" - metavar: USERNAME - extra: - pattern: *pattern_username - ### user_group_info() info: action_help: Get information about a specific group @@ -286,6 +262,38 @@ user: extra: pattern: *pattern_username + ### user_group_add() + add: + action_help: Update group + api: PUT /users/groups//add/ + arguments: + groupname: + help: Name of the group to add user(s) to + extra: + pattern: *pattern_groupname + usernames: + help: User(s) to add in the group + nargs: "*" + metavar: USERNAME + extra: + pattern: *pattern_username + + ### user_group_remove() + remove: + action_help: Update group + api: PUT /users/groups//remove/ + arguments: + groupname: + help: Name of the group to remove user(s) from + extra: + pattern: *pattern_groupname + usernames: + help: User(s) to remove from the group + nargs: "*" + metavar: USERNAME + extra: + pattern: *pattern_username + permission: subcategory_help: Manage permissions actions: diff --git a/src/yunohost/user.py b/src/yunohost/user.py index e585f5c69..b551318fc 100644 --- a/src/yunohost/user.py +++ b/src/yunohost/user.py @@ -857,6 +857,34 @@ def user_group_info(groupname): } +def user_group_add(groupname, usernames, force=False, sync_perm=True): + """ + Add user(s) to a group + + Keyword argument: + groupname -- Groupname to update + usernames -- User(s) to add in the group + + """ + return user_group_update( + groupname, add=usernames, force=force, sync_perm=sync_perm + ) + + +def user_group_remove(groupname, usernames, force=False, sync_perm=True): + """ + Remove user(s) from a group + + Keyword argument: + groupname -- Groupname to update + usernames -- User(s) to remove from the group + + """ + return user_group_update( + groupname, remove=usernames, force=force, sync_perm=sync_perm + ) + + # # Permission subcategory #