Overview¶
Asterisk 11 now supports the display of AMI event documentation. The documentation is handled in the same fashion as other portions of Asterisk, and is accessible via CLI commands.
Not all AMI events are documented in Asterisk 11, and the list of events available in Asterisk should not be considered a comprehensive list of all events. However, for any event that is listed in Asterisk, the documentation should be accurate and complete. This includes:
- When and why the event is raised
- Fields that are available in the event, both those that are always present as well as those that may be present
- Related information to that event
Building AMI Event Documentation¶
Note
Building AMI Event documentation for Asterisk requires both libxml and python.
Because AMI event documentation is handled in a slightly different fashion, a new build option 'make full' is required to generate the documentation from the Asterisk source.
Note
Because AMI event documentation must be pulled from a variety of locations in the Asterisk source, the time to generate AMI event documentation is noticeably longer then the time to generate other Asterisk documentation.
CLI Commands¶
Two new CLI commands have been added:
- manager show events - list all documented AMI events
- manager show event [event name] - provide detailed documentation on a single AMI event
Example output of both commands is shown below.
\*CLI> manager show events
Events:
-------------------- -------------------- --------------------
AgentCalled AgentComplete AgentConnect
AgentDump AgentRingNoAnswer ChanSpyStart
ChanSpyStop ConfbridgeEnd ConfbridgeJoin
ConfbridgeLeave ConfbridgeStart ConfbridgeTalking
Dial Join Leave
MeetmeEnd MeetmeJoin MeetmeLeave
MeetmeMute MeetmeTalkRequest MeetmeTalking
MessageWaiting QueueCallerAbandon QueueMemberAdded
QueueMemberPaused QueueMemberPenalty QueueMemberRemoved
QueueMemberRinginuse QueueMemberStatus UserEvent
\*CLI> manager show event Dial
Event: Dial
[Synopsis]
Raised when a dial action has started.
[Syntax]
Event: Dial
SubEvent: <value>
Channel: <value>
Destination: <value>
CallerIDNum: <value>
CallerIDName: <value>
ConnectedLineNum: <value>
ConnectedLineName: <value>
UniqueID: <value>
DestUniqueID: <value>
Dialstring: <value>
[Arguments]
SubEvent
Begin
End
A sub event type, specifying whether or not the dial action has begun
or ended.
[Synopsis]
Raised when a dial action has ended.
[Syntax]
Event: Dial
DialStatus: <value>
SubEvent: <value>
Channel: <value>
UniqueID: <value>
[Arguments]
DialStatus
The value of the ${DIALSTATUS} channel variable.
SubEvent
Begin
End
A sub event type, specifying whether or not the dial action has begun
or ended.
\*CLI>
Note
The output shown above is subject to change
Writing AMI Event Documentation¶
AMI Event documentation behaves a bit differently then other Asterisk documentation. A driving factor in the approach taken was to make documenting AMI events as simple and painless as possible, and leave the intricacies of tying instances of AMI events together to pre- and post-processing scripts. The following describes some of the differences between documenting AMI events and the normal approach for documenting items in Asterisk.
- Event documentation can be built directly from the macros that raise the AMI events. This includes manager_event, ast_manager_event, and ast_manager_event_multichan. Because of this, AMI event documentation is typically co-located with the macro call that raises the event. Note that in the example below, only the DialStatus field is explicitly defined; however, the generated AMI event documentation will include all fields found in the ast_manager_event call.
/*\*\* DOCUMENTATION
<managerEventInstance>
<synopsis>Raised when a dial action has ended.</synopsis>
<syntax>
<parameter name="DialStatus">
<para>The value of the <variable>DIALSTATUS</variable> channel variable.</para>
</parameter>
</syntax>
</managerEventInstance>
* */
ast_manager_event(src, EVENT_FLAG_CALL, "Dial",
"SubEvent: End\r\n"
"Channel: %s\r\n"
"UniqueID: %s\r\n"
"DialStatus: %s\r\n",
ast_channel_name(src), ast_channel_uniqueid(src), dialstatus);
/*\*\* DOCUMENTATION
<managerEventInstance>
<synopsis>Raised when a dial action has started.</synopsis>
<syntax>
<parameter name="SubEvent">
<enumlist>
<enum name="Begin"/>
<enum name="End"/>
</enumlist>
<para>A sub event type, specifying whether or not the dial action has begun or ended.</para>
</parameter>
</syntax>
</managerEventInstance>
* */
...
/*\*\* DOCUMENTATION
<managerEventInstance>
<synopsis>Raised when a dial action has ended.</synopsis>
<syntax>
<parameter name="DialStatus">
<para>The value of the <variable>DIALSTATUS</variable> channel variable.</para>
</parameter>
</syntax>
</managerEventInstance>
* */
/*\*\* DOCUMENTATION
<managerEventInstance>
<synopsis>Raised when a dial action has ended.</synopsis>
<syntax>
<parameter name="DialStatus">
<para>The value of the <variable>DIALSTATUS</variable> channel variable.</para>
</parameter>
</syntax>
</managerEventInstance>
* */
Is equivalent to:
/*\*\* DOCUMENTATION
<managerEventInstance>
<synopsis>Raised when a dial action has ended.</synopsis>
<parameter name="DialStatus">
<para>The value of the <variable>DIALSTATUS</variable> channel variable.</para>
</parameter>
</managerEventInstance>
* */
XML Schema¶
The following are the changes to the XML DTD schema used to validate the generated XML documentation. An example of a generated XML fragment for the Dial event is also shown below.
<!ELEMENT managerEvent (managerEventInstance+)>
<!ATTLIST managerEvent name CDATA #REQUIRED>
<!ATTLIST managerEvent language CDATA #REQUIRED>
<!ELEMENT managerEventInstance (synopsis?,syntax?,description?,see-also?)\*>
<!ATTLIST managerEventInstance class CDATA #REQUIRED>
<managerEvent language="en_US" name="Dial"><managerEventInstance class="EVENT_FLAG_CALL">
<synopsis>Raised when a dial action has started.</synopsis>
<syntax>
<parameter name="SubEvent">
<enumlist>
<enum name="Begin"/>
<enum name="End"/>
</enumlist>
<para>A sub event type, specifying whether or not the dial action has begun or ended.</para>
</parameter>
<parameter name="Channel"/>
<parameter name="Destination"/>
<parameter name="CallerIDNum"/>
<parameter name="CallerIDName"/>
<parameter name="ConnectedLineNum"/>
<parameter name="ConnectedLineName"/>
<parameter name="UniqueID"/>
<parameter name="DestUniqueID"/>
<parameter name="Dialstring"/>
</syntax>
</managerEventInstance>
<managerEventInstance class="EVENT_FLAG_CALL">
<synopsis>Raised when a dial action has ended.</synopsis>
<syntax>
<parameter name="DialStatus">
<para>The value of the <variable>DIALSTATUS</variable> channel variable.</para>
</parameter>
<parameter name="SubEvent">
<enumlist>
<enum name="Begin"/>
<enum name="End"/>
</enumlist>
<para>A sub event type, specifying whether or not the dial action has begun or ended.</para>
</parameter>
<parameter name="Channel"/>
<parameter name="UniqueID"/>
</syntax>
</managerEventInstance>
</managerEvent>
Source Comments¶
- Event documentation MUST be within a documentation comment block (shown below), regardless of its location within an implementation file.