Skip to content

Instantly share code, notes, and snippets.

@bgrewell
Last active November 12, 2019 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgrewell/b961b3c33442b1db56441a46d909a843 to your computer and use it in GitHub Desktop.
Save bgrewell/b961b3c33442b1db56441a46d909a843 to your computer and use it in GitHub Desktop.

Usage Examples for WEMO REST API version 1

Overview

Conventions

  1. REST calls follow standard convention.
REQUEST TYPE  ACTION
========================================================
GET           Retrieve information
PUT           Update information
POST          Add information
DELETE        Remove information
  1. URLs
FORMAT
========================================================
host: 	   http://172.16.0.1
port: 	   :9999
service:   /api
version:   /v1
system:    /wanem
subsystem: /rules
id:        /0

Example:   http://172.16.0.1:9999/api/v1/wanem/rules/0
  1. PUT/POST parameters
Parameters sent in put/post requests must be all lower case for the keys.

User controllable parameters

uplinkrate 				shaping rate in bits per second
downlinkrate 			
ullatency 				latency in ms
dllatency 				
uljitter 				jitter in ms
dljitter 				
ulloss 					loss in %
dlloss 					
ullossdependency 		        loss dependency in %
dllossdependency
ulduplication 			        duplication in %
dlduplication
ulcorruption 			        corruption in %
dlcorruption
ulreorder 				reorder in %
dlreorder
ulreorderdependency 	                reorder dependency in %
dlreorderdependency

API Endpoints

GET ALL RULES
========================================================
[HTTP GET]  http://172.16.0.1:9999/api/v1/wanem/rules

GET DEFAULT RULE
[HTTP GET]  http://172.16.0.1:9999/api/v1/wanem/rules/0

UPDATE DEFAULT RULE
[HTTP PUT]  http://172.16.0.1:9999/api/v1/wanem/rules/0
	    payload = x-www-for-urlencoded key/value pairs

Example HTTP request to update the default rule

** sets latency, jitter, loss and the jitter algo **

PUT /api/v1/wanem/rules/0 HTTP/1.1
Content-Type: application/x-www-form-urlencoded
User-Agent: PostmanRuntime/7.19.0
Accept: */*
Cache-Control: no-cache
Postman-Token: 68bcab34-4cdf-411f-85c0-5aaae4383741
Host: 10.100.4.20:9999
Accept-Encoding: gzip, deflate
Content-Length: 63
Connection: close

latency=100&jitter=20&ulloss=2&dlloss=1&dljitteralgo=sine&uljitteralgo=sine

Responses from update calls will return the new rule state

{
    "responseId": 0,
    "requestTimeNS": 1573596140312282033,
    "responseTimeNS": 1573596140324813342,
    "totalTime": "12.53ms",
    "status": "OK",
    "payload": {
        "id": 0,
        "uplinkInterface": "eth-up",
        "downlinkInterface": "eth-dn",
        "uplinkRate": 1000000000,
        "downlinkRate": 1000000000,
        "valid": false,
        "name": "default",
        "enabled": true,
        "active": false,
        "default": true,
        "parent": 0,
        "children": null,
        "ulLatency": 50,
        "ulJitter": 10,
        "ulJitterAlgo": "sine",
        "ulJitterEngine": {},
        "ulLoss": 2,
        "ulLossDependency": 0,
        "ulDuplication": 0,
        "ulCorruption": 0,
        "ulReorder": 0,
        "ulReorderDependency": 0,
        "dlLatency": 50,
        "dlJitter": 10,
        "dlJitterAlgo": "sine",
        "dlJitterEngine": {},
        "dlLoss": 1,
        "dlLossDependency": 0,
        "dlDuplication": 0,
        "dlCorruption": 0,
        "dlReorder": 0,
        "dlReorderDependency": 0,
        "filters": []
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment