use serde::{Deserialize, Serialize}; use crate::{Client, ClientError}; pub use crate::routing::types::Rule; /// List all routing rules pub async fn list(client: &mut Client) -> Result, ClientError> { let url = format!("{}/rule", super::BASE); client.execute_get::>(&url).await } /// Get a specific routing rule pub async fn get(client: &mut Client, id: &str) -> Result { let url = format!("{}/rule/{}", super::BASE, id); client.execute_get::(&url).await } // TODO(ishan): Figure out a smarter way to implement these common operations #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct RuleInput { pub numbers: String, } /// Disable a rule pub async fn disable(client: &mut Client, input: RuleInput) -> Result<(), ClientError> { let url = format!("{}/rule/disable", super::BASE); client .execute_post_with_no_response::(&url, input) .await } /// Enable a rule pub async fn enable(client: &mut Client, input: RuleInput) -> Result<(), ClientError> { let url = format!("{}/rule/enable", super::BASE); client .execute_post_with_no_response::(&url, input) .await } /// Remove a rule pub async fn remove(client: &mut Client, input: RuleInput) -> Result<(), ClientError> { let url = format!("{}/rule/remove", super::BASE); client .execute_post_with_no_response::(&url, input) .await }