asterisk_ari/apis/applications/
mod.rs1pub 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 pub async fn list(&self) -> Result<Vec<models::Application>> {
20 self.client.get("/applications").await
21 }
22
23 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 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 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 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}