From d11d77f4eb2eb2fbc5b640c9df4ef9e4e3c095c5 Mon Sep 17 00:00:00 2001 From: Denys Fedoryshchenko Date: Thu, 5 Dec 2024 01:08:04 +0200 Subject: [PATCH] feat(api/latest.py): Implement bulk set api call Reference PR: https://github.com/kernelci/kernelci-api/pull/584 Signed-off-by: Denys Fedoryshchenko --- kernelci/api/latest.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kernelci/api/latest.py b/kernelci/api/latest.py index c638b18219..ba7f99c5cf 100644 --- a/kernelci/api/latest.py +++ b/kernelci/api/latest.py @@ -140,6 +140,18 @@ def update(self, node: dict, noevent=False) -> dict: uri += '?noevent=true' return self._put(uri, node).json() + def bulkset(self, nodes: list, field: str, value: str): + """ + Set a field to a value for a list of nodes(ids) + """ + param = { + 'nodes': nodes, + 'field': field, + 'value': value + } + print(f"bulkset param: {param}") + return self._put(f'batch/nodeset', data=param) + def subscribe(self, channel: str, promisc: Optional[bool] = None) -> int: params = {'promisc': promisc} if promisc else None resp = self._post(f'subscribe/{channel}', params=params)