pub struct AriClient { /* private fields */ }Expand description
async client for the Asterisk REST Interface
combines REST operations with a background websocket listener for receiving Stasis events. supports both HTTP and unified WebSocket transport modes.
Implementations§
Source§impl AriClient
impl AriClient
Sourcepub async fn connect(config: AriConfig) -> Result<Self>
pub async fn connect(config: AriConfig) -> Result<Self>
connect to an ARI server
builds the transport layer and spawns the websocket event listener.
the transport mode is determined by AriConfig::transport_mode.
Sourcepub async fn get<T: DeserializeOwned>(&self, path: &str) -> Result<T>
pub async fn get<T: DeserializeOwned>(&self, path: &str) -> Result<T>
send a GET request to the given ARI path
Sourcepub async fn post<T: DeserializeOwned>(
&self,
path: &str,
body: &impl Serialize,
) -> Result<T>
pub async fn post<T: DeserializeOwned>( &self, path: &str, body: &impl Serialize, ) -> Result<T>
send a POST request with a JSON body to the given ARI path
Sourcepub async fn post_empty(&self, path: &str) -> Result<()>
pub async fn post_empty(&self, path: &str) -> Result<()>
send a POST request with no body to the given ARI path
Sourcepub async fn put<T: DeserializeOwned>(
&self,
path: &str,
body: &impl Serialize,
) -> Result<T>
pub async fn put<T: DeserializeOwned>( &self, path: &str, body: &impl Serialize, ) -> Result<T>
send a PUT request with a JSON body to the given ARI path
Sourcepub async fn put_empty(&self, path: &str) -> Result<()>
pub async fn put_empty(&self, path: &str) -> Result<()>
send a PUT request with no body to the given ARI path
Sourcepub async fn delete(&self, path: &str) -> Result<()>
pub async fn delete(&self, path: &str) -> Result<()>
send a DELETE request to the given ARI path
Sourcepub async fn delete_with_response<T: DeserializeOwned>(
&self,
path: &str,
) -> Result<T>
pub async fn delete_with_response<T: DeserializeOwned>( &self, path: &str, ) -> Result<T>
send a DELETE request and deserialize the response body
Sourcepub fn subscribe(&self) -> EventSubscription<AriMessage>
pub fn subscribe(&self) -> EventSubscription<AriMessage>
subscribe to ARI events from the websocket stream
Sourcepub fn subscribe_filtered(
&self,
predicate: impl Fn(&AriMessage) -> bool + Send + 'static,
) -> FilteredSubscription<AriMessage>
pub fn subscribe_filtered( &self, predicate: impl Fn(&AriMessage) -> bool + Send + 'static, ) -> FilteredSubscription<AriMessage>
subscribe to events matching a filter predicate
Sourcepub fn events(&self) -> &EventBus<AriMessage>
pub fn events(&self) -> &EventBus<AriMessage>
access the underlying event bus
Sourcepub fn channel(&self) -> PendingChannel
pub fn channel(&self) -> PendingChannel
create a pending channel with a pre-generated ID for race-free origination
the returned PendingChannel subscribes to events for its ID immediately, so no StasisStart events are missed between originate and subscribe.
Sourcepub fn bridge(&self) -> PendingBridge
pub fn bridge(&self) -> PendingBridge
create a pending bridge with a pre-generated ID
Sourcepub fn playback(&self) -> PendingPlayback
pub fn playback(&self) -> PendingPlayback
create a pending playback with a pre-generated ID
Sourcepub fn disconnect(&self)
pub fn disconnect(&self)
shut down the websocket listener and transport