Network Configurations

Network configurations are files that specify different networking options. These include Hostname, DNS settings, Network Time, and Default Gateway.

Viewing and Updating Configurations

Using the API you are able to view or update these configurations

Get a Network Configuration

You can get any network configuration by calling this route.

Request Object

+ URL
  /api/v2/network/config/$CONFIG_NAME/details

+ Method
  GET

+ Parameters
  config name (string, required, URL param) - the name of the network config to get. One of 'defaultgateway', 'dns', 'ntp', or 'hostname'.

+ Headers
  Content-Type: application/json
  token: ThisIsNotARealTokenGenerateYourOwnToken

+ Body
  {}

Response Object

Sending this should get you back a valid response, an object with the details you’ve requested.

+ Headers
  X-Powered-By: OpenDrives
  Access-Control-Allow-Origin: *
  Content-Type: application/json; charset=utf-8

+ Body
  {
    "dhcp": [
      {
        "domain": [
          "lab.opendrives"
        ],
        "nameserver": [
          "192.168.7.2",
          "192.168.7.1"
        ],
        "file": "mgmt0.dhclient"
      }
    ]
  }

Set a Network Configuration

Send a call to the API to set a network configuration

Request Object

+ URL
  /api/v2/network/config/$CONFIG_NAME/update

+ Method
  POST

+ Parameters
  config name (string, required, URL param) - the name of the network config to get. One of 'defaultgateway', 'dns', 'ntp', or 'hostname'.
  ip (string, optional, Body) - the address to be used for setting default gateway
  data (JSON, optional, Body) - the configuration object to be used for setting dns, or ntp
  hostname (string, optional, Body) - the new hostname to set is config is 'hostname'
  old_hostname (string, optional, Body) - the old hostname being replaced
  alias (string, optional, Body) - an alias to give this hostname

+ Headers
  Content-Type: application/json
  token: ThisIsNotARealTokenGenerateYourOwnToken

+ Body
  {
    "hostname": "sue",
    "old_hostname": "greed"
  }

Response Object

Sending this will return to you the network interface you’ve configured.

+ Headers
  X-Powered-By: OpenDrives
  Access-Control-Allow-Origin: *
  Content-Type: application/json; charset=utf-8

+ Body
  {
    "hostname": "sue"
  }