uptrakit_openapi_client/
notifications.rs1use crate::types_impl::notifications::{
2 CreateNotificationChannelRequest, CreateNotificationRuleRequest, NotificationChannelResponse,
3 NotificationLogResponse, NotificationRuleResponse, TestNotificationResponse,
4 UpdateNotificationChannelRequest, UpdateNotificationRuleRequest,
5};
6use crate::types_impl::pagination::{PaginatedResponse, PaginationParams};
7use uuid::Uuid;
8
9use crate::Result;
10use crate::paths;
11
12impl crate::UptrakitClient {
13 pub async fn create_notification_channel(
17 &self,
18 req: &CreateNotificationChannelRequest,
19 ) -> Result<NotificationChannelResponse> {
20 self.post_json(paths::notifications::CHANNELS, req).await
21 }
22
23 pub async fn list_notification_channels(
25 &self,
26 params: &PaginationParams,
27 ) -> Result<PaginatedResponse<NotificationChannelResponse>> {
28 self.get_with_query(paths::notifications::CHANNELS, params)
29 .await
30 }
31
32 pub async fn get_notification_channel(&self, id: &Uuid) -> Result<NotificationChannelResponse> {
34 self.get(&paths::notifications::channel_by_id(id)).await
35 }
36
37 pub async fn update_notification_channel(
39 &self,
40 id: &Uuid,
41 req: &UpdateNotificationChannelRequest,
42 ) -> Result<NotificationChannelResponse> {
43 self.put_json(&paths::notifications::channel_by_id(id), req)
44 .await
45 }
46
47 pub async fn delete_notification_channel(&self, id: &Uuid) -> Result<()> {
49 self.delete(&paths::notifications::channel_by_id(id)).await
50 }
51
52 pub async fn test_notification_channel(&self, id: &Uuid) -> Result<TestNotificationResponse> {
54 self.post_empty(&paths::notifications::test_channel(id))
55 .await
56 }
57
58 pub async fn create_notification_rule(
62 &self,
63 req: &CreateNotificationRuleRequest,
64 ) -> Result<NotificationRuleResponse> {
65 self.post_json(paths::notifications::RULES, req).await
66 }
67
68 pub async fn list_notification_rules(
70 &self,
71 params: &PaginationParams,
72 ) -> Result<PaginatedResponse<NotificationRuleResponse>> {
73 self.get_with_query(paths::notifications::RULES, params)
74 .await
75 }
76
77 pub async fn get_notification_rule(&self, id: &Uuid) -> Result<NotificationRuleResponse> {
79 self.get(&paths::notifications::rule_by_id(id)).await
80 }
81
82 pub async fn update_notification_rule(
84 &self,
85 id: &Uuid,
86 req: &UpdateNotificationRuleRequest,
87 ) -> Result<NotificationRuleResponse> {
88 self.put_json(&paths::notifications::rule_by_id(id), req)
89 .await
90 }
91
92 pub async fn delete_notification_rule(&self, id: &Uuid) -> Result<()> {
94 self.delete(&paths::notifications::rule_by_id(id)).await
95 }
96
97 pub async fn list_notification_log(
101 &self,
102 params: &PaginationParams,
103 ) -> Result<PaginatedResponse<NotificationLogResponse>> {
104 self.get_with_query(paths::notifications::LOG, params).await
105 }
106}