[asterisk-commits] dlee: branch dlee/stasis-http r384285 - in /team/dlee/stasis-http: res/ res/s...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Mar 28 12:27:23 CDT 2013
Author: dlee
Date: Thu Mar 28 12:27:20 2013
New Revision: 384285
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=384285
Log:
Event documentation
Added:
team/dlee/stasis-http/res/stasis_http/resource_events.c (with props)
team/dlee/stasis-http/res/stasis_http/resource_events.h (with props)
team/dlee/stasis-http/rest-api/events.json (with props)
Modified:
team/dlee/stasis-http/res/res_stasis_http.make
team/dlee/stasis-http/res/stasis_http/resources.c
team/dlee/stasis-http/rest-api/channels.json
team/dlee/stasis-http/rest-api/resources.json
Modified: team/dlee/stasis-http/res/res_stasis_http.make
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/res/res_stasis_http.make?view=diff&rev=384285&r1=384284&r2=384285
==============================================================================
--- team/dlee/stasis-http/res/res_stasis_http.make (original)
+++ team/dlee/stasis-http/res/res_stasis_http.make Thu Mar 28 12:27:20 2013
@@ -19,4 +19,4 @@
# This file is generated by a Cog template. Please see the original template
# at cog/res_stasis_http.make.cog
#
-res_stasis_http.so: stasis_http/resource_asterisk.o stasis_http/resource_bridges.o stasis_http/resource_channels.o stasis_http/resource_endpoints.o stasis_http/resource_recordings.o stasis_http/resources.o
+res_stasis_http.so: stasis_http/resource_asterisk.o stasis_http/resource_bridges.o stasis_http/resource_channels.o stasis_http/resource_endpoints.o stasis_http/resource_events.o stasis_http/resource_recordings.o stasis_http/resources.o
Added: team/dlee/stasis-http/res/stasis_http/resource_events.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/res/stasis_http/resource_events.c?view=auto&rev=384285
==============================================================================
--- team/dlee/stasis-http/res/stasis_http/resource_events.c (added)
+++ team/dlee/stasis-http/res/stasis_http/resource_events.c Thu Mar 28 12:27:20 2013
@@ -1,0 +1,40 @@
+/* -*- C -*-
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2012 - 2013, Digium, Inc.
+ *
+ * David M. Lee, II <dlee at 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.
+ */
+
+/*! \file
+ *
+ * \brief Implementation for stasis-http stubs.
+ *
+ * \author David M. Lee, II <dlee at digium.com>
+ */
+
+/*** MODULEINFO
+ <support_level>core</support_level>
+ ***/
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "resource_events.h"
+
+void stasis_http_event_websocket(struct ast_variable *headers, struct ast_event_websocket_args *args, struct stasis_http_response *response)
+{
+ /* TODO: This should promote this socket to a websocket connection */
+ ast_log(LOG_ERROR, "TODO: stasis_http_event_websocket\n");
+}
Propchange: team/dlee/stasis-http/res/stasis_http/resource_events.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/dlee/stasis-http/res/stasis_http/resource_events.c
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: team/dlee/stasis-http/res/stasis_http/resource_events.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: team/dlee/stasis-http/res/stasis_http/resource_events.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/res/stasis_http/resource_events.h?view=auto&rev=384285
==============================================================================
--- team/dlee/stasis-http/res/stasis_http/resource_events.h (added)
+++ team/dlee/stasis-http/res/stasis_http/resource_events.h Thu Mar 28 12:27:20 2013
@@ -1,0 +1,46 @@
+/* -*- C -*-
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2012 - 2013, Digium, Inc.
+ *
+ * David M. Lee, II <dlee at 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.
+ */
+
+/*! \file
+ *
+ * \brief Generated file - declares stubs to be implemented for stasis_http
+ *
+ * \author David M. Lee, II <dlee at digium.com>
+ */
+
+#include "asterisk/stasis_http.h"
+
+/*
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * !!!!! DO NOT EDIT !!!!!
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * This file is generated by a Cog template. Please see the original template
+ * at cog/stasis_http_resource.h.cog
+ */
+#ifndef _ASTERISK_RESOURCE_EVENTS_H
+#define _ASTERISK_RESOURCE_EVENTS_H
+struct ast_event_websocket_args {
+};
+/*!
+ * \brief WebSocket connection for events.
+ * \param headers HTTP headers
+ * \param args Swagger parameters
+ * \param[out] response HTTP response
+ */
+void stasis_http_event_websocket(struct ast_variable *headers, struct ast_event_websocket_args *args, struct stasis_http_response *response);
+#endif /* _ASTERISK_RESOURCE_EVENTS_H */
Propchange: team/dlee/stasis-http/res/stasis_http/resource_events.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/dlee/stasis-http/res/stasis_http/resource_events.h
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: team/dlee/stasis-http/res/stasis_http/resource_events.h
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: team/dlee/stasis-http/res/stasis_http/resources.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/res/stasis_http/resources.c?view=diff&rev=384285&r1=384284&r2=384285
==============================================================================
--- team/dlee/stasis-http/res/stasis_http/resources.c (original)
+++ team/dlee/stasis-http/res/stasis_http/resources.c Thu Mar 28 12:27:20 2013
@@ -46,6 +46,7 @@
#include "resource_channels.h"
#include "resource_bridges.h"
#include "resource_recordings.h"
+#include "resource_events.h"
#include <inttypes.h>
#include <strings.h>
@@ -472,6 +473,13 @@
struct ast_get_recordings_args args = {};
stasis_http_get_recordings(headers, &args, response);
+}
+
+static void stasis_http_event_websocket_cb(struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct stasis_http_response *response)
+{
+ struct ast_event_websocket_args args = {};
+
+ stasis_http_event_websocket(headers, &args, response);
}
static struct stasis_rest_handlers stasis_api_asterisk_info = {
@@ -707,12 +715,21 @@
.children = { &stasis_api_recordings_recordingId, },
};
+static struct stasis_rest_handlers stasis_api_events = {
+ .path_segment = "events",
+ .callbacks = {
+ [AST_HTTP_GET] = stasis_http_event_websocket_cb,
+ },
+ .num_children = 0,
+ .children = { },
+};
+
static struct stasis_rest_handlers stasis_api = {
.path_segment = "api",
.callbacks = {
},
- .num_children = 5,
- .children = { &stasis_api_asterisk, &stasis_api_endpoints, &stasis_api_channels, &stasis_api_bridges, &stasis_api_recordings, },
+ .num_children = 6,
+ .children = { &stasis_api_asterisk, &stasis_api_endpoints, &stasis_api_channels, &stasis_api_bridges, &stasis_api_recordings, &stasis_api_events, },
};
static struct stasis_rest_handlers stasis = {
Modified: team/dlee/stasis-http/rest-api/channels.json
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/rest-api/channels.json?view=diff&rev=384285&r1=384284&r2=384285
==============================================================================
--- team/dlee/stasis-http/rest-api/channels.json (original)
+++ team/dlee/stasis-http/rest-api/channels.json Thu Mar 28 12:27:20 2013
@@ -474,7 +474,7 @@
},
"creationtime": {
"required": true,
- "type": "string",
+ "type": "Date",
"description": "Timestamp when channel was created"
}
}
Added: team/dlee/stasis-http/rest-api/events.json
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/rest-api/events.json?view=auto&rev=384285
==============================================================================
--- team/dlee/stasis-http/rest-api/events.json (added)
+++ team/dlee/stasis-http/rest-api/events.json Thu Mar 28 12:27:20 2013
@@ -1,0 +1,94 @@
+{
+ "_copyright": "Copyright (C) 2012 - 2013, Digium, Inc.",
+ "_author": "David M. Lee, II <dlee at digium.com>",
+ "_svn_revision": "$Revision$",
+ "apiVersion": "0.0.1",
+ "swaggerVersion": "1.1",
+ "basePath": "http://localhost:8088/stasis",
+ "resourcePath": "/events.{format}",
+ "apis": [
+ {
+ "path": "/api/events",
+ "description": "Events from Asterisk to applications",
+ "operations": [
+ {
+ "httpMethod": "GET",
+ "summary": "WebSocket connection for events",
+ "nickname": "event_websocket",
+ "responseClass": "Event"
+ }
+ ]
+ }
+ ],
+ "models": {
+ "Event": {
+ "id": "Event",
+ "properties": {
+ "application": {
+ "type": "string",
+ "description": "Name of the application receiving the event",
+ "required": true
+ },
+ "event": {
+ "type": "string",
+ "description": "Event name.",
+ "required": true,
+ "allowableValues": {
+ "valueType": "LIST",
+ "values": [
+ "stasis-start",
+ "stasis-end",
+ "channel-state-change",
+ "application-replaced"
+ ]
+ }
+ },
+ "event_info": {
+ "type": "object",
+ "oneOf": [
+ { "$ref": "StasisStart" },
+ { "$ref": "StasisEnd" },
+ { "$ref": "ChannelStateChange" },
+ { "$ref": "ApplicationReplaced" }
+ ]
+ }
+ }
+ },
+ "StasisStart": {
+ "id": "StasisStart",
+ "properties": {
+ "args": {
+ "type": "LIST",
+ "description": "Arguments to the application",
+ "items": {
+ "$ref": "string"
+ }
+ },
+ "channel_info": {
+ "type": "Channel"
+ }
+ }
+ },
+ "StasisEnd": {
+ "id": "StasisEnd",
+ "properties": {
+ "channel_info": {
+ "type": "Channel"
+ }
+ }
+ },
+ "ChannelStateChange": {
+ "id": "ChannelStateChange",
+ "properties": {
+ "channel_info": {
+ "type": "Channel"
+ }
+ }
+ },
+ "ApplicationReplaced": {
+ "id": "ApplicationReplaced",
+ "properties": {
+ }
+ }
+ }
+}
Propchange: team/dlee/stasis-http/rest-api/events.json
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/dlee/stasis-http/rest-api/events.json
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: team/dlee/stasis-http/rest-api/events.json
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: team/dlee/stasis-http/rest-api/resources.json
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/rest-api/resources.json?view=diff&rev=384285&r1=384284&r2=384285
==============================================================================
--- team/dlee/stasis-http/rest-api/resources.json (original)
+++ team/dlee/stasis-http/rest-api/resources.json Thu Mar 28 12:27:20 2013
@@ -25,6 +25,10 @@
{
"path": "/recordings.{format}",
"description": "Recording resources"
+ },
+ {
+ "path": "/events.{format}",
+ "description": "WebSocket resource"
}
]
}
More information about the asterisk-commits
mailing list