View Source AMI.Packet (AMI v0.1.0)

Link to this section Summary

Types

t()

AMI Event received from Asterisk. It is a map with fields as header name and header values. Header value is a list as AMI supports multiple fields with same name. For example, following AMI Event

Functions

Search field value(s) in AMI Packet.

Check if received AMI packet is event. Returns true or false

Parse input Event text and convert to AMI.Packet

Converts AMI.Packet to JSON format

Link to this section Types

@type t() :: map()

AMI Event received from Asterisk. It is a map with fields as header name and header values. Header value is a list as AMI supports multiple fields with same name. For example, following AMI Event:

  Event: Status
  Name: Channels
  Var: foo=1
  Var: bar=AAA

Will be represented as:

  %AMI.Packet{
    "Event" => ["Status"],
    "Name" => ["Channels"],
    "Var" => ["foo=1", "bar=AAA"]
  }

Link to this section Functions

@spec field(pack :: t(), name :: String.t()) :: {:ok, list()} | {:error, :not_found}

Search field value(s) in AMI Packet.

map is AMI.Packet to search

name field name to search

@spec is_event?(pack :: t()) :: boolean()

Check if received AMI packet is event. Returns true or false

@spec parse(input :: String.t()) :: {:ok, t()} | :error

Parse input Event text and convert to AMI.Packet

input AMI event received from Asterisk

Converts AMI.Packet to JSON format