> For the complete documentation index, see [llms.txt](https://prosbcdocs.telcobridges.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://prosbcdocs.telcobridges.com/telecom-references/developer-reference/restful-api/northbound-interface-ruby-implementation.md).

# Northbound interface: Ruby Implementation

This ruby script ([httprestapi](https://docs.telcobridges.com/w/images/f/f8/Httprestapi.zip‎)) is an example of how to use TelcoBridges RESTful Northbound Interface.

* 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 *T*media and executed from a SSH client (as shown in the examples below using `127.0.0.1:12358`).

### Download script

* \[httprestapi.rb [click to download](https://docs.telcobridges.com/w/images/f/f8/Httprestapi.zip‎)]

### 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. `./httprestapi.rb 'http://127.0.0.1:12358' GET '/configurations'`

Show the use of "recursive=yes" to get all sub-element of configuration. Put the returned JSON in "test\_configuration.json" file. `./httprestapi.rb 'http://127.0.0.1:12358' GET '/configurations/test?recursive=yes' '-o test_configuration.json'`

Use "documentation=yes" to return documentation of all attributes of an element. Below example returns documentation for a new route element. `./httprestapi.rb 'http://127.0.0.1:12358' GET '/configurations/test/routes/new?documentation=yes'`

Get request can also be used to retrieve the status of some elements of the **active** configuration. `./httprestapi.rb 'http://127.0.0.1:12358' GET '/configurations/test/naps/xtel/status'`

### PUT

Modify attributes of an element. Below example renames the route element named "Test" to "NewName". `./httprestapi.rb 'http://127.0.0.1:12358' PUT '/configurations/test/routes/test_route' '{"name":"new_route_name"}'`

Modify attributes of an element using a JSON file for the HTTP request. `./httprestapi.rb 'http://127.0.0.1:12358' PUT '/configurations/test/routes/test_route' '-i modified_route.json'`

Activate "demo" configuration `./httprestapi.rb 'http://127.0.0.1:12358' PUT '/systems/system_1' '{"target_configuration":"demo"}'`

### POST

Create a new element. Below example add a new route named "xtel\_to\_SBC\_1". `./httprestapi.rb 'http://127.0.0.1:12358' POST '/configurations/test/routes' '{"name":"xtel_to_SBC_1","nap":"xtel","remapped_nap":"SBC_1"}'`

Create a new element using a JSON file for the HTTP request. `./httprestapi.rb 'http://127.0.0.1:12358' POST '/configurations/test/routes' '-i new_route.json'`

Create a new configuration using a JSON file for the HTTP request. `./httprestapi.rb 'http://127.0.0.1:12358' POST '/configurations' '-i test_configuration.json'`

### DELETE

Delete an element. Below example delete the route named "xtel\_to\_SBC\_1". `./httprestapi.rb 'http://127.0.0.1:12358' DELETE '/configurations/test/routes/xtel_to_SBC_1'`

### Using JSON files

#### Modify an element

1. Get route configuration in JSON file `./httprestapi.rb 'http://127.0.0.1:12358' GET '/configurations/test/routes/test_route' '-o routes.json'`
2. Edit JSON file attributes vi route.json
3. Modify element from JSON file `./httprestapi.rb 'http://127.0.0.1:12358' PUT '/configurations/test/routes/test_route' '-i routes.json'`

#### Create a new element

1. Get an element default attributes value in a JSON file `./httprestapi.rb 'http://127.0.0.1:12358' GET '/configurations/test/routes/new' '-o routes.json'`
2. Edit JSON file attributes vi route.json
3. Create new element from JSON file `./httprestapi.rb 'http://127.0.0.1:12358' POST '/configurations/test/routes/new_route' '-i routes.json'`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://prosbcdocs.telcobridges.com/telecom-references/developer-reference/restful-api/northbound-interface-ruby-implementation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
