Skip to content

Commit

Permalink
Add explicit get method on ui_restart endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicaj committed Apr 22, 2021
1 parent 649ee8e commit 8b31d28
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/middlewared/middlewared/plugins/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from middlewared.logger import CrashReporting
from middlewared.schema import accepts, Bool, Dict, Int, IPAddr, List, Str
from middlewared.service import (
CallError, ConfigService, no_auth_required, job, pass_app, private, Service, throttle, ValidationErrors
CallError, ConfigService, no_auth_required, job, pass_app, private, rest_api_metadata,
Service, throttle, ValidationErrors
)
import middlewared.sqlalchemy as sa
from middlewared.utils import Popen, run, start_daemon_thread, sw_buildtime, sw_version, osc
Expand Down Expand Up @@ -1470,6 +1471,7 @@ async def do_update(self, data):

return await self.config()

@rest_api_metadata(explicit_methods=['GET'])
@accepts(Int('delay', default=3, validators=[Range(min=0)]))
async def ui_restart(self, delay):
"""
Expand Down
5 changes: 3 additions & 2 deletions src/middlewared/middlewared/restful.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ async def register_resources(self):
res_kwargs['post'] = methodname
else:
res_kwargs['get'] = methodname
for rest_method in (method['explicit_methods'] or []):
assert rest_method in ('post', 'get')
for rest_method in map(str.lower, (method['explicit_methods'] or [])):
assert rest_method in ('get',)
# Only allow get for now as that's the only use case we have for now NAS-110243
res_kwargs[rest_method] = methodname

Resource(self, self.middleware, short_methodname, service['config'], parent=parent, **res_kwargs)
Expand Down

0 comments on commit 8b31d28

Please sign in to comment.