예제 #1
0
def _handle(ctx, method, httpmethod='get', raw=False) -> None:
    """Handle the data."""
    method = "/api/hassio/" + method
    response = api.restapi(ctx, httpmethod, method)
    api.restapi(ctx, httpmethod, method)

    _report(ctx, httpmethod, method, response)
예제 #2
0
def post(ctx: Configuration, method, json):
    """Do a POST request against api/<method>."""
    if json:
        data = json_.loads(json)
    else:
        data = {}

    response = api.restapi(ctx, 'post', method, data)

    _report(ctx, "GET", method, response)
예제 #3
0
def post(ctx: Configuration, method, json):
    """Do a POST request against api/<method>."""
    if json:
        data = json_.loads(json)
    else:
        data = {}

    response = api.restapi(ctx, 'post', method, data)

    _report(ctx, "GET", method, response)
예제 #4
0
def get(ctx: Configuration, method):
    """Do a GET request against api/<method>."""
    response = api.restapi(ctx, 'get', method)

    _report(ctx, "GET", method, response)
예제 #5
0
def get(ctx: Configuration, method):
    """Do a GET request against api/<method>."""
    response = api.restapi(ctx, 'get', method)

    _report(ctx, "GET", method, response)
예제 #6
0
def _handle_raw(ctx, method, httpmethod='get') -> Dict:
    """Handle raw data."""
    method = "/api/hassio/" + method
    response = api.restapi(ctx, httpmethod, method)
    api.restapi(ctx, httpmethod, method)
    return response.json()