Alert

class deepint.core.Alert(organization_id: str, workspace_id: str, credentials: Credentials, info: AlertInfo)

A Deep Intelligence alert.

Note: This class should not be instanced directly, and it’s recommended to use the deepint.core.alert.Alert.build or deepint.core.alert.Alert.from_url methods.

organization_id

organization where alert is located.

workspace_id

workspace where alert is located.

info

deepint.core.alert.AlertInfo to operate with alert’s information.

instances

deepint.core.alert.AlertInstances to operate with alert’s instances.

credentials

credentials to authenticate with Deep Intelligence API and be allowed to perform operations over the alert. If not provided, the credentials are generated with the deepint.auth.credentials.Credentials.build.

classmethod build(organization_id: str, workspace_id: str, alert_id: str, credentials: Optional[Credentials] = None) Alert

Builds an alert.

Note: when alert is created, the alert’s information is retrieved from API.

Parameters:
  • organization_id – organization where alert is located.

  • workspace_id – workspace where alert is located.

  • alert_id – alert’s id.

  • credentials – credentials to authenticate with Deep Intelligence API and be allowed to perform operations over the alert. If not provided, the credentials are generated with the deepint.auth.credentials.Credentials.build.

Returns:

the alert build with the given parameters and credentials.

delete()

Deletes an alert.

classmethod from_url(url: str, organization_id: Optional[str] = None, credentials: Optional[Credentials] = None) Alert

Builds a alert from it’s API or web associated URL.

The url must contain the workspace’s id and the alert’s id as in the following examples:

Example

Note: when alert is created, the alert’s information is retrieved from API.

Also it is remmarkable that if the API URL is providen, the organization_id must be provided in the optional parameter, otherwise this ID won’t be found on the URL and the Organization will not be created, raising a value error.

Parameters:
  • url – the alert’s API or web associated URL.

  • organization_id – the id of the organziation. Must be providen if the API URL is used.

  • credentials – credentials to authenticate with Deep Intelligence API and be allowed to perform operations over the alert. If not provided, the credentials are generated with the deepint.auth.credentials.Credentials.build.

Returns:

the alert build with the URL and credentials.

load()

Loads the alert’s information.

If the alert’s information is already loaded, is replace by the new one after retrieval.

to_dict() Dict[str, Any]

Builds a dictionary containing the information stored in current object.

Returns:

dictionary contining the information stored in the current object.

update(name: Optional[str] = None, description: Optional[str] = None, subscriptions: Optional[List[str]] = None, color: Optional[str] = None, alert_type: Optional[AlertType] = None, source_id: Optional[str] = None, condition: Optional[Dict[str, Any]] = None, time_stall: Optional[int] = None)

Updates a alert’s attributes

Parameters:
  • name – alert’s name. If not provided the alert’s name stored in the deepint.core.alert.Alert.alert_info attribute is taken.

  • descrpition – alert’s description. If not provided the alert’s description stored in the deepint.core.alert.Alert.alert_info attribute is taken.

  • subscriptions – list of emails subscribed to the alert. If not provided the alert’s subscriptions stored in the deepint.core.alert.Alert.alert_info attribute is taken.

  • color – alert’s color. If not provided the alert’s color stored in the deepint.core.alert.Alert.alert_info attribute is taken.

  • alert_type – alert’s type. If not provided the alert’s type stored in the deepint.core.alert.Alert.alert_info attribute is taken.

  • source_id – identifier of associated source. If not provided the alert’s target source’s id stored in the deepint.core.alert.Alert.alert_info attribute is taken.

  • condition – condition to trigger the alert. If not provided the alert’s condition stored in the deepint.core.alert.Alert.alert_info attribute is taken.

  • time_stall – time in seconds when the alert should trigger (for stall). If not provided the alert’s time_stall stored in the deepint.core.alert.Alert.alert_info attribute is taken.

class deepint.core.AlertType(value)

Available alert types in the system.

classmethod all() List[str]

Returns all available alert types serialized to str.

Returns:

all available alert types

classmethod from_string(_str: str) AlertType

Builds the deepint.core.alert.AlertType from a str.

Parameters:

_str – name of the alert type.

Returns:

the alert type converted to deepint.core.alert.AlertType.

class deepint.core.alert.AlertInfo(alert_id: str, name: str, description: str, created: datetime, last_modified: datetime, subscriptions: List[str], color: str, alert_type: AlertType, source_id: str, condition: Dict[str, Any], time_stall: int)

Stores the information of a Deep Intelligence alert.

alert_id

alert’s id in format uuid4.

name

alert’s name.

description

alert’s description.

alert_type

type of alert (update, stall). Set to ‘update’ if you want to trigger when a source updated on certain conditions. Set to ‘stall’ if you want to trigger when a source do not update for a long time.

last_modified

Last modified date.

created

Creation date.

source_id

Identifier of associated source.

color

Color for the alert

condition

condition to trigger the alert.

time_stall

Time in seconds when the alert should trigger (for stall). Must be at least 60.

subscriptions

List of emails subscribed to the alert.

static from_dict(obj: Any) AlertInfo

Builds a AlertInfo with a dictionary.

Parameters:

objobject or dict containing the a serialized AlertInfo.

Returns:

AlertInfo containing the information stored in the given dictionary.

to_dict() Dict[str, Any]

Builds a dictionary containing the information stored in current object.

Returns:

dictionary containing the information stored in the current object.

class deepint.core.alert.AlertInstances(alert: Alert)

Operates over the instances of a concrete alert.

Note: This class should not be instanced, and only be used within an deepint.core.alert.Alert

alert

the alert with which to operate with its instances