Skip to content

Commit 5403071

Browse files
authored
[resotolib][feat] Use default graph section in searches (#1574)
1 parent 4480922 commit 5403071

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

resotocore/resotocore/infra_apps/local_runtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ async def generate_template(
6868
async def perform_search(search: str) -> AsyncIterator[Json]:
6969
# parse query
7070
query = await self.template_expander.parse_query(search, on_section="reported")
71-
async with await graphdb.search_list(QueryModel(query, model)) as ctx:
71+
async with await graphdb.search_graph_gen(QueryModel(query, model)) as ctx:
7272
async for result in ctx:
7373
yield result
7474

resotolib/resotolib/core/search.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,15 @@ def execute(self, command: str) -> Iterator[Json]:
4646
execute_endpoint += f"?{query_string}"
4747
return self.post(execute_endpoint, command, headers, verify=self.verify)
4848

49-
def search(self, search: str, edge_type: Optional[EdgeType] = None) -> Iterator[Json]:
49+
def search(self, search: str, edge_type: Optional[EdgeType] = None, section: str = "reported") -> Iterator[Json]:
5050
log.debug(f"Sending search {search}")
5151
headers = {"Accept": "application/x-ndjson"}
5252
search_endpoint = self.search_uri
53+
query = {"section": section}
5354
if edge_type is not None:
54-
query_string = urlencode({"edge_type": edge_type.value})
55-
search_endpoint += f"?{query_string}"
55+
query["edge_type"] = edge_type.value
56+
query_string = urlencode(query)
57+
search_endpoint += f"?{query_string}"
5658
return self.post(search_endpoint, search, headers, verify=self.verify)
5759

5860
@staticmethod

0 commit comments

Comments
 (0)