diff --git a/README.md b/README.md index d84ceb4..15e764c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![build status][build_image]][build] -# node-ari-client +# node-ari-client-plus This module contains the Node.js client library for the Asterisk REST Interface. It builds upon the swagger-js library, providing an improved, Asterisk-specific @@ -11,7 +11,7 @@ API over the API generated by swagger-js. ## Installation ```bash -$ npm install ari-client +$ npm install ari-client-plus ``` ## API @@ -22,14 +22,14 @@ of ARI and to configure a client with all available resources and operations. Callbacks: ```javascript -var client = require('ari-client'); +var client = require('ari-client-plus'); client.connect(url, username, password, function (err, ari) {}) ``` Promises: ```javascript -var client = require('ari-client'); +var client = require('ari-client-plus'); client.connect(url, username, password) .then(function (ari) {}) .catch(function (err) {}); @@ -3423,7 +3423,7 @@ function (err) {} Callbacks: ```javascript -var client = require('ari-client'), +var client = require('ari-client-plus'), util = require('util'); client.connect('http://localhost:8088', 'user', 'secret', client_loaded); @@ -3481,7 +3481,7 @@ function client_loaded (err, ari) { Promises: ```javascript -var client = require('ari-client'), +var client = require('ari-client-plus'), Promise = require('bluebird'), util = require('util'); @@ -3542,7 +3542,7 @@ client.connect('http://localhost:8088', 'user', 'secret') # Testing -To run the mocha tests for ari-client, run the following: +To run the mocha tests for ari-client-plus, run the following: ```bash $ npm test @@ -3565,7 +3565,7 @@ Then run the following to run jshint and mocha tests: $ npm test ``` -jshint will enforce a minimal style guide. It is also a good idea to create unit tests when adding new features to ari-client. +jshint will enforce a minimal style guide. It is also a good idea to create unit tests when adding new features to ari-client-plus. To generate a test coverage report run the following: diff --git a/dev/README.mustache b/dev/README.mustache index 037da4f..d6f5aa6 100644 --- a/dev/README.mustache +++ b/dev/README.mustache @@ -11,7 +11,7 @@ API over the API generated by swagger-js. ## Installation ```bash -$ npm install ari-client +$ npm i ari-client-plus ``` ## API diff --git a/lib/client.js b/lib/client.js index b1eb7e4..f43c2cc 100644 --- a/lib/client.js +++ b/lib/client.js @@ -40,7 +40,7 @@ var _utils = require('./utils.js'); * @prop {Object} _instanceListeners - array of instance objects for * instances that registered for scoped events keyed by event type */ -function Client(baseUrl, user, pass) { +function Client(baseUrl, user, pass, options) { var self = this; events.EventEmitter.call(self); @@ -55,6 +55,10 @@ function Client(baseUrl, user, pass) { * @prop {string} hostname * @prop {string} user - username for ARI instance * @prop {string} pass - password for ARI instance + * @prop {Object} options - options for ARI instance + * @prop {number} options.maxRetries - maximum number of retries + * @prop {number} options.retryDelay - delay between retries + * @prop {number} options.retryMaxDelay - maximum delay between retries */ self._connection = { protocol: parsedUrl.protocol, @@ -63,7 +67,8 @@ function Client(baseUrl, user, pass) { // support optional path prefix in asterisk http.conf prefix: parsedUrl.pathname === '/' ? '' : parsedUrl.pathname, user: user, - pass: pass + pass: pass, + options: options || {}, }; // Keep track of instance event listeners. once true means that the callback @@ -111,20 +116,34 @@ Client.prototype._attachApi = function () { self._connection.prefix ); - request(ariUrl, function (err) { - if (err && - ['ETIMEDOUT', 'ENOTFOUND', 'ECONNREFUSED'].indexOf(err.code) !== -1) { - err.name = 'HostIsNotReachable'; + request({ + url: ariUrl, + auth: { + user: self._connection.user, + pass: self._connection.pass + } + }, function (err, res, body) { + if (err) { + return reject(err); + } - self.emit('APILoadError', err); - reject(err); - } else { - self._swagger = new swagger.SwaggerApi({ - url: ariUrl, - success: swaggerLoaded, - failure: swaggerFailed - }); + if (res?.statusCode === 401) { + const authErr = new Error("ARI Unauthorized (check username/password)"); + self.emit("APILoadError", authErr); + return reject(authErr); } + + if (res?.statusCode >= 400) { + const httpErr = new Error(`ARI HTTP error ${res.statusCode}`); + self.emit("APILoadError", httpErr); + return reject(httpErr); + } + + self._swagger = new swagger.SwaggerApi({ + url: ariUrl, + success: swaggerLoaded, + failure: swaggerFailed + }); }); /** @@ -349,7 +368,9 @@ Client.prototype.start = function (apps, subscribeAll, callback) { } var retry = backoff.create({ - delay: 100 + delay: self._connection.options.retryDelay || 100, + maxDelay: self._connection.options.retryMaxDelay, + maxRetries: self._connection.options.maxRetries, }); connect(); @@ -478,7 +499,9 @@ Client.prototype.start = function (apps, subscribeAll, callback) { processingError = false; // reset backoff handler when we successfully connect retry = backoff.create({ - delay: 100 + delay: self._connection.options.retryDelay || 100, + maxDelay: self._connection.options.retryMaxDelay, + maxRetries: self._connection.options.maxRetries, }); self.emit('WebSocketConnected'); // onced, will not be called when an automatic reconnect succeeds. @@ -594,7 +617,7 @@ Client.prototype.ping = function () { * The callback to be called upon connection * @returns {Q} promise - a promise that will resolve to a client */ -module.exports.connect = function (baseUrl, user, pass, +module.exports.connect = function (baseUrl, user, pass, options, /** * @callback connectCallback * @memberof module:ari-client @@ -603,7 +626,7 @@ module.exports.connect = function (baseUrl, user, pass, */ callback) { - var client = new Client(baseUrl, user, pass); + var client = new Client(baseUrl, user, pass, options); client.setMaxListeners(0); return client._attachApi().asCallback(callback); diff --git a/package.json b/package.json index 8364cb8..51dca98 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "ari-client", - "version": "2.2.0", + "name": "ari-client-plus", + "version": "1.0.10", "description": "JavaScript client for Asterisk REST Interface.", - "homepage": "https://github.com/asterisk/node-ari-client", + "homepage": "https://github.com/mostafaroshdy1/node-ari-client-plus", "keywords": [ "Asterisk", "ARI" @@ -15,7 +15,7 @@ }, "repository": { "type": "git", - "url": "git://github.com/asterisk/node-ari-client" + "url": "git://github.com/mostafaroshdy1/node-ari-client-plus" }, "bugs": { "url": "https://issues.asterisk.org", @@ -32,6 +32,7 @@ "uuid": "^3.0.0", "ws": "^6.0.0" }, + "types":"./types/index.d.ts" , "engines": { "node": ">=8" }, diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..2d82dec --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,6707 @@ +/// + +/** + * Create an instance of Client using the provided connection options and call + * the provided callback once the API has been attached to the Client. + * + * @param baseUrl - The URL to the ARI instance. + * @param user - The username for the ARI instance. + * @param pass - The password for the ARI instance. + * @param [callback] - The callback to be called upon connection. + */ +export function connect( + baseUrl: string, + user: string, + pass: string, + options?: { + retryDelay?: number; + maxRetries?: number; + retryMaxDelay?: number; + }, + callback?: (err: Error, client: Client) => void +): Promise; + +/* This interface is kept for compatibility */ +export interface TextMessageVariable { + key: string; + value: string; +} + +export interface Client extends Resource { + /** + * Creates the WebSocket connection, subscribing to the given apps. + * + * @param apps - Name or array of names of the applications to be started. + * @param [subscribeAll] - Subscribe to all Asterisk events (true/false). + */ + start(apps: string | string[], subscribeAll?: boolean): Promise; + + /** + * Creates the WebSocket connection, subscribing to the given apps. + * + * @param apps - Name or array of names of the applications to be started. + * @param subscribeAll - Subscribe to all Asterisk events (true/false). + * @param callback - The callback to be called after applications have started. + */ + start( + apps: string | string[], + subscribeAll: boolean, + callback: (err: Error, ...args: any[]) => void + ): void; + + /** + * Creates the WebSocket connection, subscribing to the given apps. + * + * @param apps - Name or array of names of the applications to be started. + * @param callback - The callback to be called after applications have started. + */ + start(apps: string | string[], callback: (err: Error, ...args: any[]) => void): void; + + /** + * Closes the WebSocket connection. + */ + stop(): void; + + /** + * Pings the WebSocket. + */ + ping(): void; + + /** + * Available Applications resources. + */ + applications: Applications; + + /** + * Available Asterisk resource. + */ + asterisk: Asterisk; + + /** + * Available Channels resources. + */ + channels: Channels; + + /** + * Available Bridges resources. + */ + bridges: Bridges; + + /** + * Available DeviceStates resources. + */ + deviceStates: DeviceStates; + + /** + * Available Endpoints resources. + */ + endpoints: Endpoints; + + /** + * Available Recordings resources. + */ + recordings: Recordings; + + /** + * Available Mailboxes resources. + */ + mailboxes: Mailboxes; + + /** + * Available Playbacks resources. + */ + playbacks: Playbacks; + + /** + * Available Sounds resources. + */ + sounds: Sounds; + + /** + * Available Events resources. + */ + events: Events; + + /** + * Creates a new Application instance. + */ + Application(id?: string, objValues?: IndexableObject): Application; + + /** + * Creates a new Asterisk instance. + */ + Asterisk(id?: string, objValues?: IndexableObject): Asterisk; + + /** + * Creates a new Channel instance. + */ + Channel(id?: string, objValues?: IndexableObject): Channel; + + /** + * Creates a new Bridge instance. + */ + Bridge(id?: string, objValues?: IndexableObject): Bridge; + + /** + * Creates a new DeviceState instance. + */ + DeviceState(id?: string, objValues?: IndexableObject): DeviceState; + + /** + * Creates a new Endpoint instance. + */ + Endpoint(id?: string, objValues?: IndexableObject): Endpoint; + + /** + * Creates a new LiveRecording instance. + */ + LiveRecording(id?: string, objValues?: IndexableObject): LiveRecording; + + /** + * Creates a new Mailbox instance. + */ + Mailbox(id?: string, objValues?: IndexableObject): Mailbox; + + /** + * Creates a new Playback instance. + */ + Playback(id?: string, objValues?: IndexableObject): Playback; + + /** + * Creates a new Sound instance. + */ + Sound(id?: string, objValues?: IndexableObject): Sound; + + /** + * Creates a new StoredRecording instance. + */ + StoredRecording(id?: string, objValues?: IndexableObject): StoredRecording; +} + +export interface Containers { + [key: string]: any; +} +export interface IndexableObject { + [key: string]: any; +} +/* Event Types */ +export type WebSocketConnectedEventType = "WebSocketConnected"; +export type WebSocketReconnectingEventType = "WebSocketReconnecting"; +export type WebSocketMaxRetriesEventType = "WebSocketMaxRetries"; +export type PongEventType = "pong"; +export type APILoadErrorEventType = "APILoadError"; +export type EventsEventType = "Events"; +export type MessageEventType = "Message"; +export type MissingParamsEventType = "MissingParams"; +export type EventEventType = "Event"; +export type ContactInfoEventType = "ContactInfo"; +export type PeerEventType = "Peer"; +export type DeviceStateChangedEventType = "DeviceStateChanged"; +export type PlaybackStartedEventType = "PlaybackStarted"; +export type PlaybackContinuingEventType = "PlaybackContinuing"; +export type PlaybackFinishedEventType = "PlaybackFinished"; +export type RecordingStartedEventType = "RecordingStarted"; +export type RecordingFinishedEventType = "RecordingFinished"; +export type RecordingFailedEventType = "RecordingFailed"; +export type ApplicationMoveFailedEventType = "ApplicationMoveFailed"; +export type ApplicationReplacedEventType = "ApplicationReplaced"; +export type BridgeCreatedEventType = "BridgeCreated"; +export type BridgeDestroyedEventType = "BridgeDestroyed"; +export type BridgeMergedEventType = "BridgeMerged"; +export type BridgeVideoSourceChangedEventType = "BridgeVideoSourceChanged"; +export type BridgeBlindTransferEventType = "BridgeBlindTransfer"; +export type BridgeAttendedTransferEventType = "BridgeAttendedTransfer"; +export type ChannelCreatedEventType = "ChannelCreated"; +export type ChannelDestroyedEventType = "ChannelDestroyed"; +export type ChannelEnteredBridgeEventType = "ChannelEnteredBridge"; +export type ChannelLeftBridgeEventType = "ChannelLeftBridge"; +export type ChannelStateChangeEventType = "ChannelStateChange"; +export type ChannelDtmfReceivedEventType = "ChannelDtmfReceived"; +export type ChannelDialplanEventType = "ChannelDialplan"; +export type ChannelCallerIdEventType = "ChannelCallerId"; +export type ChannelUsereventEventType = "ChannelUserevent"; +export type ChannelHangupRequestEventType = "ChannelHangupRequest"; +export type ChannelVarsetEventType = "ChannelVarset"; +export type ChannelHoldEventType = "ChannelHold"; +export type ChannelUnholdEventType = "ChannelUnhold"; +export type ChannelTalkingStartedEventType = "ChannelTalkingStarted"; +export type ChannelTalkingFinishedEventType = "ChannelTalkingFinished"; +export type ContactStatusChangeEventType = "ContactStatusChange"; +export type PeerStatusChangeEventType = "PeerStatusChange"; +export type EndpointStateChangeEventType = "EndpointStateChange"; +export type DialEventType = "Dial"; +export type StasisEndEventType = "StasisEnd"; +export type StasisStartEventType = "StasisStart"; +export type TextMessageReceivedEventType = "TextMessageReceived"; +export type ChannelConnectedLineEventType = "ChannelConnectedLine"; +export type AnyEventType = + | WebSocketConnectedEventType + | WebSocketReconnectingEventType + | WebSocketMaxRetriesEventType + | PongEventType + | APILoadErrorEventType + | EventsEventType + | MessageEventType + | MissingParamsEventType + | EventEventType + | ContactInfoEventType + | PeerEventType + | DeviceStateChangedEventType + | PlaybackStartedEventType + | PlaybackContinuingEventType + | PlaybackFinishedEventType + | RecordingStartedEventType + | RecordingFinishedEventType + | RecordingFailedEventType + | ApplicationMoveFailedEventType + | ApplicationReplacedEventType + | BridgeCreatedEventType + | BridgeDestroyedEventType + | BridgeMergedEventType + | BridgeVideoSourceChangedEventType + | BridgeBlindTransferEventType + | BridgeAttendedTransferEventType + | ChannelCreatedEventType + | ChannelDestroyedEventType + | ChannelEnteredBridgeEventType + | ChannelLeftBridgeEventType + | ChannelStateChangeEventType + | ChannelDtmfReceivedEventType + | ChannelDialplanEventType + | ChannelCallerIdEventType + | ChannelUsereventEventType + | ChannelHangupRequestEventType + | ChannelVarsetEventType + | ChannelHoldEventType + | ChannelUnholdEventType + | ChannelTalkingStartedEventType + | ChannelTalkingFinishedEventType + | ContactStatusChangeEventType + | PeerStatusChangeEventType + | EndpointStateChangeEventType + | DialEventType + | StasisEndEventType + | StasisStartEventType + | TextMessageReceivedEventType + | ChannelConnectedLineEventType; +/* Event Classes */ +export interface Events { + /** + * WebSocket connection for events. + * + * @param params.app - Applications to subscribe to. + * @param [params.subscribeAll] - Subscribe to all Asterisk events. If provided, the applications listed will be subscribed to all events, effectively disabling the application specific + * subscriptions. Default is false. + */ + eventWebsocket( + params: { app: string | string[]; subscribeAll?: boolean | undefined }, + callback: (err: Error, message: Message) => void + ): void; + + /** + * WebSocket connection for events. + * + * @param params.app - Applications to subscribe to. + * @param [params.subscribeAll] - Subscribe to all Asterisk events. If provided, the applications listed will be subscribed to all events, effectively disabling the application specific + * subscriptions. Default is false. + */ + eventWebsocket(params: { + app: string | string[]; + subscribeAll?: boolean | undefined; + }): Promise; + + /** + * Generate a user event. + * + * @param params.eventName - Event name. + * @param params.application - The name of the application that will receive this event. + * @param [params.source] - URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}/{resource}, deviceState:{deviceName}. + * @param [params.variables] - The "variables" key in the body object holds custom key/value pairs to add to the user event. Ex. { "variables": { "key": "value" } }. + */ + userEvent( + params: { + eventName: string; + application: string; + source?: string | string[] | undefined; + variables?: Containers | undefined; + }, + callback: (err: Error) => void + ): void; + + /** + * Generate a user event. + * + * @param params.eventName - Event name. + * @param params.application - The name of the application that will receive this event. + * @param [params.source] - URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}/{resource}, deviceState:{deviceName}. + * @param [params.variables] - The "variables" key in the body object holds custom key/value pairs to add to the user event. Ex. { "variables": { "key": "value" } }. + */ + userEvent(params: { + eventName: string; + application: string; + source?: string | string[] | undefined; + variables?: Containers | undefined; + }): Promise; +} +export interface Message { + /** + * Indicates the type of this message. + */ + type: string; + + /** + * The unique ID for the Asterisk instance that raised this event. + */ + asterisk_id?: string | undefined; +} +export interface MissingParams extends Message { + /** + * A list of the missing parameters. + */ + params: string | string[]; +} +export interface Event extends Message { + /** + * Name of the application receiving the event. + */ + application: string; + + /** + * ISO 8601 date/time at which this event was created. + */ + timestamp: string; +} +export interface ContactInfo { + /** + * The location of the contact. + */ + uri: string; + + /** + * The current status of the contact. + */ + contact_status: string; + + /** + * The Address of Record this contact belongs to. + */ + aor: string; + + /** + * Current round trip time, in microseconds, for the contact. + */ + roundtrip_usec?: string | undefined; +} +export interface Peer { + /** + * The current state of the peer. Note that the values of the status are dependent on the underlying peer technology. + */ + peer_status: string; + + /** + * An optional reason associated with the change in peer_status. + */ + cause?: string | undefined; + + /** + * The IP address of the peer. + */ + address?: string | undefined; + + /** + * The port of the peer. + */ + port?: string | undefined; + + /** + * The last known time the peer was contacted. + */ + time?: string | undefined; +} +export interface DeviceStateChanged extends Event { + /** + * Device state object. + */ + device_state: DeviceState; +} +export interface PlaybackStarted extends Event { + /** + * Playback control object. + */ + playback: Playback; +} +export interface PlaybackContinuing extends Event { + /** + * Playback control object. + */ + playback: Playback; +} +export interface PlaybackFinished extends Event { + /** + * Playback control object. + */ + playback: Playback; +} +export interface RecordingStarted extends Event { + /** + * Recording control object. + */ + recording: LiveRecording; +} +export interface RecordingFinished extends Event { + /** + * Recording control object. + */ + recording: LiveRecording; +} +export interface RecordingFailed extends Event { + /** + * Recording control object. + */ + recording: LiveRecording; +} +export interface ApplicationMoveFailed extends Event { + /** + * Channel. + */ + channel: Channel; + + /** + * Destination. + */ + destination: string; + + /** + * Arguments to the application. + */ + args: string | string[]; +} +export interface BridgeCreated extends Event { + /** + * Bridge. + */ + bridge: Bridge; +} +export interface BridgeDestroyed extends Event { + /** + * Bridge. + */ + bridge: Bridge; +} +export interface BridgeMerged extends Event { + /** + * Bridge. + */ + bridge: Bridge; + + /** + * Bridge_from. + */ + bridge_from: Bridge; +} +export interface BridgeVideoSourceChanged extends Event { + /** + * Bridge. + */ + bridge: Bridge; + + /** + * Old_video_source_id. + */ + old_video_source_id?: string | undefined; +} +export interface BridgeBlindTransfer extends Event { + /** + * The channel performing the blind transfer. + */ + channel: Channel; + + /** + * The channel that is replacing transferer when the transferee(s) can not be transferred directly. + */ + replace_channel?: Channel | undefined; + + /** + * The channel that is being transferred. + */ + transferee?: Channel | undefined; + + /** + * The extension transferred to. + */ + exten: string; + + /** + * The context transferred to. + */ + context: string; + + /** + * The result of the transfer attempt. + */ + result: string; + + /** + * Whether the transfer was externally initiated or not. + */ + is_external: boolean; + + /** + * The bridge being transferred. + */ + bridge: Bridge; +} +export interface BridgeAttendedTransfer extends Event { + /** + * First leg of the transferer. + */ + transferer_first_leg: Channel; + + /** + * Second leg of the transferer. + */ + transferer_second_leg: Channel; + + /** + * The channel that is replacing transferer_first_leg in the swap. + */ + replace_channel?: Channel | undefined; + + /** + * The channel that is being transferred. + */ + transferee?: Channel | undefined; + + /** + * The channel that is being transferred to. + */ + transfer_target?: Channel | undefined; + + /** + * The result of the transfer attempt. + */ + result: string; + + /** + * Whether the transfer was externally initiated or not. + */ + is_external: boolean; + + /** + * Bridge the transferer first leg is in. + */ + transferer_first_leg_bridge: Bridge; + + /** + * Bridge the transferer second leg is in. + */ + transferer_second_leg_bridge: Bridge; + + /** + * How the transfer was accomplished. + */ + destination_type: string; + + /** + * Bridge that survived the merge result. + */ + destination_bridge: string; + + /** + * Application that has been transferred into. + */ + destination_application: string; + + /** + * First leg of a link transfer result. + */ + destination_link_first_leg: Channel; + + /** + * Second leg of a link transfer result. + */ + destination_link_second_leg: Channel; + + /** + * Transferer channel that survived the threeway result. + */ + destination_threeway_channel: Channel; + + /** + * Bridge that survived the threeway result. + */ + destination_threeway_bridge: Bridge; +} +export interface ChannelCreated extends Event { + /** + * Channel. + */ + channel: Channel; +} +export interface ChannelDestroyed extends Event { + /** + * Integer representation of the cause of the hangup. + */ + cause: number; + + /** + * Text representation of the cause of the hangup. + */ + cause_txt: string; + + /** + * Channel. + */ + channel: Channel; +} +export interface ChannelEnteredBridge extends Event { + /** + * Bridge. + */ + bridge: Bridge; + + /** + * Channel. + */ + channel: Channel; +} +export interface ChannelLeftBridge extends Event { + /** + * Bridge. + */ + bridge: Bridge; + + /** + * Channel. + */ + channel: Channel; +} +export interface ChannelStateChange extends Event { + /** + * Channel. + */ + channel: Channel; +} +export interface ChannelDtmfReceived extends Event { + /** + * DTMF digit received (0-9, A-E, # or *). + */ + digit: string; + + /** + * Number of milliseconds DTMF was received. + */ + duration_ms: number; + + /** + * The channel on which DTMF was received. + */ + channel: Channel; +} +export interface ChannelDialplan extends Event { + /** + * The channel that changed dialplan location. + */ + channel: Channel; + + /** + * The application about to be executed. + */ + dialplan_app: string; + + /** + * The data to be passed to the application. + */ + dialplan_app_data: string; +} +export interface ChannelCallerId extends Event { + /** + * The integer representation of the Caller Presentation value. + */ + caller_presentation: number; + + /** + * The text representation of the Caller Presentation value. + */ + caller_presentation_txt: string; + + /** + * The channel that changed Caller ID. + */ + channel: Channel; +} +export interface ChannelUserevent extends Event { + /** + * The name of the user event. + */ + eventname: string; + + /** + * A channel that is signaled with the user event. + */ + channel?: Channel | undefined; + + /** + * A bridge that is signaled with the user event. + */ + bridge?: Bridge | undefined; + + /** + * A endpoint that is signaled with the user event. + */ + endpoint?: Endpoint | undefined; + + /** + * Custom Userevent data. + */ + userevent: IndexableObject; +} +export interface ChannelHangupRequest extends Event { + /** + * Integer representation of the cause of the hangup. + */ + cause: number; + + /** + * Whether the hangup request was a soft hangup request. + */ + soft: boolean; + + /** + * The channel on which the hangup was requested. + */ + channel: Channel; +} +export interface ChannelVarset extends Event { + /** + * The variable that changed. + */ + variable: string; + + /** + * The new value of the variable. + */ + value: string; + + /** + * The channel on which the variable was set. If missing, the variable is a global variable. + */ + channel?: Channel | undefined; +} +export interface ChannelHold extends Event { + /** + * The channel that initiated the hold event. + */ + channel: Channel; + + /** + * The music on hold class that the initiator requested. + */ + musicclass?: string | undefined; +} +export interface ChannelUnhold extends Event { + /** + * The channel that initiated the unhold event. + */ + channel: Channel; +} +export interface ChannelTalkingStarted extends Event { + /** + * The channel on which talking started. + */ + channel: Channel; +} +export interface ChannelTalkingFinished extends Event { + /** + * The channel on which talking completed. + */ + channel: Channel; + + /** + * The length of time, in milliseconds, that talking was detected on the channel. + */ + duration: number; +} +export interface ContactStatusChange extends Event { + /** + * Endpoint. + */ + endpoint: Endpoint; + + /** + * Contact_info. + */ + contact_info: ContactInfo; +} +export interface PeerStatusChange extends Event { + /** + * Endpoint. + */ + endpoint: Endpoint; + + /** + * Peer. + */ + peer: Peer; +} +export interface EndpointStateChange extends Event { + /** + * Endpoint. + */ + endpoint: Endpoint; +} +export interface Dial extends Event { + /** + * The calling channel. + */ + caller?: Channel | undefined; + + /** + * The dialed channel. + */ + peer: Channel; + + /** + * Forwarding target requested by the original dialed channel. + */ + forward?: string | undefined; + + /** + * Channel that the caller has been forwarded to. + */ + forwarded?: Channel | undefined; + + /** + * The dial string for calling the peer channel. + */ + dialstring?: string | undefined; + + /** + * Current status of the dialing attempt to the peer. + */ + dialstatus: string; +} +export interface StasisEnd extends Event { + /** + * Channel. + */ + channel: Channel; +} +export interface StasisStart extends Event { + /** + * Arguments to the application. + */ + args: string | string[]; + + /** + * Channel. + */ + channel: Channel; + + /** + * Replace_channel. + */ + replace_channel?: Channel | undefined; +} +export interface TextMessageReceived extends Event { + /** + * Message. + */ + message: TextMessage; + + /** + * Endpoint. + */ + endpoint?: Endpoint | undefined; +} +export interface ChannelConnectedLine extends Event { + /** + * The channel whose connected line has changed. + */ + channel: Channel; +} +export interface Resource { + /** + * The ARI client instance. + */ + _client: Client; + + /** + * Error emitted when WebSocket reconnection attempts exceeded MaxRetries. + */ + // tslint:disable-next-line:unified-signatures + on(type: WebSocketMaxRetriesEventType, listener: (err: Error) => void): void; + + /** + * Error emitted when the WebSocket is reconnecting. + */ + // tslint:disable-next-line:unified-signatures + on(type: WebSocketReconnectingEventType, listener: (err: Error) => void): void; + + /** + * Event emitted when the WebSocket is connected. + */ + // tslint:disable-next-line:unified-signatures + on(type: WebSocketConnectedEventType, listener: () => void): void; + + /** + * Event emitted when a WebSocket pong is received. + */ + // tslint:disable-next-line:unified-signatures + on(type: PongEventType, listener: () => void): void; + + /** + * Error event sent when connection to API fails. + */ + // tslint:disable-next-line:unified-signatures + on(type: APILoadErrorEventType, listener: (err: Error) => void): void; + + /** + * Base type for errors and events. + */ + on(event: MessageEventType, callback: (event: Message, instances: Message) => void): void; + + /** + * Error event sent when required params are missing. + */ + on( + event: MissingParamsEventType, + callback: (event: MissingParams, instances: MissingParams) => void + ): void; + + /** + * Base type for asynchronous events from Asterisk. + */ + on(event: EventEventType, callback: (event: Event, instances: Event) => void): void; + + /** + * Detailed information about a contact on an endpoint. + */ + on( + event: ContactInfoEventType, + callback: (event: ContactInfo, instances: ContactInfo) => void + ): void; + + /** + * Detailed information about a remote peer that communicates with Asterisk. + */ + on(event: PeerEventType, callback: (event: Peer, instances: Peer) => void): void; + + /** + * Notification that a device state has changed. + */ + on( + event: DeviceStateChangedEventType, + callback: (event: DeviceStateChanged, devicestate: DeviceState) => void + ): void; + + /** + * Event showing the start of a media playback operation. + */ + on( + event: PlaybackStartedEventType, + callback: (event: PlaybackStarted, playback: Playback) => void + ): void; + + /** + * Event showing the continuation of a media playback operation from one media URI to the next in the list. + */ + on( + event: PlaybackContinuingEventType, + callback: (event: PlaybackContinuing, playback: Playback) => void + ): void; + + /** + * Event showing the completion of a media playback operation. + */ + on( + event: PlaybackFinishedEventType, + callback: (event: PlaybackFinished, playback: Playback) => void + ): void; + + /** + * Event showing the start of a recording operation. + */ + on( + event: RecordingStartedEventType, + callback: (event: RecordingStarted, liverecording: LiveRecording) => void + ): void; + + /** + * Event showing the completion of a recording operation. + */ + on( + event: RecordingFinishedEventType, + callback: (event: RecordingFinished, liverecording: LiveRecording) => void + ): void; + + /** + * Event showing failure of a recording operation. + */ + on( + event: RecordingFailedEventType, + callback: (event: RecordingFailed, liverecording: LiveRecording) => void + ): void; + + /** + * Notification that trying to move a channel to another Stasis application failed. + */ + on( + event: ApplicationMoveFailedEventType, + callback: (event: ApplicationMoveFailed, channel: Channel) => void + ): void; + + /** + * 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. + */ + on(event: ApplicationReplacedEventType, callback: (event: Event) => void): void; + + /** + * Notification that a bridge has been created. + */ + on( + event: BridgeCreatedEventType, + callback: (event: BridgeCreated, bridge: Bridge) => void + ): void; + + /** + * Notification that a bridge has been destroyed. + */ + on( + event: BridgeDestroyedEventType, + callback: (event: BridgeDestroyed, bridge: Bridge) => void + ): void; + + /** + * Notification that one bridge has merged into another. + */ + on(event: BridgeMergedEventType, callback: (event: BridgeMerged, bridge: Bridge) => void): void; + + /** + * Notification that the source of video in a bridge has changed. + */ + on( + event: BridgeVideoSourceChangedEventType, + callback: (event: BridgeVideoSourceChanged, bridge: Bridge) => void + ): void; + + /** + * Notification that a blind transfer has occurred. + */ + on( + event: BridgeBlindTransferEventType, + callback: (event: BridgeBlindTransfer, instances: BridgeBlindTransfer) => void + ): void; + + /** + * Notification that an attended transfer has occurred. + */ + on( + event: BridgeAttendedTransferEventType, + callback: (event: BridgeAttendedTransfer, instances: BridgeAttendedTransfer) => void + ): void; + + /** + * Notification that a channel has been created. + */ + on( + event: ChannelCreatedEventType, + callback: (event: ChannelCreated, channel: Channel) => void + ): void; + + /** + * Notification that a channel has been destroyed. + */ + on( + event: ChannelDestroyedEventType, + callback: (event: ChannelDestroyed, channel: Channel) => void + ): void; + + /** + * Notification that a channel has entered a bridge. + */ + on( + event: ChannelEnteredBridgeEventType, + callback: (event: ChannelEnteredBridge, instances: ChannelEnteredBridge) => void + ): void; + + /** + * Notification that a channel has left a bridge. + */ + on( + event: ChannelLeftBridgeEventType, + callback: (event: ChannelLeftBridge, instances: ChannelLeftBridge) => void + ): void; + + /** + * Notification of a channels state change. + */ + on( + event: ChannelStateChangeEventType, + callback: (event: ChannelStateChange, channel: Channel) => void + ): void; + + /** + * DTMF received on a channel. This event is sent when the DTMF ends. There is no notification about the start of DTMF. + */ + on( + event: ChannelDtmfReceivedEventType, + callback: (event: ChannelDtmfReceived, channel: Channel) => void + ): void; + + /** + * Channel changed location in the dialplan. + */ + on( + event: ChannelDialplanEventType, + callback: (event: ChannelDialplan, channel: Channel) => void + ): void; + + /** + * Channel changed Caller ID. + */ + on( + event: ChannelCallerIdEventType, + callback: (event: ChannelCallerId, channel: Channel) => void + ): void; + + /** + * User-generated event with additional user-defined fields in the object. + */ + on( + event: ChannelUsereventEventType, + callback: (event: ChannelUserevent, instances: ChannelUserevent) => void + ): void; + + /** + * A hangup was requested on the channel. + */ + on( + event: ChannelHangupRequestEventType, + callback: (event: ChannelHangupRequest, channel: Channel) => void + ): void; + + /** + * Channel variable changed. + */ + on( + event: ChannelVarsetEventType, + callback: (event: ChannelVarset, channel: Channel) => void + ): void; + + /** + * A channel initiated a media hold. + */ + on(event: ChannelHoldEventType, callback: (event: ChannelHold, channel: Channel) => void): void; + + /** + * A channel initiated a media unhold. + */ + on( + event: ChannelUnholdEventType, + callback: (event: ChannelUnhold, channel: Channel) => void + ): void; + + /** + * Talking was detected on the channel. + */ + on( + event: ChannelTalkingStartedEventType, + callback: (event: ChannelTalkingStarted, channel: Channel) => void + ): void; + + /** + * Talking is no longer detected on the channel. + */ + on( + event: ChannelTalkingFinishedEventType, + callback: (event: ChannelTalkingFinished, channel: Channel) => void + ): void; + + /** + * The state of a contact on an endpoint has changed. + */ + on( + event: ContactStatusChangeEventType, + callback: (event: ContactStatusChange, endpoint: Endpoint) => void + ): void; + + /** + * The state of a peer associated with an endpoint has changed. + */ + on( + event: PeerStatusChangeEventType, + callback: (event: PeerStatusChange, endpoint: Endpoint) => void + ): void; + + /** + * Endpoint state changed. + */ + on( + event: EndpointStateChangeEventType, + callback: (event: EndpointStateChange, endpoint: Endpoint) => void + ): void; + + /** + * Dialing state has changed. + */ + on(event: DialEventType, callback: (event: Dial, channel: Channel) => void): void; + + /** + * Notification that a channel has left a Stasis application. + */ + on(event: StasisEndEventType, callback: (event: StasisEnd, channel: Channel) => void): void; + + /** + * Notification that a channel has entered a Stasis application. + */ + on(event: StasisStartEventType, callback: (event: StasisStart, channel: Channel) => void): void; + + /** + * A text message was received from an endpoint. + */ + on( + event: TextMessageReceivedEventType, + callback: (event: TextMessageReceived, endpoint: Endpoint) => void + ): void; + + /** + * Channel changed Connected Line. + */ + on( + event: ChannelConnectedLineEventType, + callback: (event: ChannelConnectedLine, channel: Channel) => void + ): void; + + /** + * Error emitted when WebSocket reconnection attempts exceeded MaxRetries. + */ + // tslint:disable-next-line:unified-signatures + once(type: WebSocketMaxRetriesEventType, listener: (err: Error) => void): void; + + /** + * Error emitted when the WebSocket is reconnecting. + */ + // tslint:disable-next-line:unified-signatures + once(type: WebSocketReconnectingEventType, listener: (err: Error) => void): void; + + /** + * Event emitted when the WebSocket is connected. + */ + // tslint:disable-next-line:unified-signatures + once(type: WebSocketConnectedEventType, listener: () => void): void; + + /** + * Event emitted when a WebSocket pong is received. + */ + // tslint:disable-next-line:unified-signatures + once(type: PongEventType, listener: () => void): void; + + /** + * Error event sent when connection to API fails. + */ + // tslint:disable-next-line:unified-signatures + once(type: APILoadErrorEventType, listener: (err: Error) => void): void; + + /** + * Base type for errors and events. + */ + once(event: MessageEventType, callback: (event: Message, instances: Message) => void): void; + + /** + * Error event sent when required params are missing. + */ + once( + event: MissingParamsEventType, + callback: (event: MissingParams, instances: MissingParams) => void + ): void; + + /** + * Base type for asynchronous events from Asterisk. + */ + once(event: EventEventType, callback: (event: Event, instances: Event) => void): void; + + /** + * Detailed information about a contact on an endpoint. + */ + once( + event: ContactInfoEventType, + callback: (event: ContactInfo, instances: ContactInfo) => void + ): void; + + /** + * Detailed information about a remote peer that communicates with Asterisk. + */ + once(event: PeerEventType, callback: (event: Peer, instances: Peer) => void): void; + + /** + * Notification that a device state has changed. + */ + once( + event: DeviceStateChangedEventType, + callback: (event: DeviceStateChanged, devicestate: DeviceState) => void + ): void; + + /** + * Event showing the start of a media playback operation. + */ + once( + event: PlaybackStartedEventType, + callback: (event: PlaybackStarted, playback: Playback) => void + ): void; + + /** + * Event showing the continuation of a media playback operation from one media URI to the next in the list. + */ + once( + event: PlaybackContinuingEventType, + callback: (event: PlaybackContinuing, playback: Playback) => void + ): void; + + /** + * Event showing the completion of a media playback operation. + */ + once( + event: PlaybackFinishedEventType, + callback: (event: PlaybackFinished, playback: Playback) => void + ): void; + + /** + * Event showing the start of a recording operation. + */ + once( + event: RecordingStartedEventType, + callback: (event: RecordingStarted, liverecording: LiveRecording) => void + ): void; + + /** + * Event showing the completion of a recording operation. + */ + once( + event: RecordingFinishedEventType, + callback: (event: RecordingFinished, liverecording: LiveRecording) => void + ): void; + + /** + * Event showing failure of a recording operation. + */ + once( + event: RecordingFailedEventType, + callback: (event: RecordingFailed, liverecording: LiveRecording) => void + ): void; + + /** + * Notification that trying to move a channel to another Stasis application failed. + */ + once( + event: ApplicationMoveFailedEventType, + callback: (event: ApplicationMoveFailed, channel: Channel) => void + ): void; + + /** + * 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. + */ + once(event: ApplicationReplacedEventType, callback: (event: Event) => void): void; + + /** + * Notification that a bridge has been created. + */ + once( + event: BridgeCreatedEventType, + callback: (event: BridgeCreated, bridge: Bridge) => void + ): void; + + /** + * Notification that a bridge has been destroyed. + */ + once( + event: BridgeDestroyedEventType, + callback: (event: BridgeDestroyed, bridge: Bridge) => void + ): void; + + /** + * Notification that one bridge has merged into another. + */ + once( + event: BridgeMergedEventType, + callback: (event: BridgeMerged, bridge: Bridge) => void + ): void; + + /** + * Notification that the source of video in a bridge has changed. + */ + once( + event: BridgeVideoSourceChangedEventType, + callback: (event: BridgeVideoSourceChanged, bridge: Bridge) => void + ): void; + + /** + * Notification that a blind transfer has occurred. + */ + once( + event: BridgeBlindTransferEventType, + callback: (event: BridgeBlindTransfer, instances: BridgeBlindTransfer) => void + ): void; + + /** + * Notification that an attended transfer has occurred. + */ + once( + event: BridgeAttendedTransferEventType, + callback: (event: BridgeAttendedTransfer, instances: BridgeAttendedTransfer) => void + ): void; + + /** + * Notification that a channel has been created. + */ + once( + event: ChannelCreatedEventType, + callback: (event: ChannelCreated, channel: Channel) => void + ): void; + + /** + * Notification that a channel has been destroyed. + */ + once( + event: ChannelDestroyedEventType, + callback: (event: ChannelDestroyed, channel: Channel) => void + ): void; + + /** + * Notification that a channel has entered a bridge. + */ + once( + event: ChannelEnteredBridgeEventType, + callback: (event: ChannelEnteredBridge, instances: ChannelEnteredBridge) => void + ): void; + + /** + * Notification that a channel has left a bridge. + */ + once( + event: ChannelLeftBridgeEventType, + callback: (event: ChannelLeftBridge, instances: ChannelLeftBridge) => void + ): void; + + /** + * Notification of a channels state change. + */ + once( + event: ChannelStateChangeEventType, + callback: (event: ChannelStateChange, channel: Channel) => void + ): void; + + /** + * DTMF received on a channel. This event is sent when the DTMF ends. There is no notification about the start of DTMF. + */ + once( + event: ChannelDtmfReceivedEventType, + callback: (event: ChannelDtmfReceived, channel: Channel) => void + ): void; + + /** + * Channel changed location in the dialplan. + */ + once( + event: ChannelDialplanEventType, + callback: (event: ChannelDialplan, channel: Channel) => void + ): void; + + /** + * Channel changed Caller ID. + */ + once( + event: ChannelCallerIdEventType, + callback: (event: ChannelCallerId, channel: Channel) => void + ): void; + + /** + * User-generated event with additional user-defined fields in the object. + */ + once( + event: ChannelUsereventEventType, + callback: (event: ChannelUserevent, instances: ChannelUserevent) => void + ): void; + + /** + * A hangup was requested on the channel. + */ + once( + event: ChannelHangupRequestEventType, + callback: (event: ChannelHangupRequest, channel: Channel) => void + ): void; + + /** + * Channel variable changed. + */ + once( + event: ChannelVarsetEventType, + callback: (event: ChannelVarset, channel: Channel) => void + ): void; + + /** + * A channel initiated a media hold. + */ + once( + event: ChannelHoldEventType, + callback: (event: ChannelHold, channel: Channel) => void + ): void; + + /** + * A channel initiated a media unhold. + */ + once( + event: ChannelUnholdEventType, + callback: (event: ChannelUnhold, channel: Channel) => void + ): void; + + /** + * Talking was detected on the channel. + */ + once( + event: ChannelTalkingStartedEventType, + callback: (event: ChannelTalkingStarted, channel: Channel) => void + ): void; + + /** + * Talking is no longer detected on the channel. + */ + once( + event: ChannelTalkingFinishedEventType, + callback: (event: ChannelTalkingFinished, channel: Channel) => void + ): void; + + /** + * The state of a contact on an endpoint has changed. + */ + once( + event: ContactStatusChangeEventType, + callback: (event: ContactStatusChange, endpoint: Endpoint) => void + ): void; + + /** + * The state of a peer associated with an endpoint has changed. + */ + once( + event: PeerStatusChangeEventType, + callback: (event: PeerStatusChange, endpoint: Endpoint) => void + ): void; + + /** + * Endpoint state changed. + */ + once( + event: EndpointStateChangeEventType, + callback: (event: EndpointStateChange, endpoint: Endpoint) => void + ): void; + + /** + * Dialing state has changed. + */ + once(event: DialEventType, callback: (event: Dial, channel: Channel) => void): void; + + /** + * Notification that a channel has left a Stasis application. + */ + once(event: StasisEndEventType, callback: (event: StasisEnd, channel: Channel) => void): void; + + /** + * Notification that a channel has entered a Stasis application. + */ + once( + event: StasisStartEventType, + callback: (event: StasisStart, channel: Channel) => void + ): void; + + /** + * A text message was received from an endpoint. + */ + once( + event: TextMessageReceivedEventType, + callback: (event: TextMessageReceived, endpoint: Endpoint) => void + ): void; + + /** + * Channel changed Connected Line. + */ + once( + event: ChannelConnectedLineEventType, + callback: (event: ChannelConnectedLine, channel: Channel) => void + ): void; + + /** + * Error emitted when WebSocket reconnection attempts exceeded MaxRetries. + */ + // tslint:disable-next-line:unified-signatures + addListener(type: WebSocketMaxRetriesEventType, listener: (err: Error) => void): void; + + /** + * Error emitted when the WebSocket is reconnecting. + */ + // tslint:disable-next-line:unified-signatures + addListener(type: WebSocketReconnectingEventType, listener: (err: Error) => void): void; + + /** + * Event emitted when the WebSocket is connected. + */ + // tslint:disable-next-line:unified-signatures + addListener(type: WebSocketConnectedEventType, listener: () => void): void; + + /** + * Event emitted when a WebSocket pong is received. + */ + // tslint:disable-next-line:unified-signatures + addListener(type: PongEventType, listener: () => void): void; + + /** + * Error event sent when connection to API fails. + */ + // tslint:disable-next-line:unified-signatures + addListener(type: APILoadErrorEventType, listener: (err: Error) => void): void; + + /** + * Base type for errors and events. + */ + addListener( + event: MessageEventType, + callback: (event: Message, instances: Message) => void + ): void; + + /** + * Error event sent when required params are missing. + */ + addListener( + event: MissingParamsEventType, + callback: (event: MissingParams, instances: MissingParams) => void + ): void; + + /** + * Base type for asynchronous events from Asterisk. + */ + addListener(event: EventEventType, callback: (event: Event, instances: Event) => void): void; + + /** + * Detailed information about a contact on an endpoint. + */ + addListener( + event: ContactInfoEventType, + callback: (event: ContactInfo, instances: ContactInfo) => void + ): void; + + /** + * Detailed information about a remote peer that communicates with Asterisk. + */ + addListener(event: PeerEventType, callback: (event: Peer, instances: Peer) => void): void; + + /** + * Notification that a device state has changed. + */ + addListener( + event: DeviceStateChangedEventType, + callback: (event: DeviceStateChanged, devicestate: DeviceState) => void + ): void; + + /** + * Event showing the start of a media playback operation. + */ + addListener( + event: PlaybackStartedEventType, + callback: (event: PlaybackStarted, playback: Playback) => void + ): void; + + /** + * Event showing the continuation of a media playback operation from one media URI to the next in the list. + */ + addListener( + event: PlaybackContinuingEventType, + callback: (event: PlaybackContinuing, playback: Playback) => void + ): void; + + /** + * Event showing the completion of a media playback operation. + */ + addListener( + event: PlaybackFinishedEventType, + callback: (event: PlaybackFinished, playback: Playback) => void + ): void; + + /** + * Event showing the start of a recording operation. + */ + addListener( + event: RecordingStartedEventType, + callback: (event: RecordingStarted, liverecording: LiveRecording) => void + ): void; + + /** + * Event showing the completion of a recording operation. + */ + addListener( + event: RecordingFinishedEventType, + callback: (event: RecordingFinished, liverecording: LiveRecording) => void + ): void; + + /** + * Event showing failure of a recording operation. + */ + addListener( + event: RecordingFailedEventType, + callback: (event: RecordingFailed, liverecording: LiveRecording) => void + ): void; + + /** + * Notification that trying to move a channel to another Stasis application failed. + */ + addListener( + event: ApplicationMoveFailedEventType, + callback: (event: ApplicationMoveFailed, channel: Channel) => void + ): void; + + /** + * 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. + */ + addListener(event: ApplicationReplacedEventType, callback: (event: Event) => void): void; + + /** + * Notification that a bridge has been created. + */ + addListener( + event: BridgeCreatedEventType, + callback: (event: BridgeCreated, bridge: Bridge) => void + ): void; + + /** + * Notification that a bridge has been destroyed. + */ + addListener( + event: BridgeDestroyedEventType, + callback: (event: BridgeDestroyed, bridge: Bridge) => void + ): void; + + /** + * Notification that one bridge has merged into another. + */ + addListener( + event: BridgeMergedEventType, + callback: (event: BridgeMerged, bridge: Bridge) => void + ): void; + + /** + * Notification that the source of video in a bridge has changed. + */ + addListener( + event: BridgeVideoSourceChangedEventType, + callback: (event: BridgeVideoSourceChanged, bridge: Bridge) => void + ): void; + + /** + * Notification that a blind transfer has occurred. + */ + addListener( + event: BridgeBlindTransferEventType, + callback: (event: BridgeBlindTransfer, instances: BridgeBlindTransfer) => void + ): void; + + /** + * Notification that an attended transfer has occurred. + */ + addListener( + event: BridgeAttendedTransferEventType, + callback: (event: BridgeAttendedTransfer, instances: BridgeAttendedTransfer) => void + ): void; + + /** + * Notification that a channel has been created. + */ + addListener( + event: ChannelCreatedEventType, + callback: (event: ChannelCreated, channel: Channel) => void + ): void; + + /** + * Notification that a channel has been destroyed. + */ + addListener( + event: ChannelDestroyedEventType, + callback: (event: ChannelDestroyed, channel: Channel) => void + ): void; + + /** + * Notification that a channel has entered a bridge. + */ + addListener( + event: ChannelEnteredBridgeEventType, + callback: (event: ChannelEnteredBridge, instances: ChannelEnteredBridge) => void + ): void; + + /** + * Notification that a channel has left a bridge. + */ + addListener( + event: ChannelLeftBridgeEventType, + callback: (event: ChannelLeftBridge, instances: ChannelLeftBridge) => void + ): void; + + /** + * Notification of a channels state change. + */ + addListener( + event: ChannelStateChangeEventType, + callback: (event: ChannelStateChange, channel: Channel) => void + ): void; + + /** + * DTMF received on a channel. This event is sent when the DTMF ends. There is no notification about the start of DTMF. + */ + addListener( + event: ChannelDtmfReceivedEventType, + callback: (event: ChannelDtmfReceived, channel: Channel) => void + ): void; + + /** + * Channel changed location in the dialplan. + */ + addListener( + event: ChannelDialplanEventType, + callback: (event: ChannelDialplan, channel: Channel) => void + ): void; + + /** + * Channel changed Caller ID. + */ + addListener( + event: ChannelCallerIdEventType, + callback: (event: ChannelCallerId, channel: Channel) => void + ): void; + + /** + * User-generated event with additional user-defined fields in the object. + */ + addListener( + event: ChannelUsereventEventType, + callback: (event: ChannelUserevent, instances: ChannelUserevent) => void + ): void; + + /** + * A hangup was requested on the channel. + */ + addListener( + event: ChannelHangupRequestEventType, + callback: (event: ChannelHangupRequest, channel: Channel) => void + ): void; + + /** + * Channel variable changed. + */ + addListener( + event: ChannelVarsetEventType, + callback: (event: ChannelVarset, channel: Channel) => void + ): void; + + /** + * A channel initiated a media hold. + */ + addListener( + event: ChannelHoldEventType, + callback: (event: ChannelHold, channel: Channel) => void + ): void; + + /** + * A channel initiated a media unhold. + */ + addListener( + event: ChannelUnholdEventType, + callback: (event: ChannelUnhold, channel: Channel) => void + ): void; + + /** + * Talking was detected on the channel. + */ + addListener( + event: ChannelTalkingStartedEventType, + callback: (event: ChannelTalkingStarted, channel: Channel) => void + ): void; + + /** + * Talking is no longer detected on the channel. + */ + addListener( + event: ChannelTalkingFinishedEventType, + callback: (event: ChannelTalkingFinished, channel: Channel) => void + ): void; + + /** + * The state of a contact on an endpoint has changed. + */ + addListener( + event: ContactStatusChangeEventType, + callback: (event: ContactStatusChange, endpoint: Endpoint) => void + ): void; + + /** + * The state of a peer associated with an endpoint has changed. + */ + addListener( + event: PeerStatusChangeEventType, + callback: (event: PeerStatusChange, endpoint: Endpoint) => void + ): void; + + /** + * Endpoint state changed. + */ + addListener( + event: EndpointStateChangeEventType, + callback: (event: EndpointStateChange, endpoint: Endpoint) => void + ): void; + + /** + * Dialing state has changed. + */ + addListener(event: DialEventType, callback: (event: Dial, channel: Channel) => void): void; + + /** + * Notification that a channel has left a Stasis application. + */ + addListener( + event: StasisEndEventType, + callback: (event: StasisEnd, channel: Channel) => void + ): void; + + /** + * Notification that a channel has entered a Stasis application. + */ + addListener( + event: StasisStartEventType, + callback: (event: StasisStart, channel: Channel) => void + ): void; + + /** + * A text message was received from an endpoint. + */ + addListener( + event: TextMessageReceivedEventType, + callback: (event: TextMessageReceived, endpoint: Endpoint) => void + ): void; + + /** + * Channel changed Connected Line. + */ + addListener( + event: ChannelConnectedLineEventType, + callback: (event: ChannelConnectedLine, channel: Channel) => void + ): void; + + /** + * Removes the event listener for the specified event type. + * @param event - The event type. + * @param handler - The event listener function. + */ + removeListener(event: AnyEventType, handler: (...args: any[]) => void): void; + + /** + * Removes all listeners of the specified event type. + * @param [event] - The event type. + */ + removeAllListeners(event: AnyEventType): void; +} +export interface Applications { + /** + * List all applications. + */ + list(callback: (err: Error, applications: Application[]) => void): void; + + /** + * List all applications. + */ + list(): Promise; + + /** + * Get details of an application. + * + * @param params.applicationName - Applications name. + */ + get( + params: { applicationName: string }, + callback: (err: Error, application: Application) => void + ): void; + + /** + * Get details of an application. + * + * @param params.applicationName - Applications name. + */ + get(params: { applicationName: string }): Promise; + + /** + * Subscribe an application to a event source. + * Returns the state of the application after the subscriptions have changed. + * + * @param params.applicationName - Applications name. + * @param params.eventSource - URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}[/{resource}], deviceState:{deviceName}. + */ + subscribe( + params: { applicationName: string; eventSource: string | string[] }, + callback: (err: Error, application: Application) => void + ): void; + + /** + * Subscribe an application to a event source. + * Returns the state of the application after the subscriptions have changed. + * + * @param params.applicationName - Applications name. + * @param params.eventSource - URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}[/{resource}], deviceState:{deviceName}. + */ + subscribe(params: { + applicationName: string; + eventSource: string | string[]; + }): Promise; + + /** + * Unsubscribe an application from an event source. + * Returns the state of the application after the subscriptions have changed. + * + * @param params.applicationName - Applications name. + * @param params.eventSource - URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}[/{resource}], deviceState:{deviceName}. + */ + unsubscribe( + params: { applicationName: string; eventSource: string | string[] }, + callback: (err: Error, application: Application) => void + ): void; + + /** + * Unsubscribe an application from an event source. + * Returns the state of the application after the subscriptions have changed. + * + * @param params.applicationName - Applications name. + * @param params.eventSource - URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}[/{resource}], deviceState:{deviceName}. + */ + unsubscribe(params: { + applicationName: string; + eventSource: string | string[]; + }): Promise; + + /** + * Filter application events types. + * Allowed and/or disallowed event type filtering can be done. The body (parameter) should specify a JSON key/value object that describes the type of event filtering needed. One, or + * both of the following keys can be designated: "allowed" - Specifies an allowed list of event types "disallowed" - Specifies a disallowed list of event types Further, each of those + * keys value should be a JSON array that holds zero, or more JSON key/value objects. Each of these objects must contain the following key with an associated value: "type" - The + * type name of the event to filter The value must be the string name (case sensitive) of the event type that needs filtering. For example: { "allowed": [ { "type": "StasisStart" }, + * { "type": "StasisEnd" } ] } As this specifies only an allowed list, then only those two event type messages are sent to the application. No other event messages are sent. The following + * rules apply: * If the body is empty, both the allowed and disallowed filters are set empty. * If both list types are given then both are set to their respective values (note, + * specifying an empty array for a given type sets that type to empty). * If only one list type is given then only that type is set. The other type is not updated. * An empty "allowed" + * list means all events are allowed. * An empty "disallowed" list means no events are disallowed. * Disallowed events take precedence over allowed events if the event type + * is specified in both lists. + * + * @param params.applicationName - Applications name. + * @param [params.filter] - Specify which event types to allow/disallow. + */ + filter( + params: { applicationName: string; filter?: IndexableObject | undefined }, + callback: (err: Error, application: Application) => void + ): void; + + /** + * Filter application events types. + * Allowed and/or disallowed event type filtering can be done. The body (parameter) should specify a JSON key/value object that describes the type of event filtering needed. One, or + * both of the following keys can be designated: "allowed" - Specifies an allowed list of event types "disallowed" - Specifies a disallowed list of event types Further, each of those + * keys value should be a JSON array that holds zero, or more JSON key/value objects. Each of these objects must contain the following key with an associated value: "type" - The + * type name of the event to filter The value must be the string name (case sensitive) of the event type that needs filtering. For example: { "allowed": [ { "type": "StasisStart" }, + * { "type": "StasisEnd" } ] } As this specifies only an allowed list, then only those two event type messages are sent to the application. No other event messages are sent. The following + * rules apply: * If the body is empty, both the allowed and disallowed filters are set empty. * If both list types are given then both are set to their respective values (note, + * specifying an empty array for a given type sets that type to empty). * If only one list type is given then only that type is set. The other type is not updated. * An empty "allowed" + * list means all events are allowed. * An empty "disallowed" list means no events are disallowed. * Disallowed events take precedence over allowed events if the event type + * is specified in both lists. + * + * @param params.applicationName - Applications name. + * @param [params.filter] - Specify which event types to allow/disallow. + */ + filter(params: { + applicationName: string; + filter?: IndexableObject | undefined; + }): Promise; +} +export interface Application extends Resource { + /** + * Name of this application. + */ + name: string; + + /** + * Ids for channels subscribed to. + */ + channel_ids: string | string[]; + + /** + * Ids for bridges subscribed to. + */ + bridge_ids: string | string[]; + + /** + * {tech}/{resource} for endpoints subscribed to. + */ + endpoint_ids: string | string[]; + + /** + * Names of the devices subscribed to. + */ + device_names: string | string[]; + + /** + * Event types sent to the application. + */ + events_allowed: IndexableObject | IndexableObject[]; + + /** + * Event types not sent to the application. + */ + events_disallowed: IndexableObject | IndexableObject[]; + + /** + * List all applications. + */ + list(callback: (err: Error, applications: Application[]) => void): void; + + /** + * List all applications. + */ + list(): Promise; + + /** + * Get details of an application. + */ + get(callback: (err: Error, application: Application) => void): void; + + /** + * Get details of an application. + */ + get(): Promise; + + /** + * Subscribe an application to a event source. + * Returns the state of the application after the subscriptions have changed. + * + * @param params.eventSource - URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}[/{resource}], deviceState:{deviceName}. + */ + subscribe( + params: { eventSource: string | string[] }, + callback: (err: Error, application: Application) => void + ): void; + + /** + * Subscribe an application to a event source. + * Returns the state of the application after the subscriptions have changed. + * + * @param params.eventSource - URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}[/{resource}], deviceState:{deviceName}. + */ + subscribe(params: { eventSource: string | string[] }): Promise; + + /** + * Unsubscribe an application from an event source. + * Returns the state of the application after the subscriptions have changed. + * + * @param params.eventSource - URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}[/{resource}], deviceState:{deviceName}. + */ + unsubscribe( + params: { eventSource: string | string[] }, + callback: (err: Error, application: Application) => void + ): void; + + /** + * Unsubscribe an application from an event source. + * Returns the state of the application after the subscriptions have changed. + * + * @param params.eventSource - URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}[/{resource}], deviceState:{deviceName}. + */ + unsubscribe(params: { eventSource: string | string[] }): Promise; + + /** + * Filter application events types. + * Allowed and/or disallowed event type filtering can be done. The body (parameter) should specify a JSON key/value object that describes the type of event filtering needed. One, or + * both of the following keys can be designated: "allowed" - Specifies an allowed list of event types "disallowed" - Specifies a disallowed list of event types Further, each of those + * keys value should be a JSON array that holds zero, or more JSON key/value objects. Each of these objects must contain the following key with an associated value: "type" - The + * type name of the event to filter The value must be the string name (case sensitive) of the event type that needs filtering. For example: { "allowed": [ { "type": "StasisStart" }, + * { "type": "StasisEnd" } ] } As this specifies only an allowed list, then only those two event type messages are sent to the application. No other event messages are sent. The following + * rules apply: * If the body is empty, both the allowed and disallowed filters are set empty. * If both list types are given then both are set to their respective values (note, + * specifying an empty array for a given type sets that type to empty). * If only one list type is given then only that type is set. The other type is not updated. * An empty "allowed" + * list means all events are allowed. * An empty "disallowed" list means no events are disallowed. * Disallowed events take precedence over allowed events if the event type + * is specified in both lists. + * + * @param [params.filter] - Specify which event types to allow/disallow. + */ + filter( + params: { filter?: IndexableObject | undefined }, + callback: (err: Error, application: Application) => void + ): void; + + /** + * Filter application events types. + * Allowed and/or disallowed event type filtering can be done. The body (parameter) should specify a JSON key/value object that describes the type of event filtering needed. One, or + * both of the following keys can be designated: "allowed" - Specifies an allowed list of event types "disallowed" - Specifies a disallowed list of event types Further, each of those + * keys value should be a JSON array that holds zero, or more JSON key/value objects. Each of these objects must contain the following key with an associated value: "type" - The + * type name of the event to filter The value must be the string name (case sensitive) of the event type that needs filtering. For example: { "allowed": [ { "type": "StasisStart" }, + * { "type": "StasisEnd" } ] } As this specifies only an allowed list, then only those two event type messages are sent to the application. No other event messages are sent. The following + * rules apply: * If the body is empty, both the allowed and disallowed filters are set empty. * If both list types are given then both are set to their respective values (note, + * specifying an empty array for a given type sets that type to empty). * If only one list type is given then only that type is set. The other type is not updated. * An empty "allowed" + * list means all events are allowed. * An empty "disallowed" list means no events are disallowed. * Disallowed events take precedence over allowed events if the event type + * is specified in both lists. + */ + filter(callback: (err: Error, application: Application) => void): void; + + /** + * Filter application events types. + * Allowed and/or disallowed event type filtering can be done. The body (parameter) should specify a JSON key/value object that describes the type of event filtering needed. One, or + * both of the following keys can be designated: "allowed" - Specifies an allowed list of event types "disallowed" - Specifies a disallowed list of event types Further, each of those + * keys value should be a JSON array that holds zero, or more JSON key/value objects. Each of these objects must contain the following key with an associated value: "type" - The + * type name of the event to filter The value must be the string name (case sensitive) of the event type that needs filtering. For example: { "allowed": [ { "type": "StasisStart" }, + * { "type": "StasisEnd" } ] } As this specifies only an allowed list, then only those two event type messages are sent to the application. No other event messages are sent. The following + * rules apply: * If the body is empty, both the allowed and disallowed filters are set empty. * If both list types are given then both are set to their respective values (note, + * specifying an empty array for a given type sets that type to empty). * If only one list type is given then only that type is set. The other type is not updated. * An empty "allowed" + * list means all events are allowed. * An empty "disallowed" list means no events are disallowed. * Disallowed events take precedence over allowed events if the event type + * is specified in both lists. + * + * @param [params.filter] - Specify which event types to allow/disallow. + */ + filter(params?: { filter?: IndexableObject | undefined }): Promise; +} +export interface Asterisk { + /** + * Retrieve a dynamic configuration object. + * + * @param params.configClass - The configuration class containing dynamic configuration objects. + * @param params.objectType - The type of configuration object to retrieve. + * @param params.id - The unique identifier of the object to retrieve. + */ + getObject( + params: { configClass: string; objectType: string; id: string }, + callback: (err: Error, configtuples: ConfigTuple[]) => void + ): void; + + /** + * Retrieve a dynamic configuration object. + * + * @param params.configClass - The configuration class containing dynamic configuration objects. + * @param params.objectType - The type of configuration object to retrieve. + * @param params.id - The unique identifier of the object to retrieve. + */ + getObject(params: { + configClass: string; + objectType: string; + id: string; + }): Promise; + + /** + * Create or update a dynamic configuration object. + * + * @param params.configClass - The configuration class containing dynamic configuration objects. + * @param params.objectType - The type of configuration object to create or update. + * @param params.id - The unique identifier of the object to create or update. + * @param [params.fields] - The body object should have a value that is a list of ConfigTuples, which provide the fields to update. Ex. [ { "attribute": "directmedia", "value": "false" } ]. + */ + updateObject( + params: { + configClass: string; + objectType: string; + id: string; + fields?: Containers | undefined; + }, + callback: (err: Error, configtuples: ConfigTuple[]) => void + ): void; + + /** + * Create or update a dynamic configuration object. + * + * @param params.configClass - The configuration class containing dynamic configuration objects. + * @param params.objectType - The type of configuration object to create or update. + * @param params.id - The unique identifier of the object to create or update. + * @param [params.fields] - The body object should have a value that is a list of ConfigTuples, which provide the fields to update. Ex. [ { "attribute": "directmedia", "value": "false" } ]. + */ + updateObject(params: { + configClass: string; + objectType: string; + id: string; + fields?: Containers | undefined; + }): Promise; + + /** + * Delete a dynamic configuration object. + * + * @param params.configClass - The configuration class containing dynamic configuration objects. + * @param params.objectType - The type of configuration object to delete. + * @param params.id - The unique identifier of the object to delete. + */ + deleteObject( + params: { configClass: string; objectType: string; id: string }, + callback: (err: Error) => void + ): void; + + /** + * Delete a dynamic configuration object. + * + * @param params.configClass - The configuration class containing dynamic configuration objects. + * @param params.objectType - The type of configuration object to delete. + * @param params.id - The unique identifier of the object to delete. + */ + deleteObject(params: { configClass: string; objectType: string; id: string }): Promise; + + /** + * Gets Asterisk system information. + * + * @param [params.only] - Filter information returned. + */ + getInfo( + params: { only?: string | string[] | undefined }, + callback: (err: Error, asteriskinfo: AsteriskInfo) => void + ): void; + + /** + * Gets Asterisk system information. + */ + getInfo(callback: (err: Error, asteriskinfo: AsteriskInfo) => void): void; + + /** + * Gets Asterisk system information. + * + * @param [params.only] - Filter information returned. + */ + getInfo(params?: { only?: string | string[] | undefined }): Promise; + + /** + * Response pong message. + */ + ping(callback: (err: Error, asteriskping: AsteriskPing) => void): void; + + /** + * Response pong message. + */ + ping(): Promise; + + /** + * List Asterisk modules. + */ + listModules(callback: (err: Error, modules: Module[]) => void): void; + + /** + * List Asterisk modules. + */ + listModules(): Promise; + + /** + * Get Asterisk module information. + * + * @param params.moduleName - Modules name. + */ + getModule(params: { moduleName: string }, callback: (err: Error, module: Module) => void): void; + + /** + * Get Asterisk module information. + * + * @param params.moduleName - Modules name. + */ + getModule(params: { moduleName: string }): Promise; + + /** + * Load an Asterisk module. + * + * @param params.moduleName - Modules name. + */ + loadModule(params: { moduleName: string }, callback: (err: Error) => void): void; + + /** + * Load an Asterisk module. + * + * @param params.moduleName - Modules name. + */ + loadModule(params: { moduleName: string }): Promise; + + /** + * Unload an Asterisk module. + * + * @param params.moduleName - Modules name. + */ + unloadModule(params: { moduleName: string }, callback: (err: Error) => void): void; + + /** + * Unload an Asterisk module. + * + * @param params.moduleName - Modules name. + */ + unloadModule(params: { moduleName: string }): Promise; + + /** + * Reload an Asterisk module. + * + * @param params.moduleName - Modules name. + */ + reloadModule(params: { moduleName: string }, callback: (err: Error) => void): void; + + /** + * Reload an Asterisk module. + * + * @param params.moduleName - Modules name. + */ + reloadModule(params: { moduleName: string }): Promise; + + /** + * Gets Asterisk log channel information. + */ + listLogChannels(callback: (err: Error, logchannels: LogChannel[]) => void): void; + + /** + * Gets Asterisk log channel information. + */ + listLogChannels(): Promise; + + /** + * Adds a log channel. + * + * @param params.logChannelName - The log channel to add. + * @param params.configuration - levels of the log channel. + */ + addLog( + params: { logChannelName: string; configuration: string }, + callback: (err: Error) => void + ): void; + + /** + * Adds a log channel. + * + * @param params.logChannelName - The log channel to add. + * @param params.configuration - levels of the log channel. + */ + addLog(params: { logChannelName: string; configuration: string }): Promise; + + /** + * Deletes a log channel. + * + * @param params.logChannelName - Log channels name. + */ + deleteLog(params: { logChannelName: string }, callback: (err: Error) => void): void; + + /** + * Deletes a log channel. + * + * @param params.logChannelName - Log channels name. + */ + deleteLog(params: { logChannelName: string }): Promise; + + /** + * Rotates a log channel. + * + * @param params.logChannelName - Log channels name. + */ + rotateLog(params: { logChannelName: string }, callback: (err: Error) => void): void; + + /** + * Rotates a log channel. + * + * @param params.logChannelName - Log channels name. + */ + rotateLog(params: { logChannelName: string }): Promise; + + /** + * Get the value of a global variable. + * + * @param params.variable - The variable to get. + */ + getGlobalVar( + params: { variable: string }, + callback: (err: Error, variable: Variable) => void + ): void; + + /** + * Get the value of a global variable. + * + * @param params.variable - The variable to get. + */ + getGlobalVar(params: { variable: string }): Promise; + + /** + * Set the value of a global variable. + * + * @param params.variable - The variable to set. + * @param [params.value] - The value to set the variable to. + */ + setGlobalVar( + params: { variable: string; value?: string | undefined }, + callback: (err: Error) => void + ): void; + + /** + * Set the value of a global variable. + * + * @param params.variable - The variable to set. + * @param [params.value] - The value to set the variable to. + */ + setGlobalVar(params: { variable: string; value?: string | undefined }): Promise; +} +export interface BuildInfo { + /** + * OS Asterisk was built on. + */ + os: string; + + /** + * Kernel version Asterisk was built on. + */ + kernel: string; + + /** + * Compile time options, or empty string if default. + */ + options: string; + + /** + * Machine architecture (x86_64, i686, ppc, etc.). + */ + machine: string; + + /** + * Date and time when Asterisk was built. + */ + date: string; + + /** + * Username that build Asterisk. + */ + user: string; +} +export interface SystemInfo { + /** + * Asterisk version. + */ + version: string; + + /** + * Entity_id. + */ + entity_id: string; +} +export interface SetId { + /** + * Effective user id. + */ + user: string; + + /** + * Effective group id. + */ + group: string; +} +export interface ConfigInfo { + /** + * Asterisk system name. + */ + name: string; + + /** + * Default language for media playback. + */ + default_language: string; + + /** + * Maximum number of simultaneous channels. + */ + max_channels?: number | undefined; + + /** + * Maximum number of open file handles (files, sockets). + */ + max_open_files?: number | undefined; + + /** + * Maximum load avg on system. + */ + max_load?: number | undefined; + + /** + * Effective user/group id for running Asterisk. + */ + setid: SetId; +} +export interface StatusInfo { + /** + * ISO 8601 date/time when Asterisk was started. + */ + startup_time: string; + + /** + * ISO 8601 date/time when Asterisk was last reloaded. + */ + last_reload_time: string; +} +export interface AsteriskInfo { + /** + * Info about how Asterisk was built. + */ + build?: BuildInfo | undefined; + + /** + * Info about the system running Asterisk. + */ + system?: SystemInfo | undefined; + + /** + * Info about Asterisk configuration. + */ + config?: ConfigInfo | undefined; + + /** + * Info about Asterisk status. + */ + status?: StatusInfo | undefined; +} +export interface AsteriskPing { + /** + * Asterisk id info. + */ + asterisk_id: string; + + /** + * Always string value is pong. + */ + ping: string; + + /** + * The timestamp string of request received time. + */ + timestamp: string; +} +export interface Module { + /** + * The name of this module. + */ + name: string; + + /** + * The description of this module. + */ + description: string; + + /** + * The number of times this module is being used. + */ + use_count: number; + + /** + * The running status of this module. + */ + status: string; + + /** + * The support state of this module. + */ + support_level: string; +} +export interface LogChannel { + /** + * The log channel path. + */ + channel: string; + + /** + * Types of logs for the log channel. + */ + type: string; + + /** + * Whether or not a log type is enabled. + */ + status: string; + + /** + * The various log levels. + */ + configuration: string; +} +export interface Variable { + /** + * The value of the variable requested. + */ + value: string; +} +export interface ConfigTuple { + /** + * A configuration object attribute. + */ + attribute: string; + + /** + * The value for the attribute. + */ + value: string; +} +export interface Bridges { + /** + * List all active bridges in Asterisk. + */ + list(callback: (err: Error, bridges: Bridge[]) => void): void; + + /** + * List all active bridges in Asterisk. + */ + list(): Promise; + + /** + * Create a new bridge. + * This bridge persists until it has been shut down, or Asterisk has been shut down. + * + * @param [params.type] - Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media, video_sfu). + * @param [params.bridgeId] - Unique ID to give to the bridge being created. + * @param [params.name] - Name to give to the bridge being created. + */ + create( + params: { + type?: string | undefined; + bridgeId?: string | undefined; + name?: string | undefined; + }, + callback: (err: Error, bridge: Bridge) => void + ): void; + + /** + * Create a new bridge. + * This bridge persists until it has been shut down, or Asterisk has been shut down. + */ + create(callback: (err: Error, bridge: Bridge) => void): void; + + /** + * Create a new bridge. + * This bridge persists until it has been shut down, or Asterisk has been shut down. + * + * @param [params.type] - Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media, video_sfu). + * @param [params.bridgeId] - Unique ID to give to the bridge being created. + * @param [params.name] - Name to give to the bridge being created. + */ + create(params?: { + type?: string | undefined; + bridgeId?: string | undefined; + name?: string | undefined; + }): Promise; + + /** + * Create a new bridge or updates an existing one. + * This bridge persists until it has been shut down, or Asterisk has been shut down. + * + * @param [params.type] - Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media, video_sfu) to set. + * @param params.bridgeId - Unique ID to give to the bridge being created. + * @param [params.name] - Set the name of the bridge. + */ + createWithId( + params: { type?: string | undefined; bridgeId: string; name?: string | undefined }, + callback: (err: Error, bridge: Bridge) => void + ): void; + + /** + * Create a new bridge or updates an existing one. + * This bridge persists until it has been shut down, or Asterisk has been shut down. + * + * @param [params.type] - Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media, video_sfu) to set. + * @param params.bridgeId - Unique ID to give to the bridge being created. + * @param [params.name] - Set the name of the bridge. + */ + createWithId(params: { + type?: string | undefined; + bridgeId: string; + name?: string | undefined; + }): Promise; + + /** + * Get bridge details. + * + * @param params.bridgeId - Bridges id. + */ + get(params: { bridgeId: string }, callback: (err: Error, bridge: Bridge) => void): void; + + /** + * Get bridge details. + * + * @param params.bridgeId - Bridges id. + */ + get(params: { bridgeId: string }): Promise; + + /** + * Shut down a bridge. + * If any channels are in this bridge, they will be removed and resume whatever they were doing beforehand. + * + * @param params.bridgeId - Bridges id. + */ + destroy(params: { bridgeId: string }, callback: (err: Error) => void): void; + + /** + * Shut down a bridge. + * If any channels are in this bridge, they will be removed and resume whatever they were doing beforehand. + * + * @param params.bridgeId - Bridges id. + */ + destroy(params: { bridgeId: string }): Promise; + + /** + * Add a channel to a bridge. + * + * @param params.bridgeId - Bridges id. + * @param params.channel - Ids of channels to add to bridge. + * @param [params.role] - Channels role in the bridge. + * @param [params.absorbDTMF] - Absorb DTMF coming from this channel, preventing it to pass through to the bridge. + * @param [params.mute] - Mute audio from this channel, preventing it to pass through to the bridge. + */ + addChannel( + params: { + bridgeId: string; + channel: string | string[]; + role?: string | undefined; + absorbDTMF?: boolean | undefined; + mute?: boolean | undefined; + }, + callback: (err: Error) => void + ): void; + + /** + * Add a channel to a bridge. + * + * @param params.bridgeId - Bridges id. + * @param params.channel - Ids of channels to add to bridge. + * @param [params.role] - Channels role in the bridge. + * @param [params.absorbDTMF] - Absorb DTMF coming from this channel, preventing it to pass through to the bridge. + * @param [params.mute] - Mute audio from this channel, preventing it to pass through to the bridge. + */ + addChannel(params: { + bridgeId: string; + channel: string | string[]; + role?: string | undefined; + absorbDTMF?: boolean | undefined; + mute?: boolean | undefined; + }): Promise; + + /** + * Remove a channel from a bridge. + * + * @param params.bridgeId - Bridges id. + * @param params.channel - Ids of channels to remove from bridge. + */ + removeChannel( + params: { bridgeId: string; channel: string | string[] }, + callback: (err: Error) => void + ): void; + + /** + * Remove a channel from a bridge. + * + * @param params.bridgeId - Bridges id. + * @param params.channel - Ids of channels to remove from bridge. + */ + removeChannel(params: { bridgeId: string; channel: string | string[] }): Promise; + + /** + * Set a channel as the video source in a multi-party mixing bridge. This operation has no effect on bridges with two or fewer participants. + * + * @param params.bridgeId - Bridges id. + * @param params.channelId - Channels id. + */ + setVideoSource( + params: { bridgeId: string; channelId: string }, + callback: (err: Error) => void + ): void; + + /** + * Set a channel as the video source in a multi-party mixing bridge. This operation has no effect on bridges with two or fewer participants. + * + * @param params.bridgeId - Bridges id. + * @param params.channelId - Channels id. + */ + setVideoSource(params: { bridgeId: string; channelId: string }): Promise; + + /** + * Removes any explicit video source in a multi-party mixing bridge. This operation has no effect on bridges with two or fewer participants. When no explicit video source is set, talk + * detection will be used to determine the active video stream. + * + * @param params.bridgeId - Bridges id. + */ + clearVideoSource(params: { bridgeId: string }, callback: (err: Error) => void): void; + + /** + * Removes any explicit video source in a multi-party mixing bridge. This operation has no effect on bridges with two or fewer participants. When no explicit video source is set, talk + * detection will be used to determine the active video stream. + * + * @param params.bridgeId - Bridges id. + */ + clearVideoSource(params: { bridgeId: string }): Promise; + + /** + * Play music on hold to a bridge or change the MOH class that is playing. + * + * @param params.bridgeId - Bridges id. + * @param [params.mohClass] - Channels id. + */ + startMoh( + params: { bridgeId: string; mohClass?: string | undefined }, + callback: (err: Error) => void + ): void; + + /** + * Play music on hold to a bridge or change the MOH class that is playing. + * + * @param params.bridgeId - Bridges id. + * @param [params.mohClass] - Channels id. + */ + startMoh(params: { bridgeId: string; mohClass?: string | undefined }): Promise; + + /** + * Stop playing music on hold to a bridge. + * This will only stop music on hold being played via POST bridges/{bridgeId}/moh. + * + * @param params.bridgeId - Bridges id. + */ + stopMoh(params: { bridgeId: string }, callback: (err: Error) => void): void; + + /** + * Stop playing music on hold to a bridge. + * This will only stop music on hold being played via POST bridges/{bridgeId}/moh. + * + * @param params.bridgeId - Bridges id. + */ + stopMoh(params: { bridgeId: string }): Promise; + + /** + * Start playback of media on a bridge. + * The media URI may be any of a number of URIs. Currently sound:, recording:, number:, digits:, characters:, and tone: URIs are supported. This operation creates a playback resource + * that can be used to control the playback of media (pause, rewind, fast forward, etc.). + * + * @param params.bridgeId - Bridges id. + * @param params.media - Media URIs to play. + * @param [params.lang] - For sounds, selects language for sound. + * @param [params.offsetms] - Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified. + * @param [params.skipms] - Number of milliseconds to skip for forward/reverse operations. + * @param [params.playbackId] - Playback Id. + */ + play( + params: { + bridgeId: string; + media: string | string[]; + lang?: string | undefined; + offsetms?: number | undefined; + skipms?: number | undefined; + playbackId?: string | undefined; + }, + callback: (err: Error, playback: Playback) => void + ): void; + + /** + * Start playback of media on a bridge. + * The media URI may be any of a number of URIs. Currently sound:, recording:, number:, digits:, characters:, and tone: URIs are supported. This operation creates a playback resource + * that can be used to control the playback of media (pause, rewind, fast forward, etc.). + * + * @param params.bridgeId - Bridges id. + * @param params.media - Media URIs to play. + * @param [params.lang] - For sounds, selects language for sound. + * @param [params.offsetms] - Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified. + * @param [params.skipms] - Number of milliseconds to skip for forward/reverse operations. + * @param [params.playbackId] - Playback Id. + */ + play(params: { + bridgeId: string; + media: string | string[]; + lang?: string | undefined; + offsetms?: number | undefined; + skipms?: number | undefined; + playbackId?: string | undefined; + }): Promise; + + /** + * Start playback of media on a bridge. + * The media URI may be any of a number of URIs. Currently sound:, recording:, number:, digits:, characters:, and tone: URIs are supported. This operation creates a playback resource + * that can be used to control the playback of media (pause, rewind, fast forward, etc.). + * + * @param params.bridgeId - Bridges id. + * @param params.playbackId - Playback ID. + * @param params.media - Media URIs to play. + * @param [params.lang] - For sounds, selects language for sound. + * @param [params.offsetms] - Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified. + * @param [params.skipms] - Number of milliseconds to skip for forward/reverse operations. + */ + playWithId( + params: { + bridgeId: string; + playbackId: string; + media: string | string[]; + lang?: string | undefined; + offsetms?: number | undefined; + skipms?: number | undefined; + }, + callback: (err: Error, playback: Playback) => void + ): void; + + /** + * Start playback of media on a bridge. + * The media URI may be any of a number of URIs. Currently sound:, recording:, number:, digits:, characters:, and tone: URIs are supported. This operation creates a playback resource + * that can be used to control the playback of media (pause, rewind, fast forward, etc.). + * + * @param params.bridgeId - Bridges id. + * @param params.playbackId - Playback ID. + * @param params.media - Media URIs to play. + * @param [params.lang] - For sounds, selects language for sound. + * @param [params.offsetms] - Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified. + * @param [params.skipms] - Number of milliseconds to skip for forward/reverse operations. + */ + playWithId(params: { + bridgeId: string; + playbackId: string; + media: string | string[]; + lang?: string | undefined; + offsetms?: number | undefined; + skipms?: number | undefined; + }): Promise; + + /** + * Start a recording. + * This records the mixed audio from all channels participating in this bridge. + * + * @param params.bridgeId - Bridges id. + * @param params.name - Recordings filename. + * @param params.format - Format to encode audio in. + * @param [params.maxDurationSeconds] - Maximum duration of the recording, in seconds. 0 for no limit. + * @param [params.maxSilenceSeconds] - Maximum duration of silence, in seconds. 0 for no limit. + * @param [params.ifExists] - Action to take if a recording with the same name already exists. + * @param [params.beep] - Play beep when recording begins. + * @param [params.terminateOn] - DTMF input to terminate recording. + */ + record( + params: { + bridgeId: string; + name: string; + format: string; + maxDurationSeconds?: number | undefined; + maxSilenceSeconds?: number | undefined; + ifExists?: string | undefined; + beep?: boolean | undefined; + terminateOn?: string | undefined; + }, + callback: (err: Error, liverecording: LiveRecording) => void + ): void; + + /** + * Start a recording. + * This records the mixed audio from all channels participating in this bridge. + * + * @param params.bridgeId - Bridges id. + * @param params.name - Recordings filename. + * @param params.format - Format to encode audio in. + * @param [params.maxDurationSeconds] - Maximum duration of the recording, in seconds. 0 for no limit. + * @param [params.maxSilenceSeconds] - Maximum duration of silence, in seconds. 0 for no limit. + * @param [params.ifExists] - Action to take if a recording with the same name already exists. + * @param [params.beep] - Play beep when recording begins. + * @param [params.terminateOn] - DTMF input to terminate recording. + */ + record(params: { + bridgeId: string; + name: string; + format: string; + maxDurationSeconds?: number | undefined; + maxSilenceSeconds?: number | undefined; + ifExists?: string | undefined; + beep?: boolean | undefined; + terminateOn?: string | undefined; + }): Promise; +} +export interface Bridge extends Resource { + /** + * Unique identifier for this bridge. + */ + id: string; + + /** + * Name of the current bridging technology. + */ + technology: string; + + /** + * Type of bridge technology. + */ + bridge_type: string; + + /** + * Bridging class. + */ + bridge_class: string; + + /** + * Entity that created the bridge. + */ + creator: string; + + /** + * Name the creator gave the bridge. + */ + name: string; + + /** + * Ids of channels participating in this bridge. + */ + channels: string | string[]; + + /** + * The video mode the bridge is using. One of none, talker, or single. + */ + video_mode?: string | undefined; + + /** + * The ID of the channel that is the source of video in this bridge, if one exists. + */ + video_source_id?: string | undefined; + + /** + * ISO 8601 date/time when the bridge was created. + */ + creationtime: string; + + /** + * List all active bridges in Asterisk. + */ + list(callback: (err: Error, bridges: Bridge[]) => void): void; + + /** + * List all active bridges in Asterisk. + */ + list(): Promise; + + /** + * Create a new bridge. + * This bridge persists until it has been shut down, or Asterisk has been shut down. + * + * @param [params.type] - Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media, video_sfu). + * @param [params.name] - Name to give to the bridge being created. + */ + create( + params: { type?: string | undefined; name?: string | undefined }, + callback: (err: Error, bridge: Bridge) => void + ): void; + + /** + * Create a new bridge. + * This bridge persists until it has been shut down, or Asterisk has been shut down. + */ + create(callback: (err: Error, bridge: Bridge) => void): void; + + /** + * Create a new bridge. + * This bridge persists until it has been shut down, or Asterisk has been shut down. + * + * @param [params.type] - Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media, video_sfu). + * @param [params.name] - Name to give to the bridge being created. + */ + create(params?: { type?: string | undefined; name?: string | undefined }): Promise; + + /** + * Create a new bridge or updates an existing one. + * This bridge persists until it has been shut down, or Asterisk has been shut down. + * + * @param [params.type] - Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media, video_sfu) to set. + * @param [params.name] - Set the name of the bridge. + */ + createWithId( + params: { type?: string | undefined; name?: string | undefined }, + callback: (err: Error, bridge: Bridge) => void + ): void; + + /** + * Create a new bridge or updates an existing one. + * This bridge persists until it has been shut down, or Asterisk has been shut down. + */ + createWithId(callback: (err: Error, bridge: Bridge) => void): void; + + /** + * Create a new bridge or updates an existing one. + * This bridge persists until it has been shut down, or Asterisk has been shut down. + * + * @param [params.type] - Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media, video_sfu) to set. + * @param [params.name] - Set the name of the bridge. + */ + createWithId(params?: { + type?: string | undefined; + name?: string | undefined; + }): Promise; + + /** + * Get bridge details. + */ + get(callback: (err: Error, bridge: Bridge) => void): void; + + /** + * Get bridge details. + */ + get(): Promise; + + /** + * Shut down a bridge. + * If any channels are in this bridge, they will be removed and resume whatever they were doing beforehand. + */ + destroy(callback: (err: Error) => void): void; + + /** + * Shut down a bridge. + * If any channels are in this bridge, they will be removed and resume whatever they were doing beforehand. + */ + destroy(): Promise; + + /** + * Add a channel to a bridge. + * + * @param params.channel - Ids of channels to add to bridge. + * @param [params.role] - Channels role in the bridge. + * @param [params.absorbDTMF] - Absorb DTMF coming from this channel, preventing it to pass through to the bridge. + * @param [params.mute] - Mute audio from this channel, preventing it to pass through to the bridge. + */ + addChannel( + params: { + channel: string | string[]; + role?: string | undefined; + absorbDTMF?: boolean | undefined; + mute?: boolean | undefined; + }, + callback: (err: Error) => void + ): void; + + /** + * Add a channel to a bridge. + * + * @param params.channel - Ids of channels to add to bridge. + * @param [params.role] - Channels role in the bridge. + * @param [params.absorbDTMF] - Absorb DTMF coming from this channel, preventing it to pass through to the bridge. + * @param [params.mute] - Mute audio from this channel, preventing it to pass through to the bridge. + */ + addChannel(params: { + channel: string | string[]; + role?: string | undefined; + absorbDTMF?: boolean | undefined; + mute?: boolean | undefined; + }): Promise; + + /** + * Remove a channel from a bridge. + * + * @param params.channel - Ids of channels to remove from bridge. + */ + removeChannel(params: { channel: string | string[] }, callback: (err: Error) => void): void; + + /** + * Remove a channel from a bridge. + * + * @param params.channel - Ids of channels to remove from bridge. + */ + removeChannel(params: { channel: string | string[] }): Promise; + + /** + * Set a channel as the video source in a multi-party mixing bridge. This operation has no effect on bridges with two or fewer participants. + * + * @param params.channelId - Channels id. + */ + setVideoSource(params: { channelId: string }, callback: (err: Error) => void): void; + + /** + * Set a channel as the video source in a multi-party mixing bridge. This operation has no effect on bridges with two or fewer participants. + * + * @param params.channelId - Channels id. + */ + setVideoSource(params: { channelId: string }): Promise; + + /** + * Removes any explicit video source in a multi-party mixing bridge. This operation has no effect on bridges with two or fewer participants. When no explicit video source is set, talk + * detection will be used to determine the active video stream. + */ + clearVideoSource(callback: (err: Error) => void): void; + + /** + * Removes any explicit video source in a multi-party mixing bridge. This operation has no effect on bridges with two or fewer participants. When no explicit video source is set, talk + * detection will be used to determine the active video stream. + */ + clearVideoSource(): Promise; + + /** + * Play music on hold to a bridge or change the MOH class that is playing. + * + * @param [params.mohClass] - Channels id. + */ + startMoh(params: { mohClass?: string | undefined }, callback: (err: Error) => void): void; + + /** + * Play music on hold to a bridge or change the MOH class that is playing. + */ + startMoh(callback: (err: Error) => void): void; + + /** + * Play music on hold to a bridge or change the MOH class that is playing. + * + * @param [params.mohClass] - Channels id. + */ + startMoh(params?: { mohClass?: string | undefined }): Promise; + + /** + * Stop playing music on hold to a bridge. + * This will only stop music on hold being played via POST bridges/{bridgeId}/moh. + */ + stopMoh(callback: (err: Error) => void): void; + + /** + * Stop playing music on hold to a bridge. + * This will only stop music on hold being played via POST bridges/{bridgeId}/moh. + */ + stopMoh(): Promise; + + /** + * Start playback of media on a bridge. + * The media URI may be any of a number of URIs. Currently sound:, recording:, number:, digits:, characters:, and tone: URIs are supported. This operation creates a playback resource + * that can be used to control the playback of media (pause, rewind, fast forward, etc.). + * + * @param params.media - Media URIs to play. + * @param [params.lang] - For sounds, selects language for sound. + * @param [params.offsetms] - Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified. + * @param [params.skipms] - Number of milliseconds to skip for forward/reverse operations. + * @param [params.playbackId] - Playback Id. + */ + play( + params: { + media: string | string[]; + lang?: string | undefined; + offsetms?: number | undefined; + skipms?: number | undefined; + playbackId?: string | undefined; + }, + callback: (err: Error, playback: Playback) => void + ): void; + + /** + * Start playback of media on a bridge. + * The media URI may be any of a number of URIs. Currently sound:, recording:, number:, digits:, characters:, and tone: URIs are supported. This operation creates a playback resource + * that can be used to control the playback of media (pause, rewind, fast forward, etc.). + * + * @param params.media - Media URIs to play. + * @param [params.lang] - For sounds, selects language for sound. + * @param [params.offsetms] - Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified. + * @param [params.skipms] - Number of milliseconds to skip for forward/reverse operations. + * @param [params.playbackId] - Playback Id. + */ + play(params: { + media: string | string[]; + lang?: string | undefined; + offsetms?: number | undefined; + skipms?: number | undefined; + playbackId?: string | undefined; + }): Promise; + + /** + * Start playback of media on a bridge. + * The media URI may be any of a number of URIs. Currently sound:, recording:, number:, digits:, characters:, and tone: URIs are supported. This operation creates a playback resource + * that can be used to control the playback of media (pause, rewind, fast forward, etc.). + * + * @param params.playbackId - Playback ID. + * @param params.media - Media URIs to play. + * @param [params.lang] - For sounds, selects language for sound. + * @param [params.offsetms] - Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified. + * @param [params.skipms] - Number of milliseconds to skip for forward/reverse operations. + */ + playWithId( + params: { + playbackId: string; + media: string | string[]; + lang?: string | undefined; + offsetms?: number | undefined; + skipms?: number | undefined; + }, + callback: (err: Error, playback: Playback) => void + ): void; + + /** + * Start playback of media on a bridge. + * The media URI may be any of a number of URIs. Currently sound:, recording:, number:, digits:, characters:, and tone: URIs are supported. This operation creates a playback resource + * that can be used to control the playback of media (pause, rewind, fast forward, etc.). + * + * @param params.playbackId - Playback ID. + * @param params.media - Media URIs to play. + * @param [params.lang] - For sounds, selects language for sound. + * @param [params.offsetms] - Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified. + * @param [params.skipms] - Number of milliseconds to skip for forward/reverse operations. + */ + playWithId(params: { + playbackId: string; + media: string | string[]; + lang?: string | undefined; + offsetms?: number | undefined; + skipms?: number | undefined; + }): Promise; + + /** + * Start a recording. + * This records the mixed audio from all channels participating in this bridge. + * + * @param params.name - Recordings filename. + * @param params.format - Format to encode audio in. + * @param [params.maxDurationSeconds] - Maximum duration of the recording, in seconds. 0 for no limit. + * @param [params.maxSilenceSeconds] - Maximum duration of silence, in seconds. 0 for no limit. + * @param [params.ifExists] - Action to take if a recording with the same name already exists. + * @param [params.beep] - Play beep when recording begins. + * @param [params.terminateOn] - DTMF input to terminate recording. + */ + record( + params: { + name: string; + format: string; + maxDurationSeconds?: number | undefined; + maxSilenceSeconds?: number | undefined; + ifExists?: string | undefined; + beep?: boolean | undefined; + terminateOn?: string | undefined; + }, + recording: LiveRecording, + callback: (err: Error, liverecording: LiveRecording) => void + ): void; + + /** + * Start a recording. + * This records the mixed audio from all channels participating in this bridge. + * + * @param params.name - Recordings filename. + * @param params.format - Format to encode audio in. + * @param [params.maxDurationSeconds] - Maximum duration of the recording, in seconds. 0 for no limit. + * @param [params.maxSilenceSeconds] - Maximum duration of silence, in seconds. 0 for no limit. + * @param [params.ifExists] - Action to take if a recording with the same name already exists. + * @param [params.beep] - Play beep when recording begins. + * @param [params.terminateOn] - DTMF input to terminate recording. + */ + record( + params: { + name: string; + format: string; + maxDurationSeconds?: number | undefined; + maxSilenceSeconds?: number | undefined; + ifExists?: string | undefined; + beep?: boolean | undefined; + terminateOn?: string | undefined; + }, + recording: LiveRecording + ): Promise; +} +export interface Channels { + /** + * List all active channels in Asterisk. + */ + list(callback: (err: Error, channels: Channel[]) => void): void; + + /** + * List all active channels in Asterisk. + */ + list(): Promise; + + /** + * Create a new channel (originate). + * The new channel is created immediately and a snapshot of it returned. If a Stasis application is provided it will be automatically subscribed to the originated channel for further + * events and updates. + * + * @param params.endpoint - Endpoint to call. + * @param [params.extension] - The extension to dial after the endpoint answers. Mutually exclusive with app. + * @param [params.context] - The context to dial after the endpoint answers. If omitted, uses default. Mutually exclusive with app. + * @param [params.priority] - The priority to dial after the endpoint answers. If omitted, uses 1. Mutually exclusive with app. + * @param [params.label] - The label to dial after the endpoint answers. Will supersede priority if provided. Mutually exclusive with app. + * @param [params.app] - The application that is subscribed to the originated channel. When the channel is answered, it will be passed to this Stasis application. Mutually exclusive + * with context, extension, priority, and label. + * @param [params.appArgs] - The application arguments to pass to the Stasis application provided by app. Mutually exclusive with context, extension, priority, and label. + * @param [params.callerId] - CallerID to use when dialing the endpoint or extension. + * @param [params.timeout] - Timeout (in seconds) before giving up dialing, or -1 for no timeout. + * @param [params.variables] - The "variables" key in the body object holds variable key/value pairs to set on the channel on creation. Other keys in the body object are interpreted + * as query parameters. Ex. { "endpoint": "SIP/Alice", "variables": { "CALLERID(name)": "Alice" } }. + * @param [params.channelId] - The unique id to assign the channel on creation. + * @param [params.otherChannelId] - The unique id to assign the second channel when using local channels. + * @param [params.originator] - The unique id of the channel which is originating this one. + * @param [params.formats] - The format name capability list to use if originator is not specified. Ex. "ulaw,slin16". Format names can be found with "core show codecs". + */ + originate( + params: { + endpoint: string; + extension?: string | undefined; + context?: string | undefined; + priority?: number | undefined; + label?: string | undefined; + app?: string | undefined; + appArgs?: string | undefined; + callerId?: string | undefined; + timeout?: number | undefined; + variables?: Containers | undefined; + channelId?: string | undefined; + otherChannelId?: string | undefined; + originator?: string | undefined; + formats?: string | undefined; + }, + callback: (err: Error, channel: Channel) => void + ): void; + + /** + * Create a new channel (originate). + * The new channel is created immediately and a snapshot of it returned. If a Stasis application is provided it will be automatically subscribed to the originated channel for further + * events and updates. + * + * @param params.endpoint - Endpoint to call. + * @param [params.extension] - The extension to dial after the endpoint answers. Mutually exclusive with app. + * @param [params.context] - The context to dial after the endpoint answers. If omitted, uses default. Mutually exclusive with app. + * @param [params.priority] - The priority to dial after the endpoint answers. If omitted, uses 1. Mutually exclusive with app. + * @param [params.label] - The label to dial after the endpoint answers. Will supersede priority if provided. Mutually exclusive with app. + * @param [params.app] - The application that is subscribed to the originated channel. When the channel is answered, it will be passed to this Stasis application. Mutually exclusive + * with context, extension, priority, and label. + * @param [params.appArgs] - The application arguments to pass to the Stasis application provided by app. Mutually exclusive with context, extension, priority, and label. + * @param [params.callerId] - CallerID to use when dialing the endpoint or extension. + * @param [params.timeout] - Timeout (in seconds) before giving up dialing, or -1 for no timeout. + * @param [params.variables] - The "variables" key in the body object holds variable key/value pairs to set on the channel on creation. Other keys in the body object are interpreted + * as query parameters. Ex. { "endpoint": "SIP/Alice", "variables": { "CALLERID(name)": "Alice" } }. + * @param [params.channelId] - The unique id to assign the channel on creation. + * @param [params.otherChannelId] - The unique id to assign the second channel when using local channels. + * @param [params.originator] - The unique id of the channel which is originating this one. + * @param [params.formats] - The format name capability list to use if originator is not specified. Ex. "ulaw,slin16". Format names can be found with "core show codecs". + */ + originate(params: { + endpoint: string; + extension?: string | undefined; + context?: string | undefined; + priority?: number | undefined; + label?: string | undefined; + app?: string | undefined; + appArgs?: string | undefined; + callerId?: string | undefined; + timeout?: number | undefined; + variables?: Containers | undefined; + channelId?: string | undefined; + otherChannelId?: string | undefined; + originator?: string | undefined; + formats?: string | undefined; + }): Promise; + + /** + * Create channel. + * + * @param params.endpoint - Endpoint for channel communication. + * @param params.app - Stasis Application to place channel into. + * @param [params.appArgs] - The application arguments to pass to the Stasis application provided by app. Mutually exclusive with context, extension, priority, and label. + * @param [params.channelId] - The unique id to assign the channel on creation. + * @param [params.otherChannelId] - The unique id to assign the second channel when using local channels. + * @param [params.originator] - Unique ID of the calling channel. + * @param [params.formats] - The format name capability list to use if originator is not specified. Ex. "ulaw,slin16". Format names can be found with "core show codecs". + */ + create( + params: { + endpoint: string; + app: string; + appArgs?: string | undefined; + channelId?: string | undefined; + otherChannelId?: string | undefined; + originator?: string | undefined; + formats?: string | undefined; + }, + callback: (err: Error, channel: Channel) => void + ): void; + + /** + * Create channel. + * + * @param params.endpoint - Endpoint for channel communication. + * @param params.app - Stasis Application to place channel into. + * @param [params.appArgs] - The application arguments to pass to the Stasis application provided by app. Mutually exclusive with context, extension, priority, and label. + * @param [params.channelId] - The unique id to assign the channel on creation. + * @param [params.otherChannelId] - The unique id to assign the second channel when using local channels. + * @param [params.originator] - Unique ID of the calling channel. + * @param [params.formats] - The format name capability list to use if originator is not specified. Ex. "ulaw,slin16". Format names can be found with "core show codecs". + */ + create(params: { + endpoint: string; + app: string; + appArgs?: string | undefined; + channelId?: string | undefined; + otherChannelId?: string | undefined; + originator?: string | undefined; + formats?: string | undefined; + }): Promise; + + /** + * Channel details. + * + * @param params.channelId - Channels id. + */ + get(params: { channelId: string }, callback: (err: Error, channel: Channel) => void): void; + + /** + * Channel details. + * + * @param params.channelId - Channels id. + */ + get(params: { channelId: string }): Promise; + + /** + * Create a new channel (originate with id). + * The new channel is created immediately and a snapshot of it returned. If a Stasis application is provided it will be automatically subscribed to the originated channel for further + * events and updates. + * + * @param params.channelId - The unique id to assign the channel on creation. + * @param params.endpoint - Endpoint to call. + * @param [params.extension] - The extension to dial after the endpoint answers. Mutually exclusive with app. + * @param [params.context] - The context to dial after the endpoint answers. If omitted, uses default. Mutually exclusive with app. + * @param [params.priority] - The priority to dial after the endpoint answers. If omitted, uses 1. Mutually exclusive with app. + * @param [params.label] - The label to dial after the endpoint answers. Will supersede priority if provided. Mutually exclusive with app. + * @param [params.app] - The application that is subscribed to the originated channel. When the channel is answered, it will be passed to this Stasis application. Mutually exclusive + * with context, extension, priority, and label. + * @param [params.appArgs] - The application arguments to pass to the Stasis application provided by app. Mutually exclusive with context, extension, priority, and label. + * @param [params.callerId] - CallerID to use when dialing the endpoint or extension. + * @param [params.timeout] - Timeout (in seconds) before giving up dialing, or -1 for no timeout. + * @param [params.variables] - The "variables" key in the body object holds variable key/value pairs to set on the channel on creation. Other keys in the body object are interpreted + * as query parameters. Ex. { "endpoint": "SIP/Alice", "variables": { "CALLERID(name)": "Alice" } }. + * @param [params.otherChannelId] - The unique id to assign the second channel when using local channels. + * @param [params.originator] - The unique id of the channel which is originating this one. + * @param [params.formats] - The format name capability list to use if originator is not specified. Ex. "ulaw,slin16". Format names can be found with "core show codecs". + */ + originateWithId( + params: { + channelId: string; + endpoint: string; + extension?: string | undefined; + context?: string | undefined; + priority?: number | undefined; + label?: string | undefined; + app?: string | undefined; + appArgs?: string | undefined; + callerId?: string | undefined; + timeout?: number | undefined; + variables?: Containers | undefined; + otherChannelId?: string | undefined; + originator?: string | undefined; + formats?: string | undefined; + }, + callback: (err: Error, channel: Channel) => void + ): void; + + /** + * Create a new channel (originate with id). + * The new channel is created immediately and a snapshot of it returned. If a Stasis application is provided it will be automatically subscribed to the originated channel for further + * events and updates. + * + * @param params.channelId - The unique id to assign the channel on creation. + * @param params.endpoint - Endpoint to call. + * @param [params.extension] - The extension to dial after the endpoint answers. Mutually exclusive with app. + * @param [params.context] - The context to dial after the endpoint answers. If omitted, uses default. Mutually exclusive with app. + * @param [params.priority] - The priority to dial after the endpoint answers. If omitted, uses 1. Mutually exclusive with app. + * @param [params.label] - The label to dial after the endpoint answers. Will supersede priority if provided. Mutually exclusive with app. + * @param [params.app] - The application that is subscribed to the originated channel. When the channel is answered, it will be passed to this Stasis application. Mutually exclusive + * with context, extension, priority, and label. + * @param [params.appArgs] - The application arguments to pass to the Stasis application provided by app. Mutually exclusive with context, extension, priority, and label. + * @param [params.callerId] - CallerID to use when dialing the endpoint or extension. + * @param [params.timeout] - Timeout (in seconds) before giving up dialing, or -1 for no timeout. + * @param [params.variables] - The "variables" key in the body object holds variable key/value pairs to set on the channel on creation. Other keys in the body object are interpreted + * as query parameters. Ex. { "endpoint": "SIP/Alice", "variables": { "CALLERID(name)": "Alice" } }. + * @param [params.otherChannelId] - The unique id to assign the second channel when using local channels. + * @param [params.originator] - The unique id of the channel which is originating this one. + * @param [params.formats] - The format name capability list to use if originator is not specified. Ex. "ulaw,slin16". Format names can be found with "core show codecs". + */ + originateWithId(params: { + channelId: string; + endpoint: string; + extension?: string | undefined; + context?: string | undefined; + priority?: number | undefined; + label?: string | undefined; + app?: string | undefined; + appArgs?: string | undefined; + callerId?: string | undefined; + timeout?: number | undefined; + variables?: Containers | undefined; + otherChannelId?: string | undefined; + originator?: string | undefined; + formats?: string | undefined; + }): Promise; + + /** + * Delete (i.e. hangup) a channel. + * + * @param params.channelId - Channels id. + * @param [params.reason] - Reason for hanging up the channel. + */ + hangup( + params: { channelId: string; reason?: string | undefined }, + callback: (err: Error) => void + ): void; + + /** + * Delete (i.e. hangup) a channel. + * + * @param params.channelId - Channels id. + * @param [params.reason] - Reason for hanging up the channel. + */ + hangup(params: { channelId: string; reason?: string | undefined }): Promise; + + /** + * Exit application; continue execution in the dialplan. + * + * @param params.channelId - Channels id. + * @param [params.context] - The context to continue to. + * @param [params.extension] - The extension to continue to. + * @param [params.priority] - The priority to continue to. + * @param [params.label] - The label to continue to - will supersede priority if both are provided. + */ + continueInDialplan( + params: { + channelId: string; + context?: string | undefined; + extension?: string | undefined; + priority?: number | undefined; + label?: string | undefined; + }, + callback: (err: Error) => void + ): void; + + /** + * Exit application; continue execution in the dialplan. + * + * @param params.channelId - Channels id. + * @param [params.context] - The context to continue to. + * @param [params.extension] - The extension to continue to. + * @param [params.priority] - The priority to continue to. + * @param [params.label] - The label to continue to - will supersede priority if both are provided. + */ + continueInDialplan(params: { + channelId: string; + context?: string | undefined; + extension?: string | undefined; + priority?: number | undefined; + label?: string | undefined; + }): Promise; + + /** + * Move the channel from one Stasis application to another. + * + * @param params.channelId - Channels id. + * @param params.app - The channel will be passed to this Stasis application. + * @param [params.appArgs] - The application arguments to pass to the Stasis application provided by app. + */ + move( + params: { channelId: string; app: string; appArgs?: string | undefined }, + callback: (err: Error) => void + ): void; + + /** + * Move the channel from one Stasis application to another. + * + * @param params.channelId - Channels id. + * @param params.app - The channel will be passed to this Stasis application. + * @param [params.appArgs] - The application arguments to pass to the Stasis application provided by app. + */ + move(params: { channelId: string; app: string; appArgs?: string | undefined }): Promise; + + /** + * Redirect the channel to a different location. + * + * @param params.channelId - Channels id. + * @param params.endpoint - The endpoint to redirect the channel to. + */ + redirect(params: { channelId: string; endpoint: string }, callback: (err: Error) => void): void; + + /** + * Redirect the channel to a different location. + * + * @param params.channelId - Channels id. + * @param params.endpoint - The endpoint to redirect the channel to. + */ + redirect(params: { channelId: string; endpoint: string }): Promise; + + /** + * Answer a channel. + * + * @param params.channelId - Channels id. + */ + answer(params: { channelId: string }, callback: (err: Error) => void): void; + + /** + * Answer a channel. + * + * @param params.channelId - Channels id. + */ + answer(params: { channelId: string }): Promise; + + /** + * Indicate ringing to a channel. + * + * @param params.channelId - Channels id. + */ + ring(params: { channelId: string }, callback: (err: Error) => void): void; + + /** + * Indicate ringing to a channel. + * + * @param params.channelId - Channels id. + */ + ring(params: { channelId: string }): Promise; + + /** + * Stop ringing indication on a channel if locally generated. + * + * @param params.channelId - Channels id. + */ + ringStop(params: { channelId: string }, callback: (err: Error) => void): void; + + /** + * Stop ringing indication on a channel if locally generated. + * + * @param params.channelId - Channels id. + */ + ringStop(params: { channelId: string }): Promise; + + /** + * Send provided DTMF to a given channel. + * + * @param params.channelId - Channels id. + * @param [params.dtmf] - DTMF To send. + * @param [params.before] - Amount of time to wait before DTMF digits (specified in milliseconds) start. + * @param [params.between] - Amount of time in between DTMF digits (specified in milliseconds). + * @param [params.duration] - Length of each DTMF digit (specified in milliseconds). + * @param [params.after] - Amount of time to wait after DTMF digits (specified in milliseconds) end. + */ + sendDTMF( + params: { + channelId: string; + dtmf?: string | undefined; + before?: number | undefined; + between?: number | undefined; + duration?: number | undefined; + after?: number | undefined; + }, + callback: (err: Error) => void + ): void; + + /** + * Send provided DTMF to a given channel. + * + * @param params.channelId - Channels id. + * @param [params.dtmf] - DTMF To send. + * @param [params.before] - Amount of time to wait before DTMF digits (specified in milliseconds) start. + * @param [params.between] - Amount of time in between DTMF digits (specified in milliseconds). + * @param [params.duration] - Length of each DTMF digit (specified in milliseconds). + * @param [params.after] - Amount of time to wait after DTMF digits (specified in milliseconds) end. + */ + sendDTMF(params: { + channelId: string; + dtmf?: string | undefined; + before?: number | undefined; + between?: number | undefined; + duration?: number | undefined; + after?: number | undefined; + }): Promise; + + /** + * Mute a channel. + * + * @param params.channelId - Channels id. + * @param [params.direction] - Direction in which to mute audio. + */ + mute( + params: { channelId: string; direction?: string | undefined }, + callback: (err: Error) => void + ): void; + + /** + * Mute a channel. + * + * @param params.channelId - Channels id. + * @param [params.direction] - Direction in which to mute audio. + */ + mute(params: { channelId: string; direction?: string | undefined }): Promise; + + /** + * Unmute a channel. + * + * @param params.channelId - Channels id. + * @param [params.direction] - Direction in which to unmute audio. + */ + unmute( + params: { channelId: string; direction?: string | undefined }, + callback: (err: Error) => void + ): void; + + /** + * Unmute a channel. + * + * @param params.channelId - Channels id. + * @param [params.direction] - Direction in which to unmute audio. + */ + unmute(params: { channelId: string; direction?: string | undefined }): Promise; + + /** + * Hold a channel. + * + * @param params.channelId - Channels id. + */ + hold(params: { channelId: string }, callback: (err: Error) => void): void; + + /** + * Hold a channel. + * + * @param params.channelId - Channels id. + */ + hold(params: { channelId: string }): Promise; + + /** + * Remove a channel from hold. + * + * @param params.channelId - Channels id. + */ + unhold(params: { channelId: string }, callback: (err: Error) => void): void; + + /** + * Remove a channel from hold. + * + * @param params.channelId - Channels id. + */ + unhold(params: { channelId: string }): Promise; + + /** + * Play music on hold to a channel. + * Using media operations such as /play on a channel playing MOH in this manner will suspend MOH without resuming automatically. If continuing music on hold is desired, the stasis application + * must reinitiate music on hold. + * + * @param params.channelId - Channels id. + * @param [params.mohClass] - Music on hold class to use. + */ + startMoh( + params: { channelId: string; mohClass?: string | undefined }, + callback: (err: Error) => void + ): void; + + /** + * Play music on hold to a channel. + * Using media operations such as /play on a channel playing MOH in this manner will suspend MOH without resuming automatically. If continuing music on hold is desired, the stasis application + * must reinitiate music on hold. + * + * @param params.channelId - Channels id. + * @param [params.mohClass] - Music on hold class to use. + */ + startMoh(params: { channelId: string; mohClass?: string | undefined }): Promise; + + /** + * Stop playing music on hold to a channel. + * + * @param params.channelId - Channels id. + */ + stopMoh(params: { channelId: string }, callback: (err: Error) => void): void; + + /** + * Stop playing music on hold to a channel. + * + * @param params.channelId - Channels id. + */ + stopMoh(params: { channelId: string }): Promise; + + /** + * Play silence to a channel. + * Using media operations such as /play on a channel playing silence in this manner will suspend silence without resuming automatically. + * + * @param params.channelId - Channels id. + */ + startSilence(params: { channelId: string }, callback: (err: Error) => void): void; + + /** + * Play silence to a channel. + * Using media operations such as /play on a channel playing silence in this manner will suspend silence without resuming automatically. + * + * @param params.channelId - Channels id. + */ + startSilence(params: { channelId: string }): Promise; + + /** + * Stop playing silence to a channel. + * + * @param params.channelId - Channels id. + */ + stopSilence(params: { channelId: string }, callback: (err: Error) => void): void; + + /** + * Stop playing silence to a channel. + * + * @param params.channelId - Channels id. + */ + stopSilence(params: { channelId: string }): Promise; + + /** + * Start playback of media. + * The media URI may be any of a number of URIs. Currently sound:, recording:, number:, digits:, characters:, and tone: URIs are supported. This operation creates a playback resource + * that can be used to control the playback of media (pause, rewind, fast forward, etc.). + * + * @param params.channelId - Channels id. + * @param params.media - Media URIs to play. + * @param [params.lang] - For sounds, selects language for sound. + * @param [params.offsetms] - Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified. + * @param [params.skipms] - Number of milliseconds to skip for forward/reverse operations. + * @param [params.playbackId] - Playback ID. + */ + play( + params: { + channelId: string; + media: string | string[]; + lang?: string | undefined; + offsetms?: number | undefined; + skipms?: number | undefined; + playbackId?: string | undefined; + }, + callback: (err: Error, playback: Playback) => void + ): void; + + /** + * Start playback of media. + * The media URI may be any of a number of URIs. Currently sound:, recording:, number:, digits:, characters:, and tone: URIs are supported. This operation creates a playback resource + * that can be used to control the playback of media (pause, rewind, fast forward, etc.). + * + * @param params.channelId - Channels id. + * @param params.media - Media URIs to play. + * @param [params.lang] - For sounds, selects language for sound. + * @param [params.offsetms] - Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified. + * @param [params.skipms] - Number of milliseconds to skip for forward/reverse operations. + * @param [params.playbackId] - Playback ID. + */ + play(params: { + channelId: string; + media: string | string[]; + lang?: string | undefined; + offsetms?: number | undefined; + skipms?: number | undefined; + playbackId?: string | undefined; + }): Promise; + + /** + * Start playback of media and specify the playbackId. + * The media URI may be any of a number of URIs. Currently sound:, recording:, number:, digits:, characters:, and tone: URIs are supported. This operation creates a playback resource + * that can be used to control the playback of media (pause, rewind, fast forward, etc.). + * + * @param params.channelId - Channels id. + * @param params.playbackId - Playback ID. + * @param params.media - Media URIs to play. + * @param [params.lang] - For sounds, selects language for sound. + * @param [params.offsetms] - Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified. + * @param [params.skipms] - Number of milliseconds to skip for forward/reverse operations. + */ + playWithId( + params: { + channelId: string; + playbackId: string; + media: string | string[]; + lang?: string | undefined; + offsetms?: number | undefined; + skipms?: number | undefined; + }, + callback: (err: Error, playback: Playback) => void + ): void; + + /** + * Start playback of media and specify the playbackId. + * The media URI may be any of a number of URIs. Currently sound:, recording:, number:, digits:, characters:, and tone: URIs are supported. This operation creates a playback resource + * that can be used to control the playback of media (pause, rewind, fast forward, etc.). + * + * @param params.channelId - Channels id. + * @param params.playbackId - Playback ID. + * @param params.media - Media URIs to play. + * @param [params.lang] - For sounds, selects language for sound. + * @param [params.offsetms] - Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified. + * @param [params.skipms] - Number of milliseconds to skip for forward/reverse operations. + */ + playWithId(params: { + channelId: string; + playbackId: string; + media: string | string[]; + lang?: string | undefined; + offsetms?: number | undefined; + skipms?: number | undefined; + }): Promise; + + /** + * Start a recording. + * Record audio from a channel. Note that this will not capture audio sent to the channel. The bridge itself has a record feature if thats what you want. + * + * @param params.channelId - Channels id. + * @param params.name - Recordings filename. + * @param params.format - Format to encode audio in. + * @param [params.maxDurationSeconds] - Maximum duration of the recording, in seconds. 0 for no limit. + * @param [params.maxSilenceSeconds] - Maximum duration of silence, in seconds. 0 for no limit. + * @param [params.ifExists] - Action to take if a recording with the same name already exists. + * @param [params.beep] - Play beep when recording begins. + * @param [params.terminateOn] - DTMF input to terminate recording. + */ + record( + params: { + channelId: string; + name: string; + format: string; + maxDurationSeconds?: number | undefined; + maxSilenceSeconds?: number | undefined; + ifExists?: string | undefined; + beep?: boolean | undefined; + terminateOn?: string | undefined; + }, + callback: (err: Error, liverecording: LiveRecording) => void + ): void; + + /** + * Start a recording. + * Record audio from a channel. Note that this will not capture audio sent to the channel. The bridge itself has a record feature if thats what you want. + * + * @param params.channelId - Channels id. + * @param params.name - Recordings filename. + * @param params.format - Format to encode audio in. + * @param [params.maxDurationSeconds] - Maximum duration of the recording, in seconds. 0 for no limit. + * @param [params.maxSilenceSeconds] - Maximum duration of silence, in seconds. 0 for no limit. + * @param [params.ifExists] - Action to take if a recording with the same name already exists. + * @param [params.beep] - Play beep when recording begins. + * @param [params.terminateOn] - DTMF input to terminate recording. + */ + record(params: { + channelId: string; + name: string; + format: string; + maxDurationSeconds?: number | undefined; + maxSilenceSeconds?: number | undefined; + ifExists?: string | undefined; + beep?: boolean | undefined; + terminateOn?: string | undefined; + }): Promise; + + /** + * Get the value of a channel variable or function. + * + * @param params.channelId - Channels id. + * @param params.variable - The channel variable or function to get. + */ + getChannelVar( + params: { channelId: string; variable: string }, + callback: (err: Error, variable: Variable) => void + ): void; + + /** + * Get the value of a channel variable or function. + * + * @param params.channelId - Channels id. + * @param params.variable - The channel variable or function to get. + */ + getChannelVar(params: { channelId: string; variable: string }): Promise; + + /** + * Set the value of a channel variable or function. + * + * @param params.channelId - Channels id. + * @param params.variable - The channel variable or function to set. + * @param [params.value] - The value to set the variable to. + */ + setChannelVar( + params: { channelId: string; variable: string; value?: string | undefined }, + callback: (err: Error) => void + ): void; + + /** + * Set the value of a channel variable or function. + * + * @param params.channelId - Channels id. + * @param params.variable - The channel variable or function to set. + * @param [params.value] - The value to set the variable to. + */ + setChannelVar(params: { + channelId: string; + variable: string; + value?: string | undefined; + }): Promise; + + /** + * Start snooping. + * Snoop (spy/whisper) on a specific channel. + * + * @param params.channelId - Channels id. + * @param [params.spy] - Direction of audio to spy on. + * @param [params.whisper] - Direction of audio to whisper into. + * @param params.app - Application the snooping channel is placed into. + * @param [params.appArgs] - The application arguments to pass to the Stasis application. + * @param [params.snoopId] - Unique ID to assign to snooping channel. + */ + snoopChannel( + params: { + channelId: string; + spy?: string | undefined; + whisper?: string | undefined; + app: string; + appArgs?: string | undefined; + snoopId?: string | undefined; + }, + callback: (err: Error, channel: Channel) => void + ): void; + + /** + * Start snooping. + * Snoop (spy/whisper) on a specific channel. + * + * @param params.channelId - Channels id. + * @param [params.spy] - Direction of audio to spy on. + * @param [params.whisper] - Direction of audio to whisper into. + * @param params.app - Application the snooping channel is placed into. + * @param [params.appArgs] - The application arguments to pass to the Stasis application. + * @param [params.snoopId] - Unique ID to assign to snooping channel. + */ + snoopChannel(params: { + channelId: string; + spy?: string | undefined; + whisper?: string | undefined; + app: string; + appArgs?: string | undefined; + snoopId?: string | undefined; + }): Promise; + + /** + * Start snooping. + * Snoop (spy/whisper) on a specific channel. + * + * @param params.channelId - Channels id. + * @param params.snoopId - Unique ID to assign to snooping channel. + * @param [params.spy] - Direction of audio to spy on. + * @param [params.whisper] - Direction of audio to whisper into. + * @param params.app - Application the snooping channel is placed into. + * @param [params.appArgs] - The application arguments to pass to the Stasis application. + */ + snoopChannelWithId( + params: { + channelId: string; + snoopId: string; + spy?: string | undefined; + whisper?: string | undefined; + app: string; + appArgs?: string | undefined; + }, + callback: (err: Error, channel: Channel) => void + ): void; + + /** + * Start snooping. + * Snoop (spy/whisper) on a specific channel. + * + * @param params.channelId - Channels id. + * @param params.snoopId - Unique ID to assign to snooping channel. + * @param [params.spy] - Direction of audio to spy on. + * @param [params.whisper] - Direction of audio to whisper into. + * @param params.app - Application the snooping channel is placed into. + * @param [params.appArgs] - The application arguments to pass to the Stasis application. + */ + snoopChannelWithId(params: { + channelId: string; + snoopId: string; + spy?: string | undefined; + whisper?: string | undefined; + app: string; + appArgs?: string | undefined; + }): Promise; + + /** + * Dial a created channel. + * + * @param params.channelId - Channels id. + * @param [params.caller] - Channel ID of caller. + * @param [params.timeout] - Dial timeout. + */ + dial( + params: { channelId: string; caller?: string | undefined; timeout?: number | undefined }, + callback: (err: Error) => void + ): void; + + /** + * Dial a created channel. + * + * @param params.channelId - Channels id. + * @param [params.caller] - Channel ID of caller. + * @param [params.timeout] - Dial timeout. + */ + dial(params: { + channelId: string; + caller?: string | undefined; + timeout?: number | undefined; + }): Promise; + + /** + * RTP stats on a channel. + * + * @param params.channelId - Channels id. + */ + rtpstatistics( + params: { channelId: string }, + callback: (err: Error, rtpstat: RTPstat) => void + ): void; + + /** + * RTP stats on a channel. + * + * @param params.channelId - Channels id. + */ + rtpstatistics(params: { channelId: string }): Promise; + + /** + * Start an External Media session. + * Create a channel to an External Media source/sink. + * + * @param [params.channelId] - The unique id to assign the channel on creation. + * @param params.app - Stasis Application to place channel into. + * @param [params.variables] - The "variables" key in the body object holds variable key/value pairs to set on the channel on creation. Other keys in the body object are interpreted + * as query parameters. Ex. { "endpoint": "SIP/Alice", "variables": { "CALLERID(name)": "Alice" } }. + * @param params.external_host - Hostname/ip:port of external host. + * @param [params.encapsulation] - Payload encapsulation protocol. + * @param [params.transport] - Transport protocol. + * @param [params.connection_type] - Connection type (client/server). + * @param params.format - Format to encode audio in. + * @param [params.direction] - External media direction. + */ + externalMedia( + params: { + channelId?: string | undefined; + app: string; + variables?: Containers | undefined; + external_host: string; + encapsulation?: string | undefined; + transport?: string | undefined; + connection_type?: string | undefined; + format: string; + direction?: string | undefined; + }, + callback: (err: Error, channel: Channel) => void + ): void; + + /** + * Start an External Media session. + * Create a channel to an External Media source/sink. + * + * @param [params.channelId] - The unique id to assign the channel on creation. + * @param params.app - Stasis Application to place channel into. + * @param [params.variables] - The "variables" key in the body object holds variable key/value pairs to set on the channel on creation. Other keys in the body object are interpreted + * as query parameters. Ex. { "endpoint": "SIP/Alice", "variables": { "CALLERID(name)": "Alice" } }. + * @param params.external_host - Hostname/ip:port of external host. + * @param [params.encapsulation] - Payload encapsulation protocol. + * @param [params.transport] - Transport protocol. + * @param [params.connection_type] - Connection type (client/server). + * @param params.format - Format to encode audio in. + * @param [params.direction] - External media direction. + */ + externalMedia(params: { + channelId?: string | undefined; + app: string; + variables?: Containers | undefined; + external_host: string; + encapsulation?: string | undefined; + transport?: string | undefined; + connection_type?: string | undefined; + format: string; + direction?: string | undefined; + }): Promise; +} +export interface DialplanCEP { + /** + * Context in the dialplan. + */ + context: string; + + /** + * Extension in the dialplan. + */ + exten: string; + + /** + * Priority in the dialplan. + */ + priority: number; + + /** + * Name of current dialplan application. + */ + app_name: string; + + /** + * Parameter of current dialplan application. + */ + app_data: string; +} +export interface CallerID { + /** + * Name. + */ + name: string; + + /** + * Number. + */ + number: string; +} +export interface RTPstat { + /** + * Number of packets transmitted. + */ + txcount: number; + + /** + * Number of packets received. + */ + rxcount: number; + + /** + * Jitter on transmitted packets. + */ + txjitter?: number | undefined; + + /** + * Jitter on received packets. + */ + rxjitter?: number | undefined; + + /** + * Maximum jitter on remote side. + */ + remote_maxjitter?: number | undefined; + + /** + * Minimum jitter on remote side. + */ + remote_minjitter?: number | undefined; + + /** + * Average jitter on remote side. + */ + remote_normdevjitter?: number | undefined; + + /** + * Standard deviation jitter on remote side. + */ + remote_stdevjitter?: number | undefined; + + /** + * Maximum jitter on local side. + */ + local_maxjitter?: number | undefined; + + /** + * Minimum jitter on local side. + */ + local_minjitter?: number | undefined; + + /** + * Average jitter on local side. + */ + local_normdevjitter?: number | undefined; + + /** + * Standard deviation jitter on local side. + */ + local_stdevjitter?: number | undefined; + + /** + * Number of transmitted packets lost. + */ + txploss: number; + + /** + * Number of received packets lost. + */ + rxploss: number; + + /** + * Maximum number of packets lost on remote side. + */ + remote_maxrxploss?: number | undefined; + + /** + * Minimum number of packets lost on remote side. + */ + remote_minrxploss?: number | undefined; + + /** + * Average number of packets lost on remote side. + */ + remote_normdevrxploss?: number | undefined; + + /** + * Standard deviation packets lost on remote side. + */ + remote_stdevrxploss?: number | undefined; + + /** + * Maximum number of packets lost on local side. + */ + local_maxrxploss?: number | undefined; + + /** + * Minimum number of packets lost on local side. + */ + local_minrxploss?: number | undefined; + + /** + * Average number of packets lost on local side. + */ + local_normdevrxploss?: number | undefined; + + /** + * Standard deviation packets lost on local side. + */ + local_stdevrxploss?: number | undefined; + + /** + * Total round trip time. + */ + rtt?: number | undefined; + + /** + * Maximum round trip time. + */ + maxrtt?: number | undefined; + + /** + * Minimum round trip time. + */ + minrtt?: number | undefined; + + /** + * Average round trip time. + */ + normdevrtt?: number | undefined; + + /** + * Standard deviation round trip time. + */ + stdevrtt?: number | undefined; + + /** + * Our SSRC. + */ + local_ssrc: number; + + /** + * Their SSRC. + */ + remote_ssrc: number; + + /** + * Number of octets transmitted. + */ + txoctetcount: number; + + /** + * Number of octets received. + */ + rxoctetcount: number; + + /** + * The Asterisk channels unique ID that owns this instance. + */ + channel_uniqueid: string; +} +export interface Channel extends Resource { + /** + * Unique identifier of the channel. This is the same as the Uniqueid field in AMI. + */ + id: string; + + /** + * Protocol id from underlying channel driver (i.e. Call-ID for chan_pjsip; will be empty if not applicable or not implemented by driver). + */ + protocol_id: string; + + /** + * Name of the channel (i.e. SIP/foo-0000a7e3). + */ + name: string; + + /** + * State. + */ + state: string; + + /** + * Caller. + */ + caller: CallerID; + + /** + * Connected. + */ + connected: CallerID; + + /** + * Accountcode. + */ + accountcode: string; + + /** + * Current location in the dialplan. + */ + dialplan: DialplanCEP; + + /** + * ISO 8601 date/time when the channel was created. + */ + creationtime: string; + + /** + * The default spoken language. + */ + language: string; + + /** + * Channel variables. + */ + channelvars?: IndexableObject | undefined; + + /** + * List all active channels in Asterisk. + */ + list(callback: (err: Error, channels: Channel[]) => void): void; + + /** + * List all active channels in Asterisk. + */ + list(): Promise; + + /** + * Create a new channel (originate). + * The new channel is created immediately and a snapshot of it returned. If a Stasis application is provided it will be automatically subscribed to the originated channel for further + * events and updates. + * + * @param params.endpoint - Endpoint to call. + * @param [params.extension] - The extension to dial after the endpoint answers. Mutually exclusive with app. + * @param [params.context] - The context to dial after the endpoint answers. If omitted, uses default. Mutually exclusive with app. + * @param [params.priority] - The priority to dial after the endpoint answers. If omitted, uses 1. Mutually exclusive with app. + * @param [params.label] - The label to dial after the endpoint answers. Will supersede priority if provided. Mutually exclusive with app. + * @param [params.app] - The application that is subscribed to the originated channel. When the channel is answered, it will be passed to this Stasis application. Mutually exclusive + * with context, extension, priority, and label. + * @param [params.appArgs] - The application arguments to pass to the Stasis application provided by app. Mutually exclusive with context, extension, priority, and label. + * @param [params.callerId] - CallerID to use when dialing the endpoint or extension. + * @param [params.timeout] - Timeout (in seconds) before giving up dialing, or -1 for no timeout. + * @param [params.variables] - The "variables" key in the body object holds variable key/value pairs to set on the channel on creation. Other keys in the body object are interpreted + * as query parameters. Ex. { "endpoint": "SIP/Alice", "variables": { "CALLERID(name)": "Alice" } }. + * @param [params.otherChannelId] - The unique id to assign the second channel when using local channels. + * @param [params.originator] - The unique id of the channel which is originating this one. + * @param [params.formats] - The format name capability list to use if originator is not specified. Ex. "ulaw,slin16". Format names can be found with "core show codecs". + */ + originate( + params: { + endpoint: string; + extension?: string | undefined; + context?: string | undefined; + priority?: number | undefined; + label?: string | undefined; + app?: string | undefined; + appArgs?: string | undefined; + callerId?: string | undefined; + timeout?: number | undefined; + variables?: Containers | undefined; + otherChannelId?: string | undefined; + originator?: string | undefined; + formats?: string | undefined; + }, + callback: (err: Error, channel: Channel) => void + ): void; + + /** + * Create a new channel (originate). + * The new channel is created immediately and a snapshot of it returned. If a Stasis application is provided it will be automatically subscribed to the originated channel for further + * events and updates. + * + * @param params.endpoint - Endpoint to call. + * @param [params.extension] - The extension to dial after the endpoint answers. Mutually exclusive with app. + * @param [params.context] - The context to dial after the endpoint answers. If omitted, uses default. Mutually exclusive with app. + * @param [params.priority] - The priority to dial after the endpoint answers. If omitted, uses 1. Mutually exclusive with app. + * @param [params.label] - The label to dial after the endpoint answers. Will supersede priority if provided. Mutually exclusive with app. + * @param [params.app] - The application that is subscribed to the originated channel. When the channel is answered, it will be passed to this Stasis application. Mutually exclusive + * with context, extension, priority, and label. + * @param [params.appArgs] - The application arguments to pass to the Stasis application provided by app. Mutually exclusive with context, extension, priority, and label. + * @param [params.callerId] - CallerID to use when dialing the endpoint or extension. + * @param [params.timeout] - Timeout (in seconds) before giving up dialing, or -1 for no timeout. + * @param [params.variables] - The "variables" key in the body object holds variable key/value pairs to set on the channel on creation. Other keys in the body object are interpreted + * as query parameters. Ex. { "endpoint": "SIP/Alice", "variables": { "CALLERID(name)": "Alice" } }. + * @param [params.otherChannelId] - The unique id to assign the second channel when using local channels. + * @param [params.originator] - The unique id of the channel which is originating this one. + * @param [params.formats] - The format name capability list to use if originator is not specified. Ex. "ulaw,slin16". Format names can be found with "core show codecs". + */ + originate(params: { + endpoint: string; + extension?: string | undefined; + context?: string | undefined; + priority?: number | undefined; + label?: string | undefined; + app?: string | undefined; + appArgs?: string | undefined; + callerId?: string | undefined; + timeout?: number | undefined; + variables?: Containers | undefined; + otherChannelId?: string | undefined; + originator?: string | undefined; + formats?: string | undefined; + }): Promise; + + /** + * Create channel. + * + * @param params.endpoint - Endpoint for channel communication. + * @param params.app - Stasis Application to place channel into. + * @param [params.appArgs] - The application arguments to pass to the Stasis application provided by app. Mutually exclusive with context, extension, priority, and label. + * @param [params.otherChannelId] - The unique id to assign the second channel when using local channels. + * @param [params.originator] - Unique ID of the calling channel. + * @param [params.formats] - The format name capability list to use if originator is not specified. Ex. "ulaw,slin16". Format names can be found with "core show codecs". + */ + create( + params: { + endpoint: string; + app: string; + appArgs?: string | undefined; + otherChannelId?: string | undefined; + originator?: string | undefined; + formats?: string | undefined; + }, + callback: (err: Error, channel: Channel) => void + ): void; + + /** + * Create channel. + * + * @param params.endpoint - Endpoint for channel communication. + * @param params.app - Stasis Application to place channel into. + * @param [params.appArgs] - The application arguments to pass to the Stasis application provided by app. Mutually exclusive with context, extension, priority, and label. + * @param [params.otherChannelId] - The unique id to assign the second channel when using local channels. + * @param [params.originator] - Unique ID of the calling channel. + * @param [params.formats] - The format name capability list to use if originator is not specified. Ex. "ulaw,slin16". Format names can be found with "core show codecs". + */ + create(params: { + endpoint: string; + app: string; + appArgs?: string | undefined; + otherChannelId?: string | undefined; + originator?: string | undefined; + formats?: string | undefined; + }): Promise; + + /** + * Channel details. + */ + get(callback: (err: Error, channel: Channel) => void): void; + + /** + * Channel details. + */ + get(): Promise; + + /** + * Create a new channel (originate with id). + * The new channel is created immediately and a snapshot of it returned. If a Stasis application is provided it will be automatically subscribed to the originated channel for further + * events and updates. + * + * @param params.endpoint - Endpoint to call. + * @param [params.extension] - The extension to dial after the endpoint answers. Mutually exclusive with app. + * @param [params.context] - The context to dial after the endpoint answers. If omitted, uses default. Mutually exclusive with app. + * @param [params.priority] - The priority to dial after the endpoint answers. If omitted, uses 1. Mutually exclusive with app. + * @param [params.label] - The label to dial after the endpoint answers. Will supersede priority if provided. Mutually exclusive with app. + * @param [params.app] - The application that is subscribed to the originated channel. When the channel is answered, it will be passed to this Stasis application. Mutually exclusive + * with context, extension, priority, and label. + * @param [params.appArgs] - The application arguments to pass to the Stasis application provided by app. Mutually exclusive with context, extension, priority, and label. + * @param [params.callerId] - CallerID to use when dialing the endpoint or extension. + * @param [params.timeout] - Timeout (in seconds) before giving up dialing, or -1 for no timeout. + * @param [params.variables] - The "variables" key in the body object holds variable key/value pairs to set on the channel on creation. Other keys in the body object are interpreted + * as query parameters. Ex. { "endpoint": "SIP/Alice", "variables": { "CALLERID(name)": "Alice" } }. + * @param [params.otherChannelId] - The unique id to assign the second channel when using local channels. + * @param [params.originator] - The unique id of the channel which is originating this one. + * @param [params.formats] - The format name capability list to use if originator is not specified. Ex. "ulaw,slin16". Format names can be found with "core show codecs". + */ + originateWithId( + params: { + endpoint: string; + extension?: string | undefined; + context?: string | undefined; + priority?: number | undefined; + label?: string | undefined; + app?: string | undefined; + appArgs?: string | undefined; + callerId?: string | undefined; + timeout?: number | undefined; + variables?: Containers | undefined; + otherChannelId?: string | undefined; + originator?: string | undefined; + formats?: string | undefined; + }, + callback: (err: Error, channel: Channel) => void + ): void; + + /** + * Create a new channel (originate with id). + * The new channel is created immediately and a snapshot of it returned. If a Stasis application is provided it will be automatically subscribed to the originated channel for further + * events and updates. + * + * @param params.endpoint - Endpoint to call. + * @param [params.extension] - The extension to dial after the endpoint answers. Mutually exclusive with app. + * @param [params.context] - The context to dial after the endpoint answers. If omitted, uses default. Mutually exclusive with app. + * @param [params.priority] - The priority to dial after the endpoint answers. If omitted, uses 1. Mutually exclusive with app. + * @param [params.label] - The label to dial after the endpoint answers. Will supersede priority if provided. Mutually exclusive with app. + * @param [params.app] - The application that is subscribed to the originated channel. When the channel is answered, it will be passed to this Stasis application. Mutually exclusive + * with context, extension, priority, and label. + * @param [params.appArgs] - The application arguments to pass to the Stasis application provided by app. Mutually exclusive with context, extension, priority, and label. + * @param [params.callerId] - CallerID to use when dialing the endpoint or extension. + * @param [params.timeout] - Timeout (in seconds) before giving up dialing, or -1 for no timeout. + * @param [params.variables] - The "variables" key in the body object holds variable key/value pairs to set on the channel on creation. Other keys in the body object are interpreted + * as query parameters. Ex. { "endpoint": "SIP/Alice", "variables": { "CALLERID(name)": "Alice" } }. + * @param [params.otherChannelId] - The unique id to assign the second channel when using local channels. + * @param [params.originator] - The unique id of the channel which is originating this one. + * @param [params.formats] - The format name capability list to use if originator is not specified. Ex. "ulaw,slin16". Format names can be found with "core show codecs". + */ + originateWithId(params: { + endpoint: string; + extension?: string | undefined; + context?: string | undefined; + priority?: number | undefined; + label?: string | undefined; + app?: string | undefined; + appArgs?: string | undefined; + callerId?: string | undefined; + timeout?: number | undefined; + variables?: Containers | undefined; + otherChannelId?: string | undefined; + originator?: string | undefined; + formats?: string | undefined; + }): Promise; + + /** + * Delete (i.e. hangup) a channel. + * + * @param [params.reason] - Reason for hanging up the channel. + */ + hangup(params: { reason?: string | undefined }, callback: (err: Error) => void): void; + + /** + * Delete (i.e. hangup) a channel. + */ + hangup(callback: (err: Error) => void): void; + + /** + * Delete (i.e. hangup) a channel. + * + * @param [params.reason] - Reason for hanging up the channel. + */ + hangup(params?: { reason?: string | undefined }): Promise; + + /** + * Exit application; continue execution in the dialplan. + * + * @param [params.context] - The context to continue to. + * @param [params.extension] - The extension to continue to. + * @param [params.priority] - The priority to continue to. + * @param [params.label] - The label to continue to - will supersede priority if both are provided. + */ + continueInDialplan( + params: { + context?: string | undefined; + extension?: string | undefined; + priority?: number | undefined; + label?: string | undefined; + }, + callback: (err: Error) => void + ): void; + + /** + * Exit application; continue execution in the dialplan. + */ + continueInDialplan(callback: (err: Error) => void): void; + + /** + * Exit application; continue execution in the dialplan. + * + * @param [params.context] - The context to continue to. + * @param [params.extension] - The extension to continue to. + * @param [params.priority] - The priority to continue to. + * @param [params.label] - The label to continue to - will supersede priority if both are provided. + */ + continueInDialplan(params?: { + context?: string | undefined; + extension?: string | undefined; + priority?: number | undefined; + label?: string | undefined; + }): Promise; + + /** + * Move the channel from one Stasis application to another. + * + * @param params.app - The channel will be passed to this Stasis application. + * @param [params.appArgs] - The application arguments to pass to the Stasis application provided by app. + */ + move( + params: { app: string; appArgs?: string | undefined }, + callback: (err: Error) => void + ): void; + + /** + * Move the channel from one Stasis application to another. + * + * @param params.app - The channel will be passed to this Stasis application. + * @param [params.appArgs] - The application arguments to pass to the Stasis application provided by app. + */ + move(params: { app: string; appArgs?: string | undefined }): Promise; + + /** + * Redirect the channel to a different location. + * + * @param params.endpoint - The endpoint to redirect the channel to. + */ + redirect(params: { endpoint: string }, callback: (err: Error) => void): void; + + /** + * Redirect the channel to a different location. + * + * @param params.endpoint - The endpoint to redirect the channel to. + */ + redirect(params: { endpoint: string }): Promise; + + /** + * Answer a channel. + */ + answer(callback: (err: Error) => void): void; + + /** + * Answer a channel. + */ + answer(): Promise; + + /** + * Indicate ringing to a channel. + */ + ring(callback: (err: Error) => void): void; + + /** + * Indicate ringing to a channel. + */ + ring(): Promise; + + /** + * Stop ringing indication on a channel if locally generated. + */ + ringStop(callback: (err: Error) => void): void; + + /** + * Stop ringing indication on a channel if locally generated. + */ + ringStop(): Promise; + + /** + * Send provided DTMF to a given channel. + * + * @param [params.dtmf] - DTMF To send. + * @param [params.before] - Amount of time to wait before DTMF digits (specified in milliseconds) start. + * @param [params.between] - Amount of time in between DTMF digits (specified in milliseconds). + * @param [params.duration] - Length of each DTMF digit (specified in milliseconds). + * @param [params.after] - Amount of time to wait after DTMF digits (specified in milliseconds) end. + */ + sendDTMF( + params: { + dtmf?: string | undefined; + before?: number | undefined; + between?: number | undefined; + duration?: number | undefined; + after?: number | undefined; + }, + callback: (err: Error) => void + ): void; + + /** + * Send provided DTMF to a given channel. + */ + sendDTMF(callback: (err: Error) => void): void; + + /** + * Send provided DTMF to a given channel. + * + * @param [params.dtmf] - DTMF To send. + * @param [params.before] - Amount of time to wait before DTMF digits (specified in milliseconds) start. + * @param [params.between] - Amount of time in between DTMF digits (specified in milliseconds). + * @param [params.duration] - Length of each DTMF digit (specified in milliseconds). + * @param [params.after] - Amount of time to wait after DTMF digits (specified in milliseconds) end. + */ + sendDTMF(params?: { + dtmf?: string | undefined; + before?: number | undefined; + between?: number | undefined; + duration?: number | undefined; + after?: number | undefined; + }): Promise; + + /** + * Mute a channel. + * + * @param [params.direction] - Direction in which to mute audio. + */ + mute(params: { direction?: string | undefined }, callback: (err: Error) => void): void; + + /** + * Mute a channel. + */ + mute(callback: (err: Error) => void): void; + + /** + * Mute a channel. + * + * @param [params.direction] - Direction in which to mute audio. + */ + mute(params?: { direction?: string | undefined }): Promise; + + /** + * Unmute a channel. + * + * @param [params.direction] - Direction in which to unmute audio. + */ + unmute(params: { direction?: string | undefined }, callback: (err: Error) => void): void; + + /** + * Unmute a channel. + */ + unmute(callback: (err: Error) => void): void; + + /** + * Unmute a channel. + * + * @param [params.direction] - Direction in which to unmute audio. + */ + unmute(params?: { direction?: string | undefined }): Promise; + + /** + * Hold a channel. + */ + hold(callback: (err: Error) => void): void; + + /** + * Hold a channel. + */ + hold(): Promise; + + /** + * Remove a channel from hold. + */ + unhold(callback: (err: Error) => void): void; + + /** + * Remove a channel from hold. + */ + unhold(): Promise; + + /** + * Play music on hold to a channel. + * Using media operations such as /play on a channel playing MOH in this manner will suspend MOH without resuming automatically. If continuing music on hold is desired, the stasis application + * must reinitiate music on hold. + * + * @param [params.mohClass] - Music on hold class to use. + */ + startMoh(params: { mohClass?: string | undefined }, callback: (err: Error) => void): void; + + /** + * Play music on hold to a channel. + * Using media operations such as /play on a channel playing MOH in this manner will suspend MOH without resuming automatically. If continuing music on hold is desired, the stasis application + * must reinitiate music on hold. + */ + startMoh(callback: (err: Error) => void): void; + + /** + * Play music on hold to a channel. + * Using media operations such as /play on a channel playing MOH in this manner will suspend MOH without resuming automatically. If continuing music on hold is desired, the stasis application + * must reinitiate music on hold. + * + * @param [params.mohClass] - Music on hold class to use. + */ + startMoh(params?: { mohClass?: string | undefined }): Promise; + + /** + * Stop playing music on hold to a channel. + */ + stopMoh(callback: (err: Error) => void): void; + + /** + * Stop playing music on hold to a channel. + */ + stopMoh(): Promise; + + /** + * Play silence to a channel. + * Using media operations such as /play on a channel playing silence in this manner will suspend silence without resuming automatically. + */ + startSilence(callback: (err: Error) => void): void; + + /** + * Play silence to a channel. + * Using media operations such as /play on a channel playing silence in this manner will suspend silence without resuming automatically. + */ + startSilence(): Promise; + + /** + * Stop playing silence to a channel. + */ + stopSilence(callback: (err: Error) => void): void; + + /** + * Stop playing silence to a channel. + */ + stopSilence(): Promise; + + /** + * Start playback of media. + * The media URI may be any of a number of URIs. Currently sound:, recording:, number:, digits:, characters:, and tone: URIs are supported. This operation creates a playback resource + * that can be used to control the playback of media (pause, rewind, fast forward, etc.). + * + * @param params.media - Media URIs to play. + * @param [params.lang] - For sounds, selects language for sound. + * @param [params.offsetms] - Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified. + * @param [params.skipms] - Number of milliseconds to skip for forward/reverse operations. + * @param [params.playbackId] - Playback ID. + */ + play( + params: { + media: string | string[]; + lang?: string | undefined; + offsetms?: number | undefined; + skipms?: number | undefined; + playbackId?: string | undefined; + }, + playback: Playback, + callback: (err: Error, playback: Playback) => void + ): void; + + /** + * Start playback of media. + * The media URI may be any of a number of URIs. Currently sound:, recording:, number:, digits:, characters:, and tone: URIs are supported. This operation creates a playback resource + * that can be used to control the playback of media (pause, rewind, fast forward, etc.). + * + * @param params.media - Media URIs to play. + * @param [params.lang] - For sounds, selects language for sound. + * @param [params.offsetms] - Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified. + * @param [params.skipms] - Number of milliseconds to skip for forward/reverse operations. + * @param [params.playbackId] - Playback ID. + */ + play( + params: { + media: string | string[]; + lang?: string | undefined; + offsetms?: number | undefined; + skipms?: number | undefined; + playbackId?: string | undefined; + }, + playback: Playback + ): Promise; + + /** + * Start playback of media and specify the playbackId. + * The media URI may be any of a number of URIs. Currently sound:, recording:, number:, digits:, characters:, and tone: URIs are supported. This operation creates a playback resource + * that can be used to control the playback of media (pause, rewind, fast forward, etc.). + * + * @param params.playbackId - Playback ID. + * @param params.media - Media URIs to play. + * @param [params.lang] - For sounds, selects language for sound. + * @param [params.offsetms] - Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified. + * @param [params.skipms] - Number of milliseconds to skip for forward/reverse operations. + */ + playWithId( + params: { + playbackId: string; + media: string | string[]; + lang?: string | undefined; + offsetms?: number | undefined; + skipms?: number | undefined; + }, + callback: (err: Error, playback: Playback) => void + ): void; + + /** + * Start playback of media and specify the playbackId. + * The media URI may be any of a number of URIs. Currently sound:, recording:, number:, digits:, characters:, and tone: URIs are supported. This operation creates a playback resource + * that can be used to control the playback of media (pause, rewind, fast forward, etc.). + * + * @param params.playbackId - Playback ID. + * @param params.media - Media URIs to play. + * @param [params.lang] - For sounds, selects language for sound. + * @param [params.offsetms] - Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified. + * @param [params.skipms] - Number of milliseconds to skip for forward/reverse operations. + */ + playWithId(params: { + playbackId: string; + media: string | string[]; + lang?: string | undefined; + offsetms?: number | undefined; + skipms?: number | undefined; + }): Promise; + + /** + * Start a recording. + * Record audio from a channel. Note that this will not capture audio sent to the channel. The bridge itself has a record feature if thats what you want. + * + * @param params.name - Recordings filename. + * @param params.format - Format to encode audio in. + * @param [params.maxDurationSeconds] - Maximum duration of the recording, in seconds. 0 for no limit. + * @param [params.maxSilenceSeconds] - Maximum duration of silence, in seconds. 0 for no limit. + * @param [params.ifExists] - Action to take if a recording with the same name already exists. + * @param [params.beep] - Play beep when recording begins. + * @param [params.terminateOn] - DTMF input to terminate recording. + */ + record( + params: { + name: string; + format: string; + maxDurationSeconds?: number | undefined; + maxSilenceSeconds?: number | undefined; + ifExists?: string | undefined; + beep?: boolean | undefined; + terminateOn?: string | undefined; + }, + recording: LiveRecording, + callback: (err: Error, liverecording: LiveRecording) => void + ): void; + + /** + * Start a recording. + * Record audio from a channel. Note that this will not capture audio sent to the channel. The bridge itself has a record feature if thats what you want. + * + * @param params.name - Recordings filename. + * @param params.format - Format to encode audio in. + * @param [params.maxDurationSeconds] - Maximum duration of the recording, in seconds. 0 for no limit. + * @param [params.maxSilenceSeconds] - Maximum duration of silence, in seconds. 0 for no limit. + * @param [params.ifExists] - Action to take if a recording with the same name already exists. + * @param [params.beep] - Play beep when recording begins. + * @param [params.terminateOn] - DTMF input to terminate recording. + */ + record( + params: { + name: string; + format: string; + maxDurationSeconds?: number | undefined; + maxSilenceSeconds?: number | undefined; + ifExists?: string | undefined; + beep?: boolean | undefined; + terminateOn?: string | undefined; + }, + recording: LiveRecording + ): Promise; + + /** + * Get the value of a channel variable or function. + * + * @param params.variable - The channel variable or function to get. + */ + getChannelVar( + params: { variable: string }, + callback: (err: Error, variable: Variable) => void + ): void; + + /** + * Get the value of a channel variable or function. + * + * @param params.variable - The channel variable or function to get. + */ + getChannelVar(params: { variable: string }): Promise; + + /** + * Set the value of a channel variable or function. + * + * @param params.variable - The channel variable or function to set. + * @param [params.value] - The value to set the variable to. + */ + setChannelVar( + params: { variable: string; value?: string | undefined }, + callback: (err: Error) => void + ): void; + + /** + * Set the value of a channel variable or function. + * + * @param params.variable - The channel variable or function to set. + * @param [params.value] - The value to set the variable to. + */ + setChannelVar(params: { variable: string; value?: string | undefined }): Promise; + + /** + * Start snooping. + * Snoop (spy/whisper) on a specific channel. + * + * @param [params.spy] - Direction of audio to spy on. + * @param [params.whisper] - Direction of audio to whisper into. + * @param params.app - Application the snooping channel is placed into. + * @param [params.appArgs] - The application arguments to pass to the Stasis application. + * @param [params.snoopId] - Unique ID to assign to snooping channel. + */ + snoopChannel( + params: { + spy?: string | undefined; + whisper?: string | undefined; + app: string; + appArgs?: string | undefined; + snoopId?: string | undefined; + }, + snoopChannel: Channel, + callback: (err: Error, channel: Channel) => void + ): void; + + /** + * Start snooping. + * Snoop (spy/whisper) on a specific channel. + * + * @param [params.spy] - Direction of audio to spy on. + * @param [params.whisper] - Direction of audio to whisper into. + * @param params.app - Application the snooping channel is placed into. + * @param [params.appArgs] - The application arguments to pass to the Stasis application. + * @param [params.snoopId] - Unique ID to assign to snooping channel. + */ + snoopChannel( + params: { + spy?: string | undefined; + whisper?: string | undefined; + app: string; + appArgs?: string | undefined; + snoopId?: string | undefined; + }, + snoopChannel: Channel + ): Promise; + + /** + * Start snooping. + * Snoop (spy/whisper) on a specific channel. + * + * @param params.snoopId - Unique ID to assign to snooping channel. + * @param [params.spy] - Direction of audio to spy on. + * @param [params.whisper] - Direction of audio to whisper into. + * @param params.app - Application the snooping channel is placed into. + * @param [params.appArgs] - The application arguments to pass to the Stasis application. + */ + snoopChannelWithId( + params: { + snoopId: string; + spy?: string | undefined; + whisper?: string | undefined; + app: string; + appArgs?: string | undefined; + }, + callback: (err: Error, channel: Channel) => void + ): void; + + /** + * Start snooping. + * Snoop (spy/whisper) on a specific channel. + * + * @param params.snoopId - Unique ID to assign to snooping channel. + * @param [params.spy] - Direction of audio to spy on. + * @param [params.whisper] - Direction of audio to whisper into. + * @param params.app - Application the snooping channel is placed into. + * @param [params.appArgs] - The application arguments to pass to the Stasis application. + */ + snoopChannelWithId(params: { + snoopId: string; + spy?: string | undefined; + whisper?: string | undefined; + app: string; + appArgs?: string | undefined; + }): Promise; + + /** + * Dial a created channel. + * + * @param [params.caller] - Channel ID of caller. + * @param [params.timeout] - Dial timeout. + */ + dial( + params: { caller?: string | undefined; timeout?: number | undefined }, + callback: (err: Error) => void + ): void; + + /** + * Dial a created channel. + */ + dial(callback: (err: Error) => void): void; + + /** + * Dial a created channel. + * + * @param [params.caller] - Channel ID of caller. + * @param [params.timeout] - Dial timeout. + */ + dial(params?: { caller?: string | undefined; timeout?: number | undefined }): Promise; + + /** + * RTP stats on a channel. + */ + rtpstatistics(callback: (err: Error, rtpstat: RTPstat) => void): void; + + /** + * RTP stats on a channel. + */ + rtpstatistics(): Promise; + + /** + * Start an External Media session. + * Create a channel to an External Media source/sink. + * + * @param params.app - Stasis Application to place channel into. + * @param [params.variables] - The "variables" key in the body object holds variable key/value pairs to set on the channel on creation. Other keys in the body object are interpreted + * as query parameters. Ex. { "endpoint": "SIP/Alice", "variables": { "CALLERID(name)": "Alice" } }. + * @param params.external_host - Hostname/ip:port of external host. + * @param [params.encapsulation] - Payload encapsulation protocol. + * @param [params.transport] - Transport protocol. + * @param [params.connection_type] - Connection type (client/server). + * @param params.format - Format to encode audio in. + * @param [params.direction] - External media direction. + */ + externalMedia( + params: { + app: string; + variables?: Containers | undefined; + external_host: string; + encapsulation?: string | undefined; + transport?: string | undefined; + connection_type?: string | undefined; + format: string; + direction?: string | undefined; + }, + callback: (err: Error, channel: Channel) => void + ): void; + + /** + * Start an External Media session. + * Create a channel to an External Media source/sink. + * + * @param params.app - Stasis Application to place channel into. + * @param [params.variables] - The "variables" key in the body object holds variable key/value pairs to set on the channel on creation. Other keys in the body object are interpreted + * as query parameters. Ex. { "endpoint": "SIP/Alice", "variables": { "CALLERID(name)": "Alice" } }. + * @param params.external_host - Hostname/ip:port of external host. + * @param [params.encapsulation] - Payload encapsulation protocol. + * @param [params.transport] - Transport protocol. + * @param [params.connection_type] - Connection type (client/server). + * @param params.format - Format to encode audio in. + * @param [params.direction] - External media direction. + */ + externalMedia(params: { + app: string; + variables?: Containers | undefined; + external_host: string; + encapsulation?: string | undefined; + transport?: string | undefined; + connection_type?: string | undefined; + format: string; + direction?: string | undefined; + }): Promise; +} +export interface DeviceStates { + /** + * List all ARI controlled device states. + */ + list(callback: (err: Error, devicestates: DeviceState[]) => void): void; + + /** + * List all ARI controlled device states. + */ + list(): Promise; + + /** + * Retrieve the current state of a device. + * + * @param params.deviceName - Name of the device. + */ + get( + params: { deviceName: string }, + callback: (err: Error, devicestate: DeviceState) => void + ): void; + + /** + * Retrieve the current state of a device. + * + * @param params.deviceName - Name of the device. + */ + get(params: { deviceName: string }): Promise; + + /** + * Change the state of a device controlled by ARI. (Note - implicitly creates the device state). + * + * @param params.deviceName - Name of the device. + * @param params.deviceState - Device state value. + */ + update( + params: { deviceName: string; deviceState: string }, + callback: (err: Error) => void + ): void; + + /** + * Change the state of a device controlled by ARI. (Note - implicitly creates the device state). + * + * @param params.deviceName - Name of the device. + * @param params.deviceState - Device state value. + */ + update(params: { deviceName: string; deviceState: string }): Promise; + + /** + * Destroy a device-state controlled by ARI. + * + * @param params.deviceName - Name of the device. + */ + delete(params: { deviceName: string }, callback: (err: Error) => void): void; + + /** + * Destroy a device-state controlled by ARI. + * + * @param params.deviceName - Name of the device. + */ + delete(params: { deviceName: string }): Promise; +} +export interface DeviceState extends Resource { + /** + * Name of the device. + */ + name: string; + + /** + * Devices state. + */ + state: string; + + /** + * List all ARI controlled device states. + */ + list(callback: (err: Error, devicestates: DeviceState[]) => void): void; + + /** + * List all ARI controlled device states. + */ + list(): Promise; + + /** + * Retrieve the current state of a device. + */ + get(callback: (err: Error, devicestate: DeviceState) => void): void; + + /** + * Retrieve the current state of a device. + */ + get(): Promise; + + /** + * Change the state of a device controlled by ARI. (Note - implicitly creates the device state). + * + * @param params.deviceState - Device state value. + */ + update(params: { deviceState: string }, callback: (err: Error) => void): void; + + /** + * Change the state of a device controlled by ARI. (Note - implicitly creates the device state). + * + * @param params.deviceState - Device state value. + */ + update(params: { deviceState: string }): Promise; + + /** + * Destroy a device-state controlled by ARI. + */ + delete(callback: (err: Error) => void): void; + + /** + * Destroy a device-state controlled by ARI. + */ + delete(): Promise; +} +export interface Endpoints { + /** + * List all endpoints. + */ + list(callback: (err: Error, endpoints: Endpoint[]) => void): void; + + /** + * List all endpoints. + */ + list(): Promise; + + /** + * Send a message to some technology URI or endpoint. + * + * @param params.to - The endpoint resource or technology specific URI to send the message to. Valid resources are sip, pjsip, and xmpp. + * @param params.from - The endpoint resource or technology specific identity to send this message from. Valid resources are sip, pjsip, and xmpp. + * @param [params.body] - The body of the message. + * @param [params.variables] - The "variables" key in the body object holds technology specific key/value pairs to append to the message. These can be interpreted and used by the various + * resource types; for example, pjsip and sip resource types will add the key/value pairs as SIP headers. + */ + sendMessage( + params: { + to: string; + from: string; + body?: string | undefined; + variables?: Containers | undefined; + }, + callback: (err: Error) => void + ): void; + + /** + * Send a message to some technology URI or endpoint. + * + * @param params.to - The endpoint resource or technology specific URI to send the message to. Valid resources are sip, pjsip, and xmpp. + * @param params.from - The endpoint resource or technology specific identity to send this message from. Valid resources are sip, pjsip, and xmpp. + * @param [params.body] - The body of the message. + * @param [params.variables] - The "variables" key in the body object holds technology specific key/value pairs to append to the message. These can be interpreted and used by the various + * resource types; for example, pjsip and sip resource types will add the key/value pairs as SIP headers. + */ + sendMessage(params: { + to: string; + from: string; + body?: string | undefined; + variables?: Containers | undefined; + }): Promise; + + /** + * List available endoints for a given endpoint technology. + * + * @param [params.tech] - Technology of the endpoints (sip,iax2,...). + */ + listByTech( + params: { tech: string }, + callback: (err: Error, endpoints: Endpoint[]) => void + ): void; + + /** + * List available endoints for a given endpoint technology. + */ + listByTech(callback: (err: Error, endpoints: Endpoint[]) => void): void; + + /** + * List available endoints for a given endpoint technology. + * + * @param [params.tech] - Technology of the endpoints (sip,iax2,...). + */ + listByTech(params?: { tech: string }): Promise; + + /** + * Details for an endpoint. + * + * @param [params.tech] - Technology of the endpoint. + * @param [params.resource] - ID of the endpoint. + */ + get( + params: { tech: string; resource: string }, + callback: (err: Error, endpoint: Endpoint) => void + ): void; + + /** + * Details for an endpoint. + */ + get(callback: (err: Error, endpoint: Endpoint) => void): void; + + /** + * Details for an endpoint. + * + * @param [params.tech] - Technology of the endpoint. + * @param [params.resource] - ID of the endpoint. + */ + get(params?: { tech: string; resource: string }): Promise; + + /** + * Send a message to some endpoint in a technology. + * + * @param [params.tech] - Technology of the endpoint. + * @param [params.resource] - ID of the endpoint. + * @param params.from - The endpoint resource or technology specific identity to send this message from. Valid resources are sip, pjsip, and xmpp. + * @param [params.body] - The body of the message. + * @param [params.variables] - The "variables" key in the body object holds technology specific key/value pairs to append to the message. These can be interpreted and used by the various + * resource types; for example, pjsip and sip resource types will add the key/value pairs as SIP headers. + */ + sendMessageToEndpoint( + params: { + tech: string; + resource: string; + from: string; + body?: string | undefined; + variables?: Containers | undefined; + }, + callback: (err: Error) => void + ): void; + + /** + * Send a message to some endpoint in a technology. + * + * @param [params.tech] - Technology of the endpoint. + * @param [params.resource] - ID of the endpoint. + * @param params.from - The endpoint resource or technology specific identity to send this message from. Valid resources are sip, pjsip, and xmpp. + * @param [params.body] - The body of the message. + * @param [params.variables] - The "variables" key in the body object holds technology specific key/value pairs to append to the message. These can be interpreted and used by the various + * resource types; for example, pjsip and sip resource types will add the key/value pairs as SIP headers. + */ + sendMessageToEndpoint(params: { + tech: string; + resource: string; + from: string; + body?: string | undefined; + variables?: Containers | undefined; + }): Promise; +} +export interface Endpoint extends Resource { + /** + * Technology of the endpoint. + */ + technology: string; + + /** + * Identifier of the endpoint, specific to the given technology. + */ + resource: string; + + /** + * Endpoints state. + */ + state?: string | undefined; + + /** + * Ids of channels associated with this endpoint. + */ + channel_ids: string | string[]; + + /** + * List all endpoints. + */ + list(callback: (err: Error, endpoints: Endpoint[]) => void): void; + + /** + * List all endpoints. + */ + list(): Promise; + + /** + * Send a message to some technology URI or endpoint. + * + * @param params.to - The endpoint resource or technology specific URI to send the message to. Valid resources are sip, pjsip, and xmpp. + * @param params.from - The endpoint resource or technology specific identity to send this message from. Valid resources are sip, pjsip, and xmpp. + * @param [params.body] - The body of the message. + * @param [params.variables] - The "variables" key in the body object holds technology specific key/value pairs to append to the message. These can be interpreted and used by the various + * resource types; for example, pjsip and sip resource types will add the key/value pairs as SIP headers. + */ + sendMessage( + params: { + to: string; + from: string; + body?: string | undefined; + variables?: Containers | undefined; + }, + callback: (err: Error) => void + ): void; + + /** + * Send a message to some technology URI or endpoint. + * + * @param params.to - The endpoint resource or technology specific URI to send the message to. Valid resources are sip, pjsip, and xmpp. + * @param params.from - The endpoint resource or technology specific identity to send this message from. Valid resources are sip, pjsip, and xmpp. + * @param [params.body] - The body of the message. + * @param [params.variables] - The "variables" key in the body object holds technology specific key/value pairs to append to the message. These can be interpreted and used by the various + * resource types; for example, pjsip and sip resource types will add the key/value pairs as SIP headers. + */ + sendMessage(params: { + to: string; + from: string; + body?: string | undefined; + variables?: Containers | undefined; + }): Promise; + + /** + * List available endoints for a given endpoint technology. + */ + listByTech(callback: (err: Error, endpoints: Endpoint[]) => void): void; + + /** + * List available endoints for a given endpoint technology. + */ + listByTech(): Promise; + + /** + * Details for an endpoint. + */ + get(callback: (err: Error, endpoint: Endpoint) => void): void; + + /** + * Details for an endpoint. + */ + get(): Promise; + + /** + * Send a message to some endpoint in a technology. + * + * @param params.from - The endpoint resource or technology specific identity to send this message from. Valid resources are sip, pjsip, and xmpp. + * @param [params.body] - The body of the message. + * @param [params.variables] - The "variables" key in the body object holds technology specific key/value pairs to append to the message. These can be interpreted and used by the various + * resource types; for example, pjsip and sip resource types will add the key/value pairs as SIP headers. + */ + sendMessageToEndpoint( + params: { from: string; body?: string | undefined; variables?: Containers | undefined }, + callback: (err: Error) => void + ): void; + + /** + * Send a message to some endpoint in a technology. + * + * @param params.from - The endpoint resource or technology specific identity to send this message from. Valid resources are sip, pjsip, and xmpp. + * @param [params.body] - The body of the message. + * @param [params.variables] - The "variables" key in the body object holds technology specific key/value pairs to append to the message. These can be interpreted and used by the various + * resource types; for example, pjsip and sip resource types will add the key/value pairs as SIP headers. + */ + sendMessageToEndpoint(params: { + from: string; + body?: string | undefined; + variables?: Containers | undefined; + }): Promise; +} +export interface TextMessage { + /** + * A technology specific URI specifying the source of the message. For sip and pjsip technologies, any SIP URI can be specified. For xmpp, the URI must correspond to the client connection + * being used to send the message. + */ + from: string; + + /** + * A technology specific URI specifying the destination of the message. Valid technologies include sip, pjsip, and xmp. The destination of a message should be an endpoint. + */ + to: string; + + /** + * The text of the message. + */ + body: string; + + /** + * Technology specific key/value pairs (JSON object) associated with the message. + */ + variables?: IndexableObject | undefined; +} +export interface Mailboxes { + /** + * List all mailboxes. + */ + list(callback: (err: Error, mailboxs: Mailbox[]) => void): void; + + /** + * List all mailboxes. + */ + list(): Promise; + + /** + * Retrieve the current state of a mailbox. + * + * @param params.mailboxName - Name of the mailbox. + */ + get(params: { mailboxName: string }, callback: (err: Error, mailbox: Mailbox) => void): void; + + /** + * Retrieve the current state of a mailbox. + * + * @param params.mailboxName - Name of the mailbox. + */ + get(params: { mailboxName: string }): Promise; + + /** + * Change the state of a mailbox. (Note - implicitly creates the mailbox). + * + * @param params.mailboxName - Name of the mailbox. + * @param params.oldMessages - Count of old messages in the mailbox. + * @param params.newMessages - Count of new messages in the mailbox. + */ + update( + params: { mailboxName: string; oldMessages: number; newMessages: number }, + callback: (err: Error) => void + ): void; + + /** + * Change the state of a mailbox. (Note - implicitly creates the mailbox). + * + * @param params.mailboxName - Name of the mailbox. + * @param params.oldMessages - Count of old messages in the mailbox. + * @param params.newMessages - Count of new messages in the mailbox. + */ + update(params: { + mailboxName: string; + oldMessages: number; + newMessages: number; + }): Promise; + + /** + * Destroy a mailbox. + * + * @param params.mailboxName - Name of the mailbox. + */ + delete(params: { mailboxName: string }, callback: (err: Error) => void): void; + + /** + * Destroy a mailbox. + * + * @param params.mailboxName - Name of the mailbox. + */ + delete(params: { mailboxName: string }): Promise; +} +export interface Mailbox extends Resource { + /** + * Name of the mailbox. + */ + name: string; + + /** + * Count of old messages in the mailbox. + */ + old_messages: number; + + /** + * Count of new messages in the mailbox. + */ + new_messages: number; + + /** + * List all mailboxes. + */ + list(callback: (err: Error, mailboxs: Mailbox[]) => void): void; + + /** + * List all mailboxes. + */ + list(): Promise; + + /** + * Retrieve the current state of a mailbox. + */ + get(callback: (err: Error, mailbox: Mailbox) => void): void; + + /** + * Retrieve the current state of a mailbox. + */ + get(): Promise; + + /** + * Change the state of a mailbox. (Note - implicitly creates the mailbox). + * + * @param params.oldMessages - Count of old messages in the mailbox. + * @param params.newMessages - Count of new messages in the mailbox. + */ + update( + params: { oldMessages: number; newMessages: number }, + callback: (err: Error) => void + ): void; + + /** + * Change the state of a mailbox. (Note - implicitly creates the mailbox). + * + * @param params.oldMessages - Count of old messages in the mailbox. + * @param params.newMessages - Count of new messages in the mailbox. + */ + update(params: { oldMessages: number; newMessages: number }): Promise; + + /** + * Destroy a mailbox. + */ + delete(callback: (err: Error) => void): void; + + /** + * Destroy a mailbox. + */ + delete(): Promise; +} +export interface Playbacks { + /** + * Get a playbacks details. + * + * @param params.playbackId - Playbacks id. + */ + get(params: { playbackId: string }, callback: (err: Error, playback: Playback) => void): void; + + /** + * Get a playbacks details. + * + * @param params.playbackId - Playbacks id. + */ + get(params: { playbackId: string }): Promise; + + /** + * Stop a playback. + * + * @param params.playbackId - Playbacks id. + */ + stop(params: { playbackId: string }, callback: (err: Error) => void): void; + + /** + * Stop a playback. + * + * @param params.playbackId - Playbacks id. + */ + stop(params: { playbackId: string }): Promise; + + /** + * Control a playback. + * + * @param params.playbackId - Playbacks id. + * @param params.operation - Operation to perform on the playback. + */ + control( + params: { playbackId: string; operation: string }, + callback: (err: Error) => void + ): void; + + /** + * Control a playback. + * + * @param params.playbackId - Playbacks id. + * @param params.operation - Operation to perform on the playback. + */ + control(params: { playbackId: string; operation: string }): Promise; +} +export interface Playback extends Resource { + /** + * ID for this playback operation. + */ + id: string; + + /** + * The URI for the media currently being played back. + */ + media_uri: string; + + /** + * If a list of URIs is being played, the next media URI to be played back. + */ + next_media_uri?: string | undefined; + + /** + * URI for the channel or bridge to play the media on. + */ + target_uri: string; + + /** + * For media types that support multiple languages, the language requested for playback. + */ + language: string; + + /** + * Current state of the playback operation. + */ + state: string; + + /** + * Get a playbacks details. + */ + get(callback: (err: Error, playback: Playback) => void): void; + + /** + * Get a playbacks details. + */ + get(): Promise; + + /** + * Stop a playback. + */ + stop(callback: (err: Error) => void): void; + + /** + * Stop a playback. + */ + stop(): Promise; + + /** + * Control a playback. + * + * @param params.operation - Operation to perform on the playback. + */ + control(params: { operation: string }, callback: (err: Error) => void): void; + + /** + * Control a playback. + * + * @param params.operation - Operation to perform on the playback. + */ + control(params: { operation: string }): Promise; +} +export interface Recordings { + /** + * List recordings that are complete. + */ + listStored(callback: (err: Error, storedrecordings: StoredRecording[]) => void): void; + + /** + * List recordings that are complete. + */ + listStored(): Promise; + + /** + * Get a stored recordings details. + * + * @param params.recordingName - The name of the recording. + */ + getStored( + params: { recordingName: string }, + callback: (err: Error, storedrecording: StoredRecording) => void + ): void; + + /** + * Get a stored recordings details. + * + * @param params.recordingName - The name of the recording. + */ + getStored(params: { recordingName: string }): Promise; + + /** + * Delete a stored recording. + * + * @param params.recordingName - The name of the recording. + */ + deleteStored(params: { recordingName: string }, callback: (err: Error) => void): void; + + /** + * Delete a stored recording. + * + * @param params.recordingName - The name of the recording. + */ + deleteStored(params: { recordingName: string }): Promise; + + /** + * Get the file associated with the stored recording. + * + * @param params.recordingName - The name of the recording. + */ + getStoredFile( + params: { recordingName: string }, + callback: (err: Error, binary: Buffer) => void + ): void; + + /** + * Get the file associated with the stored recording. + * + * @param params.recordingName - The name of the recording. + */ + getStoredFile(params: { recordingName: string }): Promise; + + /** + * Copy a stored recording. + * + * @param params.recordingName - The name of the recording to copy. + * @param params.destinationRecordingName - The destination name of the recording. + */ + copyStored( + params: { recordingName: string; destinationRecordingName: string }, + callback: (err: Error, storedrecording: StoredRecording) => void + ): void; + + /** + * Copy a stored recording. + * + * @param params.recordingName - The name of the recording to copy. + * @param params.destinationRecordingName - The destination name of the recording. + */ + copyStored(params: { + recordingName: string; + destinationRecordingName: string; + }): Promise; + + /** + * List live recordings. + * + * @param params.recordingName - The name of the recording. + */ + getLive( + params: { recordingName: string }, + callback: (err: Error, liverecording: LiveRecording) => void + ): void; + + /** + * List live recordings. + * + * @param params.recordingName - The name of the recording. + */ + getLive(params: { recordingName: string }): Promise; + + /** + * Stop a live recording and discard it. + * + * @param params.recordingName - The name of the recording. + */ + cancel(params: { recordingName: string }, callback: (err: Error) => void): void; + + /** + * Stop a live recording and discard it. + * + * @param params.recordingName - The name of the recording. + */ + cancel(params: { recordingName: string }): Promise; + + /** + * Stop a live recording and store it. + * + * @param params.recordingName - The name of the recording. + */ + stop(params: { recordingName: string }, callback: (err: Error) => void): void; + + /** + * Stop a live recording and store it. + * + * @param params.recordingName - The name of the recording. + */ + stop(params: { recordingName: string }): Promise; + + /** + * Pause a live recording. + * Pausing a recording suspends silence detection, which will be restarted when the recording is unpaused. Paused time is not included in the accounting for maxDurationSeconds. + * + * @param params.recordingName - The name of the recording. + */ + pause(params: { recordingName: string }, callback: (err: Error) => void): void; + + /** + * Pause a live recording. + * Pausing a recording suspends silence detection, which will be restarted when the recording is unpaused. Paused time is not included in the accounting for maxDurationSeconds. + * + * @param params.recordingName - The name of the recording. + */ + pause(params: { recordingName: string }): Promise; + + /** + * Unpause a live recording. + * + * @param params.recordingName - The name of the recording. + */ + unpause(params: { recordingName: string }, callback: (err: Error) => void): void; + + /** + * Unpause a live recording. + * + * @param params.recordingName - The name of the recording. + */ + unpause(params: { recordingName: string }): Promise; + + /** + * Mute a live recording. + * Muting a recording suspends silence detection, which will be restarted when the recording is unmuted. + * + * @param params.recordingName - The name of the recording. + */ + mute(params: { recordingName: string }, callback: (err: Error) => void): void; + + /** + * Mute a live recording. + * Muting a recording suspends silence detection, which will be restarted when the recording is unmuted. + * + * @param params.recordingName - The name of the recording. + */ + mute(params: { recordingName: string }): Promise; + + /** + * Unmute a live recording. + * + * @param params.recordingName - The name of the recording. + */ + unmute(params: { recordingName: string }, callback: (err: Error) => void): void; + + /** + * Unmute a live recording. + * + * @param params.recordingName - The name of the recording. + */ + unmute(params: { recordingName: string }): Promise; +} +export interface StoredRecording extends Resource { + /** + * Name. + */ + name: string; + + /** + * Format. + */ + format: string; + + /** + * List recordings that are complete. + */ + listStored(callback: (err: Error, storedrecordings: StoredRecording[]) => void): void; + + /** + * List recordings that are complete. + */ + listStored(): Promise; + + /** + * Get a stored recordings details. + */ + getStored(callback: (err: Error, storedrecording: StoredRecording) => void): void; + + /** + * Get a stored recordings details. + */ + getStored(): Promise; + + /** + * Delete a stored recording. + */ + deleteStored(callback: (err: Error) => void): void; + + /** + * Delete a stored recording. + */ + deleteStored(): Promise; + + /** + * Get the file associated with the stored recording. + */ + getStoredFile(callback: (err: Error, binary: Buffer) => void): void; + + /** + * Get the file associated with the stored recording. + */ + getStoredFile(): Promise; + + /** + * Copy a stored recording. + * + * @param params.destinationRecordingName - The destination name of the recording. + */ + copyStored( + params: { destinationRecordingName: string }, + callback: (err: Error, storedrecording: StoredRecording) => void + ): void; + + /** + * Copy a stored recording. + * + * @param params.destinationRecordingName - The destination name of the recording. + */ + copyStored(params: { destinationRecordingName: string }): Promise; + + /** + * List live recordings. + */ + getLive(callback: (err: Error, liverecording: LiveRecording) => void): void; + + /** + * List live recordings. + */ + getLive(): Promise; + + /** + * Stop a live recording and discard it. + */ + cancel(callback: (err: Error) => void): void; + + /** + * Stop a live recording and discard it. + */ + cancel(): Promise; + + /** + * Stop a live recording and store it. + */ + stop(callback: (err: Error) => void): void; + + /** + * Stop a live recording and store it. + */ + stop(): Promise; + + /** + * Pause a live recording. + * Pausing a recording suspends silence detection, which will be restarted when the recording is unpaused. Paused time is not included in the accounting for maxDurationSeconds. + */ + pause(callback: (err: Error) => void): void; + + /** + * Pause a live recording. + * Pausing a recording suspends silence detection, which will be restarted when the recording is unpaused. Paused time is not included in the accounting for maxDurationSeconds. + */ + pause(): Promise; + + /** + * Unpause a live recording. + */ + unpause(callback: (err: Error) => void): void; + + /** + * Unpause a live recording. + */ + unpause(): Promise; + + /** + * Mute a live recording. + * Muting a recording suspends silence detection, which will be restarted when the recording is unmuted. + */ + mute(callback: (err: Error) => void): void; + + /** + * Mute a live recording. + * Muting a recording suspends silence detection, which will be restarted when the recording is unmuted. + */ + mute(): Promise; + + /** + * Unmute a live recording. + */ + unmute(callback: (err: Error) => void): void; + + /** + * Unmute a live recording. + */ + unmute(): Promise; +} +export interface LiveRecording extends Resource { + /** + * Base name for the recording. + */ + name: string; + + /** + * Recording format (wav, gsm, etc.). + */ + format: string; + + /** + * URI for the channel or bridge being recorded. + */ + target_uri: string; + + /** + * State. + */ + state: string; + + /** + * Duration in seconds of the recording. + */ + duration?: number | undefined; + + /** + * Duration of talking, in seconds, detected in the recording. This is only available if the recording was initiated with a non-zero maxSilenceSeconds. + */ + talking_duration?: number | undefined; + + /** + * Duration of silence, in seconds, detected in the recording. This is only available if the recording was initiated with a non-zero maxSilenceSeconds. + */ + silence_duration?: number | undefined; + + /** + * Cause for recording failure if failed. + */ + cause?: string | undefined; + + /** + * List recordings that are complete. + */ + listStored(callback: (err: Error, storedrecordings: StoredRecording[]) => void): void; + + /** + * List recordings that are complete. + */ + listStored(): Promise; + + /** + * Get a stored recordings details. + */ + getStored(callback: (err: Error, storedrecording: StoredRecording) => void): void; + + /** + * Get a stored recordings details. + */ + getStored(): Promise; + + /** + * Delete a stored recording. + */ + deleteStored(callback: (err: Error) => void): void; + + /** + * Delete a stored recording. + */ + deleteStored(): Promise; + + /** + * Get the file associated with the stored recording. + */ + getStoredFile(callback: (err: Error, binary: Buffer) => void): void; + + /** + * Get the file associated with the stored recording. + */ + getStoredFile(): Promise; + + /** + * Copy a stored recording. + * + * @param params.destinationRecordingName - The destination name of the recording. + */ + copyStored( + params: { destinationRecordingName: string }, + callback: (err: Error, storedrecording: StoredRecording) => void + ): void; + + /** + * Copy a stored recording. + * + * @param params.destinationRecordingName - The destination name of the recording. + */ + copyStored(params: { destinationRecordingName: string }): Promise; + + /** + * List live recordings. + */ + getLive(callback: (err: Error, liverecording: LiveRecording) => void): void; + + /** + * List live recordings. + */ + getLive(): Promise; + + /** + * Stop a live recording and discard it. + */ + cancel(callback: (err: Error) => void): void; + + /** + * Stop a live recording and discard it. + */ + cancel(): Promise; + + /** + * Stop a live recording and store it. + */ + stop(callback: (err: Error) => void): void; + + /** + * Stop a live recording and store it. + */ + stop(): Promise; + + /** + * Pause a live recording. + * Pausing a recording suspends silence detection, which will be restarted when the recording is unpaused. Paused time is not included in the accounting for maxDurationSeconds. + */ + pause(callback: (err: Error) => void): void; + + /** + * Pause a live recording. + * Pausing a recording suspends silence detection, which will be restarted when the recording is unpaused. Paused time is not included in the accounting for maxDurationSeconds. + */ + pause(): Promise; + + /** + * Unpause a live recording. + */ + unpause(callback: (err: Error) => void): void; + + /** + * Unpause a live recording. + */ + unpause(): Promise; + + /** + * Mute a live recording. + * Muting a recording suspends silence detection, which will be restarted when the recording is unmuted. + */ + mute(callback: (err: Error) => void): void; + + /** + * Mute a live recording. + * Muting a recording suspends silence detection, which will be restarted when the recording is unmuted. + */ + mute(): Promise; + + /** + * Unmute a live recording. + */ + unmute(callback: (err: Error) => void): void; + + /** + * Unmute a live recording. + */ + unmute(): Promise; +} +export interface Sounds { + /** + * List all sounds. + * + * @param [params.lang] - Lookup sound for a specific language. + * @param [params.format] - Lookup sound in a specific format. + */ + list( + params: { lang?: string | undefined; format?: string | undefined }, + callback: (err: Error, sounds: Sound[]) => void + ): void; + + /** + * List all sounds. + */ + list(callback: (err: Error, sounds: Sound[]) => void): void; + + /** + * List all sounds. + * + * @param [params.lang] - Lookup sound for a specific language. + * @param [params.format] - Lookup sound in a specific format. + */ + list(params?: { lang?: string | undefined; format?: string | undefined }): Promise; + + /** + * Get a sounds details. + * + * @param params.soundId - Sounds id. + */ + get(params: { soundId: string }, callback: (err: Error, sound: Sound) => void): void; + + /** + * Get a sounds details. + * + * @param params.soundId - Sounds id. + */ + get(params: { soundId: string }): Promise; +} +export interface FormatLangPair { + /** + * Language. + */ + language: string; + + /** + * Format. + */ + format: string; +} +export interface Sound extends Resource { + /** + * Sounds identifier. + */ + id: string; + + /** + * Text description of the sound, usually the words spoken. + */ + text?: string | undefined; + + /** + * The formats and languages in which this sound is available. + */ + formats: FormatLangPair | FormatLangPair[]; + + /** + * List all sounds. + * + * @param [params.lang] - Lookup sound for a specific language. + * @param [params.format] - Lookup sound in a specific format. + */ + list( + params: { lang?: string | undefined; format?: string | undefined }, + callback: (err: Error, sounds: Sound[]) => void + ): void; + + /** + * List all sounds. + */ + list(callback: (err: Error, sounds: Sound[]) => void): void; + + /** + * List all sounds. + * + * @param [params.lang] - Lookup sound for a specific language. + * @param [params.format] - Lookup sound in a specific format. + */ + list(params?: { lang?: string | undefined; format?: string | undefined }): Promise; + + /** + * Get a sounds details. + */ + get(callback: (err: Error, sound: Sound) => void): void; + + /** + * Get a sounds details. + */ + get(): Promise; +}