TIPCommon.smp_time
The TIPCommon.smp_time module offers a comprehensive set of tools for handling temporal data within integrations. It simplifies complex tasks such as timezone shifting, timestamp persistence for connectors, and critical monitoring functions to detect approaching execution timeouts in actions and connectors.
Time conversion and manipulation
These utilities provide standardized methods for transforming time data between various formats, including Unix timestamps, RFC 3339 strings, and Python datetime objects.
| Function | Parameters | Description |
|---|---|---|
change_timezone() |
|
Returns: datetime.datetime
Shifts a datetime object to a new timezone. Raises |
convert_string_to_timestamp() |
|
Returns: int
Parses a datetime string and returns its equivalent Unix timestamp. |
datetime_to_rfc3339() |
|
Returns: str
Converts a datetime object into an RFC 3339 compliant string. |
get_timestamps() |
|
Returns: tuple[int, int]
Calculates start and end Unix timestamps based on range descriptions and bound strings. |
get_timestamps_from_range() |
|
Returns: tuple[datetime, datetime]
Calculates start and end datetime objects derived from platform-specific time range strings. |
State and persistence
Persisting the "Last Run Time" is vital for connectors to avoid duplicate ingestion. These functions interface directly with the platform to manage execution checkpoints.
| Function | Parameters | Description |
|---|---|---|
get_last_success_time() |
|
Returns: time (DataModel)
Retrieves the last successful execution time. If none exists, it calculates a fallback based on the offset. |
save_timestamp() |
|
Returns: bool
Finds the latest timestamp in an alert batch and saves it. Returns
|
siemplify_fetch_timestamp() |
|
Returns: int | datetime
Directly fetches the current execution checkpoint from the platform database. |
siemplify_save_timestamp() |
|
Returns: None
Updates the platform's execution checkpoint with a specific new value. |
validate_timestamp() |
|
Returns: datetime
Ensures a timestamp is within the allowed window. Raises
|
Execution monitoring
Timeout monitoring is a critical safety feature. These functions help scripts identify when they are nearly out of processing time, allowing them to stop gracefully and save their current state.
| Function | Parameters | Description |
|---|---|---|
is_approaching_action_timeout() |
|
Returns: bool
Checks if an action script is within its final buffer period before termination. |
is_approaching_timeout() |
|
Returns: bool
Detects if a connector has consumed its time budget based on the 90%
|