Module betterstack.uptime.helpers

This module is used to store some generic helper function that don’t belong anywhere else

Module contents

Helper utilities for the BetterStack Uptime API.

betterstack.uptime.helpers.filter_on_attribute(objects: list[T], attribute: str, value: Any) list[T][source]

Filter a list of objects by attribute value.

This function filters a list of objects, returning only those where the specified attribute matches the given value.

Args:

objects: List of objects to filter. attribute: Name of the attribute to check. value: Value the attribute should match.

Returns:

A filtered list containing only objects where the attribute matches.

Example:
>>> monitors = [monitor1, monitor2, monitor3]
>>> paused_monitors = filter_on_attribute(monitors, "paused", True)