From 82d5be68023289c3f1017b5682f2fef57fc02662 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 19 Mar 2021 16:15:16 +0100 Subject: [PATCH 01/10] Uniformize API routes --- data/actionsmap/yunohost.yml | 123 ++++++++++++++--------------------- 1 file changed, 48 insertions(+), 75 deletions(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 290952aa3..6e9461057 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -482,7 +482,7 @@ domain: - maindomain api: - GET /domains/main - - PUT /domains/main + - PUT /domains//main arguments: -n: full: --new-main-domain @@ -493,7 +493,7 @@ domain: ### certificate_status() cert-status: action_help: List status of current certificates (all by default). - api: GET /domains/cert-status/ + api: GET /domains//cert arguments: domain_list: help: Domains to check @@ -505,7 +505,7 @@ domain: ### certificate_install() cert-install: action_help: Install Let's Encrypt certificates for given domains (all by default). - api: POST /domains/cert-install/ + api: POST /domains//cert arguments: domain_list: help: Domains for which to install the certificates @@ -526,7 +526,7 @@ domain: ### certificate_renew() cert-renew: action_help: Renew the Let's Encrypt certificates for given domains (all by default). - api: POST /domains/cert-renew/ + api: PUT /domains//cert/renew arguments: domain_list: help: Domains for which to renew the certificates @@ -547,7 +547,7 @@ domain: ### domain_url_available() url-available: action_help: Check availability of a web path - api: GET /domain/urlavailable + api: GET /domain//urlavailable arguments: domain: help: The domain for the web path (e.g. your.domain.tld) @@ -556,20 +556,6 @@ domain: path: help: The path to check (e.g. /coffee) - - ### domain_info() -# info: -# action_help: Get domain informations -# api: GET /domains/ -# arguments: -# domain: -# help: "" -# extra: -# pattern: -# - '^([a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)(\.[a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)*(\.[a-zA-Z]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)$' -# - "Must be a valid domain name (e.g. my-domain.org)" - - ############################# # App # ############################# @@ -631,7 +617,7 @@ app: ### app_map() map: action_help: Show the mapping between urls and apps - api: GET /appsmap + api: GET /apps/map arguments: -a: full: --app @@ -679,7 +665,7 @@ app: ### app_upgrade() upgrade: action_help: Upgrade app - api: PUT /upgrade/apps + api: PUT /apps//upgrade arguments: app: help: App(s) to upgrade (default all) @@ -737,7 +723,6 @@ app: ### app_register_url() register-url: action_help: Book/register a web path for a given app - api: PUT /tools/registerurl arguments: app: help: App which will use the web path @@ -761,7 +746,6 @@ app: ### app_ssowatconf() ssowatconf: action_help: Regenerate SSOwat configuration file - api: PUT /ssowatconf ### app_change_label() change-label: @@ -776,7 +760,6 @@ app: ### app_addaccess() TODO: Write help addaccess: action_help: Grant access right to users (everyone by default) - api: PUT /access deprecated: true arguments: apps: @@ -788,7 +771,6 @@ app: ### app_removeaccess() TODO: Write help removeaccess: action_help: Revoke access right to users (everyone by default) - api: DELETE /access deprecated: true arguments: apps: @@ -800,7 +782,6 @@ app: ### app_clearaccess() clearaccess: action_help: Reset access rights for the app - api: POST /access deprecated: true arguments: apps: @@ -866,7 +847,7 @@ backup: ### backup_create() create: action_help: Create a backup local archive. If neither --apps or --system are given, this will backup all apps and all system parts. If only --apps if given, this will only backup apps and no system parts. Similarly, if only --system is given, this will only backup system parts and no apps. - api: POST /backup + api: POST /backups arguments: -n: full: --name @@ -894,7 +875,7 @@ backup: ### backup_restore() restore: action_help: Restore from a local backup archive. If neither --apps or --system are given, this will restore all apps and all system parts in the archive. If only --apps if given, this will only restore apps and no system parts. Similarly, if only --system is given, this will only restore system parts and no apps. - api: POST /backup/restore/ + api: PUT /backups//restore arguments: name: help: Name of the local backup archive @@ -911,7 +892,7 @@ backup: ### backup_list() list: action_help: List available local backup archives - api: GET /backup/archives + api: GET /backups arguments: -i: full: --with-info @@ -925,7 +906,7 @@ backup: ### backup_info() info: action_help: Show info about a local backup archive - api: GET /backup/archives/ + api: GET /backups/ arguments: name: help: Name of the local backup archive @@ -941,7 +922,7 @@ backup: ### backup_download() download: action_help: (API only) Request to download the file - api: GET /backup/download/ + api: GET /backups//download arguments: name: help: Name of the local backup archive @@ -949,7 +930,7 @@ backup: ### backup_delete() delete: action_help: Delete a backup archive - api: DELETE /backup/archives/ + api: DELETE /backups/ arguments: name: help: Name of the archive to delete @@ -1016,7 +997,6 @@ service: ### service_add() add: action_help: Add a service - # api: POST /services arguments: name: help: Service name to add @@ -1054,7 +1034,6 @@ service: ### service_remove() remove: action_help: Remove a service - # api: DELETE /services arguments: name: help: Service name to remove @@ -1062,7 +1041,7 @@ service: ### service_start() start: action_help: Start one or more services - api: PUT /services/ + api: PUT /services//start arguments: names: help: Service name to start @@ -1072,7 +1051,7 @@ service: ### service_stop() stop: action_help: Stop one or more services - api: DELETE /services/ + api: PUT /services//stop arguments: names: help: Service name to stop @@ -1120,7 +1099,7 @@ service: ### service_disable() disable: action_help: Disable one or more services - api: DELETE /services//enable + api: PUT /services//disable arguments: names: help: Service name to disable @@ -1155,7 +1134,6 @@ service: ### service_regen_conf() regen-conf: action_help: Regenerate the configuration file(s) for a service - api: PUT /services/regenconf deprecated_alias: - regenconf arguments: @@ -1207,19 +1185,10 @@ firewall: help: List forwarded ports with UPnP action: store_true - ### firewall_reload() - reload: - action_help: Reload all firewall rules - api: PUT /firewall - arguments: - --skip-upnp: - help: Do not refresh port forwarding using UPnP - action: store_true - ### firewall_allow() allow: action_help: Allow connections on a port - api: POST /firewall/port + api: POST /firewall/ arguments: protocol: help: "Protocol type to allow (TCP/UDP/Both)" @@ -1249,11 +1218,10 @@ firewall: help: Do not reload firewall rules action: store_true - ### firewall_disallow() disallow: action_help: Disallow connections on a port - api: DELETE /firewall/port + api: DELETE /firewall/ arguments: protocol: help: "Protocol type to allow (TCP/UDP/Both)" @@ -1281,11 +1249,10 @@ firewall: help: Do not reload firewall rules action: store_true - ### firewall_upnp() upnp: action_help: Manage port forwarding using UPnP - api: GET /firewall/upnp + api: PUT /firewall/upnp/ arguments: action: choices: @@ -1299,10 +1266,19 @@ firewall: help: Do not refresh port forwarding action: store_true + + ### firewall_reload() + reload: + action_help: Reload all firewall rules + arguments: + --skip-upnp: + help: Do not refresh port forwarding using UPnP + action: store_true + ### firewall_stop() stop: action_help: Stop iptables and ip6tables - api: DELETE /firewall + @@ -1316,7 +1292,6 @@ dyndns: ### dyndns_subscribe() subscribe: action_help: Subscribe to a DynDNS service - api: POST /dyndns arguments: --subscribe-host: help: Dynette HTTP API to subscribe to @@ -1333,7 +1308,6 @@ dyndns: ### dyndns_update() update: action_help: Update IP on DynDNS platform - api: PUT /dyndns arguments: --dyn-host: help: Dynette DNS server to inform @@ -1489,7 +1463,9 @@ tools: ### tools_regen_conf() regen-conf: action_help: Regenerate the configuration file(s) - api: PUT /tools/regenconf + api: + - PUT /regenconf + - PUT /regenconf/ arguments: names: help: Categories to regenerate configuration of (all by default) @@ -1538,7 +1514,7 @@ tools: ### tools_migrations_run() run: action_help: Run migrations - api: POST /migrations/run + api: PUT /migrations/ deprecated_alias: - migrate arguments: @@ -1561,7 +1537,6 @@ tools: ### tools_migrations_state() state: action_help: Show current migrations state - api: GET /migrations/state ############################# @@ -1590,7 +1565,6 @@ hook: ### hook_info() info: action_help: Get information about a given hook - api: GET /hooks// arguments: action: help: Action name @@ -1600,7 +1574,6 @@ hook: ### hook_list() list: action_help: List available hooks for an action - api: GET /hooks/ arguments: action: help: Action name @@ -1620,7 +1593,6 @@ hook: ### hook_callback() callback: action_help: Execute all scripts binded to an action - api: POST /hooks/ arguments: action: help: Action name @@ -1716,7 +1688,7 @@ log: ### log_share() share: action_help: Share the full log on yunopaste (alias to show --share) - api: GET /logs/share + api: GET /logs//share arguments: path: help: Log file to share @@ -1731,11 +1703,11 @@ diagnosis: list: action_help: List diagnosis categories - api: GET /diagnosis/list + api: GET /diagnosis/categories show: action_help: Show most recents diagnosis results - api: GET /diagnosis/show + api: GET /diagnosis arguments: categories: help: Diagnosis categories to display (all by default) @@ -1753,9 +1725,20 @@ diagnosis: help: Show a human-readable output action: store_true + get: + action_help: Low-level command to fetch raw data and status about a specific diagnosis test + api: GET /diagnosis/ + arguments: + category: + help: Diagnosis category to fetch results from + item: + help: "List of criteria describing the test. Must correspond exactly to the 'meta' infos in 'yunohost diagnosis show'" + metavar: CRITERIA + nargs: "*" + run: action_help: Run diagnosis - api: POST /diagnosis/run + api: PUT /diagnosis/run arguments: categories: help: Diagnosis categories to run (all by default) @@ -1786,13 +1769,3 @@ diagnosis: help: List active ignore filters action: store_true - get: - action_help: Low-level command to fetch raw data and status about a specific diagnosis test - api: GET /diagnosis/item/ - arguments: - category: - help: Diagnosis category to fetch results from - item: - help: "List of criteria describing the test. Must correspond exactly to the 'meta' infos in 'yunohost diagnosis show'" - metavar: CRITERIA - nargs: "*" From 1fb9ddd42a1c277ee354067e974e1b3899524ac6 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 19 Mar 2021 17:45:37 +0100 Subject: [PATCH 02/10] Tweak tools update/upgrade to have a single 'target' arg for simpler routing --- data/actionsmap/yunohost.yml | 29 +++++++--- src/yunohost/app.py | 2 +- .../data_migrations/0015_migrate_to_buster.py | 8 +-- src/yunohost/tools.py | 57 ++++++++++++------- 4 files changed, 63 insertions(+), 33 deletions(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 6e9461057..3e9237b1e 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -1411,25 +1411,40 @@ tools: ### tools_update() update: action_help: YunoHost update - api: PUT /update + api: PUT /update/ arguments: + target: + help: What to update, "apps" (application catalog) or "system" (fetch available package upgrades, equivalent to apt update), "all" for both + choices: + - apps + - system + - all + nargs: "?" + metavar: TARGET + default: all --apps: - help: Fetch the application list to check which apps can be upgraded + help: (Deprecated, see first positional arg) Fetch the application list to check which apps can be upgraded action: store_true --system: - help: Fetch available system packages upgrades (equivalent to apt update) + help: (Deprecated, see first positional arg) Fetch available system packages upgrades (equivalent to apt update) action: store_true ### tools_upgrade() upgrade: action_help: YunoHost upgrade - api: PUT /upgrade + api: PUT /upgrade/ arguments: + target: + help: What to upgrade, either "apps" (all apps) or "system" (all system packages) + choices: + - apps + - system + nargs: "?" --apps: - help: List of apps to upgrade (all by default) - nargs: "*" + help: (Deprecated, see first positional arg) Upgrade all applications + action: store_true --system: - help: Upgrade only the system packages + help: (Deprecated, see first positional arg) Upgrade only the system packages action: store_true ### tools_shell() diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 9d53df815..3173641b9 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -147,7 +147,7 @@ def app_fetchlist(): ) from yunohost.tools import tools_update - tools_update(apps=True) + tools_update(target="apps") def app_list(full=False, installed=False, filter=None): diff --git a/src/yunohost/data_migrations/0015_migrate_to_buster.py b/src/yunohost/data_migrations/0015_migrate_to_buster.py index e87c83087..4f2d4caf8 100644 --- a/src/yunohost/data_migrations/0015_migrate_to_buster.py +++ b/src/yunohost/data_migrations/0015_migrate_to_buster.py @@ -43,7 +43,7 @@ class MyMigration(Migration): # logger.info(m18n.n("migration_0015_patching_sources_list")) self.patch_apt_sources_list() - tools_update(system=True) + tools_update(target="system") # Tell libc6 it's okay to restart system stuff during the upgrade os.system( @@ -88,7 +88,7 @@ class MyMigration(Migration): apps_packages = self.get_apps_equivs_packages() self.hold(apps_packages) - tools_upgrade(system=True, allow_yunohost_upgrade=False) + tools_upgrade(target="system", allow_yunohost_upgrade=False) if self.debian_major_version() == 9: raise YunohostError("migration_0015_still_on_stretch_after_main_upgrade") @@ -103,7 +103,7 @@ class MyMigration(Migration): # logger.info(m18n.n("migration_0015_yunohost_upgrade")) self.unhold(apps_packages) - tools_upgrade(system=True) + tools_upgrade(target="system") def debian_major_version(self): # The python module "platform" and lsb_release are not reliable because @@ -141,7 +141,7 @@ class MyMigration(Migration): # (but we don't if 'stretch' is already in the sources.list ... # which means maybe a previous upgrade crashed and we're re-running it) if " buster " not in read_file("/etc/apt/sources.list"): - tools_update(system=True) + tools_update(target="system") upgradable_system_packages = list(_list_upgradable_apt_packages()) if upgradable_system_packages: raise YunohostError("migration_0015_system_not_fully_up_to_date") diff --git a/src/yunohost/tools.py b/src/yunohost/tools.py index e1ebe1307..42e7a01c3 100644 --- a/src/yunohost/tools.py +++ b/src/yunohost/tools.py @@ -404,22 +404,29 @@ def tools_regen_conf( return regen_conf(names, with_diff, force, dry_run, list_pending) -def tools_update(apps=False, system=False): +def tools_update(target=None, apps=False, system=False): """ Update apps & system package cache - - Keyword arguments: - system -- Fetch available system packages upgrades (equivalent to apt update) - apps -- Fetch the application list to check which apps can be upgraded """ - # If neither --apps nor --system specified, do both - if not apps and not system: - apps = True - system = True + # Legacy options (--system, --apps) + if apps or system: + logger.warning("Using 'yunohost tools update' with --apps / --system is deprecated, just write 'yunohost tools update apps system' (no -- prefix anymore)") + if apps and system: + target = "all" + elif apps: + target = "apps" + else: + target = "system" + + elif not target: + target = "all" + + if target not in ["system", "apps", "all"]: + raise YunohostError("Unknown target %s, should be 'system', 'apps' or 'all'" % target, raw_msg=True) upgradable_system_packages = [] - if system: + if target in ["system", "all"]: # Update APT cache # LC_ALL=C is here to make sure the results are in english @@ -467,7 +474,7 @@ def tools_update(apps=False, system=False): logger.debug(m18n.n("done")) upgradable_apps = [] - if apps: + if target in ["apps", "all"]: try: _update_apps_catalog() except YunohostError as e: @@ -518,7 +525,7 @@ def _list_upgradable_apps(): @is_unit_operation() def tools_upgrade( - operation_logger, apps=None, system=False, allow_yunohost_upgrade=True + operation_logger, target=None, apps=False, system=False, allow_yunohost_upgrade=True ): """ Update apps & package cache, then display changelog @@ -536,26 +543,34 @@ def tools_upgrade( if not packages.dpkg_lock_available(): raise YunohostError("dpkg_lock_not_available") - if system is not False and apps is not None: - raise YunohostError("tools_upgrade_cant_both") + # Legacy options management (--system, --apps) + if target is None: - if system is False and apps is None: - raise YunohostError("tools_upgrade_at_least_one") + logger.warning("Using 'yunohost tools upgrade' with --apps / --system is deprecated, just write 'yunohost tools upgrade apps' or 'system' (no -- prefix anymore)") + + if (system, apps) == (True, True): + raise YunohostError("tools_upgrade_cant_both") + + if (system, apps) == (False, False): + raise YunohostError("tools_upgrade_at_least_one") + + target = "apps" if apps else "system" + + if target not in ["apps", "system"]: + raise Exception("Uhoh ?! tools_upgrade should have 'apps' or 'system' value for argument target") # # Apps # This is basically just an alias to yunohost app upgrade ... # - if apps is not None: + if target == "apps": # Make sure there's actually something to upgrade upgradable_apps = [app["id"] for app in _list_upgradable_apps()] - if not upgradable_apps or ( - len(apps) and all(app not in upgradable_apps for app in apps) - ): + if not upgradable_apps: logger.info(m18n.n("apps_already_up_to_date")) return @@ -573,7 +588,7 @@ def tools_upgrade( # System # - if system is True: + if target == "system": # Check that there's indeed some packages to upgrade upgradables = list(_list_upgradable_apt_packages()) From 5f994bba98c965023b89ac8263db2aefeff31809 Mon Sep 17 00:00:00 2001 From: axolotle Date: Mon, 22 Mar 2021 16:24:23 +0100 Subject: [PATCH 03/10] separate update, add and remove permission on exposed API --- data/actionsmap/yunohost.yml | 44 ++++++++++++++++++++++++------------ src/yunohost/user.py | 29 +++++++++++++++++------- 2 files changed, 50 insertions(+), 23 deletions(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 3e9237b1e..4a46e8dee 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -319,20 +319,6 @@ user: arguments: permission: help: Permission to manage (e.g. mail or nextcloud or wordpress.editors) (use "yunohost user permission list" and "yunohost user permission -f" to see all the current permissions) - -a: - full: --add - help: Group or usernames to grant this permission to - nargs: "*" - metavar: GROUP_OR_USER - extra: - pattern: *pattern_username - -r: - full: --remove - help: Group or usernames revoke this permission from - nargs: "*" - metavar: GROUP_OR_USER - extra: - pattern: *pattern_username -l: full: --label help: Label for this permission. This label will be shown on the SSO and in the admin @@ -343,10 +329,38 @@ user: - 'True' - 'False' + ## user_permission_add() + add: + action_help: Grant permission to group or user + api: PUT /users/permissions//add/ + arguments: + permission: + help: Permission to manage (e.g. mail or nextcloud or wordpress.editors) (use "yunohost user permission list" and "yunohost user permission -f" to see all the current permissions) + names: + help: Group or usernames to grant this permission to + nargs: "*" + metavar: GROUP_OR_USER + extra: + pattern: *pattern_username + + ## user_permission_remove() + remove: + action_help: Revoke permission to group or user + api: PUT /users/permissions//remove/ + arguments: + permission: + help: Permission to manage (e.g. mail or nextcloud or wordpress.editors) (use "yunohost user permission list" and "yunohost user permission -f" to see all the current permissions) + names: + help: Group or usernames to revoke this permission to + nargs: "*" + metavar: GROUP_OR_USER + extra: + pattern: *pattern_username + ## user_permission_reset() reset: action_help: Reset allowed groups to the default (all_users) for a given permission - api: DELETE /users/permissions/ + api: DELETE /users/permissions/ arguments: permission: help: Permission to manage (e.g. mail or nextcloud or wordpress.editors) (use "yunohost user permission list" and "yunohost user permission -f" to see all the current permissions) diff --git a/src/yunohost/user.py b/src/yunohost/user.py index f1fab786a..e585f5c69 100644 --- a/src/yunohost/user.py +++ b/src/yunohost/user.py @@ -868,18 +868,31 @@ def user_permission_list(short=False, full=False): return yunohost.permission.user_permission_list(short, full, absolute_urls=True) -def user_permission_update( - permission, add=None, remove=None, label=None, show_tile=None, sync_perm=True +def user_permission_update(permission, label=None, show_tile=None, sync_perm=True): + import yunohost.permission + + return yunohost.permission.user_permission_update( + permission, label=label, show_tile=show_tile, sync_perm=sync_perm + ) + + +def user_permission_add( + permission, names, protected=None, force=False, sync_perm=True ): import yunohost.permission return yunohost.permission.user_permission_update( - permission, - add=add, - remove=remove, - label=label, - show_tile=show_tile, - sync_perm=sync_perm, + permission, add=names, protected=protected, force=force, sync_perm=sync_perm + ) + + +def user_permission_remove( + permission, names, protected=None, force=False, sync_perm=True +): + import yunohost.permission + + return yunohost.permission.user_permission_update( + permission, remove=names, protected=protected, force=force, sync_perm=sync_perm ) From da3d7db3e66ce3d0f78c5bff14eeb4629bbd54ee Mon Sep 17 00:00:00 2001 From: axolotle Date: Mon, 22 Mar 2021 16:25:00 +0100 Subject: [PATCH 04/10] use PUT for domain cert modifications --- data/actionsmap/yunohost.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 4a46e8dee..38c7b4918 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -519,7 +519,7 @@ domain: ### certificate_install() cert-install: action_help: Install Let's Encrypt certificates for given domains (all by default). - api: POST /domains//cert + api: PUT /domains//cert arguments: domain_list: help: Domains for which to install the certificates From 473c5762c6665003e26df28daeea11bd528a5435 Mon Sep 17 00:00:00 2001 From: axolotle Date: Mon, 22 Mar 2021 18:41:18 +0100 Subject: [PATCH 05/10] 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 # From 27eefcb286765a604d3fd9c6821438dc37d12084 Mon Sep 17 00:00:00 2001 From: axolotle Date: Mon, 22 Mar 2021 18:43:21 +0100 Subject: [PATCH 06/10] reexpose '/hooks/' since the web-admin needs it for backups --- data/actionsmap/yunohost.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 7fcf9e51b..de8c6a475 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -1611,6 +1611,7 @@ hook: ### hook_list() list: action_help: List available hooks for an action + api: GET /hooks/ arguments: action: help: Action name From 20553de539d655ba049d5f3fcf7dd522f6595914 Mon Sep 17 00:00:00 2001 From: axolotle Date: Mon, 22 Mar 2021 20:29:17 +0100 Subject: [PATCH 07/10] update firewall port update routes --- data/actionsmap/yunohost.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index de8c6a475..1f710202d 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -1210,7 +1210,7 @@ firewall: ### firewall_allow() allow: action_help: Allow connections on a port - api: POST /firewall/ + api: PUT /firewall//allow/ arguments: protocol: help: "Protocol type to allow (TCP/UDP/Both)" @@ -1243,7 +1243,7 @@ firewall: ### firewall_disallow() disallow: action_help: Disallow connections on a port - api: DELETE /firewall/ + api: PUT /firewall//disallow/ arguments: protocol: help: "Protocol type to allow (TCP/UDP/Both)" From 63f904850428d889ce0993cc6e850d945c420c63 Mon Sep 17 00:00:00 2001 From: axolotle Date: Mon, 22 Mar 2021 22:31:18 +0100 Subject: [PATCH 08/10] add PUT '/migration' to avoid specifying the list of the migrations to run --- data/actionsmap/yunohost.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 1f710202d..034034199 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -1551,7 +1551,9 @@ tools: ### tools_migrations_run() run: action_help: Run migrations - api: PUT /migrations/ + api: + - PUT /migrations + - PUT /migrations/ deprecated_alias: - migrate arguments: From 113d9f5a8bea4dd8e4619b9379852b187ba57743 Mon Sep 17 00:00:00 2001 From: axolotle Date: Mon, 22 Mar 2021 23:22:56 +0100 Subject: [PATCH 09/10] PUT for '/apps//config' & 'appscatalog' to 'apps/catalog' --- data/actionsmap/yunohost.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 034034199..9dc3312f4 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -587,7 +587,7 @@ app: catalog: action_help: Show the catalog of installable application - api: GET /appscatalog + api: GET /apps/catalog arguments: -f: full: --full @@ -597,7 +597,7 @@ app: full: --with-categories help: Also return a list of app categories action: store_true - + ### app_search() search: action_help: Search installable apps @@ -851,7 +851,7 @@ app: ### app_config_apply() apply: action_help: apply the new configuration - api: POST /apps//config + api: PUT /apps//config arguments: app: help: App name @@ -1500,7 +1500,7 @@ tools: ### tools_regen_conf() regen-conf: action_help: Regenerate the configuration file(s) - api: + api: - PUT /regenconf - PUT /regenconf/ arguments: From ff772cd2949c91995260462d69b8c0f59c141f96 Mon Sep 17 00:00:00 2001 From: axolotle Date: Mon, 22 Mar 2021 23:41:06 +0100 Subject: [PATCH 10/10] split '/diagnosis/ignore' and '/diagnosis/ungignore' --- data/actionsmap/yunohost.yml | 16 ++++++++++------ src/yunohost/diagnosis.py | 10 +++++++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 9dc3312f4..3c6b863db 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -1795,17 +1795,21 @@ diagnosis: ignore: action_help: Configure some diagnosis results to be ignored and therefore not considered as actual issues - api: POST /diagnosis/ignore + api: PUT /diagnosis/ignore arguments: - --add-filter: + --filter: help: "Add a filter. The first element should be a diagnosis category, and other criterias can be provided using the infos from the 'meta' sections in 'yunohost diagnosis show'. For example: 'dnsrecords domain=yolo.test category=xmpp'" nargs: "*" metavar: CRITERIA - --remove-filter: - help: Remove a filter (it should be an existing filter as listed with --list) - nargs: "*" - metavar: CRITERIA --list: help: List active ignore filters action: store_true + unignore: + action_help: Configure some diagnosis results to be unignored and therefore considered as actual issues + api: PUT /diagnosis/unignore + arguments: + --filter: + help: Remove a filter (it should be an existing filter as listed with --list) + nargs: "*" + metavar: CRITERIA diff --git a/src/yunohost/diagnosis.py b/src/yunohost/diagnosis.py index d01d56613..4a231d82c 100644 --- a/src/yunohost/diagnosis.py +++ b/src/yunohost/diagnosis.py @@ -221,7 +221,15 @@ def diagnosis_run( logger.warning(m18n.n("diagnosis_display_tip")) -def diagnosis_ignore(add_filter=None, remove_filter=None, list=False): +def diagnosis_ignore(filter, list=False): + return _diagnosis_ignore(add_filter=filter, list=list) + + +def diagnosis_unignore(filter): + return _diagnosis_ignore(remove_filter=filter) + + +def _diagnosis_ignore(add_filter=None, remove_filter=None, list=False): """ This action is meant for the admin to ignore issues reported by the diagnosis system if they are known and understood by the admin. For