示例#1
0
 def delete(self, **kwargs):
     name = self.encode_name()
     kwargs = dict(
         [normalize_to_str(k), normalize_to_str(v)] for k, v in kwargs.items()
     )
     url = PATH_PERFIX + name
     response, content = self.connector.make_request("DELETE", url)
     assert response["status"] == "200"
示例#2
0
 def update(self, **kwargs):
     name = self.encode_name()
     kwargs = dict(
         [normalize_to_str(k), normalize_to_str(v)] for k, v in kwargs.items()
     )
     url = PATH_PERFIX + name
     req_args = {"output_mode": "json"}
     response, content = self.connector.make_request("POST", url, kwargs, req_args)
     assert response["status"] == "200"
示例#3
0
 def get_search_timeline(self, **kwargs):
     sid = self._sid
     url = PATH_PERFIX + sid + TIMELINE
     req_args = {"output_mode": "json", "segmentation": "none"}
     kwargs = dict(
         [normalize_to_str(k), normalize_to_str(v)] for k, v in kwargs.items()
     )
     args = req_args.copy()
     args.update(kwargs)
     response, content = self.connector.make_request("GET", url, urlparam=args)
     return content
示例#4
0
 def delete_search(self, **kwargs):
     sid = self._sid
     kwargs = dict(
         [normalize_to_str(k), normalize_to_str(v)] for k, v in kwargs.items()
     )
     url = PATH_PERFIX + sid
     req_args = {"output_mode": "json"}
     response, content = self.connector.make_request(
         "DELETE", url, body=kwargs, urlparam=req_args
     )
     assert response["status"] == "200"
示例#5
0
 def update(self, **values):
     values = dict(
         [normalize_to_str(k), normalize_to_str(v)]
         for k, v in values.items())
     name = urllib.parse.quote_plus(self._name)
     url = (PATH_PERFIX + self.rest_conf.path +
            "{stanza_name}".format(stanza_name=name))
     user_args = values
     response, content = self.connector.make_request(
         "POST", url, user_args, {"output_mode": "json"})
     assert response["status"] == "200"
示例#6
0
 def get_search_log(self, **kwargs):
     sid = self._sid
     url = PATH_PERFIX + sid + SEARCHLOG
     req_args = {"output_mode": "json", "segmentation": "none"}
     kwargs = dict(
         [normalize_to_str(k), normalize_to_str(v)] for k, v in kwargs.items()
     )
     args = req_args.copy()
     args.update(kwargs)
     response, content = self.connector.make_request("GET", url, urlparam=args)
     assert response["status"] == "200"
     return content
示例#7
0
 def control_search(self, **kwargs):
     sid = self._sid
     kwargs = dict(
         [normalize_to_str(k), normalize_to_str(v)] for k, v in kwargs.items()
     )
     url = PATH_PERFIX + sid + CONTROL
     req_args = {"output_mode": "json"}
     response, content = self.connector.make_request(
         "POST", url, body=kwargs, urlparam=req_args
     )
     assert response["status"] == "200"
     return json.loads(content)
示例#8
0
 def _create(self, query, **kwargs):
     query = normalize_to_str(query)
     url = PATH_PERFIX
     user_args = {"search": query}
     kwargs = dict(
         [normalize_to_str(k), normalize_to_str(v)] for k, v in kwargs.items()
     )
     args = user_args.copy()
     args.update(kwargs)
     response, content = self.connector.make_request(
         "POST", url, args, {"output_mode": "json"}
     )
     assert response["status"] == "201"
     parsed_content = json.loads(content)
     return RestJob(self.connector, parsed_content["sid"])
示例#9
0
 def _create_stanza(self, stanza_name, **values):
     if stanza_name in self:
         return RestStanza(self.connector, self._raw_rest_conf, stanza_name)
     values = dict(
         [normalize_to_str(k), normalize_to_str(v)]
         for k, v in values.items())
     stanza_name = normalize_to_str(stanza_name)
     url = PATH_PERFIX + self._raw_rest_conf.path
     user_args = {"name": stanza_name}
     user_args.update(values)
     response, content = self.connector.make_request(
         "POST", url, user_args, {"output_mode": "json"})
     assert response["status"] == "201"
     if normalize_to_unicode(stanza_name) in self:
         return RestStanza(self.connector, self._raw_rest_conf, stanza_name)
示例#10
0
 def get_search_results_preview(self, **kwargs):
     sid = self._sid
     url = PATH_PERFIX + sid + RESULTS_PREVIEW
     req_args = {"output_mode": "json", "segmentation": "none"}
     kwargs = dict(
         [normalize_to_str(k), normalize_to_str(v)] for k, v in kwargs.items()
     )
     args = req_args.copy()
     args.update(kwargs)
     # Refer to INFRA-17464, get search result preview should not be recorded in ..log,
     # otherwise, the ..log might be too large to open.
     response, content = self.connector.make_request(
         "GET", url, urlparam=args, log_response=False
     )
     assert response["status"] == "200"
     return content
示例#11
0
 def _create(self, conf_name):
     conf_name = normalize_to_str(conf_name)
     url = PATH_PERFIX + PATH_PROPERTIES
     user_args = {"__conf": conf_name}
     response, content = self.connector.make_request(
         "POST", url, user_args, {"output_mode": "json"})
     assert response["status"] == "201"
     if conf_name in self:
         return Configurations(self.connector, conf_name)
示例#12
0
 def _create_index(self, index_name):
     index_name = normalize_to_str(index_name)
     url = PATH_PERFIX
     user_args = {"name": index_name}
     response, content = self.connector.make_request(
         "POST", url, user_args, {"output_mode": "json"}
     )
     assert response["status"] == "201"
     if normalize_to_unicode(index_name) in self:
         return RestIndex(self.connector, index_name)
示例#13
0
 def _delete_stanza(self, stanza_name):
     stanza_name = normalize_to_str(stanza_name)
     url = (PATH_PERFIX + self._raw_rest_conf.path +
            "/{stanza_name}".format(stanza_name=stanza_name))
     self.connector.make_request("DELETE", url)