Skip to content

Commit

Permalink
feat(api/latest.py): Implement noevent flag
Browse files Browse the repository at this point in the history
Implement feature in PR: kernelci/kernelci-api#583

Signed-off-by: Denys Fedoryshchenko <[email protected]>
  • Loading branch information
nuclearcat committed Dec 4, 2024
1 parent 17bc12d commit 7144fa1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions kernelci/api/latest.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ def find(
def findfast(
self, attributes: Dict[str, str],
) -> dict:
"""
Find nodes with arbitrary attributes using non-paginated
endpoint
"""
params = attributes.copy() if attributes else {}
return self._get_fast(params, 'nodes/fast')

Expand All @@ -125,13 +129,16 @@ def count(self, attributes: dict) -> int:
def add(self, node: dict) -> dict:
return self._post('node', node).json()

def update(self, node: dict) -> dict:
def update(self, node: dict, noevent=False) -> dict:
if node['result'] != 'incomplete':
data = node.get('data', {})
if data.get('error_code') == 'node_timeout':
node['data']['error_code'] = None
node['data']['error_msg'] = None
return self._put('/'.join(['node', node['id']]), node).json()
uri = '/'.join(['node', node['id']])
if noevent:
uri += '?noevent=true'
return self._put(uri, node).json()

def subscribe(self, channel: str, promisc: Optional[bool] = None) -> int:
params = {'promisc': promisc} if promisc else None
Expand Down

0 comments on commit 7144fa1

Please sign in to comment.