6. REST API

Ultra Config Generator is built on top of a REST API to enable automation.

6.1 Creating a Token

To automate the generation of network configuration, users will first need to create an access token.

To do so, send a POST request to the "tokens" endpoint.

https://app.ultraconfig.com.au/api/v1/tokens/

An authorization header using Basic Authentication will also be required.

Authorization: Basic <BASE64_CREDENTIALS>

If correct credentials are provided, the server will return a response including the new token.

{
"id": "5e576d3321a01232b025498f",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InVzZXJJZCI6IjVlNTc2ZDMzMjFhMDEyMzJiMDI1NDk0ZSJ9LCJpYXQiOjE1ODU5NjYzODQsImV4cCI6MTU4NjAwOTU4NH0",
"userId": "5e576d3321a01232b025494e",
"dateCreated": 1582787891513
}

Future API calls will then use the token in the authorization header.

Authorization: Bearer <TOKEN>

6.2 Sample Request

For this example, let's generate configuration for a Cisco router with a single requirement:

A layer 3 interface on the physical port "GigabitEthernet0/0/0" with an IP address of 10.10.10.2 and a prefix length of 30

To achieve this task, we'll need to create a template for a layer 3 interface. The template may be created using the Template Editor or programmatically with the API.

Once created, we may proceed to construct an API request with a JSON body as shown below.

[
{
"templateId": "5b794b468b48020c3135703c",
"templateInputs": [
{
"inputId": "PHYSICAL_INTERFACE",
"inputValue": "GigabitEthernet0/0/0"
},
{
"inputId": "IP_ADDRESS",
"inputValue": "10.10.10.2/30"
},
{
"inputId": "SUBNET_MASK",
"inputValue": "255.255.255.252"
}
]
}
]

At the top level, we have an array of templates.

Each object within the array contains a "templateId" and a "templateInputs" array.

The "templateId" is a unique reference to a template. It may be obtained from the Developer Console or programmatically with the API.

The "templateInputs" array contains the key-value pairs of input variables used by the template. If an input variable belonging to a template is omitted the default value of that variable will be used.

To invoke the relevant API, make a POST request to the endpoint below.

https://app.ultraconfig.com.au/api/v1/configurations/

6.3 Sample Response

When invoked correctly, the generated configuration will be returned.

{
"id": "5c14b57a377e6d123c543ff1",
"dateCreated": 1587192054342,
"data": [
{
"configuration": "interface GigabitEthernet0/0/0\r\n ip address 10.10.10.2 255.255.255.252\r\n exit\r\n",
"templateMetadata": {
"templateId": "5b794b468b48020c3135703c",
"templateDisplayName": "Layer 3 Interface",
"templateDescription": "Layer 3 Interface template for Cisco routers",
"templateVersion": 20,
"templateUpdatedBy": "mel.dawson",
"dateModified": 1564118172886,
"dateCreated": 1539919220503
},
"templateInputs": [
{
"inputId": "PHYSICAL_INTERFACE",
"inputValue": "GigabitEthernet0/0/0"
},
{
"inputId": "IP_ADDRESS",
"inputValue": "10.10.10.2/30"
},
{
"inputId": "SUBNET_MASK",
"inputValue": "255.255.255.252"
}
]
}
]
}

The response includes an array of instantiated templates. The number of elements inside the array will match that of the request.

Inside each element, several fields are returned. The most important field is the "configuration". This key contains the configuration generated by the POST request.

Configuration spanning over multiple lines uses the standard delimiter of "\r\n".

That is all! The client may now proceed to parse the response body and push the configuration to network infrastructure.

For more information on our REST API, please consult the API Reference or ask us a question.

6.4 API Reference


Proceed to Next Page