use crate::types_impl::notifications::{
CreateNotificationChannelRequest, CreateNotificationRuleRequest, NotificationChannelResponse,
NotificationLogResponse, NotificationRuleResponse, TestNotificationResponse,
UpdateNotificationChannelRequest, UpdateNotificationRuleRequest,
};
use crate::types_impl::pagination::{PaginatedResponse, PaginationParams};
use uuid::Uuid;
use crate::Result;
use crate::paths;
impl crate::UptrakitClient {
pub async fn create_notification_channel(
&self,
req: &CreateNotificationChannelRequest,
) -> Result<NotificationChannelResponse> {
self.post_json(paths::notifications::CHANNELS, req).await
}
pub async fn list_notification_channels(
&self,
params: &PaginationParams,
) -> Result<PaginatedResponse<NotificationChannelResponse>> {
self.get_with_query(paths::notifications::CHANNELS, params)
.await
}
pub async fn get_notification_channel(&self, id: &Uuid) -> Result<NotificationChannelResponse> {
self.get(&paths::notifications::channel_by_id(id)).await
}
pub async fn update_notification_channel(
&self,
id: &Uuid,
req: &UpdateNotificationChannelRequest,
) -> Result<NotificationChannelResponse> {
self.put_json(&paths::notifications::channel_by_id(id), req)
.await
}
pub async fn delete_notification_channel(&self, id: &Uuid) -> Result<()> {
self.delete(&paths::notifications::channel_by_id(id)).await
}
pub async fn test_notification_channel(&self, id: &Uuid) -> Result<TestNotificationResponse> {
self.post_empty(&paths::notifications::test_channel(id))
.await
}
pub async fn create_notification_rule(
&self,
req: &CreateNotificationRuleRequest,
) -> Result<NotificationRuleResponse> {
self.post_json(paths::notifications::RULES, req).await
}
pub async fn list_notification_rules(
&self,
params: &PaginationParams,
) -> Result<PaginatedResponse<NotificationRuleResponse>> {
self.get_with_query(paths::notifications::RULES, params)
.await
}
pub async fn get_notification_rule(&self, id: &Uuid) -> Result<NotificationRuleResponse> {
self.get(&paths::notifications::rule_by_id(id)).await
}
pub async fn update_notification_rule(
&self,
id: &Uuid,
req: &UpdateNotificationRuleRequest,
) -> Result<NotificationRuleResponse> {
self.put_json(&paths::notifications::rule_by_id(id), req)
.await
}
pub async fn delete_notification_rule(&self, id: &Uuid) -> Result<()> {
self.delete(&paths::notifications::rule_by_id(id)).await
}
pub async fn list_notification_log(
&self,
params: &PaginationParams,
) -> Result<PaginatedResponse<NotificationLogResponse>> {
self.get_with_query(paths::notifications::LOG, params).await
}
}