smp_time module

TIPCommon.smp_time.get_last_success_time

TIPCommon.smp_time.get_last_success_time(siemplify, offset_with_metric, time_format=2, print_value=True, microtime=False)

Get the last success time or datetime.

Parameters
siemplify obj

An instance of the SDK SiemplifyConnectorExecution class.

offset_with_metric dict

The metric and value.
Example: {'hours': 1}

time_format int

The format of the output time.
Example: DATETIME, UNIX

print_value Optional

bool

Indicates whether to print the value or not.
Default is True.

microtime Optional

bool

Indicates whether to return Unix time including microtime.
Default is False.

Returns

The last success time.

Return type

Time

TIPCommon.smp_time.is_approaching_action_timeout

TIPCommon.smp_time.is_approaching_action_timeout(action_execution_deadline_in_unix, timeout_threshold_in_sec=10)

Check if the action script is approaching its dedicated script deadline.

Each action script has a specific deadline dedicated to it. This function checks if the current time is less than the deadline by at least timeout_threshold_in_sec seconds. The default is 10 seconds, meaning that if the action is 10 or less seconds from its script deadline (at the time of the check) the function returns True. If the deadline is exceeded, the function returns False.

Parameters
action_execution_deadline_in_unix int

The deadline for action execution.

timeout_threshold_in_sec int

The timeout threshold in seconds.

Returns

True if timeout is approaching, False otherwise.

TIPCommon.smp_time.is_approaching_timeout

TIPCommon.smp_time.is_approaching_timeout(connector_starting_time, python_process_timeout, timeout_threshold=0.9)

Check if a timeout is approaching.

Parameters
connector_starting_time int

The time the connector started.

python_process_timeout int

The maximum amount of time the connector is allowed to run.

timeout_threshold float

The threshold at which the connector is considered to be approaching a timeout.
Default is TIMEOUT_THRESHOLD.

Returns

True if the connector is approaching a timeout, False otherwise.

TIPCommon.smp_time.save_timestamp

TIPCommon.smp_time.save_timestamp(siemplify, alerts, timestamp_key='timestamp', incrementation_value=0, log_timestamp=True, convert_timestamp_to_micro_time=False, convert_a_string_timestamp_to_unix=False)

Save the last timestamp for given alerts.

Parameters
siemplify obj

An instance of the SDK SiemplifyConnectorExecution class.

alerts dict

The list of alerts to find the last timestamp.

timestamp_key Optional

str

The key for getting timestamp from alert.
Default is timestamp.

incrementation_value Optional

int

The value to increment the last timestamp in milliseconds.
Default is 0.

log_timestamp Optional

bool

Indicates whether to log the timestamp or not.
Default is True.

convert_timestamp_to_micro_time Optional

bool

Indicates whether to convert the timestamp to microtime.
Default is False.

convert_a_string_timestamp_to_unix Optional

bool

Indicates whether to convert a string timestamp to Unix.
Default is False.

Returns

Boolean indicating whether the timestamp is updated.

TIPCommon.smp_time.siemplify_fetch_timestamp

TIPCommon.smp_time.siemplify_fetch_timestamp(siemplify, datetime_format=False, timezone=False)

Fetch the timestamp from Siemplify.

Parameters
siemplify obj

An instance of the SDK SiemplifyConnectorExecution class.

datetime_format Optional

bool

Indicates whether to return the timestamp in a datetime format.
Default is False.

timezone Optional

bool

Indicates whether to return the timestamp in a UTC timezone.
Default is False.

Returns

The timestamp.

TIPCommon.smp_time.siemplify_save_timestamp

TIPCommon.smp_time.siemplify_save_timestamp(siemplify, datetime_format=False, timezone=False, new_timestamp=1696256382032)

Save the timestamp to Siemplify.

Parameters
siemplify obj

An instance of the SDK SiemplifyConnectorExecution class.

datetime_format Optional

bool

Indicates whether to save the timestamp in a datetime format.
Default is False.

timezone Optional

bool

Indicates whether to save the timestamp in a UTC timezone.
Default is False.

new_timestamp Optional

int

The new timestamp to save.

Returns

None

TIPCommon.smp_time.validate_timestamp

TIPCommon.smp_time.validate_timestamp(last_run_timestamp, offset_in_hours, offset_is_in_days=False)

Validates the timestamp in a time range.

Parameters
last_run_timestamp datetime

The last run timestamp.

offset_in_hours int

The time limit in hours.

offset_is_in_days Optional

bool

Indicates whether the offset is in days.
Default is False.

Raises

ValueError, if the timestamp is not valid.

Returns

The validated timestamp.

Return type

datetime