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
This commit is contained in:
Kevin Harwell
2013-11-23 17:48:28 +00:00
parent 05cbf8df9b
commit ed48377994
21 changed files with 1952 additions and 264 deletions

View File

@@ -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
}
}
}

View File

@@ -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"
]
}
}
}
}
}
}

View File

@@ -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.",