NAME

Asterisk::AMI::Common - Extends the AMI module to provide simple access to common AMI commands and functions

VERSION

0.1.10

SYNOPSIS

use Asterisk::AMI::Common;

my $astman = Asterisk::AMI::Common->new(PeerAddr	=>	'127.0.0.1',
					PeerPort	=>	'5038',
					Username	=>	'admin',
					Secret		=>	'supersecret'
			);

die "Unable to connect to asterisk" unless ($astman);

$astman->db_get();

DESCRIPTION

This module extends the AMI module to provide easier access to common actions and commands available through the AMI.

Constructor

new([ARGS])

Creates new a Asterisk::AMI::Common object which takes the arguments as key-value pairs.

This module inherits all options from the AMI module.

Methods

commands ( [ TIMEOUT ] )

Returns a hash reference of commands available through the AMI. TIMEOUT is optional

$hashref->{'CommandName'}->{'Desc'}	Contains the command description
			   {'Priv'}	Contains list of required privileges.

db_get ( FAMILY, KEY [, TIMEOUT ])

Returns the value of the Asterisk database entry specified by the FAMILY and KEY pair, or undef if
does not exist or an error occurred. TIMEOUT is optional.

db_put ( FAMILY, KEY, VALUE [, TIMEOUT ])

Inserts VALUE for the Asterisk database entry specified by the FAMILY and KEY pair. Returns 1 on success, if it
failed or undef on error or timeout. TIMEOUT is optional.

db_show ( [ TIMEOUT ] )

Returns a hash reference containing the contents of the Asterisk database, or undef on error or timeout.
TIMEOUT is optional.

Values in the hash reference are stored as below:
$hashref->{FAMILY}->{KEY}

get_var ( CHANNEL, VARIABLE [, TIMEOUT ])

Returns the value of VARIABLE for CHANNEL, or undef on error or timeout. TIMEOUT is optional.

set_var ( CHANNEL, VARIABLE, VALUE [, TIMEOUT ])

Sets VARIABLE to VALUE for CHANNEL. Returns 1 on success, 0 if it failed, or undef on error or timeout.
TIMEOUT is optional.

hangup ( CHANNEL [, TIMEOUT ])

Hangs up CHANNEL. Returns 1 on success, 0 if it failed, or undef on error or timeout. TIMEOUT is optional.

exten_state ( EXTEN, CONTEXT [, TIMEOUT ])

Returns the state of the EXTEN in CONTEXT, or undef on error or timeout. TIMEOUT is optional

States:
-1 = Extension not found
0 = Idle
1 = In Use
2 = Busy
4 = Unavailable
8 = Ringing
16 = On Hold

park ( CHANNEL, CHANNEL2 [, PARKTIME, TIMEOUT ] )

Parks CHANNEL and announces park information to CHANNEL2. CHANNEL2 is also the channel the call will return to if
it times out. 
PARKTIME is optional and can be used to control how long a person is parked for. TIMEOUT is optional.

Returns 1 if the call was parked, or 0 if it failed, or undef on error and timeout.

parked_calls ( [ TIMEOUT ] )

Returns a hash reference containing parking lots and their members, or undef if an error/timeout or if no calls
were parked. TIMEOUT is optional.

Hash reference structure:

$hashref->{lotnumber}->{'Channel'}
		       {'Timeout'}
		       {'CallerID'}
		       {'CallerIDName'}

sip_peers ( [ TIMEOUT ] )

Returns a hash reference containing all SIP peers, or undef on error or timeout. TIMEOUT is optional.

Hash reference structure:

$hashref->{peername}->{'Channeltype'}
		      {'ChanObjectType'}
		      {'IPaddress'}
		      {'IPport'}
		      {'Dynamic'}
		      {'Natsupport'}
		      {'VideoSupport'}
		      {'ACL'}
		      {'Status'}
		      {'RealtimeDevice'}

sip_peer ( PEERNAME [, TIMEOUT ] )

Returns a hash reference containing the information for PEERNAME, or undef on error or timeout.
TIMEOUT is optional.

Hash reference structure:

$hashref->{'SIPLastMsg'}
	  {'SIP-UserPhone'}
	  {'Dynamic'}
	  {'TransferMode'}
	  {'SIP-NatSupport'}
	  {'Call-limit'}
	  {'CID-CallingPres'}
	  {'LastMsgsSent'}
	  {'Status'}
	  {'Address-IP'}
	  {'RegExpire'}
	  {'ToHost'}
	  {'Codecs'},
	  {'Default-addr-port'}
	  {'SIP-DTMFmode'}
	  {'Channeltype'}
	  {'ChanObjectType'}
	  {'AMAflags'}
	  {'SIP-AuthInsecure'}
	  {'SIP-VideoSupport'}
	  {'Callerid'}
	  {'Address-Port'}
	  {'Context'}
	  {'ObjectName'}
	  {'ACL'}
	  {'Default-addr-IP'}
	  {'SIP-PromiscRedir'}
	  {'MaxCallBR'}
	  {'MD5SecretExist'}
	  {'SIP-CanReinvite'}
	  {'CodecOrder'}
	  {'SecretExist'}

mailboxcount ( EXTENSION, CONTEXT [, TIMEOUT ] )

Returns an hash reference containing the message counts for the mailbox EXTENSION@CONTEXT, or undef on error or
timeout. TIMEOUT is optional.

Hash reference structure:

$hashref->{'Mailbox'}
	  {'NewMessages'}
	  {'OldMessages'}

mailboxstatus ( EXTENSION, CONTEXT [, TIMEOUT ] )

Returns the status of the mailbox or undef on error or timeout. TIMEOUT is optional

chan_timeout ( CHANNEL, CHANNELTIMEOUT [, TIMEOUT ] )

Sets CHANNEL to timeout in CHANNELTIMEOUT seconds. Returns 1 on success, 0 on failure, or undef on error or timeout.
TIMEOUT is optional.

queues ( [ TIMEOUT ] )

Returns a hash reference containing all queues, queue members, and people currently waiting in the queue,
or undef on error or timeout. TIMEOUT is optional

Hash reference structure:

$hashref->{queue}->{'Max'}
		   {'Calls'}
		   {'Holdtime'}
		   {'Completed'}
		   {'Abandoned'}
		   {'ServiceLevel'}
		   {'ServicelevelPerf'}
		   {'Weight'}
		   {'MEMBERS'}->{name}->{'Location'}
					{'Membership'}
					{'Penalty'}
					{'CallsTaken'}
					{'LastCall'}
					{'Status'}
					{'Paused'}
		   {'ENTRIES'}->{position}->{'Channel'}
					    {'CallerID'}
					    {'CallerIDName'}
					    {'Wait'}

queue_status ( QUEUE [, TIMEOUT ] )

Returns a hash reference containing the queue status, members, and people currently waiting in the queue,
or undef on error or timeout. TIMEOUT is optional.

Hash reference structure

$hashref->{'Max'}
	  {'Calls'}
	  {'Holdtime'}
	  {'Completed'}
	  {'Abandoned'}
	  {'ServiceLevel'}
	  {'ServicelevelPerf'}
	  {'Weight'}
	  {'MEMBERS'}->{name}->{'Location'}
			       {'Membership'}
			       {'Penalty'}
			       {'CallsTaken'}
			       {'LastCall'}
			       {'Status'}
			       {'Paused'}
	  {'ENTRIES'}->{position}->{'Channel'}
				   {'CallerID'}
				   {'CallerIDName'}
				   {'Wait'}

queue_member_pause ( QUEUE, MEMBER, PAUSEVALUE [, TIMEOUT ] )

Sets the MEMBER of QUEUE to PAUSEVALUE. A value of 0 will un-pause a member, and 1 will pause them.
Returns 1 if the PAUSEVALUE was set, 0 if it failed, or undef on error or timeout. TIMEOUT is optional.

queue_member_toggle ( QUEUE, MEMBER [, TIMEOUT ] )

Toggles MEMBER of QUEUE pause status. From paused to un-paused, and un-paused to paused.
Returns 1 if the the pause status was toggled, 0 if failed, or undef on error or timeout. TIMEOUT is optional

queue_add ( QUEUE, MEMEBER [, TIMEOUT ] )

Adds MEMBER to QUEUE. Returns 1 if the MEMBER was added, or 0 if it failed, or undef on error or timeout.
TIMEOUT is optional.

queue_remove ( QUEUE, MEMEBER [, TIMEOUT ] )

Removes MEMBER from QUEUE. Returns 1 if the MEMBER was removed, 0 if it failed, or undef on error or timeout.
TIMEOUT is optional.

play_dtmf ( CHANNEL, DIGIT [, TIMEOUT ] )

Plays the dtmf DIGIT on CHANNEL. Returns 1 if the DIGIT was queued on the channel, or 0 if it failed, or
undef on error or timeout.
TIMEOUT is optional.

play_digits ( CHANNEL, DIGITS [, TIMEOUT ] )

Plays the dtmf DIGITS on CHANNEL. DIGITS should be passed as an array reference. Returns 1 if all DIGITS
were queued on the channel, or 0 if an any queuing failed. TIMEOUT is optional.

channels ( [ TIMEOUT ] )

	Returns a hash reference containing all channels with their information, or undef on error or timeout.
	TIMEOUT is optional.

	Hash reference structure:

	$hashref->{channel}->{'Context'}
			     {'CallerID'}
			     {'CallerIDNum'}
			     {'CallerIDName'}
 			     {'Account'}
 			     {'State'}
 			     {'Context'} 
 			     {'Extension'}
 			     {'Priority'}
 			     {'Seconds'}
 			     {'Link'}
 			     {'Uniqueid'}

chan_status ( CHANNEL [, TIMEOUT ] )

	Returns a hash reference containing the status of the channel, or undef on error or timeout.
	TIMEOUT is optional.

	Hash reference structure:
	
	$hashref->{'Channel'}
		  {'CallerID'}
		  {'CallerIDNum'}
		  {'CallerIDName'}
 		  {'Account'}
 		  {'State'}
 		  {'Context'} 
 		  {'Extension'}
 		  {'Priority'}
 		  {'Seconds'}
 		  {'Link'}
 		  {'Uniqueid'}

transfer ( CHANNEL, EXTENSION, CONTEXT [, TIMEOUT ] )

Transfers CHANNEL to EXTENSION at CONTEXT. Returns 1 if the channel was transferred, 0 if it failed, 
or undef on error or timeout. TIMEOUT is optional.

meetme_mute ( CONFERENCE, USERNUM [, TIMEOUT ] )

Mutes USERNUM in CONFERENCE. Returns 1 if the user was muted, 0 if it failed, or undef on error or timeout.
TIMEOUT is optional.

meetme_unmute ( CONFERENCE, USERNUM [, TIMEOUT ] )

Un-mutes USERNUM in CONFERENCE. Returns 1 if the user was un-muted, or 0 if it failed, or undef on error or timeout.
TIMEOUT is optional.

monitor ( CHANNEL, FILE [, TIMEOUT ] )

Begins recording CHANNEL to FILE. Uses the 'wav' format and also mixes both directions into a single file. 
Returns 1 if the channel was set to record, or 0 if it failed, or undef on error or timeout. TIMEOUT is optional.

monitor_stop ( CHANNEL [, TIMEOUT ])

Stops recording CHANNEL. Returns 1 if recording on the channel was stopped, 0 if it failed, or undef on error
or timeout.
TIMEOUT is optional.

monitor_pause ( CHANNEL [, TIMEOUT ])

Pauses recording on CHANNEL. Returns 1 if recording on the channel was paused, 0 if it failed, or undef on error
or timeout.
TIMEOUT is optional.

monitor_unpause ( CHANNEL [, TIMEOUT ])

Un-pauses recording on CHANNEL. Returns 1 if recording on the channel was un-paused, 0 if it failed, or undef on error
or timeout.
TIMEOUT is optional.

monitor_change ( CHANNEL, FILE [, TIMEOUT ] )

Changes the monitor file for CHANNEL to FILE. Returns 1 if the file was change, 0 if it failed, or undef on error
or timeout.
TIMEOUT is optional.

See Also

Asterisk::AMI, Asterisk::AMI::Common::Dev

AUTHOR

Ryan Bullock (rrb3942@gmail.com)

BUG REPORTING AND FEEBACK

Please report any bugs or errors to our github issue tracker at http://github.com/rrb3942/perl-Asterisk-AMI/issues or the cpan request tracker at https://rt.cpan.org/Public/Bug/Report.html?Queue=perl-Asterisk-AMI

COPYRIGHT

Copyright (C) 2010 by Ryan Bullock (rrb3942@gmail.com)

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.