Make an API request to the Hub

    to reduce boilerplate repetition.

def api_request(path, **kwargs):
    """Make an API request to the Hub

    to reduce boilerplate repetition.
    """

    url = url_path_join(os.environ['JUPYTERHUB_API_URL'], path)
    client = AsyncHTTPClient()
    headers = {
        'Authorization': 'token %s' % os.environ['JUPYTERHUB_API_TOKEN'],
    }
    if kwargs.get('method') == 'POST':
        kwargs.setdefault('body', '')
    req = HTTPRequest(url, headers=headers, **kwargs)
    return client.fetch(req)