Ejemplo n.º 1
0
 def get_index_info_list(self, request, **kwargs):
     self.method_check(request, allowed=['get'])
     dummy_data = {}
     my_auth = MyBasicAuthentication()
     es_check = my_auth.is_authenticated(request, **kwargs)
     if es_check:
         param = {
             'token': es_check['t'],
             'operator': es_check['u'],
         }
         res = BackendRequest.get_index_info_list(param)
         print res
         if res["result"]:
             if res["index_infos"]:
                 dummy_data["status"] = "1"
                 dummy_data["list"] = res["index_infos"]
         else:
             dummy_data = err_data.build_error_new(res)
     else:
         data = err_data.build_error({}, "auth error!")
         data["location"] = "/auth/login/"
         dummy_data = data
     response_data = self.build_bundle(obj=dummy_data,
                                       data=dummy_data,
                                       request=request)
     return self.create_response(request, response_data)
Ejemplo n.º 2
0
    def get_index_match_rule_list(self, request, **kwargs):
        self.method_check(request, allowed=['get'])
        dummy_data = {}
        my_auth = MyBasicAuthentication()
        es_check = my_auth.is_authenticated(request, **kwargs)
        if es_check:
            param = {
                'token': es_check['t'],
                'operator': es_check['u'],
            }
            res_info = BackendRequest.get_index_info_list(param)
            res_index_map = {}
            if res_info['result']:
                if res_info["index_infos"]:
                    res_info_list = res_info["index_infos"]
                    print res_info_list
                    for item in res_info_list:
                        res_index_map[item['id']] = item['name']

            res = BackendRequest.get_index_match_rule_list(param)
            if res["result"]:
                if res["rules"]:
                    dummy_data["status"] = "1"
                    dummy_data["list"] = []
                    for item in res["rules"]:
                        item['index_name'] = res_index_map.get(
                            item['index_id'], '')
                        dummy_data["list"].append(item)
            else:
                dummy_data = err_data.build_error_new(res)
        else:
            data = err_data.build_error({}, "auth error!")
            data["location"] = "/auth/login/"
            dummy_data = data
        response_data = self.build_bundle(obj=dummy_data,
                                          data=dummy_data,
                                          request=request)
        return self.create_response(request, response_data)