def list_processed_parameter_group_histogram(self, group=None, start=None, stop=None, merge_time=20): """ Reads index records related to processed parameter groups between the specified start and stop time. Each iteration returns a chunk of chronologically-sorted records. :param float merge_time: Maximum gap in seconds before two consecutive index records are merged together. :rtype: ~collections.Iterable[.IndexGroup] """ params = {} if group is not None: params['group'] = group if start is not None: params['start'] = to_isostring(start) if stop is not None: params['stop'] = to_isostring(stop) if merge_time is not None: params['mergeTime'] = int(merge_time * 1000) return pagination.Iterator( client=self._client, path='/archive/{}/parameter-index'.format(self._instance), params=params, response_class=archive_pb2.IndexResponse, items_key='group', item_mapper=IndexGroup, )
def list_packet_histogram(self, name=None, start=None, stop=None, merge_time=2): """ Reads packet-related index records between the specified start and stop time. Each iteration returns a chunk of chronologically-sorted records. :param float merge_time: Maximum gap in seconds before two consecutive index records are merged together. :rtype: ~collections.abc.Iterable[.IndexGroup] """ params = {} if name is not None: params["name"] = name if start is not None: params["start"] = to_isostring(start) if stop is not None: params["stop"] = to_isostring(stop) if merge_time is not None: params["mergeTime"] = int(merge_time * 1000) return pagination.Iterator( ctx=self.ctx, path=f"/archive/{self._instance}/packet-index", params=params, response_class=index_service_pb2.IndexResponse, items_key="group", item_mapper=IndexGroup, )
def list_parameter_values(self, parameter, start=None, stop=None, page_size=500, descending=False, parameter_cache='realtime', source='ParameterArchive'): """ Reads parameter values between the specified start and stop time. :param str parameter: Either a fully-qualified XTCE name or an alias in the format ``NAMESPACE/NAME``. :param ~datetime.datetime start: Minimum generation time of the returned values (inclusive) :param ~datetime.datetime stop: Maximum generation time of the returned values (exclusive) :param int page_size: Page size of underlying requests. Higher values imply less overhead, but risk hitting the maximum message size limit. :param bool descending: If set to ``True`` values are fetched in reverse order (most recent first). :param str parameter_cache: Specify the name of the processor who's parameter cache is merged with already archived values. To disable results from the parameter cache, set this to ``None``. :param str source: Specify how to retrieve parameter values. By default this uses the ``ParameterArchive`` which is optimized for retrieval. For Yamcs instances that do not enable the ``ParameterArchive``, you can still get results by specifying ``replay`` as the source. Replay requests take longer to return because the data needs to be reprocessed. :rtype: ~collections.Iterable[.ParameterValue] """ params = { 'source': source, 'order': 'desc' if descending else 'asc', } if page_size is not None: params['limit'] = page_size if start is not None: params['start'] = to_isostring(start) if stop is not None: params['stop'] = to_isostring(stop) if parameter_cache: params['processor'] = parameter_cache else: params['norealtime'] = True return pagination.Iterator( client=self._client, path='/archive/{}/parameters{}'.format(self._instance, parameter), params=params, response_class=archive_pb2.ListParameterValuesResponse, items_key='parameter', item_mapper=ParameterValue, )
def list_events( self, source=None, severity=None, text_filter=None, start=None, stop=None, page_size=500, descending=False, ): """ Reads events between the specified start and stop time. Events are sorted by generation time, source, then sequence number. :param str source: The source of the returned events. :param str severity: The minimum severity level of the returned events. One of ``INFO``, ``WATCH``, ``WARNING``, ``DISTRESS``, ``CRITICAL`` or ``SEVERE``. :param str text_filter: Filter the text message of the returned events :param ~datetime.datetime start: Minimum start date of the returned events (inclusive) :param ~datetime.datetime stop: Maximum start date of the returned events (exclusive) :param int page_size: Page size of underlying requests. Higher values imply less overhead, but risk hitting the maximum message size limit. :param bool descending: If set to ``True`` events are fetched in reverse order (most recent first). :rtype: ~collections.abc.Iterable[.Event] """ params = { "order": "desc" if descending else "asc", } if source is not None: params["source"] = source if page_size is not None: params["limit"] = page_size if severity is not None: params["severity"] = severity if start is not None: params["start"] = to_isostring(start) if stop is not None: params["stop"] = to_isostring(stop) if text_filter is not None: params["q"] = text_filter return pagination.Iterator( ctx=self.ctx, path=f"/archive/{self._instance}/events", params=params, response_class=events_service_pb2.ListEventsResponse, items_key="event", item_mapper=Event, )
def list_command_history( self, command=None, queue=None, start=None, stop=None, page_size=500, descending=False, ): """ Reads command history entries between the specified start and stop time. :param str command: Either a fully-qualified XTCE name or an alias in the format ``NAMESPACE/NAME``. :param str queue: Name of the queue that the command was assigned to. :param ~datetime.datetime start: Minimum generation time of the returned command history entries (inclusive) :param ~datetime.datetime stop: Maximum generation time of the returned command history entries (exclusive) :param int page_size: Page size of underlying requests. Higher values imply less overhead, but risk hitting the maximum message size limit. :param bool descending: If set to ``True`` results are fetched in reverse order (most recent first). :rtype: ~collections.abc.Iterable[.CommandHistory] """ params = { "order": "desc" if descending else "asc", } if queue: params["queue"] = queue if page_size is not None: params["limit"] = page_size if start is not None: params["start"] = to_isostring(start) if stop is not None: params["stop"] = to_isostring(stop) if command: path = f"/archive/{self._instance}/commands{command}" else: path = f"/archive/{self._instance}/commands" return pagination.Iterator( ctx=self.ctx, path=path, params=params, response_class=commands_service_pb2.ListCommandsResponse, items_key="entry", item_mapper=CommandHistory, )
def list_command_history(self, command=None, start=None, stop=None, page_size=500, descending=False): """ Reads command history entries between the specified start and stop time. :param str command: Either a fully-qualified XTCE name or an alias in the format ``NAMESPACE/NAME``. :param ~datetime.datetime start: Minimum generation time of the returned command history entries (inclusive) :param ~datetime.datetime stop: Maximum generation time of the returned command history entries (exclusive) :param int page_size: Page size of underlying requests. Higher values imply less overhead, but risk hitting the maximum message size limit. :param bool descending: If set to ``True`` results are fetched in reverse order (most recent first). :rtype: ~collections.Iterable[.CommandHistory] """ params = { 'order': 'desc' if descending else 'asc', } if page_size is not None: params['limit'] = page_size if start is not None: params['start'] = to_isostring(start) if stop is not None: params['stop'] = to_isostring(stop) if command: path = '/archive/{}/commands{}'.format(self._instance, command) else: path = '/archive/{}/commands'.format(self._instance) return pagination.Iterator( client=self._client, path=path, params=params, response_class=rest_pb2.ListCommandsResponse, items_key='entry', item_mapper=CommandHistory, )
def list_packets(self, name=None, start=None, stop=None, page_size=500, descending=False): """ Reads packet information between the specified start and stop time. Packets are sorted by generation time and sequence number. :param str name: Archived name of the packet :param ~datetime.datetime start: Minimum generation time of the returned packets (inclusive) :param ~datetime.datetime stop: Maximum generation time of the returned packets (exclusive) :param int page_size: Page size of underlying requests. Higher values imply less overhead, but risk hitting the maximum message size limit. :param bool descending: If set to ``True`` packets are fetched in reverse order (most recent first). :rtype: ~collections.abc.Iterable[.Packet] """ params = { "order": "desc" if descending else "asc", } if name is not None: params["name"] = name if page_size is not None: params["limit"] = page_size if start is not None: params["start"] = to_isostring(start) if stop is not None: params["stop"] = to_isostring(stop) return pagination.Iterator( ctx=self.ctx, path=f"/archive/{self._instance}/packets", params=params, response_class=packets_service_pb2.ListPacketsResponse, items_key="packet", item_mapper=Packet, )
def list_packets(self, name=None, start=None, stop=None, page_size=500, descending=False): """ Reads packet information between the specified start and stop time. Packets are sorted by generation time and sequence number. :param ~datetime.datetime start: Minimum generation time of the returned packets (inclusive) :param ~datetime.datetime stop: Maximum genreation time of the returned packets (exclusive) :param int page_size: Page size of underlying requests. Higher values imply less overhead, but risk hitting the maximum message size limit. :param bool descending: If set to ``True`` packets are fetched in reverse order (most recent first). :rtype: ~collections.Iterable[.Packet] """ params = { 'order': 'desc' if descending else 'asc', } if name is not None: params['name'] = name if page_size is not None: params['limit'] = page_size if start is not None: params['start'] = to_isostring(start) if stop is not None: params['stop'] = to_isostring(stop) return pagination.Iterator( client=self._client, path='/archive/{}/packets'.format(self._instance), params=params, response_class=archive_pb2.ListPacketsResponse, items_key='packet', item_mapper=Packet, )
def list_space_systems(self, page_size=None): """ Lists the space systems visible to this client. Space systems are returned in lexicographical order. :rtype: :class:`.SpaceSystem` iterator """ params = {} if page_size is not None: params["limit"] = page_size return pagination.Iterator( ctx=self.ctx, path="/mdb/{}/space-systems".format(self._instance), params=params, response_class=mdb_pb2.ListSpaceSystemsResponse, items_key="spaceSystems", item_mapper=SpaceSystem, )
def list_containers(self, page_size=None): """ Lists the containers visible to this client. Containers are returned in lexicographical order. :rtype: :class:`.Container` iterator """ params = {} if page_size is not None: params["limit"] = page_size return pagination.Iterator( ctx=self.ctx, path=f"/mdb/{self._instance}/containers", params=params, response_class=mdb_pb2.ListContainersResponse, items_key="containers", item_mapper=Container, )
def list_containers(self, page_size=None): """ Lists the containers visible to this client. Containers are returned in lexicographical order. :rtype: :class:`.Container` iterator """ params = {} if page_size is not None: params['limit'] = page_size return pagination.Iterator( client=self._client, path='/mdb/{}/containers'.format(self._instance), params=params, response_class=mdb_pb2.ListContainersResponse, items_key='container', item_mapper=Container, )
def list_commands(self, page_size=None): """ Lists the commands visible to this client. Commands are returned in lexicographical order. :rtype: :class:`.Command` iterator """ params = {} if page_size is not None: params["limit"] = page_size return pagination.Iterator( client=self._client, path="/mdb/{}/commands".format(self._instance), params=params, response_class=mdb_pb2.ListCommandsResponse, items_key="commands", item_mapper=Command, )
def list_algorithms(self, page_size=None): """ Lists the algorithms visible to this client. Algorithms are returned in lexicographical order. :rtype: :class:`.Algorithm` iterator """ params = {} if page_size is not None: params["limit"] = page_size return pagination.Iterator( ctx=self.ctx, path=f"/mdb/{self._instance}/algorithms", params=params, response_class=mdb_pb2.ListAlgorithmsResponse, items_key="algorithms", item_mapper=Algorithm, )
def list_algorithms(self, page_size=None): """ Lists the algorithms visible to this client. Algorithms are returned in lexicographical order. :rtype: :class:`.Algorithm` iterator """ params = {} if page_size is not None: params['limit'] = page_size return pagination.Iterator( client=self._client, path='/mdb/{}/algorithms'.format(self._instance), params=params, response_class=mdb_pb2.ListAlgorithmsResponse, items_key='algorithm', item_mapper=Algorithm, )
def list_parameters(self, parameter_type=None, page_size=None): """Lists the parameters visible to this client. Parameters are returned in lexicographical order. :param str parameter_type: The type of parameter :rtype: :class:`.Parameter` iterator """ params = {"details": True} if parameter_type is not None: params["type"] = parameter_type if page_size is not None: params["limit"] = page_size return pagination.Iterator( ctx=self.ctx, path=f"/mdb/{self._instance}/parameters", params=params, response_class=mdb_pb2.ListParametersResponse, items_key="parameters", item_mapper=Parameter, )
def list_parameters(self, parameter_type=None, page_size=None): """Lists the parameters visible to this client. Parameters are returned in lexicographical order. :param str parameter_type: The type of parameter :rtype: :class:`.Parameter` iterator """ params = {'details': True} if parameter_type is not None: params['type'] = parameter_type if page_size is not None: params['limit'] = page_size return pagination.Iterator( client=self._client, path='/mdb/{}/parameters'.format(self._instance), params=params, response_class=mdb_pb2.ListParametersResponse, items_key='parameter', item_mapper=Parameter, )
def list_completeness_index(self, start=None, stop=None): """ Reads completeness index records between the specified start and stop time. Each iteration returns a chunk of chronologically-sorted records. :rtype: ~collections.abc.Iterable[.IndexGroup] """ params = {} if start is not None: params["start"] = to_isostring(start) if stop is not None: params["stop"] = to_isostring(stop) return pagination.Iterator( ctx=self.ctx, path=f"/archive/{self._instance}/completeness-index", params=params, response_class=index_service_pb2.IndexResponse, items_key="group", item_mapper=IndexGroup, )
def list_completeness_index(self, start=None, stop=None): """ Reads completeness index records between the specified start and stop time. Each iteration returns a chunk of chronologically-sorted records. :rtype: ~collections.Iterable[.IndexGroup] """ params = {} if start is not None: params['start'] = to_isostring(start) if stop is not None: params['stop'] = to_isostring(stop) return pagination.Iterator( client=self._client, path='/archive/{}/completeness-index'.format(self._instance), params=params, response_class=archive_pb2.IndexResponse, items_key='group', item_mapper=IndexGroup, )
def list_parameter_values( self, parameter, start=None, stop=None, page_size=500, descending=False, parameter_cache="realtime", source="ParameterArchive", ): """ Reads parameter values between the specified start and stop time. .. note:: This method will send out multiple requests when more than ``page_size`` values are queried. For large queries, consider using :meth:`stream_parameter_values` instead, it uses server-streaming based on a single request, and supports downloading the values of multiple parameter at the same time. :param str parameter: Either a fully-qualified XTCE name or an alias in the format ``NAMESPACE/NAME``. :param ~datetime.datetime start: Minimum generation time of the returned values (inclusive) :param ~datetime.datetime stop: Maximum generation time of the returned values (exclusive) :param int page_size: Page size of underlying requests. Higher values imply less overhead, but risk hitting the maximum message size limit. :param bool descending: If set to ``True`` values are fetched in reverse order (most recent first). :param str parameter_cache: Specify the name of the processor who's parameter cache is merged with already archived values. To disable results from the parameter cache, set this to ``None``. :param str source: Specify how to retrieve parameter values. By default this uses the ``ParameterArchive`` which is optimized for retrieval. For Yamcs instances that do not enable the ``ParameterArchive``, you can still get results by specifying ``replay`` as the source. Replay requests take longer to return because the data needs to be reprocessed. :rtype: ~collections.abc.Iterable[.ParameterValue] """ params = { "source": source, "order": "desc" if descending else "asc", } if page_size is not None: params["limit"] = page_size if start is not None: params["start"] = to_isostring(start) if stop is not None: params["stop"] = to_isostring(stop) if parameter_cache: params["processor"] = parameter_cache else: params["norealtime"] = True return pagination.Iterator( ctx=self.ctx, path=f"/archive/{self._instance}/parameters{parameter}", params=params, response_class=archive_pb2.ListParameterHistoryResponse, items_key="parameter", item_mapper=ParameterValue, )