Exemplo n.º 1
0
def query_store_api(request, path=None):
    response = {'status': -1}

    if USE_PROXY.get():
        content_type = 'application/json; charset=UTF-8'
        headers = {'X-Requested-By': 'das', 'Content-Type': content_type}

        client = HttpClient(QUERY_STORE.SERVER_URL.get())
        resource = Resource(client)
        if USE_SASL.get():
            client.set_kerberos_auth()

        try:
            response = resource.invoke(request.method, path,
                                       request.GET.dict(), request.body,
                                       headers)
        except RestException as e:
            ex_response = e.get_parent_ex().response
            response['code'] = ex_response.status_code
            response['message'] = ex_response.reason
            response['content'] = ex_response.text
    else:
        if path == 'api/query/search':
            filters = json.loads(request.body)
            resp = get_api(request.user,
                           interface='queries-hive').apps(filters['search'])
            response = resp['apps']

    return JsonResponse(response)
Exemplo n.º 2
0
Arquivo: api2.py Projeto: ranade1/hue
def query_store_api(request, path=None):
    response = {'status': -1}

    if USE_PROXY.get():
        response = query_store_proxy(request, path)
    else:
        if path == 'api/query/search':
            filters = json.loads(request.body)
            resp = get_api(request.user,
                           interface='queries-hive').apps(filters['search'])
            response = resp['apps']

    return JsonResponse(response)