Brokers¶
Base Broker Class¶
-
tom_alerts.alerts.
get_service_classes
()¶ Gets the broker classes available to this TOM as specified by
TOM_ALERT_CLASSES
insettings.py
. If none are specified, returns the default set.- Returns
dict of broker classes, with keys being the name of the broker and values being the broker class
- Return type
dict
-
tom_alerts.alerts.
get_service_class
(name)¶ Gets the specific broker class for a given broker name.
- Returns
Broker class
- Return type
class
-
class
tom_alerts.alerts.
GenericAlert
(timestamp: datetime.datetime, id: int, name: str, ra: float, dec: float, mag: float, score: float, url: str)¶ dataclass representing an alert in order to display it in the UI.
-
to_target
()¶ Returns a Target instance for an object defined by an alert.
- Returns
representation of object for an alert
- Return type
Target
-
-
class
tom_alerts.alerts.
GenericQueryForm
(*args, **kwargs)¶ Form class representing the default form for a broker.
-
serialize_parameters
()¶ Returns a JSON-serialized representation of the form data.
- Returns
JSON-ified form parameters
- Return type
str
-
save
(query_id=None)¶ Saves the form data in the database as a
BrokerQuery
.- Returns
BrokerQuery
model representation of the form that was saved to the db- Return type
BrokerQuery
-
-
class
tom_alerts.alerts.
GenericBroker
¶ The
GenericBroker
provides an interface for implementing a broker module. It contains a number of methods to be implemented, but only the methods decorated with@abstractmethod
are required to be implemented. In order to make use of a broker module, add the path toTOM_ALERT_CLASSES
in yoursettings.py
.For an implementation example, please see https://github.com/TOMToolkit/tom_base/blob/master/tom_alerts/brokers/mars.py
-
abstract
fetch_alerts
(parameters)¶ This method takes in the query parameters needed to filter alerts for a broker and makes the GET query to the broker endpoint.
- Parameters
parameters (str) – JSON string of query parameters
-
fetch_alert
(id)¶ This method takes an alert id and retrieves the specific alert data from the given broker.
- Parameters
id (str) – Broker-specific id corresponding with the desired alert
-
process_reduced_data
(target, alert=None)¶ Retrieves and creates records for any reduced data provided by a specific broker. Updates existing data if it has changed.
- Parameters
target (Target) –
Target
object that was previously created from aBrokerQuery
alertalert (str) – alert data from a particular
BrokerQuery
-
to_target
(alert)¶ Creates
Target
object from the broker-specific alert data.- Parameters
alert (str) – alert data from a particular
BrokerQuery
-
abstract
to_generic_alert
(alert)¶ This method creates a
GenericAlert
object from the broker-specific alert data for use outside of the implementation of theGenericBroker
.- Parameters
alert (str) – alert data from a particular
BrokerQuery
-
fetch_and_save_all
(parameters)¶ Gets all alerts using a particular
BrokerQuery
and creates aTarget
from each one.- Parameters
parameters (str) – JSON string of query parameters
- Returns
list of
Target
objects- Return type
list
-
abstract
ALeRCE¶
ANTARES¶
Lasair¶
-
class
tom_alerts.brokers.lasair.
LasairBroker
¶ The
LasairBroker
is the interface to the Lasair alert broker. For information regarding the query format for Lasair, please see https://lasair.roe.ac.uk/objlist/.
MARS¶
-
class
tom_alerts.brokers.mars.
MARSBroker
¶ The
MARSBroker
is the interface to the MARS alert broker. For information regarding MARS and its available filters for querying, please see https://mars.lco.global/help/.
Scout¶
Transient Name Server¶
-
class
tom_alerts.brokers.tns.
TNSBroker
¶ The
TNSBroker
is the interface to the Transient Name Server. For information regarding the TNS, please see https://wis-tns.weizmann.ac.il/