From 6b9c807def5df44fd0048c3944a5008617fe5fd1 Mon Sep 17 00:00:00 2001 From: Alexander Petrukhin Date: Sat, 14 Oct 2023 19:16:50 +0000 Subject: [PATCH] [operation] add ListOperations api implementation --- ydb/_apis.py | 1 + ydb/operation.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/ydb/_apis.py b/ydb/_apis.py index 27bc1bbe..79946dd4 100644 --- a/ydb/_apis.py +++ b/ydb/_apis.py @@ -66,6 +66,7 @@ class OperationService(object): ForgetOperation = "ForgetOperation" GetOperation = "GetOperation" CancelOperation = "CancelOperation" + ListOperations = "ListOperations" class SchemeService(object): diff --git a/ydb/operation.py b/ydb/operation.py index 6084ef0f..648c1089 100644 --- a/ydb/operation.py +++ b/ydb/operation.py @@ -26,6 +26,14 @@ def _get_operation_request(self): return request +def _list_operations_response(rpc_state, response): # pylint: disable=W0613 + issues._process_response(response) + + +def _list_operations_request(kind: str, page_size: int, page_token: str): + return _apis.ydb_operation.ListOperationsRequest(kind=kind, page_size=page_size, page_token=page_token) + + class OperationClient(object): def __init__(self, driver): self._driver = driver @@ -48,6 +56,15 @@ def forget(self, operation_id, settings=None): settings, ) + def list(self, kind: str, page_size: int, page_token: str, settings=None): + return self._driver( + _list_operations_request(kind, page_size, page_token), + _apis.OperationService.Stub, + _apis.OperationService.ListOperations, + _list_operations_response, + settings, + ) + class Operation(object): __slots__ = ("id", "_driver", "self_cls") @@ -99,3 +116,14 @@ def get(self, settings=None): settings, (self._driver,), ) + + def list(self, kind: str, page_size: int, page_token: str, settings=None): + self._ensure_implements() + return self._driver( + _list_operations_request(kind, page_size, page_token), + _apis.OperationService.Stub, + _apis.OperationService.ListOperations, + self.__class__, + settings, + (self._driver,), + )