@@ -108,6 +108,19 @@ def get_n_connected_agents(self):
108108 data = res .json ()
109109 return [True , data ['total' ]]
110110
111+ def list_notification_channels (self ):
112+ '''**Description**
113+ List all configured Notification Channels
114+
115+ **Arguments**
116+ none
117+
118+ **Success Return Value**
119+ A JSON representation of all the notification channels
120+ '''
121+ res = requests .get (self .url + '/api/notificationChannels' , headers = self .hdrs , verify = self .ssl_verify )
122+ return self ._request_result (res )
123+
111124 def get_notification_ids (self , channels = None ):
112125 '''**Description**
113126 Get an array of all configured Notification Channel IDs, or a filtered subset of them.
@@ -126,7 +139,7 @@ def get_notification_ids(self, channels=None):
126139 res = requests .get (self .url + '/api/notificationChannels' , headers = self .hdrs , verify = self .ssl_verify )
127140
128141 if not self ._checkResponse (res ):
129- return [ False , self .lasterr ]
142+ return False , self .lasterr
130143
131144 ids = []
132145
@@ -184,9 +197,9 @@ def get_notification_ids(self, channels=None):
184197 found = True
185198 ids .append (ch ['id' ])
186199 if not found :
187- return [ False , "Channel not found: " + str (c )]
200+ return False , "Channel not found: " + str (c )
188201
189- return [ True , ids ]
202+ return True , ids
190203
191204 def create_email_notification_channel (self , channel_name , email_recipients ):
192205 channel_json = {
@@ -203,13 +216,26 @@ def create_email_notification_channel(self, channel_name, email_recipients):
203216 res = requests .post (self .url + '/api/notificationChannels' , headers = self .hdrs , data = json .dumps (channel_json ), verify = self .ssl_verify )
204217 return self ._request_result (res )
205218
219+ def create_notification_channel (self , channel ):
220+ channel ["id" ] = None
221+ channel ["version" ] = None
222+ channel ["createdOn" ] = None
223+ channel ["modifiedOn" ] = None
224+ channel_json = {
225+ 'notificationChannel' : channel
226+ }
227+
228+ res = requests .post (self .url + '/api/notificationChannels' , headers = self .hdrs , data = json .dumps (channel_json ),
229+ verify = self .ssl_verify )
230+ return self ._request_result (res )
231+
206232 def get_notification_channel (self , id ):
207233
208234 res = requests .get (self .url + '/api/notificationChannels/' + str (id ), headers = self .hdrs , verify = self .ssl_verify )
209235 if not self ._checkResponse (res ):
210- return [ False , self .lasterr ]
236+ return False , self .lasterr
211237
212- return [ True , res .json ()['notificationChannel' ] ]
238+ return True , res .json ()['notificationChannel' ]
213239
214240 def update_notification_channel (self , channel ):
215241 if 'id' not in channel :
@@ -224,8 +250,8 @@ def delete_notification_channel(self, channel):
224250
225251 res = requests .delete (self .url + '/api/notificationChannels/' + str (channel ['id' ]), headers = self .hdrs , verify = self .ssl_verify )
226252 if not self ._checkResponse (res ):
227- return [ False , self .lasterr ]
228- return [ True , None ]
253+ return False , self .lasterr
254+ return True , None
229255
230256 def get_data_retention_info (self ):
231257 '''**Description**
0 commit comments