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)
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)
def get(ctx: Configuration, method): """Do a GET request against api/<method>.""" response = api.restapi(ctx, 'get', method) _report(ctx, "GET", method, response)
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()