Documentation ¶
Index ¶
- Variables
- func CodeFromError(err error) int
- func Connect(opts *Options) (ari.Client, error)
- type Application
- func (a *Application) Data(key *ari.Key) (*ari.ApplicationData, error)
- func (a *Application) Get(key *ari.Key) *ari.ApplicationHandle
- func (a *Application) List(filter *ari.Key) (ax []*ari.Key, err error)
- func (a *Application) Subscribe(key *ari.Key, eventSource string) error
- func (a *Application) Unsubscribe(key *ari.Key, eventSource string) error
- type Asterisk
- type AsteriskVariables
- type Bridge
- func (b *Bridge) AddChannel(key *ari.Key, channelID string) (err error)
- func (b *Bridge) Create(key *ari.Key, t string, name string) (bh *ari.BridgeHandle, err error)
- func (b *Bridge) Data(key *ari.Key) (*ari.BridgeData, error)
- func (b *Bridge) Delete(key *ari.Key) (err error)
- func (b *Bridge) Get(key *ari.Key) *ari.BridgeHandle
- func (b *Bridge) List(filter *ari.Key) (bx []*ari.Key, err error)
- func (b *Bridge) MOH(key *ari.Key, class string) error
- func (b *Bridge) Play(key *ari.Key, playbackID string, mediaURI string) (*ari.PlaybackHandle, error)
- func (b *Bridge) Record(key *ari.Key, name string, opts *ari.RecordingOptions) (*ari.LiveRecordingHandle, error)
- func (b *Bridge) RemoveChannel(key *ari.Key, channelID string) (err error)
- func (b *Bridge) StageCreate(key *ari.Key, btype, name string) (*ari.BridgeHandle, error)
- func (b *Bridge) StagePlay(key *ari.Key, playbackID string, mediaURI string) (*ari.PlaybackHandle, error)
- func (b *Bridge) StageRecord(key *ari.Key, name string, opts *ari.RecordingOptions) (*ari.LiveRecordingHandle, error)
- func (b *Bridge) StopMOH(key *ari.Key) error
- func (b *Bridge) Subscribe(key *ari.Key, n ...string) ari.Subscription
- type Channel
- func (c *Channel) Answer(key *ari.Key) error
- func (c *Channel) Busy(key *ari.Key) error
- func (c *Channel) Congestion(key *ari.Key) error
- func (c *Channel) Continue(key *ari.Key, context, extension string, priority int) (err error)
- func (c *Channel) Create(key *ari.Key, req ari.ChannelCreateRequest) (*ari.ChannelHandle, error)
- func (c *Channel) Data(key *ari.Key) (*ari.ChannelData, error)
- func (c *Channel) Dial(key *ari.Key, callingChannelID string, timeout time.Duration) error
- func (c *Channel) Get(key *ari.Key) *ari.ChannelHandle
- func (c *Channel) GetVariable(key *ari.Key, name string) (string, error)
- func (c *Channel) Hangup(key *ari.Key, reason string) error
- func (c *Channel) Hold(key *ari.Key) error
- func (c *Channel) List(filter *ari.Key) (cx []*ari.Key, err error)
- func (c *Channel) MOH(key *ari.Key, class string) error
- func (c *Channel) Mute(key *ari.Key, dir ari.Direction) error
- func (c *Channel) Originate(referenceKey *ari.Key, req ari.OriginateRequest) (*ari.ChannelHandle, error)
- func (c *Channel) Play(key *ari.Key, playbackID string, mediaURI string) (*ari.PlaybackHandle, error)
- func (c *Channel) Record(key *ari.Key, name string, opts *ari.RecordingOptions) (*ari.LiveRecordingHandle, error)
- func (c *Channel) Ring(key *ari.Key) error
- func (c *Channel) SendDTMF(key *ari.Key, dtmf string, opts *ari.DTMFOptions) error
- func (c *Channel) SetVariable(key *ari.Key, name, value string) error
- func (c *Channel) Silence(key *ari.Key) error
- func (c *Channel) Snoop(key *ari.Key, snoopID string, opts *ari.SnoopOptions) (*ari.ChannelHandle, error)
- func (c *Channel) StageOriginate(referenceKey *ari.Key, req ari.OriginateRequest) (*ari.ChannelHandle, error)
- func (c *Channel) StagePlay(key *ari.Key, playbackID string, mediaURI string) (*ari.PlaybackHandle, error)
- func (c *Channel) StageRecord(key *ari.Key, name string, opts *ari.RecordingOptions) (*ari.LiveRecordingHandle, error)
- func (c *Channel) StageSnoop(key *ari.Key, snoopID string, opts *ari.SnoopOptions) (*ari.ChannelHandle, error)
- func (c *Channel) StopHold(key *ari.Key) (err error)
- func (c *Channel) StopMOH(key *ari.Key) error
- func (c *Channel) StopRing(key *ari.Key) error
- func (c *Channel) StopSilence(key *ari.Key) error
- func (c *Channel) Subscribe(key *ari.Key, n ...string) ari.Subscription
- func (c *Channel) Unmute(key *ari.Key, dir ari.Direction) (err error)
- type Client
- func (c *Client) Application() ari.Application
- func (c *Client) ApplicationName() string
- func (c *Client) Asterisk() ari.Asterisk
- func (c *Client) Bridge() ari.Bridge
- func (c *Client) Bus() ari.Bus
- func (c *Client) Channel() ari.Channel
- func (c *Client) Close()
- func (c *Client) Connect() error
- func (c *Client) DeviceState() ari.DeviceState
- func (c *Client) Endpoint() ari.Endpoint
- func (c *Client) LiveRecording() ari.LiveRecording
- func (c *Client) Mailbox() ari.Mailbox
- func (c *Client) Playback() ari.Playback
- func (c *Client) Sound() ari.Sound
- func (c *Client) StoredRecording() ari.StoredRecording
- func (c *Client) TextMessage() ari.TextMessage
- type Config
- type DeviceState
- func (ds *DeviceState) Data(key *ari.Key) (*ari.DeviceStateData, error)
- func (ds *DeviceState) Delete(key *ari.Key) error
- func (ds *DeviceState) Get(key *ari.Key) *ari.DeviceStateHandle
- func (ds *DeviceState) List(filter *ari.Key) (dx []*ari.Key, err error)
- func (ds *DeviceState) Update(key *ari.Key, state string) error
- type Endpoint
- type LiveRecording
- func (lr *LiveRecording) Data(key *ari.Key) (d *ari.LiveRecordingData, err error)
- func (lr *LiveRecording) Get(key *ari.Key) (h *ari.LiveRecordingHandle)
- func (lr *LiveRecording) Mute(key *ari.Key) error
- func (lr *LiveRecording) Pause(key *ari.Key) error
- func (lr *LiveRecording) Resume(key *ari.Key) error
- func (lr *LiveRecording) Scrap(key *ari.Key) error
- func (lr *LiveRecording) Stop(key *ari.Key) error
- func (lr *LiveRecording) Stored(key *ari.Key) *ari.StoredRecordingHandle
- func (lr *LiveRecording) Subscribe(key *ari.Key, n ...string) ari.Subscription
- func (lr *LiveRecording) Unmute(key *ari.Key) error
- type Logging
- func (l *Logging) Create(key *ari.Key, levels string) (*ari.LogHandle, error)
- func (l *Logging) Data(key *ari.Key) (*ari.LogData, error)
- func (l *Logging) Delete(key *ari.Key) (err error)
- func (l *Logging) Get(key *ari.Key) *ari.LogHandle
- func (l *Logging) List(filter *ari.Key) ([]*ari.Key, error)
- func (l *Logging) Rotate(key *ari.Key) (err error)
- type Mailbox
- func (m *Mailbox) Data(key *ari.Key) (*ari.MailboxData, error)
- func (m *Mailbox) Delete(key *ari.Key) error
- func (m *Mailbox) Get(key *ari.Key) *ari.MailboxHandle
- func (m *Mailbox) List(filter *ari.Key) (mx []*ari.Key, err error)
- func (m *Mailbox) Update(key *ari.Key, oldMessages int, newMessages int) error
- type MissingParams
- type Modules
- func (m *Modules) Data(key *ari.Key) (*ari.ModuleData, error)
- func (m *Modules) Get(key *ari.Key) *ari.ModuleHandle
- func (m *Modules) List(filter *ari.Key) (ret []*ari.Key, err error)
- func (m *Modules) Load(key *ari.Key) error
- func (m *Modules) Reload(key *ari.Key) error
- func (m *Modules) Unload(key *ari.Key) error
- type Options
- type Playback
- type RequestError
- type Sound
- type StoredRecording
- func (sr *StoredRecording) Copy(key *ari.Key, dest string) (*ari.StoredRecordingHandle, error)
- func (sr *StoredRecording) Data(key *ari.Key) (*ari.StoredRecordingData, error)
- func (sr *StoredRecording) Delete(key *ari.Key) error
- func (sr *StoredRecording) Get(key *ari.Key) *ari.StoredRecordingHandle
- func (sr *StoredRecording) List(filter *ari.Key) (sx []*ari.Key, err error)
- func (sr *StoredRecording) StageCopy(key *ari.Key, dest string) (*ari.StoredRecordingHandle, error)
- type TextMessage
Constants ¶
This section is empty.
Variables ¶
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)
var MaxIdleConnections = 20
MaxIdleConnections is the maximum number of idle web client connections to maintain.
var RequestTimeout = 2 * time.Second
RequestTimeout describes the maximum amount of time to wait for a response to any request.
Functions ¶
func CodeFromError ¶
CodeFromError extracts and returns the code from an error, or 0 if not found.
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
Application is a native implementation of ARI's Application functions
func (*Application) Data ¶
func (a *Application) Data(key *ari.Key) (*ari.ApplicationData, error)
Data returns the details of a given ARI application Equivalent to GET /applications/{applicationName}
func (*Application) Get ¶
func (a *Application) Get(key *ari.Key) *ari.ApplicationHandle
Get returns a managed handle to an ARI application
func (*Application) Subscribe ¶
func (a *Application) Subscribe(key *ari.Key, eventSource string) error
Subscribe subscribes the given application to an event source Equivalent to POST /applications/{applicationName}/subscription
func (*Application) Unsubscribe ¶
func (a *Application) Unsubscribe(key *ari.Key, eventSource string) error
Unsubscribe unsubscribes (removes a subscription to) a given ARI application from the provided event source Equivalent to DELETE /applications/{applicationName}/subscription
type Asterisk ¶
type Asterisk struct {
// contains filtered or unexported fields
}
Asterisk provides the ARI Asterisk accessors for a native client
func (*Asterisk) Info ¶
Info returns various data about the Asterisk system Equivalent to GET /asterisk/info
func (*Asterisk) Variables ¶
func (a *Asterisk) Variables() ari.AsteriskVariables
Variables returns the variables interface for the Asterisk server
type AsteriskVariables ¶
type AsteriskVariables struct {
// contains filtered or unexported fields
}
AsteriskVariables provides the ARI Variables accessors for server-level variables
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge provides the ARI Bridge accessors for the native client
func (*Bridge) AddChannel ¶
AddChannel adds a channel to a bridge Equivalent to Post /bridges/{id}/addChannel
func (*Bridge) Delete ¶
Delete shuts down a bridge. If any channels are in this bridge, they will be removed and resume whatever they were doing beforehand. This means that the channels themselves are not deleted. Equivalent to DELETE /bridges/{id}
func (*Bridge) Get ¶
func (b *Bridge) Get(key *ari.Key) *ari.BridgeHandle
Get gets the lazy handle for the given bridge id
func (*Bridge) Play ¶
func (b *Bridge) Play(key *ari.Key, playbackID string, mediaURI string) (*ari.PlaybackHandle, error)
Play attempts to play the given mediaURI on the bridge, using the playbackID as the identifier to the created playback handle
func (*Bridge) Record ¶
func (b *Bridge) Record(key *ari.Key, name string, opts *ari.RecordingOptions) (*ari.LiveRecordingHandle, error)
Record attempts to record audio on the bridge, using name as the identifier for the created live recording handle
func (*Bridge) RemoveChannel ¶
RemoveChannel removes the specified channel from a bridge Equivalent to Post /bridges/{id}/removeChannel
func (*Bridge) StageCreate ¶
StageCreate creates a new bridge handle, staged with a bridge `Create` operation.
func (*Bridge) StagePlay ¶
func (b *Bridge) StagePlay(key *ari.Key, playbackID string, mediaURI string) (*ari.PlaybackHandle, error)
StagePlay stages a `Play` operation on the bridge
func (*Bridge) StageRecord ¶
func (b *Bridge) StageRecord(key *ari.Key, name string, opts *ari.RecordingOptions) (*ari.LiveRecordingHandle, error)
StageRecord stages a `Record` opreation
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
Channel provides the ARI Channel accessors for the native client
func (*Channel) Answer ¶
Answer answers a channel, if ringing (TODO: does this return an error if already answered?)
func (*Channel) Busy ¶
Busy sends the busy status code to the channel (TODO: does this play a busy signal too)
func (*Channel) Congestion ¶
Congestion sends the congestion status code to the channel (TODO: does this play a tone?)
func (*Channel) Continue ¶
Continue tells a channel to process to the given ARI context and extension
func (*Channel) Create ¶
func (c *Channel) Create(key *ari.Key, req ari.ChannelCreateRequest) (*ari.ChannelHandle, error)
Create creates a channel and returns the handle. TODO: expand differences between originate and create.
func (*Channel) Get ¶
func (c *Channel) Get(key *ari.Key) *ari.ChannelHandle
Get gets the lazy handle for the given channel
func (*Channel) GetVariable ¶
GetVariable gets the value of the given variable
func (*Channel) Hold ¶
Hold puts a channel on hold (TODO: does this return an error if already on hold?)
func (*Channel) MOH ¶
MOH plays the given music on hold class to the channel TODO: does this error when already playing MOH?
func (*Channel) Mute ¶
Mute mutes a channel in the given direction (TODO: does this return an error if already muted)
func (*Channel) Originate ¶
func (c *Channel) Originate(referenceKey *ari.Key, req ari.OriginateRequest) (*ari.ChannelHandle, error)
Originate originates a channel and returns the handle.
**Note** that referenceKey is completely optional. It is used for placing the new channel onto the correct Asterisk node and for assigning default values for communications parameters such as codecs.
func (*Channel) Play ¶
func (c *Channel) Play(key *ari.Key, playbackID string, mediaURI string) (*ari.PlaybackHandle, error)
Play plays the given media URI on the channel, using the playbackID as the identifier of the created ARI Playback entity
func (*Channel) Record ¶
func (c *Channel) Record(key *ari.Key, name string, opts *ari.RecordingOptions) (*ari.LiveRecordingHandle, error)
Record records audio on the channel, using the name parameter as the name of the created LiveRecording entity.
func (*Channel) Ring ¶
Ring causes a channel to start ringing (TODO: does this return an error if already ringing?)
func (*Channel) SetVariable ¶
SetVariable sets the value of the given channel variable
func (*Channel) Snoop ¶
func (c *Channel) Snoop(key *ari.Key, snoopID string, opts *ari.SnoopOptions) (*ari.ChannelHandle, error)
Snoop snoops on a channel, using the the given snoopID as the new channel handle ID (TODO: confirm and expand description)
func (*Channel) StageOriginate ¶
func (c *Channel) StageOriginate(referenceKey *ari.Key, req ari.OriginateRequest) (*ari.ChannelHandle, error)
StageOriginate creates a new channel handle with a channel originate request staged.
**Note** that referenceKey is completely optional. It is used for placing the new channel onto the correct Asterisk node and for assigning default values for communications parameters such as codecs.
func (*Channel) StagePlay ¶
func (c *Channel) StagePlay(key *ari.Key, playbackID string, mediaURI string) (*ari.PlaybackHandle, error)
StagePlay stages a `Play` operation on the bridge
func (*Channel) StageRecord ¶
func (c *Channel) StageRecord(key *ari.Key, name string, opts *ari.RecordingOptions) (*ari.LiveRecordingHandle, error)
StageRecord stages a `Record` opreation
func (*Channel) StageSnoop ¶
func (c *Channel) StageSnoop(key *ari.Key, snoopID string, opts *ari.SnoopOptions) (*ari.ChannelHandle, error)
StageSnoop creates a new `ChannelHandle` with a `Snoop` operation staged.
func (*Channel) StopHold ¶
StopHold removes a channel from hold (TODO: does this return an error if not on hold)
func (*Channel) StopMOH ¶
StopMOH stops any music on hold playing on the channel (TODO: does this error when no MOH is playing?)
func (*Channel) StopRing ¶
StopRing causes a channel to stop ringing (TODO: does this return an error if not ringing?)
func (*Channel) StopSilence ¶
StopSilence stops the silence on a channel (TODO: does this error when not silenced)
type Client ¶
type Client struct { // opts are the configuration options for the client Options *Options // WSConfig describes the configuration for the websocket connection to Asterisk, from which events will be received. WSConfig *websocket.Config // Connected is a flag indicating whether the Client is connected to Asterisk Connected bool // contains filtered or unexported fields }
Client describes a native ARI client, which connects directly to an Asterisk HTTP-based ARI service.
func New ¶
New creates a new ari.Client. This function should not be used directly unless you need finer control. nolint: gocyclo
func (*Client) Application ¶
func (c *Client) Application() ari.Application
Application returns the ARI Application accessors for this client
func (*Client) ApplicationName ¶
ApplicationName returns the client's ARI Application name
func (*Client) Connect ¶
Connect sets up and maintains and a websocket connection to Asterisk, passing any received events to the Bus
func (*Client) DeviceState ¶
func (c *Client) DeviceState() ari.DeviceState
DeviceState returns the ARI DeviceState accessors for this client
func (*Client) LiveRecording ¶
func (c *Client) LiveRecording() ari.LiveRecording
LiveRecording returns the ARI LiveRecording accessors for this client
func (*Client) StoredRecording ¶
func (c *Client) StoredRecording() ari.StoredRecording
StoredRecording returns the ARI StoredRecording accessors for this client
func (*Client) TextMessage ¶
func (c *Client) TextMessage() ari.TextMessage
TextMessage returns the ARI TextMessage accessors for this client
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config provides the ARI Configuration accessors for a native client
type DeviceState ¶
type DeviceState struct {
// contains filtered or unexported fields
}
DeviceState provides the ARI DeviceState accessors for the native client
func (*DeviceState) Data ¶
func (ds *DeviceState) Data(key *ari.Key) (*ari.DeviceStateData, error)
Data retrieves the current state of the device
func (*DeviceState) Delete ¶
func (ds *DeviceState) Delete(key *ari.Key) error
Delete deletes the device
func (*DeviceState) Get ¶
func (ds *DeviceState) Get(key *ari.Key) *ari.DeviceStateHandle
Get returns the lazy handle for the given device name
type Endpoint ¶
type Endpoint struct {
// contains filtered or unexported fields
}
Endpoint provides the ARI Endpoint accessors for the native client
func (*Endpoint) Get ¶
func (e *Endpoint) Get(key *ari.Key) *ari.EndpointHandle
Get gets a lazy handle for the endpoint entity
type LiveRecording ¶
type LiveRecording struct {
// contains filtered or unexported fields
}
LiveRecording provides the ARI LiveRecording accessors for the native client
func (*LiveRecording) Data ¶
func (lr *LiveRecording) Data(key *ari.Key) (d *ari.LiveRecordingData, err error)
Data retrieves the state of the live recording
func (*LiveRecording) Get ¶
func (lr *LiveRecording) Get(key *ari.Key) (h *ari.LiveRecordingHandle)
Get gets a lazy handle for the live recording name
func (*LiveRecording) Mute ¶
func (lr *LiveRecording) Mute(key *ari.Key) error
Mute mutes the live recording (TODO: does it error if the live recording is already muted)
func (*LiveRecording) Pause ¶
func (lr *LiveRecording) Pause(key *ari.Key) error
Pause pauses the live recording (TODO: does it error if the live recording is already paused)
func (*LiveRecording) Resume ¶
func (lr *LiveRecording) Resume(key *ari.Key) error
Resume resumes the live recording (TODO: does it error if the live recording is already resumed)
func (*LiveRecording) Scrap ¶
func (lr *LiveRecording) Scrap(key *ari.Key) error
Scrap removes a live recording (TODO: describe difference between scrap and delete)
func (*LiveRecording) Stop ¶
func (lr *LiveRecording) Stop(key *ari.Key) error
Stop stops the live recording.
NOTE: if the recording is already stopped, this will return an error.
func (*LiveRecording) Stored ¶
func (lr *LiveRecording) Stored(key *ari.Key) *ari.StoredRecordingHandle
Stored returns the StoredRecording handle for the given LiveRecording
func (*LiveRecording) Subscribe ¶
func (lr *LiveRecording) Subscribe(key *ari.Key, n ...string) ari.Subscription
Subscribe is a shim to enable recording handles to subscribe to their underlying bridge/channel for events. It should not be called directly.
type Logging ¶
type Logging struct {
// contains filtered or unexported fields
}
Logging provides the ARI Logging accessors for a native client
type Mailbox ¶
type Mailbox struct {
// contains filtered or unexported fields
}
Mailbox provides the ARI Mailbox accessors for the native client
func (*Mailbox) Get ¶
func (m *Mailbox) Get(key *ari.Key) *ari.MailboxHandle
Get gets a lazy handle for the mailbox name
type MissingParams ¶
type MissingParams struct { //Message Type string `json:"type"` Params []string `json:"params"` // List of missing parameters which are required }
MissingParams is an error message response emitted when a request does not contain required parameters
type Modules ¶
type Modules struct {
// contains filtered or unexported fields
}
Modules provides the ARI modules accessors for a native client
func (*Modules) Get ¶
func (m *Modules) Get(key *ari.Key) *ari.ModuleHandle
Get obtains a lazy handle to an asterisk module
type Options ¶
type Options struct { // Application is the the name of this ARI application Application string // URL is the root URL of the ARI server (asterisk box). // Default to http://localhost:8088/ari URL string // WebsocketURL is the URL for ARI Websocket events. // Defaults to the events directory of URL, with a protocol of ws. // Usually ws://localhost:8088/ari/events. WebsocketURL string // WebsocketOrigin is the origin to report for the websocket connection. // Defaults to http://localhost/ WebsocketOrigin string // Username for ARI authentication Username string // Password for ARI authentication Password string }
Options describes the options for connecting to a native Asterisk ARI server.
type Playback ¶
type Playback struct {
// contains filtered or unexported fields
}
Playback provides the ARI Playback accessors for the native client
func (*Playback) Control ¶
Control performs the given operation on the current playback. Available operations are:
- restart
- pause
- unpause
- reverse
- forward
func (*Playback) Data ¶
Data returns a playback's details. (Equivalent to GET /playbacks/{playbackID})
func (*Playback) Get ¶
func (a *Playback) Get(key *ari.Key) *ari.PlaybackHandle
Get gets a lazy handle for the given playback identifier
type RequestError ¶
RequestError describes an error with an error Code.
type Sound ¶
type Sound struct {
// contains filtered or unexported fields
}
Sound provides the ARI Sound accessors for the native client
type StoredRecording ¶
type StoredRecording struct {
// contains filtered or unexported fields
}
StoredRecording provides the ARI StoredRecording accessors for the native client
func (*StoredRecording) Copy ¶
func (sr *StoredRecording) Copy(key *ari.Key, dest string) (*ari.StoredRecordingHandle, error)
Copy copies a stored recording and returns the new handle
func (*StoredRecording) Data ¶
func (sr *StoredRecording) Data(key *ari.Key) (*ari.StoredRecordingData, error)
Data retrieves the state of the stored recording
func (*StoredRecording) Delete ¶
func (sr *StoredRecording) Delete(key *ari.Key) error
Delete deletes the stored recording
func (*StoredRecording) Get ¶
func (sr *StoredRecording) Get(key *ari.Key) *ari.StoredRecordingHandle
Get gets a lazy handle for the given stored recording name
func (*StoredRecording) List ¶
List lists the current stored recordings and returns a list of handles
func (*StoredRecording) StageCopy ¶
func (sr *StoredRecording) StageCopy(key *ari.Key, dest string) (*ari.StoredRecordingHandle, error)
StageCopy creates a `StoredRecordingHandle` with a `Copy` operation staged.
type TextMessage ¶
type TextMessage struct {
// contains filtered or unexported fields
}
TextMessage provides the ARI TextMessage accessors for the native client