Merge pull request #1192 from YunoHost/uniformize-actionmap-api

Uniformize API routes
This commit is contained in:
Alexandre Aubin 2021-04-12 17:51:17 +02:00 committed by GitHub
commit ce64a6380a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 243 additions and 162 deletions

View file

@ -252,30 +252,6 @@ user:
extra: extra:
pattern: *pattern_groupname pattern: *pattern_groupname
### user_group_update()
update:
action_help: Update group
api: PUT /users/groups/<groupname>
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() ### user_group_info()
info: info:
action_help: Get information about a specific group action_help: Get information about a specific group
@ -286,6 +262,38 @@ user:
extra: extra:
pattern: *pattern_username pattern: *pattern_username
### user_group_add()
add:
action_help: Update group
api: PUT /users/groups/<groupname>/add/<usernames>
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/<groupname>/remove/<usernames>
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: permission:
subcategory_help: Manage permissions subcategory_help: Manage permissions
actions: actions:
@ -322,20 +330,6 @@ user:
arguments: arguments:
permission: 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) 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: -l:
full: --label full: --label
help: Label for this permission. This label will be shown on the SSO and in the admin help: Label for this permission. This label will be shown on the SSO and in the admin
@ -346,10 +340,38 @@ user:
- 'True' - 'True'
- 'False' - 'False'
## user_permission_add()
add:
action_help: Grant permission to group or user
api: PUT /users/permissions/<permission>/add/<names>
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/<permission>/remove/<names>
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() ## user_permission_reset()
reset: reset:
action_help: Reset allowed groups to the default (all_users) for a given permission action_help: Reset allowed groups to the default (all_users) for a given permission
api: DELETE /users/permissions/<app> api: DELETE /users/permissions/<permission>
arguments: arguments:
permission: 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) 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)
@ -485,7 +507,7 @@ domain:
- maindomain - maindomain
api: api:
- GET /domains/main - GET /domains/main
- PUT /domains/main - PUT /domains/<new_main_domain>/main
arguments: arguments:
-n: -n:
full: --new-main-domain full: --new-main-domain
@ -496,7 +518,7 @@ domain:
### certificate_status() ### certificate_status()
cert-status: cert-status:
action_help: List status of current certificates (all by default). action_help: List status of current certificates (all by default).
api: GET /domains/cert-status/<domain_list> api: GET /domains/<domain_list>/cert
arguments: arguments:
domain_list: domain_list:
help: Domains to check help: Domains to check
@ -508,7 +530,7 @@ domain:
### certificate_install() ### certificate_install()
cert-install: cert-install:
action_help: Install Let's Encrypt certificates for given domains (all by default). action_help: Install Let's Encrypt certificates for given domains (all by default).
api: POST /domains/cert-install/<domain_list> api: PUT /domains/<domain_list>/cert
arguments: arguments:
domain_list: domain_list:
help: Domains for which to install the certificates help: Domains for which to install the certificates
@ -529,7 +551,7 @@ domain:
### certificate_renew() ### certificate_renew()
cert-renew: cert-renew:
action_help: Renew the Let's Encrypt certificates for given domains (all by default). action_help: Renew the Let's Encrypt certificates for given domains (all by default).
api: POST /domains/cert-renew/<domain_list> api: PUT /domains/<domain_list>/cert/renew
arguments: arguments:
domain_list: domain_list:
help: Domains for which to renew the certificates help: Domains for which to renew the certificates
@ -550,7 +572,7 @@ domain:
### domain_url_available() ### domain_url_available()
url-available: url-available:
action_help: Check availability of a web path action_help: Check availability of a web path
api: GET /domain/urlavailable api: GET /domain/<domain>/urlavailable
arguments: arguments:
domain: domain:
help: The domain for the web path (e.g. your.domain.tld) help: The domain for the web path (e.g. your.domain.tld)
@ -559,20 +581,6 @@ domain:
path: path:
help: The path to check (e.g. /coffee) help: The path to check (e.g. /coffee)
### domain_info()
# info:
# action_help: Get domain informations
# api: GET /domains/<domain>
# 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 # # App #
############################# #############################
@ -582,7 +590,7 @@ app:
catalog: catalog:
action_help: Show the catalog of installable application action_help: Show the catalog of installable application
api: GET /appscatalog api: GET /apps/catalog
arguments: arguments:
-f: -f:
full: --full full: --full
@ -592,7 +600,7 @@ app:
full: --with-categories full: --with-categories
help: Also return a list of app categories help: Also return a list of app categories
action: store_true action: store_true
### app_search() ### app_search()
search: search:
action_help: Search installable apps action_help: Search installable apps
@ -634,7 +642,7 @@ app:
### app_map() ### app_map()
map: map:
action_help: Show the mapping between urls and apps action_help: Show the mapping between urls and apps
api: GET /appsmap api: GET /apps/map
arguments: arguments:
-a: -a:
full: --app full: --app
@ -682,7 +690,7 @@ app:
### app_upgrade() ### app_upgrade()
upgrade: upgrade:
action_help: Upgrade app action_help: Upgrade app
api: PUT /upgrade/apps api: PUT /apps/<app>/upgrade
arguments: arguments:
app: app:
help: App(s) to upgrade (default all) help: App(s) to upgrade (default all)
@ -740,7 +748,6 @@ app:
### app_register_url() ### app_register_url()
register-url: register-url:
action_help: Book/register a web path for a given app action_help: Book/register a web path for a given app
api: PUT /tools/registerurl
arguments: arguments:
app: app:
help: App which will use the web path help: App which will use the web path
@ -764,7 +771,6 @@ app:
### app_ssowatconf() ### app_ssowatconf()
ssowatconf: ssowatconf:
action_help: Regenerate SSOwat configuration file action_help: Regenerate SSOwat configuration file
api: PUT /ssowatconf
### app_change_label() ### app_change_label()
change-label: change-label:
@ -779,7 +785,6 @@ app:
### app_addaccess() TODO: Write help ### app_addaccess() TODO: Write help
addaccess: addaccess:
action_help: Grant access right to users (everyone by default) action_help: Grant access right to users (everyone by default)
api: PUT /access
deprecated: true deprecated: true
arguments: arguments:
apps: apps:
@ -791,7 +796,6 @@ app:
### app_removeaccess() TODO: Write help ### app_removeaccess() TODO: Write help
removeaccess: removeaccess:
action_help: Revoke access right to users (everyone by default) action_help: Revoke access right to users (everyone by default)
api: DELETE /access
deprecated: true deprecated: true
arguments: arguments:
apps: apps:
@ -803,7 +807,6 @@ app:
### app_clearaccess() ### app_clearaccess()
clearaccess: clearaccess:
action_help: Reset access rights for the app action_help: Reset access rights for the app
api: POST /access
deprecated: true deprecated: true
arguments: arguments:
apps: apps:
@ -851,7 +854,7 @@ app:
### app_config_apply() ### app_config_apply()
apply: apply:
action_help: apply the new configuration action_help: apply the new configuration
api: POST /apps/<app>/config api: PUT /apps/<app>/config
arguments: arguments:
app: app:
help: App name help: App name
@ -869,7 +872,7 @@ backup:
### backup_create() ### backup_create()
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. 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: arguments:
-n: -n:
full: --name full: --name
@ -897,7 +900,7 @@ backup:
### backup_restore() ### backup_restore()
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. 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/<name> api: PUT /backups/<name>/restore
arguments: arguments:
name: name:
help: Name of the local backup archive help: Name of the local backup archive
@ -914,7 +917,7 @@ backup:
### backup_list() ### backup_list()
list: list:
action_help: List available local backup archives action_help: List available local backup archives
api: GET /backup/archives api: GET /backups
arguments: arguments:
-i: -i:
full: --with-info full: --with-info
@ -928,7 +931,7 @@ backup:
### backup_info() ### backup_info()
info: info:
action_help: Show info about a local backup archive action_help: Show info about a local backup archive
api: GET /backup/archives/<name> api: GET /backups/<name>
arguments: arguments:
name: name:
help: Name of the local backup archive help: Name of the local backup archive
@ -944,7 +947,7 @@ backup:
### backup_download() ### backup_download()
download: download:
action_help: (API only) Request to download the file action_help: (API only) Request to download the file
api: GET /backup/download/<name> api: GET /backups/<name>/download
arguments: arguments:
name: name:
help: Name of the local backup archive help: Name of the local backup archive
@ -952,7 +955,7 @@ backup:
### backup_delete() ### backup_delete()
delete: delete:
action_help: Delete a backup archive action_help: Delete a backup archive
api: DELETE /backup/archives/<name> api: DELETE /backups/<name>
arguments: arguments:
name: name:
help: Name of the archive to delete help: Name of the archive to delete
@ -1019,7 +1022,6 @@ service:
### service_add() ### service_add()
add: add:
action_help: Add a service action_help: Add a service
# api: POST /services
arguments: arguments:
name: name:
help: Service name to add help: Service name to add
@ -1057,7 +1059,6 @@ service:
### service_remove() ### service_remove()
remove: remove:
action_help: Remove a service action_help: Remove a service
# api: DELETE /services
arguments: arguments:
name: name:
help: Service name to remove help: Service name to remove
@ -1065,7 +1066,7 @@ service:
### service_start() ### service_start()
start: start:
action_help: Start one or more services action_help: Start one or more services
api: PUT /services/<names> api: PUT /services/<names>/start
arguments: arguments:
names: names:
help: Service name to start help: Service name to start
@ -1075,7 +1076,7 @@ service:
### service_stop() ### service_stop()
stop: stop:
action_help: Stop one or more services action_help: Stop one or more services
api: DELETE /services/<names> api: PUT /services/<names>/stop
arguments: arguments:
names: names:
help: Service name to stop help: Service name to stop
@ -1123,7 +1124,7 @@ service:
### service_disable() ### service_disable()
disable: disable:
action_help: Disable one or more services action_help: Disable one or more services
api: DELETE /services/<names>/enable api: PUT /services/<names>/disable
arguments: arguments:
names: names:
help: Service name to disable help: Service name to disable
@ -1158,7 +1159,6 @@ service:
### service_regen_conf() ### service_regen_conf()
regen-conf: regen-conf:
action_help: Regenerate the configuration file(s) for a service action_help: Regenerate the configuration file(s) for a service
api: PUT /services/regenconf
deprecated_alias: deprecated_alias:
- regenconf - regenconf
arguments: arguments:
@ -1210,19 +1210,10 @@ firewall:
help: List forwarded ports with UPnP help: List forwarded ports with UPnP
action: store_true 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() ### firewall_allow()
allow: allow:
action_help: Allow connections on a port action_help: Allow connections on a port
api: POST /firewall/port api: PUT /firewall/<protocol>/allow/<port>
arguments: arguments:
protocol: protocol:
help: "Protocol type to allow (TCP/UDP/Both)" help: "Protocol type to allow (TCP/UDP/Both)"
@ -1252,11 +1243,10 @@ firewall:
help: Do not reload firewall rules help: Do not reload firewall rules
action: store_true action: store_true
### firewall_disallow() ### firewall_disallow()
disallow: disallow:
action_help: Disallow connections on a port action_help: Disallow connections on a port
api: DELETE /firewall/port api: PUT /firewall/<protocol>/disallow/<port>
arguments: arguments:
protocol: protocol:
help: "Protocol type to allow (TCP/UDP/Both)" help: "Protocol type to allow (TCP/UDP/Both)"
@ -1284,11 +1274,10 @@ firewall:
help: Do not reload firewall rules help: Do not reload firewall rules
action: store_true action: store_true
### firewall_upnp() ### firewall_upnp()
upnp: upnp:
action_help: Manage port forwarding using UPnP action_help: Manage port forwarding using UPnP
api: GET /firewall/upnp api: PUT /firewall/upnp/<action>
arguments: arguments:
action: action:
choices: choices:
@ -1302,10 +1291,19 @@ firewall:
help: Do not refresh port forwarding help: Do not refresh port forwarding
action: store_true 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() ### firewall_stop()
stop: stop:
action_help: Stop iptables and ip6tables action_help: Stop iptables and ip6tables
api: DELETE /firewall
@ -1319,7 +1317,6 @@ dyndns:
### dyndns_subscribe() ### dyndns_subscribe()
subscribe: subscribe:
action_help: Subscribe to a DynDNS service action_help: Subscribe to a DynDNS service
api: POST /dyndns
arguments: arguments:
--subscribe-host: --subscribe-host:
help: Dynette HTTP API to subscribe to help: Dynette HTTP API to subscribe to
@ -1336,7 +1333,6 @@ dyndns:
### dyndns_update() ### dyndns_update()
update: update:
action_help: Update IP on DynDNS platform action_help: Update IP on DynDNS platform
api: PUT /dyndns
arguments: arguments:
--dyn-host: --dyn-host:
help: Dynette DNS server to inform help: Dynette DNS server to inform
@ -1440,25 +1436,40 @@ tools:
### tools_update() ### tools_update()
update: update:
action_help: YunoHost update action_help: YunoHost update
api: PUT /update api: PUT /update/<target>
arguments: 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: --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 action: store_true
--system: --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 action: store_true
### tools_upgrade() ### tools_upgrade()
upgrade: upgrade:
action_help: YunoHost upgrade action_help: YunoHost upgrade
api: PUT /upgrade api: PUT /upgrade/<target>
arguments: arguments:
target:
help: What to upgrade, either "apps" (all apps) or "system" (all system packages)
choices:
- apps
- system
nargs: "?"
--apps: --apps:
help: List of apps to upgrade (all by default) help: (Deprecated, see first positional arg) Upgrade all applications
nargs: "*" action: store_true
--system: --system:
help: Upgrade only the system packages help: (Deprecated, see first positional arg) Upgrade only the system packages
action: store_true action: store_true
### tools_shell() ### tools_shell()
@ -1492,7 +1503,9 @@ tools:
### tools_regen_conf() ### tools_regen_conf()
regen-conf: regen-conf:
action_help: Regenerate the configuration file(s) action_help: Regenerate the configuration file(s)
api: PUT /tools/regenconf api:
- PUT /regenconf
- PUT /regenconf/<names>
arguments: arguments:
names: names:
help: Categories to regenerate configuration of (all by default) help: Categories to regenerate configuration of (all by default)
@ -1541,7 +1554,9 @@ tools:
### tools_migrations_run() ### tools_migrations_run()
run: run:
action_help: Run migrations action_help: Run migrations
api: POST /migrations/run api:
- PUT /migrations
- PUT /migrations/<targets>
deprecated_alias: deprecated_alias:
- migrate - migrate
arguments: arguments:
@ -1564,7 +1579,6 @@ tools:
### tools_migrations_state() ### tools_migrations_state()
state: state:
action_help: Show current migrations state action_help: Show current migrations state
api: GET /migrations/state
############################# #############################
@ -1593,7 +1607,6 @@ hook:
### hook_info() ### hook_info()
info: info:
action_help: Get information about a given hook action_help: Get information about a given hook
api: GET /hooks/<action>/<name>
arguments: arguments:
action: action:
help: Action name help: Action name
@ -1623,7 +1636,6 @@ hook:
### hook_callback() ### hook_callback()
callback: callback:
action_help: Execute all scripts binded to an action action_help: Execute all scripts binded to an action
api: POST /hooks/<action>
arguments: arguments:
action: action:
help: Action name help: Action name
@ -1719,7 +1731,7 @@ log:
### log_share() ### log_share()
share: share:
action_help: Share the full log on yunopaste (alias to show --share) action_help: Share the full log on yunopaste (alias to show --share)
api: GET /logs/share api: GET /logs/<path>/share
arguments: arguments:
path: path:
help: Log file to share help: Log file to share
@ -1734,11 +1746,11 @@ diagnosis:
list: list:
action_help: List diagnosis categories action_help: List diagnosis categories
api: GET /diagnosis/list api: GET /diagnosis/categories
show: show:
action_help: Show most recents diagnosis results action_help: Show most recents diagnosis results
api: GET /diagnosis/show api: GET /diagnosis
arguments: arguments:
categories: categories:
help: Diagnosis categories to display (all by default) help: Diagnosis categories to display (all by default)
@ -1756,9 +1768,20 @@ diagnosis:
help: Show a human-readable output help: Show a human-readable output
action: store_true action: store_true
get:
action_help: Low-level command to fetch raw data and status about a specific diagnosis test
api: GET /diagnosis/<category>
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: run:
action_help: Run diagnosis action_help: Run diagnosis
api: POST /diagnosis/run api: PUT /diagnosis/run
arguments: arguments:
categories: categories:
help: Diagnosis categories to run (all by default) help: Diagnosis categories to run (all by default)
@ -1775,27 +1798,21 @@ diagnosis:
ignore: ignore:
action_help: Configure some diagnosis results to be ignored and therefore not considered as actual issues 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: 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'" 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: "*" nargs: "*"
metavar: CRITERIA metavar: CRITERIA
--remove-filter:
help: Remove a filter (it should be an existing filter as listed with --list)
nargs: "*"
metavar: CRITERIA
--list: --list:
help: List active ignore filters help: List active ignore filters
action: store_true action: store_true
get: unignore:
action_help: Low-level command to fetch raw data and status about a specific diagnosis test action_help: Configure some diagnosis results to be unignored and therefore considered as actual issues
api: GET /diagnosis/item/<category> api: PUT /diagnosis/unignore
arguments: arguments:
category: --filter:
help: Diagnosis category to fetch results from help: Remove a filter (it should be an existing filter as listed with --list)
item:
help: "List of criteria describing the test. Must correspond exactly to the 'meta' infos in 'yunohost diagnosis show'"
metavar: CRITERIA
nargs: "*" nargs: "*"
metavar: CRITERIA

View file

@ -144,7 +144,7 @@ def app_fetchlist():
) )
from yunohost.tools import tools_update from yunohost.tools import tools_update
tools_update(apps=True) tools_update(target="apps")
def app_list(full=False, installed=False, filter=None): def app_list(full=False, installed=False, filter=None):

View file

@ -43,7 +43,7 @@ class MyMigration(Migration):
# #
logger.info(m18n.n("migration_0015_patching_sources_list")) logger.info(m18n.n("migration_0015_patching_sources_list"))
self.patch_apt_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 # Tell libc6 it's okay to restart system stuff during the upgrade
os.system( os.system(
@ -88,7 +88,7 @@ class MyMigration(Migration):
apps_packages = self.get_apps_equivs_packages() apps_packages = self.get_apps_equivs_packages()
self.hold(apps_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: if self.debian_major_version() == 9:
raise YunohostError("migration_0015_still_on_stretch_after_main_upgrade") 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")) logger.info(m18n.n("migration_0015_yunohost_upgrade"))
self.unhold(apps_packages) self.unhold(apps_packages)
tools_upgrade(system=True) tools_upgrade(target="system")
def debian_major_version(self): def debian_major_version(self):
# The python module "platform" and lsb_release are not reliable because # 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 ... # (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) # which means maybe a previous upgrade crashed and we're re-running it)
if " buster " not in read_file("/etc/apt/sources.list"): 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()) upgradable_system_packages = list(_list_upgradable_apt_packages())
if upgradable_system_packages: if upgradable_system_packages:
raise YunohostError("migration_0015_system_not_fully_up_to_date") raise YunohostError("migration_0015_system_not_fully_up_to_date")

View file

@ -221,7 +221,15 @@ def diagnosis_run(
logger.warning(m18n.n("diagnosis_display_tip")) 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 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 diagnosis system if they are known and understood by the admin. For

View file

@ -405,22 +405,29 @@ def tools_regen_conf(
return regen_conf(names, with_diff, force, dry_run, list_pending) 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 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 # Legacy options (--system, --apps)
if not apps and not system: if apps or system:
apps = True logger.warning("Using 'yunohost tools update' with --apps / --system is deprecated, just write 'yunohost tools update apps system' (no -- prefix anymore)")
system = True 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 = [] upgradable_system_packages = []
if system: if target in ["system", "all"]:
# Update APT cache # Update APT cache
# LC_ALL=C is here to make sure the results are in english # LC_ALL=C is here to make sure the results are in english
@ -468,7 +475,7 @@ def tools_update(apps=False, system=False):
logger.debug(m18n.n("done")) logger.debug(m18n.n("done"))
upgradable_apps = [] upgradable_apps = []
if apps: if target in ["apps", "all"]:
try: try:
_update_apps_catalog() _update_apps_catalog()
except YunohostError as e: except YunohostError as e:
@ -519,7 +526,7 @@ def _list_upgradable_apps():
@is_unit_operation() @is_unit_operation()
def tools_upgrade( 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 Update apps & package cache, then display changelog
@ -537,26 +544,34 @@ def tools_upgrade(
if not packages.dpkg_lock_available(): if not packages.dpkg_lock_available():
raise YunohostValidationError("dpkg_lock_not_available") raise YunohostValidationError("dpkg_lock_not_available")
if system is not False and apps is not None: # Legacy options management (--system, --apps)
raise YunohostValidationError("tools_upgrade_cant_both") if target is None:
if system is False and apps is None: logger.warning("Using 'yunohost tools upgrade' with --apps / --system is deprecated, just write 'yunohost tools upgrade apps' or 'system' (no -- prefix anymore)")
raise YunohostValidationError("tools_upgrade_at_least_one")
if (system, apps) == (True, True):
raise YunohostValidationError("tools_upgrade_cant_both")
if (system, apps) == (False, False):
raise YunohostValidationError("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 # Apps
# This is basically just an alias to yunohost app upgrade ... # 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 # Make sure there's actually something to upgrade
upgradable_apps = [app["id"] for app in _list_upgradable_apps()] upgradable_apps = [app["id"] for app in _list_upgradable_apps()]
if not upgradable_apps or ( if not upgradable_apps:
len(apps) and all(app not in upgradable_apps for app in apps)
):
logger.info(m18n.n("apps_already_up_to_date")) logger.info(m18n.n("apps_already_up_to_date"))
return return
@ -574,7 +589,7 @@ def tools_upgrade(
# System # System
# #
if system is True: if target == "system":
# Check that there's indeed some packages to upgrade # Check that there's indeed some packages to upgrade
upgradables = list(_list_upgradable_apt_packages()) upgradables = list(_list_upgradable_apt_packages())

View file

@ -862,6 +862,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 # Permission subcategory
# #
@ -873,18 +901,31 @@ def user_permission_list(short=False, full=False, apps=[]):
return yunohost.permission.user_permission_list(short, full, absolute_urls=True, apps=apps) return yunohost.permission.user_permission_list(short, full, absolute_urls=True, apps=apps)
def user_permission_update( def user_permission_update(permission, label=None, show_tile=None, sync_perm=True):
permission, add=None, remove=None, 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 import yunohost.permission
return yunohost.permission.user_permission_update( return yunohost.permission.user_permission_update(
permission, permission, add=names, protected=protected, force=force, sync_perm=sync_perm
add=add, )
remove=remove,
label=label,
show_tile=show_tile, def user_permission_remove(
sync_perm=sync_perm, 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
) )