ari

package module
v3.0.14+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

README

ari

Golang Asterisk ARI library

Golang ARI library with support for native ARI interface as well as an ARI-NATS bridge. Also includes common convenience wrappers for various tasks.

V3 is the current release, which is available using gopkg.in versioning semantics.

  # Version 3 release
  go get gopkg.in/CyCoreSystems/ari.v3

This repository also includes semver tags for version 3 releases.

The latest development version is maintained as the master branch, which you can obtain by

  # Development version
  go get github.com/CyCoreSystems/ari

Documentation

Index

Constants

View Source
const DateFormat = "2006-01-02T15:04:05.000-0700"

DateFormat is the date format that ARI returns in the JSON bodies

View Source
const EndpointIDSeparator = "|" //TODO: confirm separator isn't terrible

EndpointIDSeparator seperates the ID components of the endpoint ID

Variables

View Source
var Logger = log15.New()

Logger defaults to a discard handler (null output). If you wish to enable logging, you can set your own handler like so:

ari.Logger.SetHandler(log15.StderrHandler)

Functions

func FromEndpointID

func FromEndpointID(id string) (tech string, resource string, err error)

FromEndpointID converts the endpoint ID to the tech, resource pair.

Types

type Application

type Application interface {

	// List returns the list of applications in Asterisk
	List() ([]*ApplicationHandle, error)

	// Get returns a handle to the application for further interaction
	Get(name string) *ApplicationHandle

	// Data returns the applications data
	Data(name string) (ApplicationData, error)

	// Subscribe subscribes the given application to an event source
	// event source may be one of:
	//  - channel:<channelId>
	//  - bridge:<bridgeId>
	//  - endpoint:<tech>/<resource> (e.g. SIP/102)
	//  - deviceState:<deviceName>
	Subscribe(name string, eventSource string) error

	// Unsubscribe unsubscribes (removes a subscription to) a given
	// ARI application from the provided event source
	// Equivalent to DELETE /applications/{applicationName}/subscription
	Unsubscribe(name string, eventSource string) error
}

Application represents a communication path interacting with an Asterisk server for application-level resources

type ApplicationData

type ApplicationData struct {
	BridgeIDs   []string `json:"bridge_ids"`   // Subscribed BridgeIds
	ChannelIDs  []string `json:"channel_ids"`  // Subscribed ChannelIds
	DeviceNames []string `json:"device_names"` // Subscribed Device names
	EndpointIDs []string `json:"endpoint_ids"` // Subscribed Endpoints (tech/resource format)
	Name        string   `json:"name"`         // Name of the application
}

ApplicationData describes the data for a Stasis (Ari) application

type ApplicationEvent

type ApplicationEvent interface {
	GetApplication() string
}

An ApplicationEvent is an event with an application (which is every event actually)

type ApplicationHandle

type ApplicationHandle struct {
	// contains filtered or unexported fields
}

ApplicationHandle provides a wrapper to an Application interface for operations on a specific application

func NewApplicationHandle

func NewApplicationHandle(name string, app Application) *ApplicationHandle

NewApplicationHandle creates a new handle to the application name

func (*ApplicationHandle) Data

func (ah *ApplicationHandle) Data() (ad ApplicationData, err error)

Data retrives the data for the application

func (*ApplicationHandle) ID

func (ah *ApplicationHandle) ID() string

ID returns the identifier for the application

func (*ApplicationHandle) Match

func (ah *ApplicationHandle) Match(evt Event) bool

Match returns true fo the event matches the application

func (*ApplicationHandle) Subscribe

func (ah *ApplicationHandle) Subscribe(eventSource string) (err error)

Subscribe subscribes the application to an event source event source may be one of:

  • channel:<channelId>
  • bridge:<bridgeId>
  • endpoint:<tech>/<resource> (e.g. SIP/102)
  • deviceState:<deviceName>

func (*ApplicationHandle) Unsubscribe

func (ah *ApplicationHandle) Unsubscribe(eventSource string) (err error)

Unsubscribe unsubscribes (removes a subscription to) a given ARI application from the provided event source Equivalent to DELETE /applications/{applicationName}/subscription

type ApplicationReplaced

type ApplicationReplaced struct {
	EventData
}

ApplicationReplaced - "Notification that another WebSocket has taken over for an application.An application may only be subscribed to by a single WebSocket at a time. If multiple WebSockets attempt to subscribe to the same application, the newer WebSocket wins, and the older one receives this event."

type Asterisk

type Asterisk interface {

	// Info gets data about the asterisk system
	Info(only string) (*AsteriskInfo, error)

	// Variables returns the global asterisk variables
	Variables() Variables

	// Logging returns the interface for working with asterisk logs
	Logging() Logging

	// Modules returns the interface for working with asterisk modules
	Modules() Modules

	// Config returns the interface for working with dynamic configuration
	Config() Config

	// ReloadModule tells asterisk to load the given module
	ReloadModule(name string) error
}

Asterisk represents a communication path for the Asterisk server for system-level resources

type AsteriskInfo

type AsteriskInfo struct {
	BuildInfo  BuildInfo  `json:"build"`
	ConfigInfo ConfigInfo `json:"config"`
	StatusInfo StatusInfo `json:"status"`
	SystemInfo SystemInfo `json:"system"`
}

AsteriskInfo describes a running asterisk system

type Bridge

type Bridge interface {

	// Create creates a bridge
	Create(id string, btype string, name string) (*BridgeHandle, error)

	// Get gets the BridgeHandle
	Get(id string) *BridgeHandle

	// Lists returns the lists of bridges in asterisk
	List() ([]*BridgeHandle, error)

	// Data gets the bridge data
	Data(id string) (BridgeData, error)

	// AddChannel adds a channel to the bridge
	AddChannel(bridgeID string, channelID string) error

	// RemoveChannel removes a channel from the bridge
	RemoveChannel(bridgeID string, channelID string) error

	// Delete deletes the bridge
	Delete(id string) error

	// Play plays the media URI to the bridge
	Play(id string, playbackID string, mediaURI string) (*PlaybackHandle, error)

	// Record records the bridge
	Record(id string, name string, opts *RecordingOptions) (*LiveRecordingHandle, error)

	// Subscribe subscribes the given bridge events events
	Subscribe(id string, n ...string) Subscription
}

Bridge represents a communication path to an Asterisk server for working with bridge resources

type BridgeAttendedTransfer

type BridgeAttendedTransfer struct {
	EventData
	DestinationApplication     string      `json:"destination_application"`      // Application that has been transferred into
	DestinationBridge          string      `json:"destination_bridge"`           // Bridge that survived the merge result
	DestinationLinkFirstLeg    ChannelData `json:"destination_link_first_leg"`   // First leg of a link transfer result
	DestinationLinkSecondLeg   ChannelData `json:"destination_link_second_leg"`  // Second leg of a link transfer result
	DestinationThreewayBridge  BridgeData  `json:"destination_threeway_bridge"`  // Bridge that survived the threeway result
	DestinationThreewayChannel ChannelData `json:"destination_threeway_channel"` // Transferer channel that survived the threeway result
	DestinationType            string      `json:"destination_type"`             // How the transfer was accomplished
	IsExternal                 bool        `json:"is_external"`                  // Whether the transfer was externally initiated or not
	ReplaceChannel             ChannelData `json:"replace_channel,omitempty"`    // The channel that is replacing transferer_first_leg in the swap
	Result                     string      `json:"result"`                       // The result of the transfer attempt
	TransferTarget             ChannelData `json:"transfer_target,omitempty"`    // The channel that is being transferred to
	Transferee                 ChannelData `json:"transferee,omitempty"`         // The channel that is being transferred
	TransfererFirstLeg         ChannelData `json:"transferer_first_leg"`         // First leg of the transferer
	TransfererFirstLegBridge   BridgeData  `json:"transferer_first_leg_bridge"`  // Bridge the transferer first leg is in
	TransfererSecondLeg        ChannelData `json:"transferer_second_leg"`        // Second leg of the transferer
	TransfererSecondLegBridge  BridgeData  `json:"transferer_second_leg_bridge"` // Bridge the transferer second leg is in
}

BridgeAttendedTransfer - "Notification that an attended transfer has occurred."

func (*BridgeAttendedTransfer) GetBridgeIDs

func (evt *BridgeAttendedTransfer) GetBridgeIDs() (sx []string)

GetBridgeIDs gets the bridge IDs for the event

func (*BridgeAttendedTransfer) GetChannelIDs

func (evt *BridgeAttendedTransfer) GetChannelIDs() (sx []string)

GetChannelIDs gets the channel IDs for the event

type BridgeBlindTransfer

type BridgeBlindTransfer struct {
	EventData
	Bridge         BridgeData  `json:"bridge"`                    // The bridge being transferred
	Channel        ChannelData `json:"channel"`                   // The channel performing the blind transfer
	Context        string      `json:"context"`                   // The context transferred to
	Exten          string      `json:"exten"`                     // The extension transferred to
	IsExternal     bool        `json:"is_external"`               // Whether the transfer was externally initiated or not
	ReplaceChannel ChannelData `json:"replace_channel,omitempty"` // The channel that is replacing transferer when the transferee(s) can not be transferred directly
	Result         string      `json:"result"`                    // The result of the transfer attempt
	Transferee     ChannelData `json:"transferee,omitempty"`      // The channel that is being transferred
}

BridgeBlindTransfer - "Notification that a blind transfer has occurred."

func (*BridgeBlindTransfer) GetBridgeIDs

func (evt *BridgeBlindTransfer) GetBridgeIDs() (sx []string)

GetBridgeIDs gets the bridge IDs for the event

func (*BridgeBlindTransfer) GetChannelIDs

func (evt *BridgeBlindTransfer) GetChannelIDs() (sx []string)

GetChannelIDs gets the channel IDs for the event

type BridgeCreated

type BridgeCreated struct {
	EventData
	Bridge BridgeData `json:"bridge"`
}

BridgeCreated - "Notification that a bridge has been created."

func (*BridgeCreated) Created

func (evt *BridgeCreated) Created() (bridgeID string, related string)

Created marks the BridgeCreated event that it created an event

func (*BridgeCreated) GetBridgeIDs

func (evt *BridgeCreated) GetBridgeIDs() (sx []string)

GetBridgeIDs gets the bridge IDs for the event

func (*BridgeCreated) GetChannelIDs

func (evt *BridgeCreated) GetChannelIDs() (sx []string)

GetChannelIDs gets the channel IDs for the event

type BridgeData

type BridgeData struct {
	ID         string   `json:"id"`           // Unique Id for this bridge
	Class      string   `json:"bridge_class"` // Class of the bridge
	Type       string   `json:"bridge_type"`  // Type of bridge (mixing, holding, dtmf_events, proxy_media)
	ChannelIDs []string `json:"channels"`     // List of pariticipating channel ids
	Creator    string   `json:"creator"`      // Creating entity of the bridge
	Name       string   `json:"name"`         // The name of the bridge
	Technology string   `json:"technology"`   // Name of the bridging technology
}

BridgeData describes an Asterisk Bridge, the entity which merges media from one or more channels into a common audio output

type BridgeDestroyed

type BridgeDestroyed struct {
	EventData
	Bridge BridgeData `json:"bridge"`
}

BridgeDestroyed - "Notification that a bridge has been destroyed."

func (*BridgeDestroyed) Destroyed

func (evt *BridgeDestroyed) Destroyed() string

Destroyed returns the bridge that was finished by this event. Used by the proxy to route events to dialogs.

func (*BridgeDestroyed) GetBridgeIDs

func (evt *BridgeDestroyed) GetBridgeIDs() (sx []string)

GetBridgeIDs gets the bridge IDs for the event

type BridgeEvent

type BridgeEvent interface {
	GetBridgeIDs() []string
}

A BridgeEvent is an event with one or more Bridge IDs

type BridgeHandle

type BridgeHandle struct {
	// contains filtered or unexported fields
}

BridgeHandle is the handle to a bridge for performing operations

func NewBridgeHandle

func NewBridgeHandle(id string, b Bridge) *BridgeHandle

NewBridgeHandle creates a new bridge handle

func (*BridgeHandle) AddChannel

func (bh *BridgeHandle) AddChannel(channelID string) (err error)

AddChannel adds a channel to the bridge

func (*BridgeHandle) Data

func (bh *BridgeHandle) Data() (bd BridgeData, err error)

Data gets the bridge data

func (*BridgeHandle) Delete

func (bh *BridgeHandle) Delete() (err error)

Delete deletes the bridge

func (*BridgeHandle) ID

func (bh *BridgeHandle) ID() string

ID returns the identifier for the bridge

func (*BridgeHandle) Match

func (bh *BridgeHandle) Match(e Event) bool

Match returns true if the event matches the bridge

func (*BridgeHandle) Play

func (bh *BridgeHandle) Play(id string, mediaURI string) (ph *PlaybackHandle, err error)

Play initiates playback of the specified media uri to the bridge, returning the Playback handle

func (*BridgeHandle) Playback

func (bh *BridgeHandle) Playback() Playback

Playback returns the playback transport

func (*BridgeHandle) Record

func (bh *BridgeHandle) Record(name string, opts *RecordingOptions) (rh *LiveRecordingHandle, err error)

Record records the bridge to the given filename

func (*BridgeHandle) RemoveChannel

func (bh *BridgeHandle) RemoveChannel(channelID string) (err error)

RemoveChannel removes a channel from the bridge

func (*BridgeHandle) Subscribe

func (bh *BridgeHandle) Subscribe(n ...string) Subscription

Subscribe creates a subscription to the list of events

type BridgeMerged

type BridgeMerged struct {
	EventData
	Bridge     BridgeData `json:"bridge"`
	BridgeFrom BridgeData `json:"bridge_from"`
}

BridgeMerged - "Notification that one bridge has merged into another."

func (*BridgeMerged) GetBridgeIDs

func (evt *BridgeMerged) GetBridgeIDs() (sx []string)

GetBridgeIDs gets the bridge IDs for the event

type BuildInfo

type BuildInfo struct {
	Date    string `json:"date"`
	Kernel  string `json:"kernel"`
	Machine string `json:"machine"`
	Options string `json:"options"`
	Os      string `json:"os"`
	User    string `json:"user"`
}

BuildInfo describes information about how Asterisk was built

type Bus

type Bus interface {
	Close()
	Sender
	Subscriber
}

Bus is an event bus for ARI events. It receives and redistributes events based on a subscription model.

type CallerID

type CallerID struct {
	Name   string `json:"name"`
	Number string `json:"number"`
}

CallerID describes the name and number which identifies the caller to other endpoints

func CallerIDFromString

func CallerIDFromString(src string) (*CallerID, error)

CallerIDFromString interprets the provided string as a CallerID. Usually, this string will be of the following forms:

  • "Name" <number>
  • <number>
  • "Name" number

func (*CallerID) String

func (cid *CallerID) String() string

String returns the stringified callerid

type Channel

type Channel interface {
	// Get returns a handle to a channel for further interaction
	Get(id string) *ChannelHandle

	// List lists the channels in asterisk
	List() ([]*ChannelHandle, error)

	// Originate creates a new channel, returning a handle to it or an
	// error, if the creation failed
	Originate(OriginateRequest) (*ChannelHandle, error)

	// Create creates a new channel, returning a handle to it or an
	// error, if the creation failed
	Create(ChannelCreateRequest) (*ChannelHandle, error)

	// Data returns the channel data for a given channel
	Data(id string) (ChannelData, error)

	// Continue tells Asterisk to return a channel to the dialplan
	Continue(id, context, extension string, priority int) error

	// Busy hangs up the channel with the "busy" cause code
	Busy(id string) error

	// Congestion hangs up the channel with the "congestion" cause code
	Congestion(id string) error

	// Answer answers the channel
	Answer(id string) error

	// Hangup hangs up the given channel
	Hangup(id string, reason string) error

	// Ring indicates ringing to the channel
	Ring(id string) error

	// StopRing stops ringing on the channel
	StopRing(id string) error

	// SendDTMF sends DTMF to the channel
	SendDTMF(id string, dtmf string, opts *DTMFOptions) error

	// Hold puts the channel on hold
	Hold(id string) error

	// StopHold retrieves the channel from hold
	StopHold(id string) error

	// Mute mutes a channel in the given direction (in,out,both)
	Mute(id string, dir string) error

	// Unmute unmutes a channel in the given direction (in,out,both)
	Unmute(id string, dir string) error

	// MOH plays music on hold
	MOH(id string, moh string) error

	// StopMOH stops music on hold
	StopMOH(id string) error

	// Silence plays silence to the channel
	Silence(id string) error

	// StopSilence stops the silence on the channel
	StopSilence(id string) error

	// Play plays the media URI to the channel
	Play(id string, playbackID string, mediaURI string) (*PlaybackHandle, error)

	// Record records the channel
	Record(id string, name string, opts *RecordingOptions) (*LiveRecordingHandle, error)

	// Dial dials a created channel
	Dial(id string, caller string, timeout time.Duration) error

	// Snoop spies on a specific channel, creating a new snooping channel
	Snoop(id string, snoopID string, app string, opts *SnoopOptions) (*ChannelHandle, error)

	// Subscribe subscribes on the channel events
	Subscribe(id string, n ...string) Subscription

	// Variables gets the channel Variables
	Variables(id string) Variables
}

Channel represents a communication path interacting with an Asterisk server.

type ChannelCallerID

type ChannelCallerID struct {
	EventData
	CallerPresentation    int         `json:"caller_presentation"`     // The integer representation of the Caller Presentation value.
	CallerPresentationTxt string      `json:"caller_presentation_txt"` // The text representation of the Caller Presentation value.
	Channel               ChannelData `json:"channel"`                 // The channel that changed Caller ID.
}

ChannelCallerID - "Channel changed Caller ID."

func (*ChannelCallerID) GetChannelIDs

func (evt *ChannelCallerID) GetChannelIDs() (sx []string)

GetChannelIDs gets the channel IDs for the event

type ChannelConnectedLine

type ChannelConnectedLine struct {
	EventData
	Channel ChannelData `json:"channel"` // The channel whose connected line has changed.
}

ChannelConnectedLine - "Channel changed Connected Line."

type ChannelCreateRequest

type ChannelCreateRequest struct {
	// Endpoint is the target endpoint for the dial
	Endpoint string `json:"endpoint"`

	// App is the name of the Stasis application to execute on connection
	App string `json:"app"`

	// AppArgs is the set of (comma-separated) arguments for the Stasis App
	AppArgs string `json:"appArgs,omitempty"`

	// ChannelID is the ID to give to the newly-created channel
	ChannelID string `json:"channelId,omitempty"`

	// OtherChannelID is the ID of the second created channel (when creating Local channels)
	OtherChannelID string `json:"otherChannelId,omitempty"`

	// Originator is the unique ID of the calling channel, for which this new channel-dial is being created
	Originator string `json:"originator,omitempty"`

	// Formats is the comma-separated list of valid codecs to allow for the new channel, in the case that
	// the Originator is not specified
	Formats string `json:"formats,omitempty"`
}

ChannelCreateRequest describes how a channel should be created, when using the separate Create and Dial calls.

type ChannelCreated

type ChannelCreated struct {
	EventData
	Channel ChannelData `json:"channel"`
}

ChannelCreated - "Notification that a channel has been created."

func (*ChannelCreated) GetChannelIDs

func (evt *ChannelCreated) GetChannelIDs() (sx []string)

GetChannelIDs gets the channel IDs for the event

type ChannelData

type ChannelData struct {
	ID           string      `json:"id"`    // Unique id for this channel (same as for AMI)
	Name         string      `json:"name"`  // Name of this channel (tech/name-id format)
	State        string      `json:"state"` // State of the channel
	Accountcode  string      `json:"accountcode"`
	Caller       CallerID    `json:"caller"`    // CallerId of the calling endpoint
	Connected    CallerID    `json:"connected"` // CallerId of the connected line
	Creationtime DateTime    `json:"creationtime"`
	Dialplan     DialplanCEP `json:"dialplan"` // Current location in the dialplan
}

ChannelData is the data for a specific channel

type ChannelDestroyed

type ChannelDestroyed struct {
	EventData
	Cause    int         `json:"cause"`     // Integer representation of the cause of the hangup
	CauseTxt string      `json:"cause_txt"` // Text representation of the cause of the hangup
	Channel  ChannelData `json:"channel"`
}

ChannelDestroyed - "Notification that a channel has been destroyed."

type ChannelDialplan

type ChannelDialplan struct {
	EventData
	Channel         ChannelData `json:"channel"`           // The channel that changed dialplan location.
	DialplanApp     string      `json:"dialplan_app"`      // The application about to be executed.
	DialplanAppData string      `json:"dialplan_app_data"` // The data to be passed to the application.
}

ChannelDialplan - "Channel changed location in the dialplan."

func (*ChannelDialplan) GetChannelIDs

func (evt *ChannelDialplan) GetChannelIDs() (sx []string)

GetChannelIDs gets the channel IDs for the event

type ChannelDtmfReceived

type ChannelDtmfReceived struct {
	EventData
	Channel    ChannelData `json:"channel"`     // The channel on which DTMF was received
	Digit      string      `json:"digit"`       // DTMF digit received (0-9, A-E, # or *)
	DurationMs int         `json:"duration_ms"` // Number of milliseconds DTMF was received
}

ChannelDtmfReceived - "DTMF received on a channel.This event is sent when the DTMF ends. There is no notification about the start of DTMF"

func (*ChannelDtmfReceived) GetChannelIDs

func (evt *ChannelDtmfReceived) GetChannelIDs() (sx []string)

GetChannelIDs gets the channel IDs for the event

type ChannelEnteredBridge

type ChannelEnteredBridge struct {
	EventData
	Bridge  BridgeData  `json:"bridge"`
	Channel ChannelData `json:"channel"`
}

ChannelEnteredBridge - "Notification that a channel has entered a bridge."

func (*ChannelEnteredBridge) Created

func (evt *ChannelEnteredBridge) Created() (o string, related string)

Created marks the event as creating a bridge for a channel and dialog

func (*ChannelEnteredBridge) GetBridgeIDs

func (evt *ChannelEnteredBridge) GetBridgeIDs() (sx []string)

GetBridgeIDs gets the bridge IDs for the event

func (*ChannelEnteredBridge) GetChannelIDs

func (evt *ChannelEnteredBridge) GetChannelIDs() (sx []string)

GetChannelIDs gets the channel IDs for the event

type ChannelEvent

type ChannelEvent interface {
	GetChannelIDs() []string
}

A ChannelEvent is an event with one or more channel IDs

type ChannelHandle

type ChannelHandle struct {
	// contains filtered or unexported fields
}

ChannelHandle provides a wrapper to a Channel interface for operations on a particular channel ID

func NewChannelHandle

func NewChannelHandle(id string, c Channel) *ChannelHandle

NewChannelHandle returns a handle to the given ARI channel

func (*ChannelHandle) Answer

func (ch *ChannelHandle) Answer() error

Answer answers the channel

func (*ChannelHandle) Busy

func (ch *ChannelHandle) Busy() error

Busy hangs up the channel with the "busy" cause code

func (*ChannelHandle) Congestion

func (ch *ChannelHandle) Congestion() error

Congestion hangs up the channel with the congestion cause code

func (*ChannelHandle) Continue

func (ch *ChannelHandle) Continue(context, extension string, priority int) error

Continue tells Asterisk to return the channel to the dialplan

func (*ChannelHandle) Data

func (ch *ChannelHandle) Data() (ChannelData, error)

Data returns the channel's data

func (*ChannelHandle) Dial

func (ch *ChannelHandle) Dial(caller string, timeout time.Duration) error

Dial dials a created channel. `caller` is the optional channel ID of the calling party (if there is one). Timeout is the length of time to wait before the dial is answered before aborting.

func (*ChannelHandle) Hangup

func (ch *ChannelHandle) Hangup() error

Hangup hangs up the channel with the normal cause code

func (*ChannelHandle) Hold

func (ch *ChannelHandle) Hold() error

Hold puts the channel on hold

func (*ChannelHandle) ID

func (ch *ChannelHandle) ID() string

ID returns the identifier for the channel handle

func (*ChannelHandle) IsAnswered

func (ch *ChannelHandle) IsAnswered() (bool, error)

IsAnswered checks the current state of the channel to see if it is "Up"

func (*ChannelHandle) MOH

func (ch *ChannelHandle) MOH(mohClass string) error

MOH plays music on hold of the given class to the channel

func (*ChannelHandle) Match

func (ch *ChannelHandle) Match(e Event) bool

Match returns true if the event matches the channel

func (*ChannelHandle) Mute

func (ch *ChannelHandle) Mute(dir string) (err error)

Mute mutes the channel in the given direction (in, out, both)

func (*ChannelHandle) Originate

func (ch *ChannelHandle) Originate(req OriginateRequest) (*ChannelHandle, error)

Originate creates (and dials) a new channel using the present channel as its Originator.

func (*ChannelHandle) Play

func (ch *ChannelHandle) Play(id string, mediaURI string) (ph *PlaybackHandle, err error)

Play initiates playback of the specified media uri to the channel, returning the Playback handle

func (*ChannelHandle) Playback

func (ch *ChannelHandle) Playback() Playback

Playback returns the playback transport

func (*ChannelHandle) Record

func (ch *ChannelHandle) Record(name string, opts *RecordingOptions) (rh *LiveRecordingHandle, err error)

Record records the channel to the given filename

func (*ChannelHandle) Ring

func (ch *ChannelHandle) Ring() error

Ring indicates ringing to the channel

func (*ChannelHandle) SendDTMF

func (ch *ChannelHandle) SendDTMF(dtmf string, opts *DTMFOptions) error

SendDTMF sends the DTMF information to the server

func (*ChannelHandle) Silence

func (ch *ChannelHandle) Silence() error

Silence plays silence to the channel

func (*ChannelHandle) Snoop

func (ch *ChannelHandle) Snoop(snoopID string, app string, opts *SnoopOptions) (*ChannelHandle, error)

Snoop spies on a specific channel, creating a new snooping channel placed into the given app

func (*ChannelHandle) StopHold

func (ch *ChannelHandle) StopHold() error

StopHold retrieves the channel from hold

func (*ChannelHandle) StopMOH

func (ch *ChannelHandle) StopMOH() error

StopMOH stops playing of music on hold to the channel

func (*ChannelHandle) StopRing

func (ch *ChannelHandle) StopRing() error

StopRing stops ringing on the channel

func (*ChannelHandle) StopSilence

func (ch *ChannelHandle) StopSilence() error

StopSilence stops silence to the channel

func (*ChannelHandle) Subscribe

func (ch *ChannelHandle) Subscribe(n ...string) Subscription

Subscribe subscribes the list of channel events

func (*ChannelHandle) Unmute

func (ch *ChannelHandle) Unmute(dir string) (err error)

Unmute unmutes the channel in the given direction (in, out, both)

func (*ChannelHandle) Variables

func (ch *ChannelHandle) Variables() Variables

Variables returns the channel variables

type ChannelHangupRequest

type ChannelHangupRequest struct {
	EventData
	Cause   int         `json:"cause"`   // Integer representation of the cause of the hangup.
	Channel ChannelData `json:"channel"` // The channel on which the hangup was requested.
	Soft    bool        `json:"soft"`    // Whether the hangup request was a soft hangup request.
}

ChannelHangupRequest - "A hangup was requested on the channel."

func (*ChannelHangupRequest) GetChannelIDs

func (evt *ChannelHangupRequest) GetChannelIDs() (sx []string)

GetChannelIDs gets the channel IDs for the event

type ChannelHold

type ChannelHold struct {
	EventData
	Channel    ChannelData `json:"channel"`              // The channel that initiated the hold event.
	Musicclass string      `json:"musicclass,omitempty"` // The music on hold class that the initiator requested.
}

ChannelHold - "A channel initiated a media hold."

func (*ChannelHold) GetChannelIDs

func (evt *ChannelHold) GetChannelIDs() (sx []string)

GetChannelIDs gets the channel IDs for the event

type ChannelLeftBridge

type ChannelLeftBridge struct {
	EventData
	Bridge  BridgeData  `json:"bridge"`
	Channel ChannelData `json:"channel"`
}

ChannelLeftBridge - "Notification that a channel has left a bridge."

func (*ChannelLeftBridge) GetBridgeIDs

func (evt *ChannelLeftBridge) GetBridgeIDs() (sx []string)

GetBridgeIDs gets the bridge IDs for the event

func (*ChannelLeftBridge) GetChannelIDs

func (evt *ChannelLeftBridge) GetChannelIDs() (sx []string)

GetChannelIDs gets the channel IDs for the event

type ChannelStateChange

type ChannelStateChange struct {
	EventData
	Channel ChannelData `json:"channel"`
}

ChannelStateChange - "Notification of a channel's state change."

func (*ChannelStateChange) GetChannelIDs

func (evt *ChannelStateChange) GetChannelIDs() (sx []string)

GetChannelIDs gets the channel IDs for the event

type ChannelTalkingFinished

type ChannelTalkingFinished struct {
	EventData
	Channel  ChannelData `json:"channel"`  // The channel on which talking completed.
	Duration int         `json:"duration"` // The length of time, in milliseconds, that talking was detected on the channel
}

ChannelTalkingFinished - "Talking is no longer detected on the channel."

type ChannelTalkingStarted

type ChannelTalkingStarted struct {
	EventData
	Channel ChannelData `json:"channel"` // The channel on which talking started.
}

ChannelTalkingStarted - "Talking was detected on the channel."

func (*ChannelTalkingStarted) GetChannelIDs

func (evt *ChannelTalkingStarted) GetChannelIDs() (sx []string)

GetChannelIDs gets the channel IDs for the event

type ChannelUnhold

type ChannelUnhold struct {
	EventData
	Channel ChannelData `json:"channel"` // The channel that initiated the unhold event.
}

ChannelUnhold - "A channel initiated a media unhold."

func (*ChannelUnhold) GetChannelIDs

func (evt *ChannelUnhold) GetChannelIDs() (sx []string)

GetChannelIDs gets the channel IDs for the event

type ChannelUserevent

type ChannelUserevent struct {
	EventData
	Bridge    BridgeData   `json:"bridge,omitempty"`   // A bridge that is signaled with the user event.
	Channel   ChannelData  `json:"channel,omitempty"`  // A channel that is signaled with the user event.
	Endpoint  EndpointData `json:"endpoint,omitempty"` // A endpoint that is signaled with the user event.
	Eventname string       `json:"eventname"`          // The name of the user event.
	Userevent interface{}  `json:"userevent"`          // Custom Userevent data
}

ChannelUserevent - "User-generated event with additional user-defined fields in the object."

func (*ChannelUserevent) GetBridgeIDs

func (evt *ChannelUserevent) GetBridgeIDs() (sx []string)

GetBridgeIDs gets the bridge IDs for the event

func (*ChannelUserevent) GetChannelIDs

func (evt *ChannelUserevent) GetChannelIDs() (sx []string)

GetChannelIDs gets the channel IDs for the event

func (*ChannelUserevent) GetEndpointIDs

func (evt *ChannelUserevent) GetEndpointIDs() (sx []string)

GetEndpointIDs gets the bridge IDs for the event

type ChannelVarset

type ChannelVarset struct {
	EventData
	Channel  ChannelData `json:"channel,omitempty"` // The channel on which the variable was set.If missing, the variable is a global variable.
	Value    string      `json:"value"`             // The new value of the variable.
	Variable string      `json:"variable"`          // The variable that changed.
}

ChannelVarset - "Channel variable changed."

func (*ChannelVarset) GetChannelIDs

func (evt *ChannelVarset) GetChannelIDs() (sx []string)

GetChannelIDs gets the channel IDs for the event

type Client

type Client struct {
	// Namespaced Interfaces
	Application Application
	Asterisk    Asterisk
	Channel     Channel
	Bridge      Bridge
	Playback    Playback
	Mailbox     Mailbox
	Endpoint    Endpoint
	DeviceState DeviceState
	TextMessage TextMessage
	Sound       Sound
	Recording   *Recording
	Bus         Bus

	Cleanup func() error

	// Optional application details
	ApplicationName      string
	ApplicationArguments []string
}

Client represents a set of operations to interact with an Asterisk ARI server. It is agnostic to transport and implementation.

func (*Client) Close

func (cl *Client) Close() error

Close closes the client and calls any implementation specific cleanup code

type Config

type Config interface {

	// Get gets the reference to a config object
	Get(configClass, objectType, id string) *ConfigHandle

	// Data gets the data for the config object
	Data(configClass, objectType, id string) (ConfigData, error)

	// Update creates or updates the given tuples
	Update(configClass, objectType, id string, tuples []ConfigTuple) error

	// Delete deletes the dynamic configuration object.
	Delete(configClass, objectType, id string) error
}

Config represents a transport to the asterisk config ARI resource.

type ConfigData

type ConfigData struct {
	ID     string
	Class  string
	Type   string
	Fields []ConfigTuple
}

ConfigData contains the data for a given configuration object

type ConfigHandle

type ConfigHandle struct {
	// contains filtered or unexported fields
}

A ConfigHandle is a reference to a Config object on the asterisk service

func NewConfigHandle

func NewConfigHandle(configClass, objectType, id string, c Config) *ConfigHandle

NewConfigHandle builds a new config handle

func (*ConfigHandle) Data

func (ch *ConfigHandle) Data() (ConfigData, error)

Data gets the current data for the config handle

func (*ConfigHandle) Delete

func (ch *ConfigHandle) Delete() error

Delete deletes the dynamic configuration object

func (*ConfigHandle) ID

func (ch *ConfigHandle) ID() string

ID returns the unique identifier for the config object

func (*ConfigHandle) Update

func (ch *ConfigHandle) Update(tuples []ConfigTuple) error

Update creates or updates the given config tuples

type ConfigInfo

type ConfigInfo struct {
	DefaultLanguage string  `json:"default_language"`
	MaxChannels     int     `json:"max_channels,omitempty"` //omitempty denotes an optional field, meaning the field may not be present if no value is assigned.
	MaxLoad         float64 `json:"max_load,omitempty"`
	MaxOpenFiles    int     `json:"max_open_files,omitempty"`
	Name            string  `json:"name"`  // Asterisk system name
	SetID           SetID   `json:"setid"` // Effective user/group id under which Asterisk is running
}

ConfigInfo describes information about the Asterisk configuration

type ConfigTuple

type ConfigTuple struct {
	Attribute string `json:"attribute"`
	Value     string `json:"value"`
}

ConfigTuple is the key-value pair that defines a configuration entry

type ContactInfo

type ContactInfo struct {
	EventData
	Aor           string `json:"aor"`                      // The Address of Record this contact belongs to.
	ContactStatus string `json:"contact_status"`           // The current status of the contact.
	RoundtripUsec string `json:"roundtrip_usec,omitempty"` // Current round trip time, in microseconds, for the contact.
	Uri           string `json:"uri"`                      // The location of the contact.
}

ContactInfo - "Detailed information about a contact on an endpoint."

type ContactStatusChange

type ContactStatusChange struct {
	EventData
	ContactInfo ContactInfo  `json:"contact_info"`
	Endpoint    EndpointData `json:"endpoint"`
}

ContactStatusChange - "The state of a contact on an endpoint has changed."

func (*ContactStatusChange) GetEndpointIDs

func (evt *ContactStatusChange) GetEndpointIDs() (sx []string)

GetEndpointIDs gets the bridge IDs for the event

type DTMFOptions

type DTMFOptions struct {
	Before   time.Duration
	Between  time.Duration
	Duration time.Duration
	After    time.Duration
}

DTMFOptions is the list of pptions for DTMF sending

type DTMFSender

type DTMFSender interface {
	SendDTMF(dtmf string, opts *DTMFOptions)
}

DTMFSender is an object which can be send DTMF signals

type DateTime

type DateTime time.Time

DateTime is an alias type for attaching a custom asterisk unmarshaller and marshaller for JSON

func (DateTime) MarshalJSON

func (dt DateTime) MarshalJSON() ([]byte, error)

MarshalJSON converts the given date object to ARIs date format

func (DateTime) String

func (dt DateTime) String() string

func (*DateTime) UnmarshalJSON

func (dt *DateTime) UnmarshalJSON(data []byte) error

UnmarshalJSON parses the given date per ARIs date format

type DeviceState

type DeviceState interface {
	Get(name string) *DeviceStateHandle

	List() ([]*DeviceStateHandle, error)

	Data(name string) (DeviceStateData, error)

	Update(name string, state string) error

	Delete(name string) error
}

DeviceState represents a communication path interacting with an Asterisk server for device state resources

type DeviceStateChanged

type DeviceStateChanged struct {
	EventData
	DeviceState DeviceStateData `json:"device_state"` // Device state object
}

DeviceStateChanged - "Notification that a device state has changed."

type DeviceStateData

type DeviceStateData string

DeviceStateData is the device state for the device

type DeviceStateHandle

type DeviceStateHandle struct {
	// contains filtered or unexported fields
}

DeviceStateHandle is a representation of a device state that can be interacted with

func NewDeviceStateHandle

func NewDeviceStateHandle(name string, d DeviceState) *DeviceStateHandle

NewDeviceStateHandle creates a new deviceState handle

func (*DeviceStateHandle) Data

func (dsh *DeviceStateHandle) Data() (d DeviceStateData, err error)

Data gets the device state

func (*DeviceStateHandle) Delete

func (dsh *DeviceStateHandle) Delete() (err error)

Delete deletes the device state

func (*DeviceStateHandle) ID

func (dsh *DeviceStateHandle) ID() string

ID returns the identifier for the device

func (*DeviceStateHandle) Update

func (dsh *DeviceStateHandle) Update(state string) (err error)

Update updates the device state, implicitly creating it if not exists

type Dial

type Dial struct {
	EventData
	Caller     ChannelData `json:"caller,omitempty"`     // The calling channel.
	Dialstatus string      `json:"dialstatus"`           // Current status of the dialing attempt to the peer.
	Dialstring string      `json:"dialstring,omitempty"` // The dial string for calling the peer channel.
	Forward    string      `json:"forward,omitempty"`    // Forwarding target requested by the original dialed channel.
	Forwarded  ChannelData `json:"forwarded,omitempty"`  // Channel that the caller has been forwarded to.
	Peer       ChannelData `json:"peer"`                 // The dialed channel.
}

Dial - "Dialing state has changed."

func (*Dial) GetChannelIDs

func (evt *Dial) GetChannelIDs() (sx []string)

GetChannelIDs gets the bridge IDs for the event

type DialplanCEP

type DialplanCEP struct {
	Context  string `json:"context"`
	Exten    string `json:"exten"`
	Priority int64  `json:"priority"` //int64 derived from Java's 'long'
}

DialplanCEP describes a location in the dialplan (context,extension,priority)

type DurationSec

type DurationSec time.Duration

DurationSec is a JSON type for duration in seconds

func (DurationSec) MarshalJSON

func (ds DurationSec) MarshalJSON() ([]byte, error)

MarshalJSON converts the duration into a JSON friendly format

func (*DurationSec) UnmarshalJSON

func (ds *DurationSec) UnmarshalJSON(data []byte) error

UnmarshalJSON parses the data into the duration seconds object

type Endpoint

type Endpoint interface {

	// List lists the endpoints
	// TODO: associated with the application, or on the entire system?
	List() ([]*EndpointHandle, error)

	// List available endpoints for a given endpoint technology
	ListByTech(tech string) ([]*EndpointHandle, error)

	// Get returns a handle to the endpoint for further operations
	Get(tech string, resource string) *EndpointHandle

	// Data returns the state of the endpoint
	Data(tech string, resource string) (EndpointData, error)
}

Endpoint represents a communication path to an Asterisk server for endpoint resources

type EndpointData

type EndpointData struct {
	ChannelIDs []string `json:"channel_ids"`     // List of channel Ids which are associated with this endpoint
	Resource   string   `json:"resource"`        // The endpoint's resource name
	State      string   `json:"state,omitempty"` // The state of the endpoint
	Technology string   `json:"technology"`      // The technology of the endpoint (e.g. SIP, PJSIP, DAHDI, etc)
}

EndpointData describes an external device which may offer or accept calls to or from Asterisk. Devices are defined by a technology/resource pair.

Allowed states: 'unknown', 'offline', 'online'

func (*EndpointData) ID

func (ed *EndpointData) ID() string

ID returns the ID for the endpoint

type EndpointEvent

type EndpointEvent interface {
	GetEndpointIDs() []string
}

An EndpointEvent is an event with one or more endpoint IDs

type EndpointHandle

type EndpointHandle struct {
	// contains filtered or unexported fields
}

An EndpointHandle is a reference to an endpoint attached to a transport to an asterisk server

func NewEndpointHandle

func NewEndpointHandle(tech string, resource string, e Endpoint) *EndpointHandle

NewEndpointHandle creates a new EndpointHandle

func (*EndpointHandle) Data

func (eh *EndpointHandle) Data() (EndpointData, error)

Data returns the state of the endpoint

func (*EndpointHandle) ID

func (eh *EndpointHandle) ID() string

ID returns the identifier for the endpoint

func (*EndpointHandle) Match

func (eh *EndpointHandle) Match(e Event) bool

Match returns true if the event matches the bridge

type EndpointStateChange

type EndpointStateChange struct {
	EventData
	Endpoint EndpointData `json:"endpoint"`
}

EndpointStateChange - "Endpoint state changed."

func (*EndpointStateChange) GetEndpointIDs

func (evt *EndpointStateChange) GetEndpointIDs() (sx []string)

GetEndpointIDs gets the bridge IDs for the event

type Event

type Event interface {
	MessageRawer
	ApplicationEvent
	GetType() string
}

Event is the top level event interface

type EventData

type EventData struct {
	Message
	Application string   `json:"application"`
	Timestamp   DateTime `json:"timestamp,omitempty"`
}

EventData is the base struct for all events

func (*EventData) GetApplication

func (e *EventData) GetApplication() string

GetApplication gets the application of the event

func (*EventData) GetType

func (e *EventData) GetType() string

GetType gets the type of the event

type EventTypes

type EventTypes struct {
	All                    string
	ApplicationReplaced    string
	BridgeAttendedTransfer string
	BridgeBlindTransfer    string
	BridgeCreated          string
	BridgeDestroyed        string
	BridgeMerged           string
	ChannelCallerID        string
	ChannelConnectedLine   string
	ChannelCreated         string
	ChannelDestroyed       string
	ChannelDialplan        string
	ChannelDtmfReceived    string
	ChannelEnteredBridge   string
	ChannelHangupRequest   string
	ChannelHold            string
	ChannelLeftBridge      string
	ChannelStateChange     string
	ChannelTalkingFinished string
	ChannelTalkingStarted  string
	ChannelUnhold          string
	ChannelUserevent       string
	ChannelVarset          string
	ContactInfo            string
	ContactStatusChange    string
	DeviceStateChanged     string
	Dial                   string
	EndpointStateChange    string
	MissingParams          string
	Peer                   string
	PeerStatusChange       string
	PlaybackContinuing     string
	PlaybackFinished       string
	PlaybackStarted        string
	RecordingFailed        string
	RecordingFinished      string
	RecordingStarted       string
	StasisEnd              string
	StasisStart            string
	TextMessageReceived    string
}

EventTypes enumerates the list of event types

var Events EventTypes

Events is the instance for grabbing event types

func (*EventTypes) Parse

func (ev *EventTypes) Parse(msg *Message) Event

Parse parses the message into the specific eventer

type FormatLangPair

type FormatLangPair struct {
	Format   string `json:"format"`
	Language string `json:"language"`
}

FormatLangPair describes the format and language of a sound file

type LiveRecording

type LiveRecording interface {

	// Get gets the Recording by type
	Get(name string) *LiveRecordingHandle

	// Data gets the data for the live recording
	Data(name string) (LiveRecordingData, error)

	// Stop stops the live recording
	Stop(name string) error

	// Pause pauses the live recording
	Pause(name string) error

	// Resume resumes the live recording
	Resume(name string) error

	// Mute mutes the live recording
	Mute(name string) error

	// Unmute unmutes the live recording
	Unmute(name string) error

	// Delete deletes the live recording
	Delete(name string) error

	// Scrap Stops and deletes the current LiveRecording
	//TODO: reproduce this error in isolation: does not delete. Cannot delete any recording produced by this.
	Scrap(name string) error
}

LiveRecording represents a communication path interacting with an Asterisk server for live recording resources

type LiveRecordingData

type LiveRecordingData struct {
	Cause     string      `json:"cause,omitempty"`            // If failed, the cause of the failure
	Duration  DurationSec `json:"duration,omitempty"`         // Length of recording in seconds
	Format    string      `json:"format"`                     // Format of recording (wav, gsm, etc)
	Name      string      `json:"name"`                       // (base) name for the recording
	Silence   DurationSec `json:"silence_duration,omitempty"` // If silence was detected in the recording, the duration in seconds of that silence (requires that maxSilenceSeconds be non-zero)
	State     string      `json:"state"`                      // Current state of the recording
	Talking   DurationSec `json:"talking_duration,omitempty"` // Duration of talking, in seconds, that has been detected in the recording (requires that maxSilenceSeconds be non-zero)
	TargetURI string      `json:"target_uri"`                 // URI for the channel or bridge which is being recorded (TODO: figure out format for this)
}

LiveRecordingData is the data for a stored recording

func (*LiveRecordingData) ID

func (s *LiveRecordingData) ID() string

ID returns the identifier of the live recording

type LiveRecordingHandle

type LiveRecordingHandle struct {
	// contains filtered or unexported fields
}

A LiveRecordingHandle is a reference to a stored recording that can be operated on

func NewLiveRecordingHandle

func NewLiveRecordingHandle(name string, s LiveRecording) *LiveRecordingHandle

NewLiveRecordingHandle creates a new stored recording handle

func (*LiveRecordingHandle) Data

func (s *LiveRecordingHandle) Data() (d LiveRecordingData, err error)

Data gets the data for the stored recording

func (*LiveRecordingHandle) Delete

func (s *LiveRecordingHandle) Delete() (err error)

Delete deletes the recording

func (*LiveRecordingHandle) ID

func (s *LiveRecordingHandle) ID() string

ID returns the identifier of the live recording

func (*LiveRecordingHandle) Match

func (s *LiveRecordingHandle) Match(e Event) bool

Match returns true if the event matches the bridge

func (*LiveRecordingHandle) Mute

func (s *LiveRecordingHandle) Mute() (err error)

Mute mutes the recording

func (*LiveRecordingHandle) Pause

func (s *LiveRecordingHandle) Pause() (err error)

Pause pauses the recording

func (*LiveRecordingHandle) Resume

func (s *LiveRecordingHandle) Resume() (err error)

Resume resumes the recording

func (*LiveRecordingHandle) Scrap

func (s *LiveRecordingHandle) Scrap() (err error)

Scrap stops and deletes the recording

func (*LiveRecordingHandle) Unmute

func (s *LiveRecordingHandle) Unmute() (err error)

Unmute mutes the recording

type LogData

type LogData struct {
	Name          string `json:"channel"`
	Configuration string `json:"configuration"`
	Type          string `json:"type"`
	Status        string `json:"configuration"`
}

LogData represents the log data

type Logging

type Logging interface {

	// Create creates a new log
	Create(name string, level string) error

	// List the logs
	List() ([]LogData, error)

	// Rotate rotates the log
	Rotate(name string) error

	// Delete deletes the log
	Delete(name string) error
}

Logging represents a communication path to an Asterisk server for working with logging resources

type Mailbox

type Mailbox interface {

	// Get gets a handle to the mailbox for further operations
	Get(name string) *MailboxHandle

	// List lists the mailboxes in asterisk
	List() ([]*MailboxHandle, error)

	// Data gets the current state of the mailbox
	Data(name string) (MailboxData, error)

	// Update updates the state of the mailbox, or creates if does not exist
	Update(name string, oldMessages int, newMessages int) error

	// Delete deletes the mailbox
	Delete(name string) error
}

Mailbox is the communication path to an Asterisk server for operating on mailbox resources

type MailboxData

type MailboxData struct {
	Name        string `json:"name"`
	NewMessages int    `json:"new_messages"` // Number of new (unread) messages
	OldMessages int    `json:"old_messages"` // Number of old (read) messages
}

MailboxData respresents the state of an Asterisk (voice) mailbox

type MailboxHandle

type MailboxHandle struct {
	// contains filtered or unexported fields
}

A MailboxHandle is a handle to a mailbox instance attached to an ari transport

func NewMailboxHandle

func NewMailboxHandle(name string, m Mailbox) *MailboxHandle

NewMailboxHandle creates a new mailbox handle given the name and mailbox transport

func (*MailboxHandle) Data

func (mh *MailboxHandle) Data() (MailboxData, error)

Data gets the current state of the mailbox

func (*MailboxHandle) Delete

func (mh *MailboxHandle) Delete() error

Delete deletes the mailbox

func (*MailboxHandle) ID

func (mh *MailboxHandle) ID() string

ID returns the identifier for the mailbox handle

func (*MailboxHandle) Update

func (mh *MailboxHandle) Update(oldMessages int, newMessages int) error

Update updates the state of the mailbox, or creates if does not exist

type Matcher

type Matcher interface {
	Match(evt Event) bool
}

A Matcher is an entity which can query an event

type Message

type Message struct {
	RawMessage
	Type string `json:"type"`
}

Message is the first extension of the RawMessage type, containing only a Type

func NewMessage

func NewMessage(raw []byte) (*Message, error)

NewMessage constructs a Message from a byte slice

type MessageRawer

type MessageRawer interface {
	SetRaw(*[]byte)
	GetRaw() *[]byte
}

MessageRawer provides operations to get raw message data

type MissingParams

type MissingParams struct {
	EventData
	Params []string `json:"params"` // A list of the missing parameters
}

MissingParams - "Error event sent when required params are missing."

type ModuleData

type ModuleData struct {
	Name         string `json:"name"`
	Description  string `json:"description"`
	SupportLevel string `json:"support_level"`
	UseCount     int    `json:"use_count"`
	Status       string `json:"status"`
}

ModuleData is the data for an asterisk module

type ModuleHandle

type ModuleHandle struct {
	// contains filtered or unexported fields
}

ModuleHandle is the reference to an asterisk module

func NewModuleHandle

func NewModuleHandle(name string, m Modules) *ModuleHandle

NewModuleHandle returns a new module handle

func (*ModuleHandle) Data

func (mh *ModuleHandle) Data() (ModuleData, error)

Data gets the module data

func (*ModuleHandle) ID

func (mh *ModuleHandle) ID() string

ID returns the identifier for the module

func (*ModuleHandle) Load

func (mh *ModuleHandle) Load() error

Load loads the module

func (*ModuleHandle) Reload

func (mh *ModuleHandle) Reload() error

Reload reloads the module

func (*ModuleHandle) Unload

func (mh *ModuleHandle) Unload() error

Unload unloads the module

type Modules

type Modules interface {
	Get(name string) *ModuleHandle

	List() ([]*ModuleHandle, error)

	Load(name string) error

	Reload(name string) error

	Unload(name string) error

	Data(name string) (ModuleData, error)
}

Modules is the communication path for interacting with the asterisk modules resource

type OriginateRequest

type OriginateRequest struct {
	Endpoint string `json:"endpoint"`           // Endpoint to use (tech/resource notation)
	Timeout  int    `json:"timeout,omitempty"`  // Dial Timeout in seconds (-1 = no limit)
	CallerID string `json:"callerId,omitempty"` // CallerID to set for outgoing call

	// One set of:
	Context   string `json:"context,omitempty"` // Drop the channel into the dialplan
	Extension string `json:"extension,omitempty"`
	Priority  int64  `json:"priority,omitempty"`
	// OR
	App     string `json:"app,omitempty"`     // Associate channel to Stasis (Ari) application
	AppArgs string `json:"appArgs,omitempty"` // Arguments to the application

	//  The label to dial after the endpoint answers.
	// Will supersede 'priority' if provided. Mutually exclusive with 'app'.
	Label string `json:"label,omitempty"`

	// The format name capability list to use if originator is not specified.
	// Ex. "ulaw,slin16". Format names can be found with "core show codecs".
	Formats string `json:"formats,omitempty"` //

	// Channel ID declarations
	ChannelID      string `json:"channelId,omitempty"`      // Optionally assign channel id
	OtherChannelID string `json:"otherChannelId,omitempty"` // Optionally assign second channel's id (only for local channels)

	// Originator is the channel for whom this Originate request is being made, if there is one.
	// It is used by Asterisk to set the right codecs (and possibly other parameters) such that
	// when the new channel is bridged to the Originator channel, there should be no transcoding.
	// This is a purely optional (but helpful, where applicable) field.
	Originator string `json:"originator,omitempty"`

	// Variables describes the set of channel variables to apply to the new channel
	Variables map[string]string `json:"variables,omitempty"`
}

OriginateRequest is the basic structure for all channel creation methods

type Peer

type Peer struct {
	EventData
	Address    string `json:"address,omitempty"` // The IP address of the peer.
	Cause      string `json:"cause,omitempty"`   // An optional reason associated with the change in peer_status.
	PeerStatus string `json:"peer_status"`       // The current state of the peer. Note that the values of the status are dependent on the underlying peer technology.
	Port       string `json:"port,omitempty"`    // The port of the peer.
	Time       string `json:"time,omitempty"`    // The last known time the peer was contacted.
}

Peer - "Detailed information about a remote peer that communicates with Asterisk."

type PeerStatusChange

type PeerStatusChange struct {
	EventData
	Endpoint EndpointData `json:"endpoint"`
	Peer     Peer         `json:"peer"`
}

PeerStatusChange - "The state of a peer associated with an endpoint has changed."

func (*PeerStatusChange) GetEndpointIDs

func (evt *PeerStatusChange) GetEndpointIDs() (sx []string)

GetEndpointIDs gets the bridge IDs for the event

type Playback

type Playback interface {

	// Get gets the handle to the given playbacl ID
	Get(id string) *PlaybackHandle

	// Data gets the playback data
	Data(id string) (PlaybackData, error)

	// Control performs the given operation on the current playback
	Control(id string, op string) error

	// Stop stops the playback
	Stop(id string) error

	// Subscribe subscribes on the playback events
	Subscribe(id string, n ...string) Subscription
}

Playback represents a communication path for interacting with an Asterisk server for playback resources

type PlaybackContinuing

type PlaybackContinuing struct {
	EventData
	Playback PlaybackData `json:"playback"` // Playback control object
}

PlaybackContinuing - "Event showing the continuation of a media playback operation from one media URI to the next in the list."

func (*PlaybackContinuing) GetPlaybackIDs

func (evt *PlaybackContinuing) GetPlaybackIDs() (sx []string)

GetPlaybackIDs gets the playback IDs for the event

type PlaybackData

type PlaybackData struct {
	ID        string `json:"id"` // Unique ID for this playback session
	Language  string `json:"language,omitempty"`
	MediaURI  string `json:"media_uri"`  // URI for the media which is to be played
	State     string `json:"state"`      // State of the playback operation
	TargetURI string `json:"target_uri"` // URI of the channel or bridge on which the media should be played (follows format of 'type':'name')
}

PlaybackData represents the state of a playback

type PlaybackEvent

type PlaybackEvent interface {
	GetPlaybackIDs() []string
}

A PlaybackEvent is an event with one or more playback IDs

type PlaybackFinished

type PlaybackFinished struct {
	EventData
	Playback PlaybackData `json:"playback"` // Playback control object
}

PlaybackFinished - "Event showing the completion of a media playback operation."

func (*PlaybackFinished) Destroyed

func (evt *PlaybackFinished) Destroyed() (playbackID string)

Destroyed returns the playbacK ID that was finished by this event. Used by the proxy to route events to dialogs.

func (*PlaybackFinished) GetPlaybackIDs

func (evt *PlaybackFinished) GetPlaybackIDs() (sx []string)

GetPlaybackIDs gets the playback IDs for the event

type PlaybackHandle

type PlaybackHandle struct {
	// contains filtered or unexported fields
}

PlaybackHandle is the handle for performing playback operations

func NewPlaybackHandle

func NewPlaybackHandle(id string, pb Playback) *PlaybackHandle

NewPlaybackHandle builds a handle to the playback id

func (*PlaybackHandle) Control

func (ph *PlaybackHandle) Control(op string) (err error)

Control performs the given operation

func (*PlaybackHandle) Data

func (ph *PlaybackHandle) Data() (pd PlaybackData, err error)

Data gets the playback data

func (*PlaybackHandle) ID

func (ph *PlaybackHandle) ID() string

ID returns the identifier for the playback

func (*PlaybackHandle) Match

func (ph *PlaybackHandle) Match(e Event) bool

Match returns true if the event matches the playback

func (*PlaybackHandle) Stop

func (ph *PlaybackHandle) Stop() (err error)

Stop stops the playback

func (*PlaybackHandle) Subscribe

func (ph *PlaybackHandle) Subscribe(n ...string) Subscription

Subscribe subscribes the list of channel events

type PlaybackStarted

type PlaybackStarted struct {
	EventData
	Playback PlaybackData `json:"playback"` // Playback control object
}

PlaybackStarted - "Event showing the start of a media playback operation."

func (*PlaybackStarted) Created

func (evt *PlaybackStarted) Created() (playbackID, otherID string)

Created returns the playbacK ID that we created plus the ID that the playback is operating on (a bridge or channel). Used by the proxy to route events to dialogs

func (*PlaybackStarted) GetPlaybackIDs

func (evt *PlaybackStarted) GetPlaybackIDs() (sx []string)

GetPlaybackIDs gets the playback IDs for the event

type Playbacker

type Playbacker interface {
	Playback() Playback
}

Playbacker contains a playback transport

type RawMessage

type RawMessage struct {
	// contains filtered or unexported fields
}

RawMessage contains the raw bytes

func (*RawMessage) DecodeAs

func (m *RawMessage) DecodeAs(v MessageRawer) error

DecodeAs converts the current message to a new message type

func (*RawMessage) GetRaw

func (m *RawMessage) GetRaw() *[]byte

GetRaw gets the raw value of this RawMessage

func (*RawMessage) SetRaw

func (m *RawMessage) SetRaw(raw *[]byte)

SetRaw sets the raw value of this RawMessage

type Recording

type Recording struct {
	Stored StoredRecording
	Live   LiveRecording
}

Recording is a namespace for the recording types

type RecordingEvent

type RecordingEvent interface {
	GetRecordingIDs() []string
}

A RecordingEvent is an event with one or more recording IDs

type RecordingFailed

type RecordingFailed struct {
	EventData
	Recording LiveRecordingData `json:"recording"` // Recording control object
}

RecordingFailed - "Event showing failure of a recording operation."

func (*RecordingFailed) Destroyed

func (evt *RecordingFailed) Destroyed() string

Destroyed returns the item that gets destroyed by this event

func (*RecordingFailed) GetRecordingIDs

func (evt *RecordingFailed) GetRecordingIDs() (sx []string)

GetRecordingIDs gets the recording IDs for the event

type RecordingFinished

type RecordingFinished struct {
	EventData
	Recording LiveRecordingData `json:"recording"` // Recording control object
}

RecordingFinished - "Event showing the completion of a recording operation."

func (*RecordingFinished) Destroyed

func (evt *RecordingFinished) Destroyed() string

Destroyed returns the item that gets destroyed by this event

func (*RecordingFinished) GetRecordingIDs

func (evt *RecordingFinished) GetRecordingIDs() (sx []string)

GetRecordingIDs gets the recording IDs for the event

type RecordingOptions

type RecordingOptions struct {
	// Format is the file format/encoding to which the recording should be stored.
	// This will usually be one of: slin, ulaw, alaw, wav, gsm.
	// If not specified, this will default to slin.
	Format string

	// MaxDuration is the maximum duration of the recording, after which the recording will
	// automatically stop.  If not set, there is no maximum.
	MaxDuration time.Duration

	// MaxSilence is the maximum duration of detected to be found before terminating the recording.
	MaxSilence time.Duration

	// Exists determines what should happen if the given recording already exists.
	// Valid values are: "fail", "overwrite", or "append".
	// If not specified, it will default to "fail"
	Exists string

	// Beep indicates whether a beep should be played to the recorded
	// party at the beginning of the recording.
	Beep bool

	// Terminate indicates whether the recording should be terminated on
	// receipt of a DTMF digit.
	// valid options are: "none", "any", "*", and "#"
	// If not specified, it will default to "none" (never terminate on DTMF).
	Terminate string
}

RecordingOptions describes the set of options available when making a recording.

type RecordingStarted

type RecordingStarted struct {
	EventData
	Recording LiveRecordingData `json:"recording"` // Recording control object
}

RecordingStarted - "Event showing the start of a recording operation."

func (*RecordingStarted) GetRecordingIDs

func (evt *RecordingStarted) GetRecordingIDs() (sx []string)

GetRecordingIDs gets the recording IDs for the event

type Sender

type Sender interface {
	Send(m *Message)
}

A Sender is an entity which can send event bus messages

type SetID

type SetID struct {
	Group string `json:"group"` // group id (not name? why string?)
	User  string `json:"user"`  // user id (not name? why string?)
}

SetID describes a userid/groupid pair

type SnoopOptions

type SnoopOptions struct {
	Direction string // Direction of audio to spy on (in, out, both)
	Whisper   string // Direction of audio to whisper into (in, out, both)
	AppArgs   string // The arguments to pass to the new application.
}

SnoopOptions enumerates the non-required arguments for the snoop operation

type Sound

type Sound interface {

	// List returns available sounds limited by the provided filters.
	// Valid filters are "lang", "format", and nil (no filter)
	List(filters map[string]string) ([]*SoundHandle, error)

	// Get returns a handle pointer to the sound for further interaction
	Get(name string) *SoundHandle

	// Data returns the Sound's data
	Data(name string) (SoundData, error)
}

Sound represents a communication path to the asterisk server for Sound resources

type SoundData

type SoundData struct {
	Formats []FormatLangPair `json:"formats"`
	ID      string           `json:"id"`
	Text    string           `json:"text,omitempty"`
}

SoundData describes a media file which may be played back

type SoundHandle

type SoundHandle struct {
	// contains filtered or unexported fields
}

SoundHandle provides a wrapper to a Sound interface for operations on a specific Sound

func NewSoundHandle

func NewSoundHandle(name string, snd Sound) *SoundHandle

NewSoundHandle creates a new handle to the sound name

func (*SoundHandle) Data

func (sh *SoundHandle) Data() (sd SoundData, err error)

Data retrieves the data for the Sound

func (*SoundHandle) ID

func (sh *SoundHandle) ID() string

ID returns the identifier for the sound

type StasisEnd

type StasisEnd struct {
	EventData
	Channel ChannelData `json:"channel"`
}

StasisEnd - "Notification that a channel has left a Stasis application."

func (*StasisEnd) GetChannelIDs

func (evt *StasisEnd) GetChannelIDs() (sx []string)

GetChannelIDs gets the channel IDs for the event

type StasisStart

type StasisStart struct {
	EventData
	Args           []string    `json:"args"` // Arguments to the application
	Channel        ChannelData `json:"channel"`
	ReplaceChannel ChannelData `json:"replace_channel,omitempty"`
}

StasisStart - "Notification that a channel has entered a Stasis application."

func (*StasisStart) GetChannelIDs

func (evt *StasisStart) GetChannelIDs() (sx []string)

GetChannelIDs gets the channel IDs for the event

type StatusInfo

type StatusInfo struct {
	LastReloadTime DateTime `json:"last_reload_time"`
	StartupTime    DateTime `json:"startup_time"`
}

StatusInfo describes the state of an Asterisk system

type StoredRecording

type StoredRecording interface {

	// List lists the recordings
	List() ([]*StoredRecordingHandle, error)

	// Get gets the Recording by type
	Get(name string) *StoredRecordingHandle

	// data gets the data for the stored recording
	Data(name string) (StoredRecordingData, error)

	// Copy copies the recording to the destination name
	Copy(name string, dest string) (*StoredRecordingHandle, error)

	// Delete deletes the recording
	Delete(name string) error
}

StoredRecording represents a communication path interacting with an Asterisk server for stored recording resources

type StoredRecordingData

type StoredRecordingData struct {
	Format string `json:"format"`
	Name   string `json:"name"`
}

StoredRecordingData is the data for a stored recording

func (StoredRecordingData) ID

func (d StoredRecordingData) ID() string

ID returns the identifier for the stored recording.

type StoredRecordingHandle

type StoredRecordingHandle struct {
	// contains filtered or unexported fields
}

A StoredRecordingHandle is a reference to a stored recording that can be operated on

func NewStoredRecordingHandle

func NewStoredRecordingHandle(name string, s StoredRecording) *StoredRecordingHandle

NewStoredRecordingHandle creates a new stored recording handle

func (*StoredRecordingHandle) Copy

func (s *StoredRecordingHandle) Copy(dest string) (h *StoredRecordingHandle, err error)

Copy copies the stored recording

func (*StoredRecordingHandle) Data

func (s *StoredRecordingHandle) Data() (d StoredRecordingData, err error)

Data gets the data for the stored recording

func (*StoredRecordingHandle) Delete

func (s *StoredRecordingHandle) Delete() (err error)

Delete deletes the recording

func (*StoredRecordingHandle) ID

func (s *StoredRecordingHandle) ID() string

ID returns the identifier for the stored recording

type Subscriber

type Subscriber interface {
	Subscribe(n ...string) Subscription
}

A Subscriber is an entity which can create ARI event subscriptions

type Subscription

type Subscription interface {
	Events() chan Event
	Cancel()
}

A Subscription is a subscription on series of ARI events

type SystemInfo

type SystemInfo struct {
	EntityID string `json:"entity_id"`
	Version  string `json:"version"`
}

SystemInfo describes information about the Asterisk system

type TextMessage

type TextMessage interface {

	// Send() sends a text message to an endpoint
	Send(from, tech, resource, body string, vars map[string]string) error

	// SendByURI sends a text message to an endpoint by free-form URI
	SendByURI(from, to, body string, vars map[string]string) error
}

TextMessage needs some verbiage here

type TextMessageData

type TextMessageData struct {
	Body      string                `json:"body"` // The body (text) of the message
	From      string                `json:"from"` // Technology-specific source URI
	To        string                `json:"to"`   // Technology-specific destination URI
	Variables []TextMessageVariable `json:"variables,omitempty"`
}

TextMessageData describes text message

type TextMessageReceived

type TextMessageReceived struct {
	EventData
	Endpoint EndpointData    `json:"endpoint,omitempty"`
	Message  TextMessageData `json:"message"`
}

TextMessageReceived - "A text message was received from an endpoint."

func (*TextMessageReceived) GetEndpointIDs

func (evt *TextMessageReceived) GetEndpointIDs() (sx []string)

GetEndpointIDs gets the bridge IDs for the event

type TextMessageVariable

type TextMessageVariable struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

TextMessageVariable describes a key-value pair (associated with a text message)

type Variables

type Variables interface {

	// Get returns the value of the given variable
	Get(variable string) (string, error)

	// Set sets the variable
	Set(variable string, value string) error
}

Variables represents a set of variables attached to an entity (Asterisk Server, Channel, etc)

Directories

Path Synopsis
_examples
client
mock
Package mock is a mock client used for unit testing
Package mock is a mock client used for unit testing
ext
audio/audiouri
Package audiouri provides conversions for common sounds to asterisk-supported audio URIs
Package audiouri provides conversions for common sounds to asterisk-supported audio URIs
prompt
Package prompt is the utility section for working with asterisk prompts.
Package prompt is the utility section for working with asterisk prompts.
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL