@@ -49,6 +49,34 @@ def stop(self):
4949 )
5050 self .status = "stopped"
5151
52+ def create_alert (self , event_id , callback_url ) -> str :
53+ alert_data = self ._connection .post (
54+ f"{ ApiPath .rtstream } /{ self .rtstream_id } /{ ApiPath .index } /{ self .rtstream_index_id } /{ ApiPath .alert } " ,
55+ data = {
56+ "event_id" : event_id ,
57+ "callback_url" : callback_url ,
58+ },
59+ )
60+ return alert_data .get ("alert_id" , None )
61+
62+ def list_alerts (self ):
63+ alert_data = self ._connection .get (
64+ f"{ ApiPath .rtstream } /{ self .rtstream_id } /{ ApiPath .index } /{ self .rtstream_index_id } /{ ApiPath .alert } "
65+ )
66+ return alert_data .get ("alerts" , [])
67+
68+ def enable_alert (self , alert_id ):
69+ self ._connection .patch (
70+ f"{ ApiPath .rtstream } /{ self .rtstream_id } /{ ApiPath .index } /{ self .rtstream_index_id } /{ ApiPath .alert } /{ alert_id } /{ ApiPath .status } " ,
71+ data = {"status" : "enabled" },
72+ )
73+
74+ def disable_alert (self , alert_id ):
75+ self ._connection .patch (
76+ f"{ ApiPath .rtstream } /{ self .rtstream_id } /{ ApiPath .index } /{ self .rtstream_index_id } /{ ApiPath .alert } /{ alert_id } /{ ApiPath .status } " ,
77+ data = {"status" : "disabled" },
78+ )
79+
5280
5381class RTStream :
5482 def __init__ (self , _connection , id : str , ** kwargs ) -> None :
0 commit comments