TimeSeries

class cloudpassage.TimeSeries(session, start_time, start_url, item_key, params={})

Wrap time-series object retrieval in a generator.

This method enables the consumption of time-ordered API objects as a generator. This method is multi-threaded and ensures that objects are yielded in chronological order according to the created_at field. This method also automatically adjusts the number of threads in use based on the volume of objects published via the selected API endpoint.

In order to cleanly stop the generator, set the object’s stop attribute to True.

Example:

# Print event IDs as they occur
import datetime
import os
import cloudpassage
start_time = datetime.datetime.now().isoformat()
key = os.getenv("HALO_API_KEY")
secret = os.getenv("HALO_API_SECRET_KEY")
session = cloudpassage.HaloSession(key, secret)
event_stream = cloudpassage.TimeSeries(session, start_time,
                                       "/v1/events", "events")
for x in event_stream:
    print(x["id"])
Parameters:
  • session (object) – HaloSession object.
  • start_time (str) – ISO 8601-formatted timestamp.
  • start_url (str) – Path from URL, no hostname and no URL-encoded params.
  • item_key (str) – Top-level key, below which is a list of target items.
  • params (dict) – Parameters for URL, which will be URL-encoded.
stop

Set to False by default. When set to True, the generator will return, effecting a clean exit.

Type:bool
__iter__()

Yields one item from a time-series query against Halo. Forever.