Skip to content
This repository has been archived by the owner on Oct 11, 2020. It is now read-only.

Healthbot REST calls with CURL

Khelil Sator edited this page Feb 10, 2019 · 7 revisions

About CURL

curl is an open source command line tool for transferring data.

$ curl --help

Demo

Here's a basic Healthbot REST API demo using CURL.

Add a device to healthbot

get the list of devices from the running configuration

$ curl -X GET "https://100.123.35.0:8080/api/v1/device/" -H "accept: application/json" -H "Content-Type: application/json" -u jcluser:Juniper\!1 --insecure
{
  "detail": "No devices configured",
  "status": 404
}

Add a new device update to the candidate configuration

$ curl -X POST "https://100.123.35.0:8080/api/v1/device/vMX1/" -H  "accept: application/json" -H "Content-Type: application/json" -u jcluser:Juniper\!1 -d '{"authentication": {"password": {"password": "Juniper!1", "username": "jcluser"}}, "description": "vMX1", "device-id": "vMX1", "host": "100.123.1.0", "iAgent": {"port": 830}, "open-config": {"port": 32768}, "system-id": "vMX1"}' --insecure

get the list of devices from the candidate configuration

$ curl -X GET "https://100.123.35.0:8080/api/v1/device/?working=true" -H "accept: application/json" -H "Content-Type: application/json" -u jcluser:Juniper\!1 --insecure
[
  "vMX1"
]

get the devices details from the candidate configuration

$ curl -X GET "https://100.123.35.0:8080/api/v1/devices/?working=true" -H  "accept: application/json" -H "Content-Type: application/json" -u jcluser:Juniper\!1 --insecure
{
  "device": [
    {
      "authentication": {
        "password": {
          "password": "$9$UTiqPFnCBIc5QIcylLXUjHq.P5QF",
          "username": "jcluser"
        }
      },
      "device-id": "vMX1",
      "host": "100.123.1.0",
      "iAgent": {
        "port": 830
      },
      "open-config": {
        "port": 32768
      },
      "system-id": "vMX1"
    }
  ]
}

get the list of devices from the running configuration

$ curl -X GET "https://100.123.35.0:8080/api/v1/device/" -H "accept: application/json" -H "Content-Type: application/json" -u jcluser:Juniper\!1 --insecure
{
  "detail": "No devices configured",
  "status": 404
}

commit the candidate configuration

$ curl -X POST "https://100.123.35.0:8080/api/v1/configuration" -u jcluser:Juniper\!1 --insecure

get the list of devices from the running configuration

$ curl -X GET "https://100.123.35.0:8080/api/v1/device/" -H "accept: application/json" -H "Content-Type: application/json" -u jcluser:Juniper\!1 --insecure
[
  "vMX1"
]

get the devices details from running configuration

$ curl -X GET "https://100.123.35.0:8080/api/v1/devices/" -H  "accept: application/json" -H "Content-Type: application/json" -u jcluser:Juniper\!1 --insecure
{
  "device": [
    {
      "authentication": {
        "password": {
          "password": "$9$UTiqPFnCBIc5QIcylLXUjHq.P5QF",
          "username": "jcluser"
        }
      },
      "device-id": "vMX1",
      "host": "100.123.1.0",
      "iAgent": {
        "port": 830
      },
      "open-config": {
        "port": 32768
      },
      "system-id": "vMX1"
    }
  ]
}

Tables and views - Add a table to healthbot

$ ls tables_and_views

add a table to healthbot

$ curl -X POST "https://100.123.35.0:8080/api/v1/files/helper-files/bgp.yml" -H  "accept: application/json" -H  "Content-Type: multipart/form-data" -u jcluser:Juniper\!1 -F "up_file=@tables_and_views/bgp.yml" --insecure

get a table from healthbot

$ curl -X GET "https://100.123.35.0:8080/api/v1/files/helper-files/bgp.yml" -H  "accept: application/json" -H  "Content-Type: multipart/form-data" -u jcluser:Juniper\!1 --insecure

Get the list of tables from healthbot

$ curl -X GET "https://100.123.35.0:8080/api/v1/files/helper-files/" -H  "accept: application/json" -H  "Content-Type: multipart/form-data" -u jcluser:Juniper\!1 --insecure

Remove a device from healthbot

remove a device from the candidate configuration

$ curl -X DELETE "https://100.123.35.0:8080/api/v1/device/vMX1/" -u jcluser:Juniper\!1 --insecure

Get the devices list from healthbot candidate configuration

$ curl -X GET "https://100.123.35.0:8080/api/v1/device/?working=true" -H "accept: application/json" -H "Content-Type: application/json" -u jcluser:Juniper\!1 --insecure

{
  "detail": "No devices configured",
  "status": 404
}

get the devices list from running configuration

$ curl -X GET "https://100.123.35.0:8080/api/v1/device/" -H "accept: application/json" -H "Content-Type: application/json" -u jcluser:Juniper\!1 --insecure

[
  "vMX1"
]

commit the candidate configuration

$ curl -X POST "https://100.123.35.0:8080/api/v1/configuration" -u jcluser:Juniper\!1 --insecure

get the devices list from running configuration

$ curl -X GET "https://100.123.35.0:8080/api/v1/device/" -H "accept: application/json" -H "Content-Type: application/json" -u jcluser:Juniper\!1 --insecure

{
  "detail": "No devices configured",
  "status": 404
}
Clone this wiki locally