Rename info (#750)

* Rename version to info

* fix security
This commit is contained in:
Pascal Vizeli 2018-10-10 16:46:34 +02:00 committed by GitHub
parent 78e093df96
commit 468cb0c36b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 13 deletions

3
API.md
View File

@ -663,12 +663,13 @@ return:
### Misc
- GET `/version`
- GET `/info`
```json
{
"supervisor": "version",
"homeassistant": "version",
"hassos": "null|version",
"hostname": "name",
"machine": "type",
"arch": "arch",
"channel": "stable|beta|dev"

View File

@ -10,11 +10,11 @@ from .homeassistant import APIHomeAssistant
from .hardware import APIHardware
from .host import APIHost
from .hassos import APIHassOS
from .info import APIInfo
from .proxy import APIProxy
from .supervisor import APISupervisor
from .snapshots import APISnapshots
from .services import APIServices
from .version import APIVersion
from .security import SecurityMiddleware
from ..coresys import CoreSysAttributes
@ -48,7 +48,7 @@ class RestAPI(CoreSysAttributes):
self._register_snapshots()
self._register_discovery()
self._register_services()
self._register_version()
self._register_info()
def _register_host(self):
"""Register hostcontrol functions."""
@ -92,13 +92,13 @@ class RestAPI(CoreSysAttributes):
web.get('/hardware/audio', api_hardware.audio),
])
def _register_version(self):
"""Register version functions."""
api_version = APIVersion()
api_version.coresys = self.coresys
def _register_info(self):
"""Register info functions."""
api_info = APIInfo()
api_info.coresys = self.coresys
self.webapp.add_routes([
web.get('/version', api_version.info),
web.get('/info', api_info.info),
])
def _register_supervisor(self):

View File

@ -1,4 +1,4 @@
"""Init file for Hass.io version RESTful API."""
"""Init file for Hass.io info RESTful API."""
import logging
from .utils import api_process
@ -10,12 +10,12 @@ from ..coresys import CoreSysAttributes
_LOGGER = logging.getLogger(__name__)
class APIVersion(CoreSysAttributes):
"""Handle RESTful API for version functions."""
class APIInfo(CoreSysAttributes):
"""Handle RESTful API for info functions."""
@api_process
async def info(self, request):
"""Show version info."""
"""Show system info."""
return {
ATTR_SUPERVISOR: self.sys_supervisor.version,
ATTR_HOMEASSISTANT: self.sys_homeassistant.version,

View File

@ -33,7 +33,7 @@ NO_SECURITY_CHECK = re.compile(
ADDONS_API_BYPASS = re.compile(
r"^(?:"
r"|/addons/self/(?!security|update)[^/]+"
r"|/version"
r"|/info"
r"|/services.*"
r"|/discovery.*"
r")$"