asterisk_ari/apis/asterisk/logging/
mod.rs

1pub mod models;
2pub mod params;
3
4use crate::apis::client::Client;
5use std::fmt::Display;
6
7pub struct Logging<'c> {
8    client: &'c Client,
9}
10
11impl<'c> Logging<'c> {
12    pub fn new(client: &'c Client) -> Self {
13        Self { client }
14    }
15}
16
17impl Logging<'_> {
18    /// Gets Asterisk log channel information.
19    pub async fn list(&self) -> crate::errors::Result<Vec<models::LogChannel>> {
20        self.client.get("/asterisk/logging").await
21    }
22
23    /// Add a log channel
24    ///
25    /// Example: NOTICE WARNING ERROR VERBOSE
26    pub async fn add(&self, request: params::AddRequest) -> crate::errors::Result<()> {
27        self.client
28            .post_with_query(
29                format!("/asterisk/logging/{}", request.name).as_str(),
30                vec![] as Vec<String>,
31                &request,
32            )
33            .await
34    }
35
36    /// Deletes a log channel.
37    pub async fn delete(
38        &self,
39        name: impl Into<String> + Display + Send,
40    ) -> crate::errors::Result<()> {
41        self.client
42            .delete(format!("/asterisk/logging/{name}").as_str())
43            .await
44    }
45
46    /// Rotates a log channel
47    pub async fn rotate(
48        &self,
49        name: impl Into<String> + Display + Send,
50    ) -> crate::errors::Result<()> {
51        self.client
52            .put(
53                format!("/asterisk/logging/{name}/rotate",).as_str(),
54                vec![] as Vec<String>,
55            )
56            .await
57    }
58}