Using the FlexSwitch REST Interface

You can configure your FlexSwitch using the REST interface. This guide provides examples of each REST request for both configuration and state objects.

Using cURL

The following examples are templates for use when configuring objects or getting information from state objects in FlexSwitch.

To use the examples, simply copy and paste them into your terminal and replace the <place holders> with the appropriate information.

Place Holders

  • user: username
  • password: password
  • object: the object you are configuring (e.g., ntpserver, vlan, etc.)
  • device-management-IP: the device management IP Address of your switch.
  • Model Object as json data: Properly formatted json data for the object.

JSON Data Models

POST, PATCH, GET by KEY, GET by ID, and EXECUTE methods all required configuration data passed as JSON data. The following is an example of correctly formatted JSON data.

Span Object Example:

{
    "AdminState": "UP",
    "DstIntfRef": "fpPort1",
    "MirrorDir": "BOTH",
    "SpanSessionName": "sp1",
    "SrcIntfRefList": [
        "fpPort2"
    ]
}

Examples for Config Objects

GET By Key

curl -k -u <user>:<password> -X GET -H ‘Content-Type: application/json’ –header ‘Accept: application/json’ -d ‘{<Model Object as json-Data>}’ https://<device-management-IP>:443/public/v1/config/<object>

GET ALL

curl -k -u <user>:<password> -X GET https://<device-management-IP>:443/public/v1/config/<object>s

GET By ID

curl -k -u <user>:<password> -X GET https://<device-management-IP>:443/public/v1/config/<object>/<uuid>

CREATE(POST)

curl -k -u <user>:<password> -X POST -H ‘Content-Type: application/json’ –header ‘Accept: application/json’ -d ‘{<Model Object as json-Data>}’ https://<device-management-IP>:443/public/v1/config/<object>

UPDATE(PATCH) By Key

curl -k -u <user>:<password> -X PATCH -H ‘Content-Type: application/json’ -d ‘{<Model Object as json data>}’ https://<device-management-IP>:443/public/v1/config/<object>

UPDATE(PATCH) By ID

curl -k -u <user>:<password> -X PATCH -H ‘Content-Type: application/json’ -d ‘{<Model Object as json data>}’ https://<device-management-IP>:443/public/v1/config/<object><uuid>

DELETE By Key

curl -k -u <user>:<password> -X DELETE -i -H ‘Accept:application/json’ -d ‘{<Model Object as json data>}’ https://<device-management-IP>:443/public/v1/config/<object>

DELETE By ID

curl -k -u <user>:<password> -X DELETE https://<device-management-IP>:443/public/v1/config/<object><uuid>

EXECUTE

Note

This method only applies to certain objects. Refer to the object reference to determine which objects use the EXECUTE method.

curl -k -u <user>:<password> -H "Content-Type: application/json" -d '{<Model Object as json data>}' -X POST https://192.168.100.199:443/public/v1/action/<object>

Examples for State Objects

The only methods available for use with state objects are the three GET methods.

Note

When GETTING state objects, use the config object name (i.e., Use SystemParam and not SystemParamState) in the request.

GET By Key

curl -k -u <user>:<password> —X GET -H ‘Content-Type: application/json’ –header ‘Accept: application/json’ -d ‘{<Model Object as json-Data>}’ https://<device-management-IP>:443/public/v1/state/<object>

GET ALL

curl -k -u <user>:<password> -X GET https://<device-management-IP>:443/public/v1/state/<object>s

GET By ID

curl -k -u <user>:<password> -X GET https://<device-management-IP>:443/public/v1/state/<object>/<uuid>