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 toTrue
.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: -
stop
¶ Set to
False
by default. When set toTrue
, the generator will return, effecting a clean exit.Type: bool
-
__iter__
()¶ Yields one item from a time-series query against Halo. Forever.
-