diff options
author | Kevin Harwell <kharwell@digium.com> | 2013-11-23 17:48:28 +0000 |
---|---|---|
committer | Kevin Harwell <kharwell@digium.com> | 2013-11-23 17:48:28 +0000 |
commit | ed483779946553e2ec42472c6b665b86dcb07066 (patch) | |
tree | 954ae85065f670f111954e36e5bd77d4f271778a /rest-api | |
parent | 05cbf8df9b2ea0b41e049698b9f51ee4365ceab0 (diff) |
ARI: Implement device state API
Created a data model and implemented functionality for an ARI device state
resource. The following operations have been added that allow a user to
manipulate an ARI controlled device:
Create/Change the state of an ARI controlled device
PUT /deviceStates/{deviceName}&{deviceState}
Retrieve all ARI controlled devices
GET /deviceStates
Retrieve the current state of a device
GET /deviceStates/{deviceName}
Destroy a device-state controlled by ARI
DELETE /deviceStates/{deviceName}
The ARI controlled device must begin with 'Stasis:'. An example controlled
device name would be Stasis:Example. A 'DeviceStateChanged' event has also
been added so that an application can subscribe and receive device change
events. Any device state, ARI controlled or not, can be subscribed to.
While adding the event, the underlying subscription control mechanism was
refactored so that all current and future resource subscriptions would be
the same. Each event resource must now register itself in order to be able
to properly handle [un]subscribes.
(issue ASTERISK-22838)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/3025/
........
Merged revisions 403134 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403135 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'rest-api')
-rw-r--r-- | rest-api/api-docs/applications.json | 9 | ||||
-rw-r--r-- | rest-api/api-docs/deviceStates.json | 151 | ||||
-rw-r--r-- | rest-api/api-docs/events.json | 12 | ||||
-rw-r--r-- | rest-api/resources.json | 4 |
4 files changed, 174 insertions, 2 deletions
diff --git a/rest-api/api-docs/applications.json b/rest-api/api-docs/applications.json index 494088dc5..cd27d586e 100644 --- a/rest-api/api-docs/applications.json +++ b/rest-api/api-docs/applications.json @@ -68,7 +68,7 @@ }, { "name": "eventSource", - "description": "URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}/{resource}", + "description": "URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}/{resource}, deviceState:{deviceName}", "paramType": "query", "required": true, "allowMultiple": true, @@ -107,7 +107,7 @@ }, { "name": "eventSource", - "description": "URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}/{resource}", + "description": "URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}/{resource}, device_state:{deviceName}", "paramType": "query", "required": true, "allowMultiple": true, @@ -160,6 +160,11 @@ "type": "List[string]", "description": "{tech}/{resource} for endpoints subscribed to.", "required": true + }, + "device_names": { + "type": "List[string]", + "description": "Names of the devices subscribed to.", + "required": true } } } diff --git a/rest-api/api-docs/deviceStates.json b/rest-api/api-docs/deviceStates.json new file mode 100644 index 000000000..529bc70da --- /dev/null +++ b/rest-api/api-docs/deviceStates.json @@ -0,0 +1,151 @@ +{ + "_copyright": "Copyright (C) 2012 - 2013, Digium, Inc.", + "_author": "Kevin Harwell <kharwell@digium.com>", + "_svn_revision": "$Revision$", + "apiVersion": "0.0.1", + "swaggerVersion": "1.1", + "basePath": "http://localhost:8088/stasis", + "resourcePath": "/api-docs/deviceStates.{format}", + "apis": [ + { + "path": "/deviceStates", + "description": "Device states", + "operations": [ + { + "httpMethod": "GET", + "summary": "List all ARI controlled device states.", + "nickname": "list", + "responseClass": "List[DeviceState]" + } + ] + }, + { + "path": "/deviceStates/{deviceName}", + "description": "Device state", + "operations": [ + { + "httpMethod": "GET", + "summary": "Retrieve the current state of a device.", + "nickname": "get", + "responseClass": "DeviceState", + "parameters": [ + { + "name": "deviceName", + "description": "Name of the device", + "paramType": "path", + "required": true, + "allowMultiple": false, + "dataType": "string" + } + ] + }, + { + "httpMethod": "PUT", + "summary": "Change the state of a device controlled by ARI. (Note - implicitly creates the device state).", + "nickname": "update", + "responseClass": "void", + "parameters": [ + { + "name": "deviceName", + "description": "Name of the device", + "paramType": "path", + "required": true, + "allowMultiple": false, + "dataType": "string" + }, + { + "name": "deviceState", + "description": "Device state value", + "paramType": "query", + "required": true, + "allowMultiple": false, + "dataType": "string", + "allowableValues": { + "valueType": "LIST", + "values": [ + "NOT_INUSE", + "INUSE", + "BUSY", + "INVALID", + "UNAVAILABLE", + "RINGING", + "RINGINUSE", + "ONHOLD" + ] + } + + } + ], + "errorResponses": [ + { + "code": 404, + "reason": "Device name is missing" + }, + { + "code": 409, + "reason": "Uncontrolled device specified" + } + ] + }, + { + "httpMethod": "DELETE", + "summary": "Destroy a device-state controlled by ARI.", + "nickname": "delete", + "responseClass": "void", + "parameters": [ + { + "name": "deviceName", + "description": "Name of the device", + "paramType": "path", + "required": true, + "allowMultiple": false, + "dataType": "string" + } + ], + "errorResponses": [ + { + "code": 404, + "reason": "Device name is missing" + }, + { + "code": 409, + "reason": "Uncontrolled device specified" + } + ] + } + ] + } + ], + "models": { + "DeviceState": { + "id": "DeviceState", + "description": "Represents the state of a device.", + "properties": { + "name": { + "type": "string", + "description": "Name of the device.", + "required": true + }, + "state": { + "type": "string", + "description": "Device's state", + "required": true, + "allowableValues": { + "valueType": "LIST", + "values": [ + "UNKNOWN", + "NOT_INUSE", + "INUSE", + "BUSY", + "INVALID", + "UNAVAILABLE", + "RINGING", + "RINGINUSE", + "ONHOLD" + ] + } + } + } + } + } +} diff --git a/rest-api/api-docs/events.json b/rest-api/api-docs/events.json index e30a193c1..a342099a8 100644 --- a/rest-api/api-docs/events.json +++ b/rest-api/api-docs/events.json @@ -76,6 +76,7 @@ } }, "subTypes": [ + "DeviceStateChanged", "PlaybackStarted", "PlaybackFinished", "ApplicationReplaced", @@ -98,6 +99,17 @@ "StasisStart" ] }, + "DeviceStateChanged": { + "id": "DeviceStateChanged", + "description": "Notification that a device state has changed.", + "properties": { + "device_state": { + "type": "DeviceState", + "description": "Device state object", + "required": true + } + } + }, "PlaybackStarted": { "id": "PlaybackStarted", "description": "Event showing the start of a media playback operation.", diff --git a/rest-api/resources.json b/rest-api/resources.json index 7e0b793fb..495348a21 100644 --- a/rest-api/resources.json +++ b/rest-api/resources.json @@ -35,6 +35,10 @@ "description": "Playback control resources" }, { + "path": "/api-docs/deviceStates.{format}", + "description": "Device state resources" + }, + { "path": "/api-docs/events.{format}", "description": "WebSocket resource" }, |