Skip to main content
Version: 2.0.0

SDK

Installation

$ npm install --save @routr/sdk

APIs

Acls ⇐ APIClient

Use Routr ACL, a capability of Routr SIP Proxy, to create, update, get and delete Access Control Lists. The ACL API requires of a running Routr deployment.

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

new Acls(options)

Constructs a new Acl API object.

ParamTypeDescription
optionsClientOptionsOptions to indicate the objects endpoint

Example

const SDK = require("@routr/sdk")
const acl = new SDK.Acls()

const request = {
name: "Peer network",
allow: "27.116.56.0/22",
deny: "0.0.0.0/0"
}

acl.createAcl(request)
.then(console.log)
.catch(console.error) // an error occurred

acls.createAcl(request) ⇒ Promise.<CreateAclResponse>

Creates a new AccessControlList on Routr.

Kind: instance method of Acls
Returns: Promise.<CreateAclResponse> - The newly created AccessControlList
Throws:

  • if request is null
ParamTypeDescription
requestCreateAclRequestThe request to create an ACL
request.namestringName of the ACL
request.allowArray.<string>List of IP addresses or CIDR blocks to allow
request.denyArray.<string>List of IP addresses or CIDR blocks to deny
request.extendedObjectOptional extended attributes

Example

const request = {
name: "Peer network",
allow: "27.116.56.0/22",
deny: "0.0.0.0/0"
}

acl.createAcl(request)
.then(console.log)
.catch(console.error) // an error occurred

acls.updateAcl(request) ⇒ Promise.<UpdateAclResponse>

Updates an already existing AccessControlList on Routr.

Kind: instance method of Acls
Returns: Promise.<UpdateAclResponse> - The AccessControlList

ParamTypeDescription
requestUpdateAclRequestPartial with the fields to update
request.namestringName of the ACL
request.allowArray.<string>List of IP addresses or CIDR blocks to allow
request.denyArray.<string>List of IP addresses or CIDR blocks to deny
request.extendedObjectOptional extended attributes

Example

const request = {
ref: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3",
name: "Peer network updated",
}

acl.updateAcl(request)
.then(console.log)
.catch(console.error) // an error occurred

acls.getAcl(ref) ⇒ Promise.<GetAclResponse>

Gets an AccessControlList from Routr.

Kind: instance method of Acls
Returns: Promise.<GetAclResponse> - The AccessControlList

ParamTypeDescription
refstringThe ACL reference

Example

const ref = "4671371b-ff5d-48b1-aabe-d3c5ca5317a3"

acl.getAcl(ref)
.then(console.log)
.catch(console.error) // an error occurred

acls.deleteAcl(ref) ⇒ Promise.<void>

Deletes an AccessControlList from Routr.

Kind: instance method of Acls

ParamTypeDescription
refstringThe ACL reference

Example

const ref = "4671371b-ff5d-48b1-aabe-d3c5ca5317a3"

acl.deleteAcl(ref)
.then(console.log)
.catch(console.error) // an error occurred

acls.listAcls(request) ⇒ Promise.<ListAclResponse>

Lists all AccessControlLists from Routr with pagination.

Kind: instance method of Acls
Returns: Promise.<ListAclResponse> - The list of AccessControlLists

ParamTypeDescription
requestListAclRequestThe request to list ACLs
request.pageSizenumberThe number of ACLs to return
request.pageTokenstringThe page token to use for pagination

Example

const request = {
pageSize: 10
}

acl.listAcls(request)
.then(console.log)
.catch(console.error) // an error occurred

Agents ⇐ APIClient

Use Routr Agents, a capability of Routr SIP Proxy, to create, update, get and delete Agents. The Agents API requires of a running Routr deployment.

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

new Agents(options)

Constructs a new Agent API object.

ParamTypeDescription
optionsClientOptionsOptions to indicate the objects endpoint

Example

const SDK = require("@routr/sdk")
const agents = new SDK.Agents()

const request = {
name: "Jonh Doe",
username: "jdoe",
privacy: Privacy.PRIVATE,
domainRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3",
credentialsRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3",
enabled: true,
extended: {
"key": "value"
}
}

agents.createAgent(request)
.then(console.log)
.catch(console.error) // an error occurred

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

Creates a new Agent on Routr.

Kind: instance method of Agents
Returns: Promise.<CreateAgentResponse> - The newly created Agent
Throws:

  • if request is null
ParamTypeDescription
requestCreateAgentRequestThe request to create an Agent
request.namestringName of the Agent
request.usernamestringUsername of the Agent
request.privacyPrivacyPrivacy of the Agent (e.g., Privacy.PRIVATE)
request.domainRefstringDomain reference of the Domain the Agent belongs to
request.credentialsRefstringCredentials reference of the Credentials for the Agent
request.enabledbooleanWhether the Agent is enabled or not (for future use)
request.extendedObjectOptional extended attributes

Example

const request = {
name: "Jonh Doe",
username: "jdoe",
privacy: Privacy.PRIVATE,
domainRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3",
credentialsRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3",
enabled: true,
extended: {
"key": "value"
}
}

agents.createAgent(request)
.then(console.log)
.catch(console.error) // an error occurred

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

Updates an already existing Agent on Routr.

Kind: instance method of Agents
Returns: Promise.<UpdateAgentResponse> - The updated Agent

ParamTypeDescription
requestUpdateAgentRequestPartial with the fields to update
request.namestringName of the Agent
request.privacyPrivacyPrivacy of the Agent (e.g., Privacy.PRIVATE)
request.domainRefstringDomain reference of the Domain the Agent belongs to
request.credentialsRefstringCredentials reference of the Credentials for the Agent
request.enabledbooleanWhether the Agent is enabled or not (for future use)
request.extendedObjectOptional extended attributes

Example

const request = {
ref: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3",
name: "John D Doe",
enabled: false
}

agents.updateAgent(request)
.then(console.log)
.catch(console.error) // an error occurred

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

Gets an Agent from Routr.

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

ParamTypeDescription
refstringThe Agent's reference

Example

const ref = "4671371b-ff5d-48b1-aabe-d3c5ca5317a3"

agents.getAgent(ref)
.then(console.log)
.catch(console.error) // an error occurred

agents.deleteAgent(ref) ⇒ Promise.<void>

Deletes an Agent from Routr.

Kind: instance method of Agents

ParamTypeDescription
refstringThe Agent's reference

Example

const ref = "4671371b-ff5d-48b1-aabe-d3c5ca5317a3"

agents.deleteAgent(ref)
.then(console.log)
.catch(console.error) // an error occurred

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

Lists all Agents from Routr with pagination.

Kind: instance method of Agents
Returns: Promise.<ListAgentResponse> - The list of Agents in the current page

ParamTypeDescription
requestListAgentRequestThe request to list Agents
request.pageSizenumberThe number of Agents to return
request.pageTokenstringThe page token to use for pagination

Example

const request = {
pageSize: 10
}

agents.listAgents(request)
.then(console.log)
.catch(console.error) // an error occurred

Credentials ⇐ APIClient

Use Routr Credentials, a capability of Routr SIP Proxy, to create, update, get and delete Credentials. The Credentials API requires of a running Routr deployment.

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

new Credentials(options)

Constructs a new Credentials API object.

ParamTypeDescription
optionsClientOptionsOptions to indicate the objects endpoint

Example

const SDK = require("@routr/sdk")
const credentials = new SDK.Credentials()

const request = {
name: "Credentials for John Doe",
username: "jdoe",
password: "123456",
extended: {
"key": "value"
}
}

credentials.createCredentials(request)
.then(console.log)
.catch(console.error) // an error occurred

credentials.createCredentials(request) ⇒ Promise.<CreateCredentialsResponse>

Creates a new Credentials on Routr.

Kind: instance method of Credentials
Returns: Promise.<CreateCredentialsResponse> - The newly created Credentials
Throws:

  • if request is null
ParamTypeDescription
requestCreateCredentialsRequestThe request to create an Credentials
request.namestringThe friendly name of the Credentials
request.usernamestringUsername of the Credentials
request.passwordstringPassword of the Credentials
request.extendedObjectOptional extended attributes

Example

const request = {
name: "Credentials for John Doe",
username: "jdoe",
password: "123456",
extended: {
"key": "value"
}
}

credentials.createCredentials(request)
.then(console.log)
.catch(console.error) // an error occurred

credentials.updateCredentials(request) ⇒ Promise.<UpdateCredentialsResponse>

Updates an already existing Credentials on Routr.

Kind: instance method of Credentials
Returns: Promise.<UpdateCredentialsResponse> - The updated Credentials

ParamTypeDescription
requestUpdateCredentialsRequestPartial with the fields to update
request.namestringThe friendly name of the Credentials
request.usernamestringUsername of the Credentials
request.passwordstringPassword of the Credentials
request.extendedObjectOptional extended attributes

Example

const request = {
ref: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3",
name: "John Doe's Credentials"
}

credentials.updateCredentials(request)
.then(console.log)
.catch(console.error) // an error occurred

credentials.getCredentials(ref) ⇒ Promise.<GetCredentialsResponse>

Gets an Credentials from Routr.

Kind: instance method of Credentials
Returns: Promise.<GetCredentialsResponse> - The Credentials

ParamTypeDescription
refstringThe Credentials's reference

Example

const ref = "4671371b-ff5d-48b1-aabe-d3c5ca5317a3"

credentials.getCredentials(ref)
.then(console.log)
.catch(console.error) // an error occurred

credentials.deleteCredentials(ref) ⇒ Promise.<void>

Deletes an Credentials from Routr.

Kind: instance method of Credentials

ParamTypeDescription
refstringThe Credentials's reference

Example

const ref = "4671371b-ff5d-48b1-aabe-d3c5ca5317a3"

credentials.deleteCredentials(ref)
.then(console.log)
.catch(console.error) // an error occurred

credentials.listCredentials(request) ⇒ Promise.<ListCredentialsResponse>

Lists all Credentials from Routr with pagination.

Kind: instance method of Credentials
Returns: Promise.<ListCredentialsResponse> - The list of Credentials in the current page

ParamTypeDescription
requestListCredentialsRequestThe request to list Credentials
request.pageSizenumberThe number of Credentials to return
request.pageTokenstringThe page token to use for pagination

Example

const request = {
pageSize: 10
}

credentials.listCredentials(request)
.then(console.log)
.catch(console.error) // an error occurred

Domains ⇐ APIClient

Use Routr Domains, a capability of Routr SIP Proxy, to create, update, get and delete Domains. The Domains API requires of a running Routr deployment.

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

new Domains(options)

Constructs a new Domain API object.

ParamTypeDescription
optionsClientOptionsOptions to indicate the objects endpoint

Example

const SDK = require("@routr/sdk")
const domains = new SDK.Domains()

const request = {
name: "Local domain",
domainUri: "sip.local",
accessControlListRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3",
egressPolicies: [{
rule: ".*",
numberRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3"
}],
extended: {
"key": "value"
}
}

domains.createDomain(request)
.then(console.log)
.catch(console.error) // an error occurred

domains.createDomain(request) ⇒ Promise.<CreateDomainResponse>

Creates a new Domain on Routr.

Kind: instance method of Domains
Returns: Promise.<CreateDomainResponse> - The newly created Domain
Throws:

  • if request is null
ParamTypeDescription
requestCreateDomainRequestThe request to create an Domain
request.namestringName of the Domain
request.domainUristringThe FQDN of the Domain
request.accessControlListRefstringThe reference to the AccessControlList for the Domain
request.egressPoliciesArray.<EgressPolicy>The list of EgressPolicies for the Domain
request.extendedstringOptional extended attributes

Example

const request = {
name: "Local domain",
domainUri: "sip.local",
accessControlListRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3",
egressPolicies: [{
rule: ".*",
numberRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3"
}],
extended: {
"key": "value"
}
}

domains.createDomain(request)
.then(console.log)
.catch(console.error) // an error occurred

domains.updateDomain(request) ⇒ Promise.<UpdateDomainResponse>

Updates an already existing Domain on Routr.

Kind: instance method of Domains
Returns: Promise.<UpdateDomainResponse> - The updated Domain

ParamTypeDescription
requestUpdateDomainRequestPartial with the fields to update
request.namestringName of the Domain
request.accessControlListRefstringThe reference to the AccessControlList for the Domain
request.egressPoliciesArray.<EgressPolicy>The list of EgressPolicies for the Domain
request.extendedstringOptional extended attributes

Example

const request = {
name: "Local domain updated",
accessControlListRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3"
}

domains.updateDomain(request)
.then(console.log)
.catch(console.error) // an error occurred

domains.getDomain(ref) ⇒ Promise.<GetDomainResponse>

Gets a Domain from Routr.

Kind: instance method of Domains
Returns: Promise.<GetDomainResponse> - The Domain

ParamTypeDescription
refstringThe Domain's reference

Example

const ref = "4671371b-ff5d-48b1-aabe-d3c5ca5317a3"

domains.getDomain(ref)
.then(console.log)
.catch(console.error) // an error occurred

domains.deleteDomain(ref) ⇒ Promise.<void>

Deletes a Domain from Routr.

Kind: instance method of Domains

ParamTypeDescription
refstringThe Domain's reference

Example

const ref = "4671371b-ff5d-48b1-aabe-d3c5ca5317a3"

domains.deleteDomain(ref)
.then(console.log)
.catch(console.error) // an error occurred

domains.listDomains(request) ⇒ Promise.<ListDomainResponse>

Lists all Domains from Routr with pagination.

Kind: instance method of Domains
Returns: Promise.<ListDomainResponse> - The list of Domains

ParamTypeDescription
requestListDomainRequestThe request to list Domains
request.pageSizenumberThe number of Domains to return
request.pageTokenstringThe page token to use for pagination

Example

const request = {
pageSize: 10
}

domains.listDomains(request)
.then(console.log)
.catch(console.error) // an error occurred

Numbers ⇐ APIClient

Use Routr Numbers, a capability of Routr SIP Proxy, to create, update, get and delete Numbers. The Number API requires of a running Routr deployment.

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

new Numbers(options)

Constructs a new Number API object.

ParamTypeDescription
optionsClientOptionsOptions to indicate the objects endpoint

Example

const SDK = require("@routr/sdk")
const numbers = new SDK.Numbers()

const request = {
name: "(415) 555-1212",
telUrl: "teL:+14155551212",
trunkRef: "6f941c63-880c-419a-a72a-4a107cbaf5c5",
aorLink: "sip:100@sip.local",
city: "San Francisco",
country: "United States",
countryIsoCode: "US",
sessionAffinityHeader: "X-Room-Id"
extraHeaders: [{
name: "X-Room-Id",
value: "abc-us-123"
}],
extended: {
"key": "value"
}
}

numbers.createNumber(request)
.then(console.log)
.catch(console.error) // an error occurred

numbers.createNumber(request) ⇒ Promise.<CreateNumberResponse>

Creates a new Number on Routr.

Kind: instance method of Numbers
Returns: Promise.<CreateNumberResponse> - The newly created Number
Throws:

  • if request is null
ParamTypeDescription
requestCreateNumberRequestThe request to create an Number
request.namestringName of the Number
request.telUrlstringThe number URI to be used (e.g., te:+1234567890)
request.aorLinkstringThe AOR link to be used (e.g., sip:1001@sip.local)
request.citystringThe city where the number is located
request.countrystringThe country where the number is located
request.countryIsoCodestringThe country ISO code where the number is located
request.extraHeadersArray.<JsonObject>Extra headers to be used (e.g., [{name: "X-Room-Id", value: "abc-us-123"}])
request.trunkRefstringThe Trunk reference to be used
request.sessionAffinityHeaderstringOptional session affinity header
request.extendedstringOptional extended attributes

Example

const request = {
name: "(415) 555-1212",
telUrl: "teL:+14155551212",
trunkRef: "6f941c63-880c-419a-a72a-4a107cbaf5c5",
aorLink: "sip:100@sip.local",
city: "San Francisco",
country: "United States",
countryIsoCode: "US",
sessionAffinityHeader: "X-Room-Id"
extraHeaders: [{
name: "X-Room-Id",
value: "abc-us-123"
}],
extended: {
"key": "value"
}
}

numbers.createNumber(request)
.then(console.log)
.catch(console.error) // an error occurred

numbers.updateNumber(request) ⇒ Promise.<UpdateNumberResponse>

Updates an already existing Number on Routr.

Kind: instance method of Numbers
Returns: Promise.<UpdateNumberResponse> - The updated Number

ParamTypeDescription
requestUpdateNumberRequestPartial with the fields to update
request.namestringName of the Number
request.aorLinkstringThe AOR link to be used (e.g., sip:1001@sip.local)
request.extraHeadersArray.<JsonObject>Extra headers to be used (e.g., [{name: "X-Room-Id", value: "abc-us-123"}])
request.trunkRefstringThe Trunk reference to be used
request.sessionAffinityHeaderstringOptional session affinity header
request.extendedstringOptional extended attributes

Example

const request = {
name: "(415) 555-1212 (friendly name)",
aorLink: "sip:2001@sip.local"
}

numbers.updateNumber(request)
.then(console.log)
.catch(console.error) // an error occurred

numbers.getNumber(ref) ⇒ Promise.<GetNumberResponse>

Gets a Number from Routr.

Kind: instance method of Numbers
Returns: Promise.<GetNumberResponse> - The Number

ParamTypeDescription
refstringThe Number's reference

Example

const ref = "4671371b-ff5d-48b1-aabe-d3c5ca5317a3"

numbers.getNumber(ref)
.then(console.log)
.catch(console.error) // an error occurred

numbers.deleteNumber(ref) ⇒ Promise.<void>

Deletes a Number from Routr.

Kind: instance method of Numbers

ParamTypeDescription
refstringThe Number's reference

Example

const ref = "4671371b-ff5d-48b1-aabe-d3c5ca5317a3"

numbers.deleteNumber(ref)
.then(console.log)
.catch(console.error) // an error occurred

numbers.listNumbers(request) ⇒ Promise.<ListNumberResponse>

Lists all Numbers from Routr with pagination.

Kind: instance method of Numbers
Returns: Promise.<ListNumberResponse> - The list of Numbers

ParamTypeDescription
requestListNumberRequestThe request to list Numbers
request.pageSizenumberThe number of Numbers to return
request.pageTokenstringThe page token to use for pagination

Example

const request = {
pageSize: 10
}

numbers.listNumbers(request)
.then(console.log)
.catch(console.error) // an error occurred

Peers ⇐ APIClient

Use Routr Peers, a capability of Routr SIP Proxy, to create, update, get and delete Peers. The Peers API requires of a running Routr deployment.

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

new Peers(options)

Constructs a new Peer API object.

ParamTypeDescription
optionsClientOptionsOptions to indicate the objects endpoint

Example

const SDK = require("@routr/sdk")
const peers = new SDK.Peers()

const request = {
name: "Asterisk Conference Server",
username: "conference",
aor: "sip:conference@sip.local",
contactAddr: "10.0.0.1:5060",
accessControlListRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3",
credentialsRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3",
balancingAlgorithm: LoadBalancingAlgorithm.LEAST_SESSIONS,
withSessionAffinity: true,
enabled: true,
extended: {
"key": "value"
}
}

peers.createPeer(request)
.then(console.log)
.catch(console.error) // an error occurred

peers.createPeer(request) ⇒ Promise.<CreatePeerResponse>

Creates a new Peer on Routr.

Kind: instance method of Peers
Returns: Promise.<CreatePeerResponse> - The newly created Peer
Throws:

  • if request is null
ParamTypeDescription
requestCreatePeerRequestThe request to create an Peer
request.namestringName of the Peer
request.aorstringAddress of Record of the Peer
request.contactAddrstringOptional contact address of the Peer
request.accessControlListRefstringAccess Control List reference of the Peer
request.credentialsRefstringCredentials reference of the Credentials for the Peer
request.balancingAlgorithmLoadBalancingAlgorithmOptional balancing algorithm for the Peer (defaults to "round-robin")
request.withSessionAffinitybooleanWhether the Peer has session affinity or not (defaults to false)
request.enabledbooleanWhether the Peer is enabled or not (for future use)
request.extendedObjectOptional extended attributes

Example

const request = {
name: "Asterisk Conference Server",
username: "conference",
aor: "sip:conference@sip.local",
contactAddr: "10.0.0.1:5060",
accessControlListRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3",
credentialsRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3",
balancingAlgorithm: LoadBalancingAlgorithm.LEAST_SESSIONS,
withSessionAffinity: true,
enabled: true,
extended: {
"key": "value"
}
}

peers.createPeer(request)
.then(console.log)
.catch(console.error) // an error occurred

peers.updatePeer(request) ⇒ Promise.<UpdatePeerResponse>

Updates an already existing Peer on Routr.

Kind: instance method of Peers
Returns: Promise.<UpdatePeerResponse> - The updated Peer

ParamTypeDescription
requestUpdatePeerRequestPartial with the fields to update
request.namestringName of the Peer
request.aorstringAddress of Record of the Peer
request.contactAddrstringOptional contact address of the Peer
request.accessControlListRefstringAccess Control List reference of the Peer
request.credentialsRefstringCredentials reference of the Credentials for the Peer
request.balancingAlgorithmLoadBalancingAlgorithmOptional balancing algorithm for the Peer (defaults to "round-robin")
request.withSessionAffinitybooleanWhether the Peer has session affinity or not (defaults to false)
request.enabledbooleanWhether the Peer is enabled or not (for future use)
request.extendedObjectOptional extended attributes

Example

const request = {
ref: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3",
name: "Feature Server"
}

peers.updatePeer(request)
.then(console.log)
.catch(console.error) // an error occurred

peers.getPeer(ref) ⇒ Promise.<GetPeerResponse>

Gets an Peer from Routr.

Kind: instance method of Peers
Returns: Promise.<GetPeerResponse> - The Peer

ParamTypeDescription
refstringThe Peer's reference

Example

const ref = "4671371b-ff5d-48b1-aabe-d3c5ca5317a3"

peers.getPeer(ref)
.then(console.log)
.catch(console.error) // an error occurred

peers.deletePeer(ref) ⇒ Promise.<void>

Deletes an Peer from Routr.

Kind: instance method of Peers

ParamTypeDescription
refstringThe Peer's reference

Example

const ref = "4671371b-ff5d-48b1-aabe-d3c5ca5317a3"

peers.deletePeer(ref)
.then(console.log)
.catch(console.error) // an error occurred

peers.listPeers(request) ⇒ Promise.<ListPeerResponse>

Lists all Peers from Routr with pagination.

Kind: instance method of Peers
Returns: Promise.<ListPeerResponse> - The list of Peers in the current page

ParamTypeDescription
requestListPeerRequestThe request to list Peers
request.pageSizenumberThe number of Peers to return
request.pageTokenstringThe page token to use for pagination

Example

const request = {
pageSize: 10
}

peers.listPeers(request)
.then(console.log)
.catch(console.error) // an error occurred

Trunks ⇐ APIClient

Use Routr Trunks, a capability of Routr SIP Proxy, to create, update, get and delete Trunks. The Trunks API requires of a running Routr deployment.

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

new Trunks(options)

Constructs a new Trunk API object.

ParamTypeDescription
optionsClientOptionsOptions to indicate the objects endpoint

Example

const SDK = require("@routr/sdk")
const trunks = new SDK.Trunks()

const request = {
name: "Trunk from Twilio",
inboundUri: "sip:twilio.sip.acme.io",
accessControlListRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3",
inboundCredentialsRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3",
outboundCredentialsRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3",
uris: [{
host: "acme.sip.twilio.com",
port: 5060,
transport: "udp",
user: "AC1234567890",
weight: 1,
priority: 1
}],
extended: {
"key": "value"
}
}

trunks.createTrunk(request)
.then(console.log)
.catch(console.error) // an error occurred

trunks.createTrunk(request) ⇒ Promise.<CreateTrunkResponse>

Creates a new Trunk on Routr.

Kind: instance method of Trunks
Returns: Promise.<CreateTrunkResponse> - The newly created Trunk
Throws:

  • if request is null
ParamTypeDescription
requestCreateTrunkRequestThe request to create an Trunk
request.namestringName of the Trunk
request.inboundUristringInbound URI of the Trunk
request.accessControlListRefstringAccess Control List reference
request.inboundCredentialsRefstringThe reference of the inbound credentials
request.outboundCredentialsRefstringThe reference of the outbound credentials
request.urisArray.<TrunkURI>The outbound URIs of the Trunk

Example

const request = {
name: "Trunk from Twilio",
inboundUri: "sip:twilio.sip.acme.io",
accessControlListRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3",
inboundCredentialsRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3",
outboundCredentialsRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3",
uris: [{
host: "acme.sip.twilio.com",
port: 5060,
transport: "udp",
user: "AC1234567890",
weight: 1,
priority: 1
}],
extended: {
"key": "value"
}
}

trunks.createTrunk(request)
.then(console.log)
.catch(console.error) // an error occurred

trunks.updateTrunk(request) ⇒ Promise.<UpdateTrunkResponse>

Updates an already existing Trunk on Routr.

Kind: instance method of Trunks
Returns: Promise.<UpdateTrunkResponse> - The updated Trunk

ParamTypeDescription
requestUpdateTrunkRequestPartial with the fields to update
request.namestringName of the Trunk
request.inboundUristringInbound URI of the Trunk
request.accessControlListRefstringAccess Control List reference
request.inboundCredentialsRefstringThe reference of the inbound credentials
request.outboundCredentialsRefstringThe reference of the outbound credentials
request.urisArray.<TrunkURI>The outbound URIs of the Trunk
request.extendedObjectOptional extended attributes

Example

const request = {
ref: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3",
name: "Trunk from Twilio (US-East)",
}

trunks.updateTrunk(request)
.then(console.log)
.catch(console.error) // an error occurred

trunks.getTrunk(ref) ⇒ Promise.<GetTrunkResponse>

Gets an Trunk from Routr.

Kind: instance method of Trunks
Returns: Promise.<GetTrunkResponse> - The Trunk

ParamTypeDescription
refstringThe Trunk's reference

Example

const ref = "4671371b-ff5d-48b1-aabe-d3c5ca5317a3"

trunks.getTrunk(ref)
.then(console.log)
.catch(console.error) // an error occurred

trunks.deleteTrunk(ref) ⇒ Promise.<void>

Deletes an Trunk from Routr.

Kind: instance method of Trunks

ParamTypeDescription
refstringThe Trunk's reference

Example

const ref = "4671371b-ff5d-48b1-aabe-d3c5ca5317a3"

trunks.deleteTrunk(ref)
.then(console.log)
.catch(console.error) // an error occurred

trunks.listTrunks(request) ⇒ Promise.<ListTrunkResponse>

Lists all Trunks from Routr with pagination.

Kind: instance method of Trunks
Returns: Promise.<ListTrunkResponse> - The list of Trunks in the current page

ParamTypeDescription
requestListTrunkRequestThe request to list Trunks
request.pageSizenumberThe number of Trunks to return
request.pageTokenstringThe page token to use for pagination

Example

const request = {
pageSize: 10
}

trunks.listTrunks(request)
.then(console.log)
.catch(console.error) // an error occurred