mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
REST code and header fixes
This commit is contained in:
parent
d5725fd243
commit
588ee4b13f
2 changed files with 56 additions and 12 deletions
|
@ -51,6 +51,7 @@ user:
|
||||||
### user_list()
|
### user_list()
|
||||||
list:
|
list:
|
||||||
action_help: List users
|
action_help: List users
|
||||||
|
api: GET /user/list
|
||||||
arguments:
|
arguments:
|
||||||
--fields:
|
--fields:
|
||||||
help: fields to fetch
|
help: fields to fetch
|
||||||
|
@ -68,6 +69,7 @@ user:
|
||||||
### user_create()
|
### user_create()
|
||||||
create:
|
create:
|
||||||
action_help: Create user
|
action_help: Create user
|
||||||
|
api: POST /user
|
||||||
arguments:
|
arguments:
|
||||||
-u:
|
-u:
|
||||||
full: --username
|
full: --username
|
||||||
|
@ -93,6 +95,7 @@ user:
|
||||||
### user_delete()
|
### user_delete()
|
||||||
delete:
|
delete:
|
||||||
action_help: Delete user
|
action_help: Delete user
|
||||||
|
api: DELETE /user
|
||||||
arguments:
|
arguments:
|
||||||
-u:
|
-u:
|
||||||
full: --users
|
full: --users
|
||||||
|
@ -106,6 +109,7 @@ user:
|
||||||
### user_update()
|
### user_update()
|
||||||
update:
|
update:
|
||||||
action_help: Update user informations
|
action_help: Update user informations
|
||||||
|
api: PUT /user
|
||||||
arguments:
|
arguments:
|
||||||
username:
|
username:
|
||||||
help: Username of user to update
|
help: Username of user to update
|
||||||
|
@ -139,6 +143,7 @@ user:
|
||||||
### user_info()
|
### user_info()
|
||||||
info:
|
info:
|
||||||
action_help: Get user informations
|
action_help: Get user informations
|
||||||
|
api: GET /user
|
||||||
arguments:
|
arguments:
|
||||||
user-or-mail:
|
user-or-mail:
|
||||||
help: Username or mail to get informations
|
help: Username or mail to get informations
|
||||||
|
@ -154,6 +159,7 @@ domain:
|
||||||
### domain_list()
|
### domain_list()
|
||||||
list:
|
list:
|
||||||
action_help: List domains
|
action_help: List domains
|
||||||
|
api: GET /domain/list
|
||||||
arguments:
|
arguments:
|
||||||
-f:
|
-f:
|
||||||
full: --filter
|
full: --filter
|
||||||
|
@ -168,6 +174,7 @@ domain:
|
||||||
### domain_add()
|
### domain_add()
|
||||||
add:
|
add:
|
||||||
action_help: Create a custom domain
|
action_help: Create a custom domain
|
||||||
|
api: POST /domain
|
||||||
arguments:
|
arguments:
|
||||||
domains:
|
domains:
|
||||||
help: Domain name to add
|
help: Domain name to add
|
||||||
|
@ -181,6 +188,7 @@ domain:
|
||||||
### domain_remove()
|
### domain_remove()
|
||||||
remove:
|
remove:
|
||||||
action_help: Delete domains
|
action_help: Delete domains
|
||||||
|
api: DELETE /domain
|
||||||
arguments:
|
arguments:
|
||||||
domains:
|
domains:
|
||||||
help: Domain(s) to delete
|
help: Domain(s) to delete
|
||||||
|
@ -190,18 +198,12 @@ domain:
|
||||||
### domain_info()
|
### domain_info()
|
||||||
info:
|
info:
|
||||||
action_help: Get domain informations
|
action_help: Get domain informations
|
||||||
|
api: GET /domain
|
||||||
arguments:
|
arguments:
|
||||||
domain:
|
domain:
|
||||||
help: ""
|
help: ""
|
||||||
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])*)$'
|
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])*)$'
|
||||||
|
|
||||||
### domain_renewcert()
|
|
||||||
renewcert:
|
|
||||||
action_help: Renew domain certificate
|
|
||||||
arguments:
|
|
||||||
domain:
|
|
||||||
help: ""
|
|
||||||
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])*)$'
|
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
# App #
|
# App #
|
||||||
|
@ -213,6 +215,7 @@ app:
|
||||||
### app_fetchlist()
|
### app_fetchlist()
|
||||||
fetchlist:
|
fetchlist:
|
||||||
action_help: Fetch application list from app server
|
action_help: Fetch application list from app server
|
||||||
|
api: PUT /app/lists
|
||||||
arguments:
|
arguments:
|
||||||
-u:
|
-u:
|
||||||
full: --url
|
full: --url
|
||||||
|
@ -224,10 +227,12 @@ app:
|
||||||
### app_listlists()
|
### app_listlists()
|
||||||
listlists:
|
listlists:
|
||||||
action_help: List fetched lists
|
action_help: List fetched lists
|
||||||
|
api: GET /app/lists
|
||||||
|
|
||||||
### app_removelist()
|
### app_removelist()
|
||||||
removelist:
|
removelist:
|
||||||
action_help: Remove list from the repositories
|
action_help: Remove list from the repositories
|
||||||
|
api: DELETE /app/lists
|
||||||
arguments:
|
arguments:
|
||||||
-n:
|
-n:
|
||||||
full: --name
|
full: --name
|
||||||
|
@ -238,6 +243,7 @@ app:
|
||||||
### app_list()
|
### app_list()
|
||||||
list:
|
list:
|
||||||
action_help: List apps
|
action_help: List apps
|
||||||
|
api: GET /app/list
|
||||||
arguments:
|
arguments:
|
||||||
-l:
|
-l:
|
||||||
full: --limit
|
full: --limit
|
||||||
|
@ -256,6 +262,7 @@ app:
|
||||||
### app_map()
|
### app_map()
|
||||||
map:
|
map:
|
||||||
action_help: List apps by domain
|
action_help: List apps by domain
|
||||||
|
api: GET /app/map
|
||||||
arguments:
|
arguments:
|
||||||
-a:
|
-a:
|
||||||
full: --app
|
full: --app
|
||||||
|
@ -268,6 +275,7 @@ app:
|
||||||
### app_install() TODO: Write help
|
### app_install() TODO: Write help
|
||||||
install:
|
install:
|
||||||
action_help: Install apps
|
action_help: Install apps
|
||||||
|
api: POST /app
|
||||||
arguments:
|
arguments:
|
||||||
app:
|
app:
|
||||||
help: App to install
|
help: App to install
|
||||||
|
@ -289,6 +297,7 @@ app:
|
||||||
### app_remove() TODO: Write help
|
### app_remove() TODO: Write help
|
||||||
remove:
|
remove:
|
||||||
action_help: Remove app
|
action_help: Remove app
|
||||||
|
api: DELETE /app
|
||||||
arguments:
|
arguments:
|
||||||
app:
|
app:
|
||||||
help: App(s) to delete
|
help: App(s) to delete
|
||||||
|
@ -300,6 +309,7 @@ app:
|
||||||
### app_upgrade()
|
### app_upgrade()
|
||||||
upgrade:
|
upgrade:
|
||||||
action_help: Upgrade app
|
action_help: Upgrade app
|
||||||
|
api: PUT /app
|
||||||
arguments:
|
arguments:
|
||||||
app:
|
app:
|
||||||
help: App(s) to upgrade (default all)
|
help: App(s) to upgrade (default all)
|
||||||
|
@ -318,6 +328,7 @@ app:
|
||||||
### app_info() TODO: Write help
|
### app_info() TODO: Write help
|
||||||
info:
|
info:
|
||||||
action_help: Get app informations
|
action_help: Get app informations
|
||||||
|
api: GET /app
|
||||||
arguments:
|
arguments:
|
||||||
app:
|
app:
|
||||||
help: App ID
|
help: App ID
|
||||||
|
@ -333,6 +344,7 @@ 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 /app/access
|
||||||
arguments:
|
arguments:
|
||||||
apps:
|
apps:
|
||||||
nargs: "+"
|
nargs: "+"
|
||||||
|
@ -343,6 +355,7 @@ 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 /app/access
|
||||||
arguments:
|
arguments:
|
||||||
apps:
|
apps:
|
||||||
nargs: "+"
|
nargs: "+"
|
||||||
|
@ -361,6 +374,7 @@ backup:
|
||||||
### backup_init()
|
### backup_init()
|
||||||
init:
|
init:
|
||||||
action_help: Init Tahoe-LAFS configuration
|
action_help: Init Tahoe-LAFS configuration
|
||||||
|
api: POST /backup/init
|
||||||
arguments:
|
arguments:
|
||||||
--helper:
|
--helper:
|
||||||
help: Init as a helper node rather than a "helped" one
|
help: Init as a helper node rather than a "helped" one
|
||||||
|
@ -439,10 +453,12 @@ firewall:
|
||||||
### firewall_list()
|
### firewall_list()
|
||||||
list:
|
list:
|
||||||
action_help: List all firewall rules
|
action_help: List all firewall rules
|
||||||
|
api: GET /firewall/list
|
||||||
|
|
||||||
### firewall_reload()
|
### firewall_reload()
|
||||||
reload:
|
reload:
|
||||||
action_help: Reload all firewall rules
|
action_help: Reload all firewall rules
|
||||||
|
api: PUT /firewall/list
|
||||||
arguments:
|
arguments:
|
||||||
-u:
|
-u:
|
||||||
full: --upnp
|
full: --upnp
|
||||||
|
@ -451,6 +467,7 @@ firewall:
|
||||||
### firewall_allow()
|
### firewall_allow()
|
||||||
allow:
|
allow:
|
||||||
action_help: Allow connection port/protocol
|
action_help: Allow connection port/protocol
|
||||||
|
api: POST /firewall/port
|
||||||
arguments:
|
arguments:
|
||||||
port:
|
port:
|
||||||
help: Port to open
|
help: Port to open
|
||||||
|
@ -473,6 +490,7 @@ firewall:
|
||||||
### firewall_disallow()
|
### firewall_disallow()
|
||||||
disallow:
|
disallow:
|
||||||
action_help: Disallow connection
|
action_help: Disallow connection
|
||||||
|
api: DELETE /firewall/port
|
||||||
arguments:
|
arguments:
|
||||||
port:
|
port:
|
||||||
help: Port to open
|
help: Port to open
|
||||||
|
@ -495,21 +513,25 @@ firewall:
|
||||||
### firewall_installupnp()
|
### firewall_installupnp()
|
||||||
installupnp:
|
installupnp:
|
||||||
action_help: Add upnp cron
|
action_help: Add upnp cron
|
||||||
|
api: POST /firewall/upnp
|
||||||
|
|
||||||
|
|
||||||
### firewall_removeupnp()
|
### firewall_removeupnp()
|
||||||
removeupnp:
|
removeupnp:
|
||||||
action_help: Remove upnp cron
|
action_help: Remove upnp cron
|
||||||
|
api: DELETE /firewall/upnp
|
||||||
|
|
||||||
|
|
||||||
### firewall_stop()
|
### firewall_stop()
|
||||||
stop:
|
stop:
|
||||||
action_help: Stop iptables and ip6tables
|
action_help: Stop iptables and ip6tables
|
||||||
|
api: DELETE /firewall
|
||||||
|
|
||||||
|
|
||||||
### firewall_checkupnp()
|
### firewall_checkupnp()
|
||||||
checkupnp:
|
checkupnp:
|
||||||
action_help: check if UPNP is install or not (0 yes 1 no)
|
action_help: check if UPNP is install or not (0 yes 1 no)
|
||||||
|
api: GET /firewall/upnp
|
||||||
|
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
|
@ -522,6 +544,7 @@ 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
|
||||||
|
@ -536,6 +559,7 @@ 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
|
||||||
|
@ -553,10 +577,12 @@ dyndns:
|
||||||
### dyndns_installcron()
|
### dyndns_installcron()
|
||||||
installcron:
|
installcron:
|
||||||
action_help: Install IP update cron
|
action_help: Install IP update cron
|
||||||
|
api: POST /dyndns/cron
|
||||||
|
|
||||||
### dyndns_removecron()
|
### dyndns_removecron()
|
||||||
removecron:
|
removecron:
|
||||||
action_help: Remove IP update cron
|
action_help: Remove IP update cron
|
||||||
|
api: DELETE /dyndns/cron
|
||||||
|
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
|
@ -569,10 +595,12 @@ tools:
|
||||||
### tools_ldapinit()
|
### tools_ldapinit()
|
||||||
ldapinit:
|
ldapinit:
|
||||||
action_help: YunoHost LDAP initialization
|
action_help: YunoHost LDAP initialization
|
||||||
|
api: POST /ldap
|
||||||
|
|
||||||
### tools_adminpw()
|
### tools_adminpw()
|
||||||
adminpw:
|
adminpw:
|
||||||
action_help: Change admin password
|
action_help: Change admin password
|
||||||
|
api: PUT /adminpw
|
||||||
arguments:
|
arguments:
|
||||||
-o:
|
-o:
|
||||||
full: --old-password
|
full: --old-password
|
||||||
|
@ -586,6 +614,7 @@ tools:
|
||||||
### tools_maindomain()
|
### tools_maindomain()
|
||||||
maindomain:
|
maindomain:
|
||||||
action_help: Main domain change tool
|
action_help: Main domain change tool
|
||||||
|
api: PUT /domain/main
|
||||||
arguments:
|
arguments:
|
||||||
-o:
|
-o:
|
||||||
full: --old-domain
|
full: --old-domain
|
||||||
|
@ -598,6 +627,7 @@ tools:
|
||||||
### tools_postinstall()
|
### tools_postinstall()
|
||||||
postinstall:
|
postinstall:
|
||||||
action_help: YunoHost post-install
|
action_help: YunoHost post-install
|
||||||
|
api: POST /postinstall
|
||||||
arguments:
|
arguments:
|
||||||
-d:
|
-d:
|
||||||
full: --domain
|
full: --domain
|
||||||
|
|
24
yunohost.tac
24
yunohost.tac
|
@ -36,7 +36,7 @@ class LDAPHTTPAuth():
|
||||||
return credentials.username
|
return credentials.username
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise defer.fail(UnauthorizedLogin("Unable to verify password for "+ credentials.username)) #TODO: Reask for password
|
return defer.fail(UnauthorizedLogin())
|
||||||
|
|
||||||
|
|
||||||
class SimpleRealm(object):
|
class SimpleRealm(object):
|
||||||
|
@ -52,13 +52,13 @@ class SimpleRealm(object):
|
||||||
return IResource, self._api, lambda: None
|
return IResource, self._api, lambda: None
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
|
||||||
action_dict = {}
|
action_dict = {}
|
||||||
|
|
||||||
def http_exec(request):
|
def http_exec(request):
|
||||||
global win
|
global win
|
||||||
dict = action_dict[request.method+' '+request.path]
|
dict = action_dict[request.method+' '+request.path]
|
||||||
args = dict['arguments']
|
if 'arguments' in dict: args = dict['arguments']
|
||||||
|
else: args = {}
|
||||||
for arg, params in args.items():
|
for arg, params in args.items():
|
||||||
sanitized_key = arg.replace('-', '_')
|
sanitized_key = arg.replace('-', '_')
|
||||||
if sanitized_key is not arg:
|
if sanitized_key is not arg:
|
||||||
|
@ -95,9 +95,23 @@ def http_exec(request):
|
||||||
if win:
|
if win:
|
||||||
result['win'] = win
|
result['win'] = win
|
||||||
win = []
|
win = []
|
||||||
except YunoHostError, error:
|
if request.method == 'POST':
|
||||||
result = { "error" : str(error.code) +' : '+ error.message }
|
request.setResponseCode(201, 'Created')
|
||||||
|
elif request.method == 'DELETE':
|
||||||
|
request.setResponseCode(204, 'No Content')
|
||||||
|
else:
|
||||||
|
request.setResponseCode(200, 'OK')
|
||||||
|
|
||||||
|
except YunoHostError, error:
|
||||||
|
server_errors = [1, 111, 169]
|
||||||
|
client_errors = [13, 17, 22, 87, 122, 125, 167, 168]
|
||||||
|
if error.code in client_errors:
|
||||||
|
request.setResponseCode(400, 'Bad Request')
|
||||||
|
else:
|
||||||
|
request.setResponseCode(500, 'Internal Server Error')
|
||||||
|
result = { 'error' : error.message }
|
||||||
|
|
||||||
|
request.setHeader('Content-Type', 'application/json')
|
||||||
return json.dumps(result)
|
return json.dumps(result)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue