def list_events(query, include=None): result = ManagerElasticsearch.search_events(body=query, include=include) events = ManagerElasticsearch.extract_search_result_values(result) metadata = ManagerElasticsearch.build_list_result_metadata(query, result) return ListResult(events, metadata)
def _list_docs(self, doc_type, model_class, body=None, fields=None): include = list(fields) if fields else True result = self._connection.search(index=STORAGE_INDEX_NAME, doc_type=doc_type, body=body, _source=include) docs = ManagerElasticsearch.extract_search_result_values(result) # ES doesn't return _version if using its search API. if doc_type == NODE_INSTANCE_TYPE: for doc in docs: doc['version'] = None items = [self._fill_missing_fields_and_deserialize(doc, model_class) for doc in docs] metadata = ManagerElasticsearch.build_list_result_metadata(body, result) return ListResult(items, metadata)