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
- Domains ⇐
APIClient
- new Domains(options)
- .createDomain(request) ⇒
Promise.<CreateDomainResponse>
- .getDomain(ref) ⇒
Promise.<GetDomainResponse>
- .updateDomain(request) ⇒
Promise.<UpdateDomainResponse>
- .listDomains(request) ⇒
Promise.<ListDomainsResponse>
- .deleteDomain(ref)
new Domains(options)
Constructs a new Domains object.
Param | Type | Description |
---|---|---|
options | ClientOptions | Options 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
Param | Type | Description |
---|---|---|
request | CreateDomainRequest | Request for the provision of a new Domain |
request.name | string | Friendly name for the SIP domain |
request.domainUri | string | Domain URI. FQDN is recommended |
request.egressNumberRef | string | A valid reference to a Number in Fonoster |
request.egressRule | string | Regular expression indicating when a call will be routed via request.egressNumberRef |
request.accessDeny | string | Optional list of IPs or networks that cannot communicate with this Domain |
request.accessAllow | string | Optional 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
Param | Type | Description |
---|---|---|
ref | string | Reference 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
Param | Type | Description |
---|---|---|
request | UpdateDomainRequest | Request for the update of an existing Domain |
request.ref | string | To update a Domain you must provide its reference |
request.name | string | Friendly name for the SIP domain |
request.egressNumberRef | string | A valid reference to a Number in Fonoster |
request.egressRule | string | Regular expression indicating when a call will be routed via request.egressNumberRef |
request.accessDeny | string | Optional list of IPs or networks that cannot communicate with this Domain |
request.accessAllow | string | Optional 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>
Lists the Domains registered in the Fonoster SIP Proxy subsystem.
Kind: instance method of Domains
Returns: Promise.<ListDomainsResponse>
- Paginated list of Domains
Param | Type | Description |
---|---|---|
request | ListDomainsRequest | Optional parameter with size and token for the request |
request.pageSize | number | Number of element 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
};
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
Param | Type | Description |
---|---|---|
ref | string | Reference 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