Skip to main content

Domains

Domains ⇐ APIClient

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

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

new Domains(options)

Constructs a new Domains object.

ParamTypeDescription
optionsClientOptionsOptions to indicate the objects endpoint

Example

const Fonoster = require("@fonoster/sdk");
const domains = new Fonoster.Domains();

domains.createDomain({name: "Local Domain", domainUri: "sip.local"...})
.then(result => {
console.log(result) // successful response
}).catch(e => console.error(e)); // an error occurred

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

Creates a new Domain on the SIP Proxy subsystem.

Kind: instance method of Domains

ParamTypeDescription
requestCreateDomainRequestRequest for the provision of a new Domain
request.namestringFriendly name for the SIP domain
request.domainUristringDomain URI. FQDN is recommended
request.egressNumberRefstringA valid reference to a Number in Fonos
request.egressRulestringRegular expression indicating when a call will be routed via request.egressNumberRef
request.accessDenystringOptional list of IPs or networks that cannot communicate with this Domain
request.accessAllowstringOptional list of IPs or networks allow if request.accessDeny is defined

Example

const request = {
name: "Local Domain",
domainUri: "sip.local",
egressRule: ".*",
egressNumberRef: "cb8V0CNTfH",
accessDeny: ["0.0.0.0/1"] // Deny all
accessAllow: ["192.168.1.0/255.255.255.0", "192.168.0.1/31"]
};

domains.createDomain(request)
.then(result => {
console.log(result) // returns the CreateDomainResponse interface
}).catch(e => console.error(e)); // an error occurred

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

Retrives a Domain by its reference.

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

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

Example

const ref = "Nx05y-ldZa";

domains.getDomain(ref)
.then(result => {
console.log(result) // returns the CreateGetResponse interface
}).catch(e => console.error(e)); // an error occurred

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

Update a Domain at the SIP Proxy subsystem.

Kind: instance method of Domains

ParamTypeDescription
requestUpdateDomainRequestRequest for the update of an existing Domain
request.refstringTo update a Domain you must provide its reference
request.namestringFriendly name for the SIP domain
request.egressNumberRefstringA valid reference to a Number in Fonos
request.egressRulestringRegular expression indicating when a call will be routed via request.egressNumberRef
request.accessDenystringOptional list of IPs or networks that cannot communicate with this Domain
request.accessAllowstringOptiona list of IPs or networks allow if request.accessDeny is defined

Example

const request = {
ref: "Nx05y-ldZa",
name: "Office Domain",
accessAllow: ["192.168.1.0/255.255.255.0", "192.168.0.1/31"]
};

domains.updateDomain(request)
.then(result => {
console.log(result) // returns the UpdateDomainResponse interface
}).catch(e => console.error(e)); // an error occurred

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

List the Domains registered in Fonoster SIP Proxy subsystem.

Kind: instance method of Domains
Returns: Promise.<ListDomainsResponse> - Paginated list of Domains

ParamTypeDescription
requestListDomainsRequestOptional parameter with size and token for the request
request.pageSizenumberNumber of element 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
};

domains.listDomains(request)
.then(() => {
console.log(result) // returns a ListDomainsResponse interface
}).catch(e => console.error(e)); // an error occurred

domains.deleteDomain(ref)

Deletes a Domain from SIP Proxy subsystem. Notice, that in order to delete a Domain, you must first delete all it's Agents.

Kind: instance method of Domains

ParamTypeDescription
refstringReference to the Domain you wish to delete

Example

const ref = "Nx05y-ldZa";

domains.deleteDomain(ref)
.then(() => {
console.log("done") // returns a reference of the domain
}).catch(e => console.error(e)); // an error occurred