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
- Agents ⇐
APIClient
- new Agents(options)
- .createAgent(request) ⇒
Promise.<CreateAgentResponse>
- .getAgent(ref) ⇒
Promise.<GetAgentResponse>
- .updateAgent(request) ⇒
Promise.<UpdateAgentResponse>
- .listAgents(request) ⇒
Promise.<ListAgentsResponse>
- .deleteAgent(ref)
new Agents(options)
Constructs a new Agents object.
Param | Type | Description |
---|---|---|
options | ClientOptions | Options 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
Param | Type | Description |
---|---|---|
request | CreateAgentRequest | Request for the provision of a new Agent |
request.name | string | Friendly name for the SIP device |
request.username | string | Agent's credential username |
request.secret | string | Agent's credential secret |
request.privacy | string | If set to "Private" Fonoster removes identifiable information for the requests. Defaults to "None" |
request.domains | Array.<string> | List of domains this Agent has access to |
Example
const request = {
name: "John Doe",
username: "john",
secret: "1234",
domains: ["sip.local"]
}
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
Param | Type | Description |
---|---|---|
ref | string | Reference to Agent |
Example
const ref = "507f1f77bcf86cd799439011";
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
Param | Type | Description |
---|---|---|
request | UpdateAgentRequest | Request update of an Agent |
request.ref | string | Reference to the Agent |
request.name | string | Friendly name for the SIP device |
request.secret | string | Agent'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
Param | Type | Description |
---|---|---|
request | ListAgentsRequest | Optional parameter with size and token for the request |
request.pageSize | number | Elements per page (defaults to 20) |
request.pageToken | string | The 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
Param | Type | Description |
---|---|---|
ref | string | Agent's reference |
Example
const ref = "507f1f77bcf86cd799439011"
agents.deleteAgent(ref)
.then(() => {
console.log("done") // returns a reference of the agent
}).catch(e => console.error(e)) // an error occurred