1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//! Asterisk ARI Client
//!
//! This crate provides a simple yet powerful Rust library for managing the
//! [Asterisk](https://www.asterisk.org/) ARI (Asterisk REST Interface). It offers
//! full implementation of Asterisk's REST APIs and WebSocket event handling,
//! enabling developers to build custom telephony applications with ease.
//!
//! ## Features
//!
//! - Comprehensive coverage of Asterisk REST APIs.
//! - WebSocket support for real-time ARI event streaming.
//! - Designed for simplicity and ease of use.
//! - Ideal for telephony application development and integration.
//!
//! ## Quick Start
//!
//! To use this crate, add it to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! asterisk-ari-rs = "x.y.z" // Replace with the latest version
//! ```
//!
//! ### Example
//!
//! ```no_run
//! use asterisk_ari::apis::channels;
//! use asterisk_ari::AriClient;
//! use asterisk_ari::Config;
//! use asterisk_ari::Result;
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//!
//! let config = Config::new("http://localhost:8088", "asterisk", "asterisk");
//!
//! let mut client = AriClient::with_config(config);
//!
//! client.on_stasis_start(|client, event| async move {
//! println!("Handling StasisStart event: {:?}", event);
//!
//! client
//! .channels()
//! .answer(&event.data.channel.id)
//! .await
//! .unwrap();
//!
//! client
//! .channels()
//! .play(channels::params::PlayRequest::new(
//! &event.data.channel.id,
//! "sound:tt-monkeys",
//! ))
//! .await
//! .unwrap();
//! });
//!
//! println!("Applications: {:?}", client.applications().list().await?);
//! println!("Ping: {:?}", client.asterisk().ping().await?);
//! println!("Info: {:?}", client.asterisk().info().await?);
//!
//! let _client = client.clone();
//! tokio::spawn(async move {
//! _client.start("my-application".to_string()).await.unwrap();
//! });
//!
//! tokio::time::sleep(std::time::Duration::from_secs(30)).await;
//!
//! println!("Stopping client");
//! client.stop();
//!
//! println!("Await client to stop");
//! tokio::time::sleep(std::time::Duration::from_secs(4)).await;
//!
//! Ok(())
//! }
//! ```
//!
//!
//! ## License
//!
//! This crate is dual-licensed under the [Apache License 2.0](LICENSE-APACHE) or
//! [MIT License](LICENSE-MIT). Choose the license that suits your project.
/// Apis implementation
pub use *;
pub use *;
pub use *;
/// WebSocket implementation