def list(self, workspace=None): """ Return accesible notification channels. Parameters ---------- workspace : str, optional Workspace from which to list notification channels. Defaults to the client's default workspace. Returns ------- list of :class:`NotificationChannel` Notification channels. """ msg = _AlertService.FindNotificationChannelRequest( page_number=1, page_limit=-1, workspace_name=workspace, ) endpoint = "/api/v1/alerts/findNotificationChannel" response = self._conn.make_proto_request("POST", endpoint, body=msg) channels = self._conn.must_proto_response(response, msg.Response).channels return [ NotificationChannel(self._conn, self._conf, channel) for channel in channels ]
def _get_proto_by_id(cls, conn, id): msg = _AlertService.FindNotificationChannelRequest( ids=[int(id)], page_number=1, page_limit=-1, ) endpoint = "/api/v1/alerts/findNotificationChannel" response = conn.make_proto_request("POST", endpoint, body=msg) channels = conn.must_proto_response(response, msg.Response).channels if len(channels) > 1: warnings.warn( "unexpectedly found multiple notification channels with ID" " {}".format(id) ) if channels: return channels[0] else: return None