Ruby Examples

This ruby script (below) is an example of how to use TelcoBridges RESTful Northbound Interface.

1KB
Open
  • The script can be executed from any computer having access to the management web interface.

  • The script can also be copied on the internal host of a Tmedia and executed from a SSH client (as shown in the examples below using 127.0.0.1:12358).

Download script

1KB
Open

Usage

./httprestapi.rb <URI> <user> <password> <http request>

  With <URI> = http://ip:port
    Example: ./httprestapi.rb 'http://127.0.0.1:12358' 'root' 'password' <http request>

  With <http request> = <GET|PUT|POST|DELETE> <element path> [json | -i jsonfile | -o jsonfile]
    -i jsonfile = input json file used for PUT or POST http request
    -o jsonfile = output json file used for GET http request

GET

Get the configuration collection list and display the JSON returned in the body of the HTTP response.

Show the use of "recursive=yes" to get all sub-element of configuration. Put the returned JSON in "test_configuration.json" file.

Use "documentation=yes" to return documentation of all attributes of an element. Below example returns documentation for a new route element.

Get request can also be used to retrieve the status of some elements of the active configuration.

PUT

Modify attributes of an element. Below example renames the route element named "Test" to "NewName".

Modify attributes of an element using a JSON file for the HTTP request.

Activate "demo" configuration

POST

Create a new element. Below example add a new route named "xtel_to_SBC_1".

Create a new element using a JSON file for the HTTP request.

Create a new configuration using a JSON file for the HTTP request.

DELETE

Delete an element. Below example delete the route named "xtel_to_SBC_1".

Using JSON files

Modify an element

1. Get route configuration in JSON file

2. Edit JSON file attributes

3. Modify element from JSON file

Create a new element

1. Get an element default attributes value in a JSON file

2. Edit JSON file attributes

3. Create new element from JSON file

Last updated

Was this helpful?