Files
asterisk/include/asterisk/stasis_app_device_state.h
Kevin Harwell ed48377994 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
2013-11-23 17:48:28 +00:00

96 lines
2.6 KiB
C

/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2013, Digium, Inc.
*
* Kevin Harwell <kharwell@digium.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
#ifndef _ASTERISK_STASIS_APP_DEVICE_STATE_H
#define _ASTERISK_STASIS_APP_DEVICE_STATE_H
/*! \file
*
* \brief Stasis Application Device State API. See \ref res_stasis "Stasis
* Application API" for detailed documentation.
*
* \author Kevin Harwell <kharwell@digium.com>
* \since 12
*/
#include "asterisk/app.h"
#include "asterisk/stasis_app.h"
/*! @{ */
/*!
* \brief Convert device state to json.
*
* \param name the name of the device
* \param state the device state
* \return JSON representation.
* \return \c NULL on error.
*/
struct ast_json *stasis_app_device_state_to_json(
const char *name, enum ast_device_state state);
/*!
* \brief Convert device states to json array.
*
* \return JSON representation.
* \return \c NULL on error.
*/
struct ast_json *stasis_app_device_states_to_json(void);
/*! Stasis device state application result codes */
enum stasis_device_state_result {
/*! Application controlled device state is okay */
STASIS_DEVICE_STATE_OK,
/*! The device name is not application controlled */
STASIS_DEVICE_STATE_NOT_CONTROLLED,
/*! The application controlled device name is missing */
STASIS_DEVICE_STATE_MISSING,
/*! The application controlled device is unknown */
STASIS_DEVICE_STATE_UNKNOWN,
/*! The application controlled device has subscribers */
STASIS_DEVICE_STATE_SUBSCRIBERS
};
/*!
* \brief Changes the state of a device controlled by ARI.
*
* \note The controlled device must be prefixed with 'Stasis:'.
* \note Implicitly creates the device state.
*
* \param name the name of the ARI controlled device
* \param value a valid device state value
*
* \return a stasis device state application result.
*/
enum stasis_device_state_result stasis_app_device_state_update(
const char *name, const char *value);
/*!
* \brief Delete a device controlled by ARI.
*
* \param name the name of the ARI controlled device
*
* \returna stasis device state application result.
*/
enum stasis_device_state_result stasis_app_device_state_delete(
const char *name);
/*! @} */
#endif /* _ASTERISK_STASIS_APP_DEVICE_STATE_H */