Skip to main content

Agents

Agents ⇐ APIClient

Use Fonoster Agents, a capability of Fonoster SIP Proxy subsystem, to create, update, get and delete Agents. Agents requires of a running Fonoster deployment.

Kind: global class
Extends: APIClient
See: module:core:APIClient

new Agents(options)

Constructs a new Agents object.

ParamTypeDescription
optionsClientOptionsOptions to indicate the objects endpoint

Example

const Fonoster = require("@fonoster/sdk")
const agents = new Fonoster.Agents()

const request = {
name: "John Doe",
username: "john",
secret: "1234",
domains: ["sip.local"]
}

agents.createAgent(request)
.then(result => {
console.log(result) // successful response
}).catch(e => console.error(e)) // an error occurred

agents.createAgent(request) ⇒ Promise.<CreateAgentResponse>

Creates a new Agent on the SIP Proxy subsystem.

Kind: instance method of Agents

ParamTypeDescription
requestCreateAgentRequestRequest for the provision of a new Agent
request.namestringFriendly name for the SIP device
request.usernamestringAgent's credential username
request.secretstringAgent's credential secret
request.privacyPrivacyIf set to Privacy.PRIVATE Fonoster removes identifiable information for the requests. Defaults to Privacy.NONE
request.domainsArray.<string>List of domains this Agent has access to

Example

const request = {
name: "John Doe",
username: "john",
secret: "1234",
domains: ["sip.local"]
privacy: Privacy.PRIVATE
}

agents.createAgent(request)
.then(result => {
console.log(result) // returns the CreateAgentResponse interface
}).catch(e => console.error(e)) // an error occurred

agents.getAgent(ref) ⇒ Promise.<GetAgentResponse>

Retrives an Agent by reference.

Kind: instance method of Agents
Returns: Promise.<GetAgentResponse> - The agent
Throws:

  • if ref is null or Agent does not exist
ParamTypeDescription
refstringReference to Agent

Example

const ref = "aynB1z0tzd";

agents.getAgent(ref)
.then(result => {
console.log(result) // returns the GetAgentResponse interface
}).catch(e => console.error(e)) // an error occurred

agents.updateAgent(request) ⇒ Promise.<UpdateAgentResponse>

Update an Agent at the SIP Proxy subsystem.

Kind: instance method of Agents

ParamTypeDescription
requestUpdateAgentRequestRequest update of an Agent
request.refstringReference to the Agent
request.namestringFriendly name for the SIP device
request.secretstringAgent's credential secret

Example

const request = {
name: "John Dee",
secret: "12345"
}

agents.updateAgent(request)
.then(result => {
console.log(result) // returns the UpdateAgentResponse interface
}).catch(e => console.error(e)) // an error occurred

agents.listAgents(request) ⇒ Promise.<ListAgentsResponse>

List registered Agents in Fonoster SIP Proxy subsystem.

Kind: instance method of Agents
Returns: Promise.<ListAgentsResponse> - Paginated List of Agents

ParamTypeDescription
requestListAgentsRequestOptional parameter with size and token for the request
request.pageSizenumberElements per page (defaults to 20)
request.pageTokenstringThe next_page_token value returned from a previous List request, if any

Example

const request = {
pageSize: 20,
pageToken: 2
}

agents.listAgents(request)
.then(() => {
console.log(result) // returns a ListAgentsResponse interface
}).catch(e => console.error(e)) // an error occurred

agents.deleteAgent(ref)

Deletes an Agent from the SIP Proxy subsystem.

Kind: instance method of Agents

ParamTypeDescription
refstringAgent's reference

Example

const ref = "aynB1z0tzd"

agents.deleteAgent(ref)
.then(() => {
console.log("done") // returns a reference of the Agent
}).catch(e => console.error(e)) // an error occurred