#!/bin/bash

address=http://localhost:8088/ari
api_key=admin:secret

cmd="curl -v -u $api_key"
post="$cmd -X POST"
delete="$cmd -X DELETE"
get="$cmd -X GET"

###############################################################################

applications="$address/applications"
bridges="$address/bridges"
channels="$address/channels"
events="$address/events"

###############################################################################
### Subscribe to an event source
###############################################################################
#$get "$events?app=foo"
#$get "$events?bar=foo"

$post "$applications/foo/subscription?eventSource=endpoint:PJSIP"
$post "$applications/bar/subscription?eventSource=endpoint:PJSIP"
echo "" && sleep 3
$delete "$applications/foo/subscription?eventSource=endpoint:PJSIP"
echo "" && sleep 3
$post "$applications/foo/subscription?eventSource=endpoint:PJSIP"
#$post "$applications/bar/subscription?eventSource=endpoint:PJSIP"

