asterisk_ari/apis/applications/
mod.rs

1pub mod models;
2pub mod params;
3
4use crate::apis::client::Client;
5use crate::errors::Result;
6
7pub struct Applications<'c> {
8    client: &'c Client,
9}
10
11impl<'c> Applications<'c> {
12    pub fn new(client: &'c Client) -> Self {
13        Applications { client }
14    }
15}
16
17impl Applications<'_> {
18    /// List all applications
19    pub async fn list(&self) -> Result<Vec<models::Application>> {
20        self.client.get("/applications").await
21    }
22
23    /// Get details of an application.
24    pub async fn get(
25        &self,
26        application_name: impl Into<String> + Send,
27    ) -> Result<models::Application> {
28        self.client
29            .get(format!("/applications/{}", application_name.into()).as_str())
30            .await
31    }
32
33    /// Subscribe an application to an event source.
34    /// Implementation Notes
35    /// Returns the state of the application after the subscriptions have changed
36    pub async fn subscribe(
37        &self,
38        request: params::SubscribeRequest,
39    ) -> Result<models::Application> {
40        self.client
41            .post_with_query(
42                format!("/applications/{}/subscription", request.name).as_str(),
43                vec![] as Vec<String>,
44                &request,
45            )
46            .await
47    }
48
49    /// Unsubscribe an application from an event source.
50    /// Implementation Notes
51    /// Returns the state of the application after the subscriptions have changed
52    pub async fn unsubscribe(
53        &self,
54        request: params::UnSubscribeRequest,
55    ) -> Result<models::Application> {
56        self.client
57            .delete_with_query(
58                format!("/applications/{}/subscription", request.name).as_str(),
59                &request,
60            )
61            .await
62    }
63
64    /// Filter application events types
65    ///
66    /// Allowed and/or disallowed event type filtering can be done.
67    pub async fn filter_events(
68        &self,
69        request: params::FilterEventsRequest,
70    ) -> Result<models::Application> {
71        self.client
72            .put(
73                format!("/applications/{}/eventFilter", request.name).as_str(),
74                request,
75            )
76            .await
77    }
78}