Skip to content

Commit

Permalink
[operation] add ListOperations api implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
shmel1k committed Oct 14, 2023
1 parent 8aad508 commit d63887c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions ydb/_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class OperationService(object):
ForgetOperation = "ForgetOperation"
GetOperation = "GetOperation"
CancelOperation = "CancelOperation"
ListOperations = "ListOperations"


class SchemeService(object):
Expand Down
32 changes: 32 additions & 0 deletions ydb/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ 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
Expand All @@ -48,6 +60,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")
Expand Down Expand Up @@ -99,3 +120,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,),
)

0 comments on commit d63887c

Please sign in to comment.