Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[operation] add ListOperations api implementation #360

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
28 changes: 28 additions & 0 deletions ydb/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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,),
)
Loading