mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-12 19:56:29 +00:00
Part 3 of rest api / new files
This commit is contained in:
parent
ad057352c0
commit
56e8c349c9
29
hassio_api/hassio/api/homeassistant.py
Normal file
29
hassio_api/hassio/api/homeassistant.py
Normal file
@ -0,0 +1,29 @@
|
||||
"""Init file for HassIO homeassistant rest api."""
|
||||
import logging
|
||||
|
||||
from aiohttp import web
|
||||
from aiohttp.web_exceptions import HTTPMethodNotAllowed
|
||||
|
||||
from ..const import ATTR_VERSION
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class APIHomeAssistant(object):
|
||||
"""Handle rest api for homeassistant functions."""
|
||||
|
||||
def __init__(self, config, loop, dock_hass):
|
||||
"""Initialize homeassistant rest api part."""
|
||||
self.config = config
|
||||
self.loop = loop
|
||||
self.dock_hass = hass
|
||||
|
||||
async def info(self, request):
|
||||
"""Return host information."""
|
||||
return web.json_response({
|
||||
ATTR_VERSION: self.dock_hass.version,
|
||||
})
|
||||
|
||||
async def update(self, request):
|
||||
"""Update host OS."""
|
||||
raise HTTPMethodNotAllowed()
|
32
hassio_api/hassio/api/supervisor.py
Normal file
32
hassio_api/hassio/api/supervisor.py
Normal file
@ -0,0 +1,32 @@
|
||||
"""Init file for HassIO supervisor rest api."""
|
||||
import logging
|
||||
|
||||
from aiohttp import web
|
||||
from aiohttp.web_exceptions import HTTPOk, HTTPMethodNotAllowed
|
||||
|
||||
from ..const import ATTR_VERSION, HASSIO_VERSION
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class APISupervisor(object):
|
||||
"""Handle rest api for supervisor functions."""
|
||||
|
||||
def __init__(self, config, loop, host_controll):
|
||||
"""Initialize supervisor rest api part."""
|
||||
self.config = config
|
||||
self.loop = loop
|
||||
self.host_controll = host_controll
|
||||
|
||||
async def info(self, request):
|
||||
"""Return host information."""
|
||||
return web.json_response({
|
||||
ATTR_VERSION: HASSIO_DOCKER,
|
||||
})
|
||||
|
||||
async def update(self, request):
|
||||
"""Update host OS."""
|
||||
body = await request.json() or {}
|
||||
if await self.host_controll.supervisor_update(body.get(ATTR_VERSION)):
|
||||
raise HTTPOk()
|
||||
raise HTTPMethodNotAllowed()
|
Loading…
x
Reference in New Issue
Block a user