def list_all_events(self, start_time: int = None, start_version: int = None, end_version: int = None) -> List[BaseEvent]: """ List specific `key` or `version` of events in Notification Service. :param start_time: (Optional) Start time of the events. :param start_version: (Optional) the version of the events must greater than the start_version. :param end_version: (Optional) the version of the events must equal or less than the end_version. :return: The event list. """ request = ListAllEventsRequest(start_time=start_time, start_version=start_version, end_version=end_version) response = self.notification_stub.listAllEvents(request) if response.return_code == ReturnStatus.SUCCESS: if response.events is None: return [] else: events = [] for event_proto in response.events: event = event_proto_to_event(event_proto) events.append(event) return events else: raise Exception(response.return_msg)
def list_events(stub: NotificationServiceStub, start, timeout_seconds: int = None): request = ListAllEventsRequest(start_time=start, timeout_seconds=timeout_seconds) response = stub.listAllEvents(request) if response.return_code == str(ReturnStatus.SUCCESS): if response.events is None: return None else: events = [] for event_proto in response.events: event = event_proto_to_event(event_proto) events.append(event) return events else: raise Exception(response.return_msg)
def list_events_from_version(client, v, timeout_seconds: int = None): request = ListAllEventsRequest(start_version=v, timeout_seconds=timeout_seconds) response = client.notification_stub.listAllEvents(request) if response.return_code == ReturnStatus.SUCCESS: if response.events is None: return None else: events = [] for event_proto in response.events: event = event_proto_to_event(event_proto) events.append(event) return events else: raise Exception(response.return_msg)
def list_all_events(self, start_time: int): """ List specific `key` or `version` of events in Notification Service. :param start_time: the event after this time. :return: """ request = ListAllEventsRequest(start_time=start_time) response = self.notification_stub.listAllEvents(request) if response.return_code == str(ReturnStatus.SUCCESS): if response.events is None: return None else: events = [] for event_proto in response.events: event = event_proto_to_event(event_proto) events.append(event) return events else: raise Exception(response.return_msg)