[asterisk-commits] qwell: branch qwell/ari_channel_variables r392361 - in /team/qwell/ari_channe...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jun 20 14:57:30 CDT 2013
Author: qwell
Date: Thu Jun 20 14:57:28 2013
New Revision: 392361
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392361
Log:
Stub out getVar and setVar.
Modified:
team/qwell/ari_channel_variables/res/res_stasis_http_channels.c
team/qwell/ari_channel_variables/res/stasis_http/resource_channels.c
team/qwell/ari_channel_variables/res/stasis_http/resource_channels.h
team/qwell/ari_channel_variables/rest-api/api-docs/channels.json
Modified: team/qwell/ari_channel_variables/res/res_stasis_http_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/ari_channel_variables/res/res_stasis_http_channels.c?view=diff&rev=392361&r1=392360&r2=392361
==============================================================================
--- team/qwell/ari_channel_variables/res/res_stasis_http_channels.c (original)
+++ team/qwell/ari_channel_variables/res/res_stasis_http_channels.c Thu Jun 20 14:57:28 2013
@@ -404,6 +404,65 @@
}
stasis_http_record_channel(headers, &args, response);
}
+/*!
+ * \brief Parameter parsing callback for /channels/{channelId}/variable.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_get_var_cb(
+ struct ast_variable *get_params, struct ast_variable *path_vars,
+ struct ast_variable *headers, struct stasis_http_response *response)
+{
+ struct ast_get_var_args args = {};
+ struct ast_variable *i;
+
+ for (i = get_params; i; i = i->next) {
+ if (strcmp(i->name, "variable") == 0) {
+ args.variable = (i->value);
+ } else
+ {}
+ }
+ for (i = path_vars; i; i = i->next) {
+ if (strcmp(i->name, "channelId") == 0) {
+ args.channel_id = (i->value);
+ } else
+ {}
+ }
+ stasis_http_get_var(headers, &args, response);
+}
+/*!
+ * \brief Parameter parsing callback for /channels/{channelId}/variable.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_set_var_cb(
+ struct ast_variable *get_params, struct ast_variable *path_vars,
+ struct ast_variable *headers, struct stasis_http_response *response)
+{
+ struct ast_set_var_args args = {};
+ struct ast_variable *i;
+
+ for (i = get_params; i; i = i->next) {
+ if (strcmp(i->name, "variable") == 0) {
+ args.variable = (i->value);
+ } else
+ if (strcmp(i->name, "value") == 0) {
+ args.value = (i->value);
+ } else
+ {}
+ }
+ for (i = path_vars; i; i = i->next) {
+ if (strcmp(i->name, "channelId") == 0) {
+ args.channel_id = (i->value);
+ } else
+ {}
+ }
+ stasis_http_set_var(headers, &args, response);
+}
/*! \brief REST handler for /api-docs/channels.{format} */
static struct stasis_rest_handlers channels_channelId_dial = {
@@ -482,6 +541,16 @@
.path_segment = "record",
.callbacks = {
[AST_HTTP_POST] = stasis_http_record_channel_cb,
+ },
+ .num_children = 0,
+ .children = { }
+};
+/*! \brief REST handler for /api-docs/channels.{format} */
+static struct stasis_rest_handlers channels_channelId_variable = {
+ .path_segment = "variable",
+ .callbacks = {
+ [AST_HTTP_GET] = stasis_http_get_var_cb,
+ [AST_HTTP_POST] = stasis_http_set_var_cb,
},
.num_children = 0,
.children = { }
@@ -494,8 +563,8 @@
[AST_HTTP_GET] = stasis_http_get_channel_cb,
[AST_HTTP_DELETE] = stasis_http_delete_channel_cb,
},
- .num_children = 9,
- .children = { &channels_channelId_dial,&channels_channelId_continue,&channels_channelId_answer,&channels_channelId_mute,&channels_channelId_unmute,&channels_channelId_hold,&channels_channelId_unhold,&channels_channelId_play,&channels_channelId_record, }
+ .num_children = 10,
+ .children = { &channels_channelId_dial,&channels_channelId_continue,&channels_channelId_answer,&channels_channelId_mute,&channels_channelId_unmute,&channels_channelId_hold,&channels_channelId_unhold,&channels_channelId_play,&channels_channelId_record,&channels_channelId_variable, }
};
/*! \brief REST handler for /api-docs/channels.{format} */
static struct stasis_rest_handlers channels = {
Modified: team/qwell/ari_channel_variables/res/stasis_http/resource_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/ari_channel_variables/res/stasis_http/resource_channels.c?view=diff&rev=392361&r1=392360&r2=392361
==============================================================================
--- team/qwell/ari_channel_variables/res/stasis_http/resource_channels.c (original)
+++ team/qwell/ari_channel_variables/res/stasis_http/resource_channels.c Thu Jun 20 14:57:28 2013
@@ -382,3 +382,14 @@
stasis_http_response_no_content(response);
}
+
+void stasis_http_get_var(struct ast_variable *headers, struct ast_get_var_args *args, struct stasis_http_response *response)
+{
+ ast_log(LOG_ERROR, "TODO: stasis_http_get_var\n");
+}
+
+void stasis_http_set_var(struct ast_variable *headers, struct ast_set_var_args *args, struct stasis_http_response *response)
+{
+ ast_log(LOG_ERROR, "TODO: stasis_http_set_var\n");
+}
+
Modified: team/qwell/ari_channel_variables/res/stasis_http/resource_channels.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/ari_channel_variables/res/stasis_http/resource_channels.h?view=diff&rev=392361&r1=392360&r2=392361
==============================================================================
--- team/qwell/ari_channel_variables/res/stasis_http/resource_channels.h (original)
+++ team/qwell/ari_channel_variables/res/stasis_http/resource_channels.h Thu Jun 20 14:57:28 2013
@@ -254,5 +254,37 @@
* \param[out] response HTTP response
*/
void stasis_http_record_channel(struct ast_variable *headers, struct ast_record_channel_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_get_var() */
+struct ast_get_var_args {
+ /*! \brief Channel's id */
+ const char *channel_id;
+ /*! \brief The variable to get */
+ const char *variable;
+};
+/*!
+ * \brief Get the value of a channel variable.
+ *
+ * \param headers HTTP headers
+ * \param args Swagger parameters
+ * \param[out] response HTTP response
+ */
+void stasis_http_get_var(struct ast_variable *headers, struct ast_get_var_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_set_var() */
+struct ast_set_var_args {
+ /*! \brief Channel's id */
+ const char *channel_id;
+ /*! \brief The variable to set */
+ const char *variable;
+ /*! \brief The value to set the variable to */
+ const char *value;
+};
+/*!
+ * \brief Set the value of a channel variable.
+ *
+ * \param headers HTTP headers
+ * \param args Swagger parameters
+ * \param[out] response HTTP response
+ */
+void stasis_http_set_var(struct ast_variable *headers, struct ast_set_var_args *args, struct stasis_http_response *response);
#endif /* _ASTERISK_RESOURCE_CHANNELS_H */
Modified: team/qwell/ari_channel_variables/rest-api/api-docs/channels.json
URL: http://svnview.digium.com/svn/asterisk/team/qwell/ari_channel_variables/rest-api/api-docs/channels.json?view=diff&rev=392361&r1=392360&r2=392361
==============================================================================
--- team/qwell/ari_channel_variables/rest-api/api-docs/channels.json (original)
+++ team/qwell/ari_channel_variables/rest-api/api-docs/channels.json Thu Jun 20 14:57:28 2013
@@ -584,6 +584,80 @@
]
}
]
+ },
+ {
+ "path": "/channels/{channelId}/variable",
+ "description": "Variables on a channel",
+ "operations": [
+ {
+ "httpMethod": "GET",
+ "summary": "Get the value of a channel variable.",
+ "nickname": "getVar",
+ "responseClass": "Variable",
+ "parameters": [
+ {
+ "name": "channelId",
+ "description": "Channel's id",
+ "paramType": "path",
+ "required": true,
+ "allowMultiple": false,
+ "dataType": "string"
+ },
+ {
+ "name": "variable",
+ "description": "The variable to get",
+ "paramType": "query",
+ "required": true,
+ "allowMultiple": false,
+ "dataType": "string"
+ }
+ ],
+ "errorResponses": [
+ {
+ "code": 404,
+ "reason": "Channel not found"
+ }
+ ]
+ },
+ {
+ "httpMethod": "POST",
+ "summary": "Set the value of a channel variable.",
+ "nickname": "setVar",
+ "responseClass": "void",
+ "parameters": [
+ {
+ "name": "channelId",
+ "description": "Channel's id",
+ "paramType": "path",
+ "required": true,
+ "allowMultiple": false,
+ "dataType": "string"
+ },
+ {
+ "name": "variable",
+ "description": "The variable to set",
+ "paramType": "query",
+ "required": true,
+ "allowMultiple": false,
+ "dataType": "string"
+ },
+ {
+ "name": "value",
+ "description": "The value to set the variable to",
+ "paramType": "query",
+ "required": false,
+ "allowMultiple": false,
+ "dataType": "string"
+ }
+ ],
+ "errorResponses": [
+ {
+ "code": 404,
+ "reason": "Channel not found"
+ }
+ ]
+ }
+ ]
}
],
"models": {
More information about the asterisk-commits
mailing list