asterisk_ari/apis/asterisk/modules/
mod.rs

1pub mod models;
2
3use crate::apis::client::Client;
4
5pub struct Modules<'c> {
6    client: &'c Client,
7}
8
9impl<'c> Modules<'c> {
10    pub fn new(client: &'c Client) -> Self {
11        Self { client }
12    }
13}
14
15impl Modules<'_> {
16    /// List Asterisk modules.
17    pub async fn list(&self) -> crate::errors::Result<Vec<models::Module>> {
18        self.client.get("/asterisk/modules").await
19    }
20
21    /// Get Asterisk module information.
22    pub async fn get(
23        &self,
24        name: impl Into<String> + Send,
25    ) -> crate::errors::Result<models::Module> {
26        self.client
27            .get(format!("/asterisk/modules/{}", name.into(),).as_str())
28            .await
29    }
30
31    /// Load an Asterisk module.
32    pub async fn load(&self, name: impl Into<String> + Send) -> crate::errors::Result<()> {
33        self.client
34            .post(
35                format!("/asterisk/modules/{}", name.into(),).as_str(),
36                vec![] as Vec<String>,
37            )
38            .await
39    }
40
41    /// Unload an Asterisk module.
42    pub async fn unload(&self, name: impl Into<String> + Send) -> crate::errors::Result<()> {
43        self.client
44            .delete(format!("/asterisk/modules/{}", name.into()).as_str())
45            .await
46    }
47
48    /// Reload an Asterisk module
49    pub async fn reload(&self, name: impl Into<String> + Send) -> crate::errors::Result<()> {
50        self.client
51            .put(
52                format!("/asterisk/modules/{}", name.into()).as_str(),
53                vec![] as Vec<String>,
54            )
55            .await
56    }
57}