Introduction To The Idirect Web Service Interface: Revision B
Introduction To The Idirect Web Service Interface: Revision B
Revision B
0.1 DRAFT 2012-11-02 Guy Adams Initial Web Service Standards document
Ivan Miletic
Tom Najdek
0.2 DRAFT 2012-11-16 Ivan Miletic Web Service Standards Work-in-progress document:
Tom Najdek
Resource relations
Non-CRUD operations
File Upload
Use cases
0.3 DRAFT 2012-11-20 Milosz Chmura Work-in-progress document:
Ivan Miletic
Web Service Standards Streaming
Tom Najdek
Adding/Removing relations
Major re-formatting
1.0 DRAFT 2012-11-27 Milosz Chmura Web Service Standards Final document recommendation:
Tom Najdek
Streaming
Non-fatal errors
Consistency fixes
Adding/Removing relations
Applied template, major re-formatting
1.1 DRAFT 2012-12-11 Tom Najdek Web Service Standards added ‘in’ filter
While iDirect, Inc. strives to make the information in this document as accurate as possible, iDirect
makes no claims, promises, or guarantees about the accuracy, completeness, or adequacy of the
contents, and expressly disclaims liability for errors and omissions. No warranty of any kind, whether
implied, expressed, or statutory, including but not limited to the warranties of non-infringement of
third party rights, title, merchantability, or fitness for a particular purpose, is given with respect to the
contents of this document.
iDirect, Inc. reserves the right to change or update this document at any time.
Disclaimer .......................................................................... iv
Contents .............................................................................v
About ................................................................................ ix
Purpose ..................................................................................................... ix
Audience ................................................................................................... ix
Contents .................................................................................................... ix
iDirect Documents ........................................................................................ ix
Standards References.................................................................................... ix
Document Conventions ................................................................................... x
Purpose
This document is an introduction to the iDirect system web service interface. It explains when the web
service interface should be used, and an overview of how to use it. Detailed descriptions of the
methods available in the web service are available in other documentation. All system-wide iDX web
services are based on common use cases and best-practices of the REST architecture.
Audience
The intended audience for this document is a system engineering team responsible for interfacing with
iDirect hub (NMS) or remote systems.
Contents
The document contains the following chapters and appendices:
The Web Service Interface
Request Format
Response Status Codes
Request/Response Data Format
Resource Relations
GET Request Filtering/Searching
Executing Actions on Resources
File Uploads
Use Cases
Streaming Model with WebSocket
iDirect Documents
Standards References
http://tools.ietf.org/html/rfc6455
Bold Trebuchet font Used when referring to text that 1. To add a remote to an inroute group,
appears on the screen on a right-click the Inroute Group and select
windows-type Graphical User Add Remote.
Interface (GUI). The Remote dialog box has a number of
Used when specifying names of user selectable tabs across the top. The
commands, menus, folders, tabs, Information tab is visible when the dialog
dialogs, list boxes, and options. box opens.
2.2 Authentication
Clients authenticate to the iDirect system using a username and password. This is passed in every
request to the service, as an HTTP Basic authentication header.
The username, a colon, and the password should be concatenated. This string should then be base64
encoded. The string “Basic” and a space is prepended to the resulting string, and this is used as the
value in an “Authorization” header that is passed along with the request.
For example, if the username is “test”, and the password is “password”, then the authentication
header will be:
Authorization: Basic dGVzdDpwYXNzd29yZA==
This header should be sent with every request. A request without the header, or with an incorrect
username/password combination, will be rejected.
This is a read-only operation, and thus does not change the visibility or state of the resource.
POST Adds new instance of a resource.
Posting multiple times will usually result in multiple items being created.
PUT Sends an update of a uniquely identified resource where the ENTIRE resource is contained
within a message. Missing fields are assumed nulls.
Putting multiple times attempts to change the same resource over and over again and will
always result in the same outcome.
PATCH Sends a partial update of a uniquely identified resource. Missing fields are assumed
unchanged.
Patching multiple times attempts to change the same resource over and over again and will
always result in the same outcome.
DELETE Removes an instance of a uniquely identified resource.
Deleting multiple times attempts to remove the same resource over and over again and will
always result in the same outcome.
OPTIONS Returns detailed descriptions on resource actions. Not applicable to Pulse NMS API 2.0
PROPFIND Returns detailed descriptions on resource actions. Applicable only to Pulse NMS API 2.0
Too many requests have been made to the system. This 429 Too Many Requests
can be used for request throttling.
Uncaught exceptions in the Middle-End. 500 Internal Server Error
The requested function isn’t supported. 501 Unsupported
In the case of an Error Status, the response body may contain additional error messages in the
following format.
"errors":[
{
"message": "<error message>", // the text of the error
"code": <error code>, // a unique number
"source": "BE", // Back End, “FE” Front End, or “ME” Middle
End
"silent": false, // or true if this error is not for
display in the GUI
The result will be a list of resource instances in the format specified in the request by the Accept
header. If no resources instances match the specified filter, an empty list will be returned.
In Config API 2.x Query filters use a more SQL like syntax, with a wildcard character % placed before,
after or before and after the text in the argument. For queries searching for a set, the arguments are
passed as a comma separated list in brackets, e.g. ?id=[10,25,33,42]
Note: The results are returned in pages. Navigating pages is done by specifying the skip and
limit filters in the complex filter. The default values can be overridden on per resource basis.
skip – how many instances to skip before returning. (Default=0)
limit – number of instances to return in one page. (Default=20)
The limit is capped by a system wide default, so the total returned will be the lower of the limit
and the system wide cap.
HTTP 200 OK
Content-type: application/json
{
“data”: [
…
],
“meta”:{
“actions”:[
“/~/server/1/iptables”,
“/~/server/1/reboot”,
“/~/server/1/apply-changes”
]
},
“errors”: <optional non-fatal errors>
}
OPTIONS /~/server/1/reboot
Accept: application/json
HTTP 200 OK
Allow: POST
Content-type:application/json
{
“POST”: {
Description: “Sends TERM signal to all processes and reboots the
server”,
resource_uri: “/~/server/1/iptables”
}
POST /~/server/1/reboot
HTTP 200 OK
Allow: GET, POST, DELETE
Content-type: application/json
{
“GET”: {
description: “List all rules”,
resource_uri: “/~/server/1/iptables”
}
“POST”: {
description:“Append rule from the POST body”,
resource_uri: “/~/server/1/iptables”,
arguments: {
protocol: “The protocol of the rule or of the packet to check. The
specified protocol can be one of tcp, udp, udplite, icmp, esp, ah,
sctp or the special keyword "all", or it can be a numeric
value, representing one of these protocols or a different one.”,
source: “Source specification. Address can be either a network
name, a hostname, a network IP address (with/mask), or a plain IP
address”,
destination: “Destination specification. Address can be either a
network name, a hostname, a network IP address (with/mask), or a
plain IP address”,
…
}
},
“DELETE: {
description:“Drop all current rules”,
resource_uri: “/~/server/1/iptables”
}
}
POST /~/files/example.txt
Content-type: text/plain
Hello World!
GET /~/files/example.txt
Accept: */*
HTTP 200 OK
Content-type: text/plain
Hello World
POST /~/files/
Content-Length: <length>
Content-Type: multipart/form-data; boundary=----------------8237465289374652
------------------8237465289374652
Content-Length: <length of software.pkg>
Content-Type: application/octet-stream
Content-Disposition: form-data; name=softwarePackage; filename=software.pkg
To obtain file uploaded using this method, specific endpoint has to be used. It can be obtained using a
GET request on the same endpoint used for multiple-part file upload. Consider the following workflow:
GET /~/files/
Accept: application/json
HTTP 200 OK
Content-type:application/json
{
Data: [
{
filename: “software.pkg”,
size: “<length of software.pkg”>,
GET /~/files/software.pkg
Accept: */*
HTTP 200 OK
Content-type:application/octet-stream
<binary content of software.pkg>
GET /~/alarm/80
Accept:application/json
HTTP 200 OK
Content-Type:application/json
{
...
“EventSiteIDs”:[
“/api/1.0/dde/event/32/432”,
“/api/1.0/dde/event/32/433”,
“/api/1.0/dde/event/55/434”
]
}
Once relations are known, additional ones can be attached and sent back to the server:
PATCH /~alarm/80
Content-type:application/json
{
“EventSiteIDs”:[
“/api/1.0/dde/event/32/432”,
“/api/1.0/dde/event/32/433”,
“/api/1.0/dde/event/55/434”,
“/api/1.0/dde/event/55/500”
]
}
In similar fashion, one or more related item can be removed from the related objects list.
The “Connection” header that contains “Upgrade” indicates that the client wants to switch to the
protocol specified in the “Upgrade” header (“websocket” in this case).
If the server supports the protocol requested by the client it replies with “101 Switching Protocols”. In
the response it includes the “Connection” header that contains “Upgrade” and “Upgrade” header
with value of one of the supported protocol (“websocket” in this case).
If the server does not support the WebSocket protocol it will respond with HTTP code “400 Bad
Request”.
“Sec-WebSocket-Key” header is used to ensure that the server does not accept connections from
non-WebSocket clients. Its value is calculated by base64 encoding of random 16-byte data.
The server concatenates its value to “258EAFA5-E914-47DA-95CA-C5AB0DC85B11” string and the
resulting string is hashed by SHA-1. The resultant value is base64 encoded and is sent in the response
using “Sec-WebSocket-Accept” header.
Using this header’s value, the client can then check if the server truly supports WebSocket connection
by performing the same operations performed on the server and by comparing the resultant strings.
For each request, the server replies with one of the messages described below.
10.6 Ping/Pong
In WebSocket protocol there exist ping and pong frames. This is a low level of the protocol and they
cannot be controlled through JavaScript. They are described in more detail in
http://tools.ietf.org/html/rfc6455.
Whenever the client sends a ping frame (opcode 0x9), the server must reply with pong frame (opcode
0xA).
10.7 Heartbeats
Checking that the WebSocket connection to the server is still alive can be achieved by sending a ping
frame to the server at equal intervals. This is a low level of the protocol and the browser’s
implementation should handle keeping the connection alive. If the network connection has dropped
then the client will already have received a disconnect, but if the WS network connection is still up but
the server has stopped responding to this connection then the Ping -> Pong will detect it. When a Pong
is not received back then the connection should be re-established.