Update web API for HassIO 0.4
This commit is contained in:
parent
722d7fbf35
commit
9e4581ac4c
|
@ -80,6 +80,8 @@ Payload: {"beta": true|false}
|
|||
|
||||
- `/host/shutdown`
|
||||
|
||||
- `/host/reboot`
|
||||
|
||||
- `/host/info`
|
||||
|
||||
See HostControll info command.
|
||||
|
@ -87,12 +89,13 @@ See HostControll info command.
|
|||
- `/host/update`
|
||||
On some device we support host upates. Like ResinOS.
|
||||
|
||||
- `/host/network/info`
|
||||
### Network
|
||||
|
||||
- `/host/network/update`
|
||||
- `/network/info`
|
||||
|
||||
- `/network/options`
|
||||
Payload: {'hostname': '', 'mode': 'dhcp|fixed', 'ssid': '', 'ip': '', 'netmask': '', 'gateway': ''}
|
||||
|
||||
- `/host/reboot`
|
||||
|
||||
### HomeAssistant
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import logging
|
|||
from aiohttp import web
|
||||
|
||||
from .host import APIHost
|
||||
from .network import APINetwork
|
||||
from .supervisor import APISupervisor
|
||||
from .homeassistant import APIHomeAssistant
|
||||
|
||||
|
@ -31,10 +32,13 @@ class RestAPI(object):
|
|||
self.webapp.router.add_get('/host/reboot', api_host.reboot)
|
||||
self.webapp.router.add_get('/host/shutdown', api_host.shutdown)
|
||||
self.webapp.router.add_get('/host/update', api_host.update)
|
||||
self.webapp.router.add_get(
|
||||
'/host/network/info', api_host.network_info)
|
||||
self.webapp.router.add_get(
|
||||
'/host/network/update', api_host.network_update)
|
||||
|
||||
def register_network(self, host_controll):
|
||||
"""Register network function."""
|
||||
api_net = APINetwork(self.config, self.loop, host_controll)
|
||||
|
||||
self.webapp.router.add_get('/network/info', api_net.info)
|
||||
self.webapp.router.add_get('/network/options', api_net.options)
|
||||
|
||||
def register_supervisor(self, host_controll):
|
||||
"""Register supervisor function."""
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
"""Init file for HassIO network rest api."""
|
||||
import logging
|
||||
|
||||
from .util import api_process_hostcontroll, json_loads
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class APINetwork(object):
|
||||
"""Handle rest api for network functions."""
|
||||
|
||||
def __init__(self, config, loop, host_controll):
|
||||
"""Initialize network rest api part."""
|
||||
self.config = config
|
||||
self.loop = loop
|
||||
self.host_controll = host_controll
|
||||
|
||||
@api_process_hostcontroll
|
||||
def info(self, request):
|
||||
"""Show network settings."""
|
||||
pass
|
||||
|
||||
@api_process_hostcontroll
|
||||
def options(self, request):
|
||||
"""Edit network settings."""
|
||||
pass
|
|
@ -9,10 +9,10 @@ from .tools import fetch_current_versions
|
|||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
HOMEASSISTANT_CONFIG = "{}/homeassistant_config"
|
||||
HOMEASSISTANT_SSL = "{}/homeassistant_ssl"
|
||||
HOMEASSISTANT_IMAGE = 'homeassistant_image'
|
||||
HOMEASSISTANT_CURRENT = 'homeassistant_current'
|
||||
|
||||
HASSIO_SSL = "{}/ssl"
|
||||
HASSIO_CURRENT = 'hassio_current'
|
||||
UPSTREAM_BETA = 'upstream_beta'
|
||||
|
||||
|
@ -106,9 +106,9 @@ class CoreConfig(object):
|
|||
@property
|
||||
def path_ssl_docker(self):
|
||||
"""Return SSL path extern for docker."""
|
||||
return HOMEASSISTANT_SSL.format(os.environ['SUPERVISOR_SHARE'])
|
||||
return HASSIO_SSL.format(os.environ['SUPERVISOR_SHARE'])
|
||||
|
||||
@property
|
||||
def path_ssl(self):
|
||||
"""Return SSL path inside supervisor."""
|
||||
return HOMEASSISTANT_SSL.format(HASSIO_SHARE)
|
||||
return HASSIO_SSL.format(HASSIO_SHARE)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
"""Const file for HassIO."""
|
||||
HASSIO_VERSION = '0.3'
|
||||
HASSIO_VERSION = '0.4'
|
||||
|
||||
URL_HASSIO_VERSION = \
|
||||
'https://raw.githubusercontent.com/pvizeli/hassio/master/version.json'
|
||||
|
|
|
@ -55,6 +55,7 @@ class HassIO(object):
|
|||
|
||||
# rest api views
|
||||
self.api.register_host(self.host_controll)
|
||||
self.api.register_network(self.host_controll)
|
||||
self.api.register_supervisor(self.host_controll)
|
||||
self.api.register_homeassistant(self.homeassistant)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"hassio_tag": "0.3",
|
||||
"homeassistant_tag": "0.41",
|
||||
"resinos_version": "0.2",
|
||||
"resinos_version": "0.3",
|
||||
"resinhup_version": "0.1"
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"hassio_tag": "0.3",
|
||||
"hassio_tag": "0.4",
|
||||
"homeassistant_tag": "0.41",
|
||||
"resinos_version": "0.2",
|
||||
"resinos_version": "0.3",
|
||||
"resinhup_version": "0.1"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue