Provisioning

This chapter provides a description of the database schema and instructions for provisioning the CRS databases through both the web UI and the API.

Central to the database is the call plan table which is structured so that the records map serialized routing objects to serialized destination objects.

There are also route and destination tables that store the fully qualified names of the implementations of any routing or destination objects provided by the engine. Thus, the call plan table stores physical route and destination objects in the database using two columns. One column is an ID reference to either the route or destination table which indicates the implementing class of the object. The second column is a serialized string of the physical object’s value. The tables in the provisioning section illustrate this concept.

Call plans are also tied to users and groups. This relationship allows for the quick development of small/simple schemas that do little more than add meta information to the routing engine core on a per user or per group basis. Thus, the core CRS engine remains very generic and customization can be done as needed.

Information that is stored in the database can be divided into the following tables: Administrators, Service Providers, Subscribers, Call Plans, Groups, Supergroups, and Numbers.


CSV File Columns and Format

Administrators

The CSV files to be imported for any administrator account should have the following format:

Column

Value

1

Username

2

Role ID

3

First Name

4

Last Name

5

Email

6

Permissions

username

A unique string that is the user name for this user. Limit of 64 characters. Can contain only lowercase characters, numbers, or underscores.

role_id

A string that defines the type of administrator that is being created. Accepted values are:

  • platform_owner

  • service_provider:<service_provider_name>

  • subscriber:<service_provider_name>:<subscriber_name>

first_name (optional)

A string that is the first name of this user. Limit of 250 characters.

last_name (optional)

A string that is the last name of this user. Limit of 250 characters.

email (optional)

A string that is the email address for this user. Limit of 250 characters.

permissions (optional)

An array of permission groups that this user is a member of. Permissions are dependent on the specified role_id of the created administrator.


Service Providers

The CSV files to be imported for Service Providers should have the following format:

Column

Value

1

Name

2

Display Name

3

First Name

4

Last Name

5

Email

6

Address

7

Phone

name

A unique string that is the name of this Service Provider. Limit of 64 characters.

display_name (optional)

An unconstrained string used as a display name. Limit of 250 characters.

first_name (optional)

A string that is the first name of a contact for this Service Provider. Limit of 250 characters.

last_name (optional)

A string that is the last name of a contact for this Service Provider. Limit of 250 characters.

email (optional)

A string that is the email address of this Service Provider, where notifications and password reset requests will be sent. Limit of 250 characters.

address (optional)

A string that is the physical address of this Service Provider. Limit of 250 characters.

phone (optional)

A string that is the primary phone number of this Service Provider. Limit of 250 characters.


Subscribers

The CSV files to be imported for Subscribers, should have the following format:

Column

Value

1

Name

2

Display Name

3

Service Provider Name

4

First Name

5

Last Name

6

Email

7

Address

8

Phone

9

Override

10

IVR Pin

name

A unique string that is the name of this Subscriber. Limit of 64 characters.

display_name (optional)

An unconstrained string used as a display name. Limit of 250 characters.

service_provider_name

A unique string that is the name of the Service Provider for this Subscriber. Must match an existing Service Provider.

first_name (optional)

A string that is the first name of a contact for this Subscriber. Limit of 250 characters.

last_name (optional)

A string that is the last name of a contact for this Subscriber. Limit of 250 characters.

email (optional)

A string that is the email address of this Subscriber, where notifications and password reset requests will be sent. Limit of 250 characters.

address (optional)

A string that is the physical address of this Subscriber. Limit of 250 characters.

phone (optional)

A string that is the primary phone number of this Subscriber. Limit of 250 characters.

override

A boolean value that determines whether this Subscriber can use an override number to direct all numbers to a single destination.

ivr_pin

A string that is the PIN used by this Subscriber to log in to the IVR interface.


Numbers

The CSV files to be imported for numbers should have the following format:

Column

Value

1

Number

2

Timezone

3

Service Provider Name

4

Subscriber Name

5

Parameters

number

A unique string that must be a valid phone number. Limit of 250 characters.

timezone

A unique string that is the time zone associated with this number. It is used for time of day, day of week, and holiday/event based routing.

service_provider_name

A unique string that is the name of the Service Provider for the Subscriber who uses this number. Must match an existing Service Provider.

subscriber_name

A unique string that is the name of the Subscriber who uses this number. Must match an existing Subscriber.

params

A JSON object that defines the set of parameters configured for this number that are passed to the routing engine.


Call Plans

The CSV files to be imported for call plans should have the following format:

Column

Value

1

Call Plan Name

2

Display Name

3

Service Provider Name

4

Subscriber Name

5

Rules

call_plan_name

A unique string that is the name of this call plan.

display_name

A string that is the display name for this call plan, which will be used in the web UI.

service_provider_name

A unique string that is the name of the Service Provider for the subscriber who uses this call plan. Must match an existing Service Provider.

subscriber_name

A unique string that is the Subscriber who uses this call plan. Must match an existing Subscriber.

rules

A JSON object that defines the routing rules for this call plan.

Rule Strings

The following table shows the format used based on which rule type is specified by the CSV file.

Rule Type

Format of criteria

always

Empty

time-of-day

HH:MM-HH:MM in 24 hour/military time

day-of-week

Number 1-7 where 1 is Sunday and 7 is Saturday

holiday

YYYY/MM/DD.HH:MM-YYYY/MM/DD.HH:MM

percent-allocation

Number 1 to 99

match

Posix regular expression

geo

Name of NPA list

Destination Value Strings

The following table shows the format used based on which destination is specified by the CSV file.

Destination

Format of destination value

number

String of digits, no hyphens or parenthesis

sip-uri

String of digits with @ symbol

terminate

No value required

continue

No value required

rule

No value required

trunk-group

String of digits or comma separated list of digits or identifiers

tg-with-outpulse

No value required


Groups

The CSV files to be imported for groups should have the following format:

Column

Value

1

Group Number

2

Display Name

3

Members

4

Call Plans

5

Override Number

6

Service Provider Name

7

Subscriber Name

8

Constraints

group_number

An integer that is the number for identifying this group.

display_name

A string that is the display name for this group, which will be used in the web UI.

members

A list of numbers associated with this group. An individual number can be associated with more than one group.

call_plans

A list of call plans associated with this group. An individual call plan can be associated with more than one group.

override_number

The number to route calls to by default for this group.

service_provider_name

A unique string that is the name of the Service Provider for the subscriber who uses this group. Must match an existing Service Provider.

subscriber_name

A unique string that is the Subscriber who uses this group. Must match an existing Subscriber.

constraints

A list of routing constraints that apply to this group. This should be a set of regex strings that define which destinations are prohibited.


Supergroups

The CSV files to be imported for supergroups should have the following format:

Column

Value

1

Supergroup Number

2

Display Name

3

Group Entries

4

Service Provider Name

5

Subscriber Name

supergroup_number

An integer that is the number for identifying this supergroup.

display_name

A string that is the display name for this supergroup, which will be used in the web UI.

group_entries

A list of groups associated with this supergroup.

service_provider_name

A unique string that is the name of the Service Provider for the subscriber who uses this supergroup. Must match an existing Service Provider.

subscriber_name

A unique string that is the Subscriber who uses this supergroup. Must match an existing Subscriber.


Importing Data

A CSV file can be used to import large amounts of information into a database. Importing data appends the new information to the existing database, and any conflicting records are not overwritten. Each table has at least one unique column that is used to determine if there are conflicting records. Any database entries that are not in the CSV file remain unchanged in the database after the file has been imported.

Note

All columns must be included. If the field is blank, make sure that the column is still included in the CSV file.

Import a CSV file

Note

When importing CSV files into CRS, do not log off until the import is complete. Logging off before the import is complete will cause the entire import of data to fail.

Import Using the Web UI

Whether the database operation to import records from a file is available depends on which page is currently displayed.

  1. Click Import on the task bar.

  2. Click Choose File to browse for a CSV file to import.

  3. Click Start Import.

The file is uploaded and the import begins and runs in the background.

Note

Click Cancel at any time to close the window and stop the import.

The status of an import can be found on the My Account page under Job Logs.

Import Using the API

To import data with the API, the user sends a POST command to the specific object.

The example below shows a Service Provider importing a Subscriber.

curl -X POST \
 -H "Content-Type:crs/json" localhost/crs/api/job/service_provider:crs_service_provider?executable=restworkx-crs \
 -H "Authorization:Basic <secure-access-token>" \
 -d '{"job_type":"import","in_file":"/var/opt/xpressworkx/app-manager/crs/media/upload/subscriber-import.csv","object":"subscriber","service_provider_name":"crs_service_provider"}'

Which would return a message such as:

"meta": {
        "executable": "restworkx-crs",
        "code": 200,
        "encoding": "ascii",
        "scope": "success",
        "records_shown": 1,
        "message": "",
        "authorization": "Basic <secure-access-token>"
},
"data": [{
        "scope": "job",
        "meta": {
                "modified_by": "system",
                "txnid": null,
                "modified": "2022-04-07 11:39:44.724128",
                "created_by": "system",
                "created": "2022-04-07 11:39:44.724102"
        },
        "links": {
                "self": {
                        "scope": "job",
                        "identifier": {
                                "job_id": 104,
                                "out_file": "/var/opt/xpressworkx/app-manager/crs/media/download/subscriber-import-2022-04-07-23770cb05d.csv"
                        },
                        "uri": "/job"
                },
        },
        "attributes": {
                "status": "processing",
                "out_file": "/var/opt/xpressworkx/app-manager/crs/media/download/subscriber-import-2022-04-07-23770cb05d.csv",
                "pid": null,
                "object": "subscriber",
                "job_type": "import",
                "job_id": 104,
                "elapsed": "0",
                "in_file": "/var/opt/xpressworkx/app-manager/crs/media/upload/subscriber-import.csv",
                "kwargs": null,
                "progress": null,
                "role_id": "service_provider:crs_service_provider",
                "output_hash": null
        },
}],
"jsonapi": {
        "version": "2.2-17",
        "name": "Custom Redirect Service",
        "short_name": "crs",
        "author": "IMSWorkX, Inc."
}

Note

The parameter executable=restworkx-crs is required to import an object.


Exporting Data

Information can be exported from the database, saved, and then imported to restore a database.

Export a CSV file

Export Using the Web UI

Whether the database operation to export records to a file is available depends on which page is currently displayed.

  1. Click Export on the task bar.

  2. Click Start Export.

The output CSV file can be found on the My Account page under Job Logs.

Export Using the API

To export data with the API, the user sends a POST command to the specific object.

The example below shows a Platform Owner exporting Service Providers.

curl -X POST \
 -H "Content-Type:crs/json" localhost/crs/api/job/platform_owner?executable=restworkx-crs \
 -H "Authorization:Basic <secure-access-token>" \
 -d '{"job_type": "export","object": "service_provider"}'

Which would return a message such as:

"meta": {
        "executable": "restworkx-crs",
        "code": 200,
        "encoding": "ascii",
        "scope": "success",
        "records_shown": 1,
        "message": "",
        "authorization": "Basic <secure-access-token>"
},
"data": [{
        "scope": "job",
        "meta": {
                "modified_by": "system",
                "txnid": null,
                "modified": "2022-04-07 13:50:20.834266",
                "created_by": "system",
                "created": "2022-04-07 13:50:20.834246"
        },
        "links": {
                "self": {
                        "scope": "job",
                        "identifier": {
                                "job_id": 109,
                                "out_file": "/var/opt/xpressworkx/app-manager/crs/media/download/service_provider-export-2022-04-07-e996a4f9dc.csv"
                        },
                        "uri": "/job"
                },
        },
        "attributes": {
                "status": "processing",
                "out_file": "/var/opt/xpressworkx/app-manager/crs/media/download/service_provider-export-2022-04-07-e996a4f9dc.csv",
                "pid": null,
                "object": "service_provider",
                "job_type": "export",
                "job_id": 109,
                "elapsed": "0",
                "in_file": null,
                "kwargs": null,
                "progress": null,
                "role_id": "platform_owner",
                "output_hash": null
        },
}],
"jsonapi": {
        "version": "2.2-17",
        "name": "Custom Redirect Service",
        "short_name": "crs",
        "author": "IMSWorkX, Inc."
}

Note

The parameter executable=restworkx-crs is required to export an object.


Call Detail Records

The CSV files exported for Call Detail Records (CDRs) will have the following format.

Column

Value

1

Called Number

2

Subscriber Name

3

CDRs

4

Start Time

5

Calling Number

6

End Time

7

Original Called Number

8

Route

9

Service Provider Name

called_number

The number to which this specific call is routed.

subscriber_name

A unique string that is the name of the Subscriber using this service. Must match an existing Subscriber.

cdrs

An array that is all of the events for this specific call.

start_time

A timestamp indicating the date and time this specific call started.

calling_number

The number making this specific call.

end_time

A timestamp indicating the date and time this specific call ended.

original_called_number

The number that was dialed to start this call.

route

A JSON object that is the route event of the CDR. If blank, this CDR was ended without a route being returned.

service_provider_name

A unique string that is the name of the Service Provider for this Subscriber using this service. Must match an existing Service Provider.


Archiving, Restoring, and Purging Data

CRS does not have an explicit delete function for any of its data. Instead, CRS has the ability to archive data that is not in use.

Archived data remains in the CRS application, but this data is not used when routing calls. Archived data can then be returned to the live data by restoring or can be removed completely by purging. When viewing data through the web UI or with an API request, the user can switch between the live and archived database to see all data.

Note

By default, CRS permanently purges archived data after seven days. This can be changed by a Platform Owner in Settings.


Archiving

Data that is not currently in use by the CRS application can be removed from the live database by archiving the data. Provisioned data can be archived in the web UI or through the API.

Archive a Single Object Using the Web UI

  1. Navigate to the object that you want to archive.

  2. Right-click on the object to be archived.

  3. Click Archive.

The object will be moved to the archive database.

Archive Multiple Objects Using the Web UI

  1. Navigate to the objects that you want to archive.

  2. Select the objects by clicking on the first object then:

    • Hold the Shift key and click another object to select everything between and including the two selected objects.

    • Hold the Ctrl key and click the other objects you want.

  3. Click Archive Selected on the bottom of the page.

The objects will be moved to the archive database.

Archive Using the API

To archive an object with the API, the user sends a DELETE command to the specific object.

The example below shows a user archiving a Subscriber object called new_subscriber.

curl -X DELETE \
 -H "Authorization:Basic <secure-access-token>" \
 -d 'localhost/crs/api/subscriber/service_test/new_subscriber'

Which would return a message such as:

"meta": {
        "encoding": "ascii",
        "records_shown": 0,
        "message": "Record successfully archived or restored.",
        "code": "205",
        "scope": "success"
},
"data": [],
"jsonapi": {
        "version": "2.2-17",
        "name": "Custom Redirect Service",
        "short_name": "crs",
        "author": "IMSWorkX, Inc."
}

Restoring

Restoring data will move data from the archive database to the live database. Restoring data can be done through the web UI or the API.

Restore a Single Object Using the Web UI

  1. Switch to the archive view by toggling Live / Archive Database in the task bar.

  2. Navigate to the object that you want to restore.

  3. Right-click on the object to be restored.

  4. Click Restore.

The object will be moved to the live database.

Restore Multiple Objects Using the Web UI

  1. Switch to the archive view by toggling Live / Archive Database in the task bar.

  2. Navigate to the objects that you want to restore.

  3. Select the objects by clicking on the first object then:

    • Hold the Shift key and click another object to select everything between and including the two selected objects.

    • Hold the Ctrl key and click the other objects you want.

  4. Click Restore Selected on the bottom of the page.

The objects will be moved to the live database.

Restore Using the API

To restore an object with the API, the user sends a DELETE command to the specific object.

The example below shows a user restoring a Subscriber object called new_subscriber.

curl -X DELETE \
         -H "Authorization:Basic <secure-access-token>" \
         -d 'localhost/crs/api/subscriber/service_test/new_subscriber?archive=true&restore=true'

Which would return a message such as:

"meta": {
        "encoding": "ascii",
        "records_shown": 0,
        "message": "Record successfully archived or restored.",
        "code": "205",
        "scope": "success"
},
"data": [],
"jsonapi": {
        "version": "2.2-14",
        "name": "Custom Redirect Service",
        "short_name": "crs",
        "author": "IMSWorkX, Inc."
}

Note

The parameters archive=true&restore=true are required to restore an object.

Purging

Purging data permanently removes the data from the archived database. Purging data can be done through the API, web UI, or the Maximum Inactive Days for Records setting in the web UI.

Warning

Once data has been purged from the database, it cannot be restored.

Purge a Single Object Using the Web UI

  1. Switch to the archive view by toggling Live / Archive Database in the task bar.

  2. Navigate to the object that you want to purge.

  3. Right-click on the object to be purged.

  4. Click Purge.

The object will be permanently removed from the database.

Purge Multiple Objects Using the Web UI

  1. Switch to the archive view by toggling Live / Archive Database in the task bar.

  2. Navigate to the objects that you want to purge.

  3. Select the objects by clicking on the first object then:

    • Hold the Shift key and click another object to select everything between and including the two selected objects.

    • Hold the Ctrl key and click the other objects you want.

  4. Click Purge Selected on the bottom of the page.

The objects will be permanently removed from the database.

Purge Using the Maximum Inactive Days Setting

CRS will remove records that have been archived longer than the value specified by this setting every night at midnight, which is determined by the time on the active NIU. A value of zero will always keep archived records in the database.

This setting can be found in the Settings page when the user is logged in as a Platform Owner.

Purge Using the API

To purge an object with the API, the user sends a DELETE command to the specific object.

The example below shows a user purging a Subscriber object called new_subscriber.

curl -X DELETE \
 -H "Authorization:Basic <secure-access-token>" \
 -d 'localhost/crs/api/subscriber/service_test/new_subscriber?archive=true'

Which would return a message such as:

"meta": {
        "encoding": "ascii",
        "records_shown": 0,
        "message": "Record successfully archived or restored.",
        "code": "205",
        "scope": "success"
},
"data": [],
"jsonapi": {
        "version": "2.2-14",
        "name": "Custom Redirect Service",
        "short_name": "crs",
        "author": "IMSWorkX, Inc."
}

Note

The parameter archive=true is required to purge an object.