[asterisk-commits] dlee: branch dlee/ari-event-remodel2 r392115 - in /team/dlee/ari-event-remode...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jun 17 17:20:00 CDT 2013


Author: dlee
Date: Mon Jun 17 17:19:58 2013
New Revision: 392115

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392115
Log:
Plug in the model validators to RESTful API's

Modified:
    team/dlee/ari-event-remodel2/res/res_ari_model.c
    team/dlee/ari-event-remodel2/res/res_stasis_http_asterisk.c
    team/dlee/ari-event-remodel2/res/res_stasis_http_bridges.c
    team/dlee/ari-event-remodel2/res/res_stasis_http_channels.c
    team/dlee/ari-event-remodel2/res/res_stasis_http_endpoints.c
    team/dlee/ari-event-remodel2/res/res_stasis_http_events.c
    team/dlee/ari-event-remodel2/res/res_stasis_http_playback.c
    team/dlee/ari-event-remodel2/res/res_stasis_http_recordings.c
    team/dlee/ari-event-remodel2/res/res_stasis_http_sounds.c
    team/dlee/ari-event-remodel2/res/stasis_http/ari_model.h
    team/dlee/ari-event-remodel2/res/stasis_http/resource_recordings.c
    team/dlee/ari-event-remodel2/res/stasis_http/resource_recordings.h
    team/dlee/ari-event-remodel2/rest-api-templates/ari_model.h.mustache
    team/dlee/ari-event-remodel2/rest-api-templates/asterisk_processor.py
    team/dlee/ari-event-remodel2/rest-api-templates/res_stasis_http_resource.c.mustache
    team/dlee/ari-event-remodel2/rest-api-templates/swagger_model.py
    team/dlee/ari-event-remodel2/rest-api/api-docs/recordings.json

Modified: team/dlee/ari-event-remodel2/res/res_ari_model.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/res/res_ari_model.c?view=diff&rev=392115&r1=392114&r2=392115
==============================================================================
--- team/dlee/ari-event-remodel2/res/res_ari_model.c (original)
+++ team/dlee/ari-event-remodel2/res/res_ari_model.c Mon Jun 17 17:19:58 2013
@@ -80,6 +80,11 @@
 		return 0;
 	}
 	return 1;
+}
+
+int ari_validate_void(struct ast_json *json)
+{
+	return check_type(json, AST_JSON_NULL);
 }
 
 int ari_validate_byte(struct ast_json *json)

Modified: team/dlee/ari-event-remodel2/res/res_stasis_http_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/res/res_stasis_http_asterisk.c?view=diff&rev=392115&r1=392114&r2=392115
==============================================================================
--- team/dlee/ari-event-remodel2/res/res_stasis_http_asterisk.c (original)
+++ team/dlee/ari-event-remodel2/res/res_stasis_http_asterisk.c Mon Jun 17 17:19:58 2013
@@ -44,6 +44,9 @@
 #include "asterisk/module.h"
 #include "asterisk/stasis_app.h"
 #include "stasis_http/resource_asterisk.h"
+#if defined(AST_DEVMODE)
+#include "stasis_http/ari_model.h"
+#endif
 
 /*!
  * \brief Parameter parsing callback for /asterisk/info.
@@ -53,9 +56,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_get_asterisk_info_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
 {
+	int is_valid;
 	struct ast_get_asterisk_info_args args = {};
 	struct ast_variable *i;
 
@@ -66,6 +70,14 @@
 		{}
 	}
 	stasis_http_get_asterisk_info(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_asterisk_info(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /asterisk/info\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 
 /*! \brief REST handler for /api-docs/asterisk.{format} */

Modified: team/dlee/ari-event-remodel2/res/res_stasis_http_bridges.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/res/res_stasis_http_bridges.c?view=diff&rev=392115&r1=392114&r2=392115
==============================================================================
--- team/dlee/ari-event-remodel2/res/res_stasis_http_bridges.c (original)
+++ team/dlee/ari-event-remodel2/res/res_stasis_http_bridges.c Mon Jun 17 17:19:58 2013
@@ -44,6 +44,9 @@
 #include "asterisk/module.h"
 #include "asterisk/stasis_app.h"
 #include "stasis_http/resource_bridges.h"
+#if defined(AST_DEVMODE)
+#include "stasis_http/ari_model.h"
+#endif
 
 /*!
  * \brief Parameter parsing callback for /bridges.
@@ -53,11 +56,21 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_get_bridges_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_get_bridges_args args = {};
 	stasis_http_get_bridges(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_list(response->message,
+		ari_validate_bridge);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /bridges\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /bridges.
@@ -67,9 +80,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_new_bridge_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_new_bridge_args args = {};
 	struct ast_variable *i;
 
@@ -80,6 +94,14 @@
 		{}
 	}
 	stasis_http_new_bridge(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_bridge(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /bridges\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /bridges/{bridgeId}.
@@ -89,9 +111,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_get_bridge_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_get_bridge_args args = {};
 	struct ast_variable *i;
 
@@ -102,6 +125,14 @@
 		{}
 	}
 	stasis_http_get_bridge(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_bridge(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /bridges/{bridgeId}.
@@ -111,9 +142,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_delete_bridge_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_delete_bridge_args args = {};
 	struct ast_variable *i;
 
@@ -124,6 +156,14 @@
 		{}
 	}
 	stasis_http_delete_bridge(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_void(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /bridges/{bridgeId}/addChannel.
@@ -133,9 +173,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_add_channel_to_bridge_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_add_channel_to_bridge_args args = {};
 	struct ast_variable *i;
 
@@ -152,6 +193,14 @@
 		{}
 	}
 	stasis_http_add_channel_to_bridge(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_void(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/addChannel\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /bridges/{bridgeId}/removeChannel.
@@ -161,9 +210,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_remove_channel_from_bridge_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_remove_channel_from_bridge_args args = {};
 	struct ast_variable *i;
 
@@ -180,6 +230,14 @@
 		{}
 	}
 	stasis_http_remove_channel_from_bridge(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_void(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/removeChannel\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /bridges/{bridgeId}/record.
@@ -189,9 +247,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_record_bridge_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_record_bridge_args args = {};
 	struct ast_variable *i;
 
@@ -223,6 +282,14 @@
 		{}
 	}
 	stasis_http_record_bridge(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_live_recording(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/record\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 
 /*! \brief REST handler for /api-docs/bridges.{format} */

Modified: team/dlee/ari-event-remodel2/res/res_stasis_http_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/res/res_stasis_http_channels.c?view=diff&rev=392115&r1=392114&r2=392115
==============================================================================
--- team/dlee/ari-event-remodel2/res/res_stasis_http_channels.c (original)
+++ team/dlee/ari-event-remodel2/res/res_stasis_http_channels.c Mon Jun 17 17:19:58 2013
@@ -44,6 +44,9 @@
 #include "asterisk/module.h"
 #include "asterisk/stasis_app.h"
 #include "stasis_http/resource_channels.h"
+#if defined(AST_DEVMODE)
+#include "stasis_http/ari_model.h"
+#endif
 
 /*!
  * \brief Parameter parsing callback for /channels.
@@ -53,11 +56,21 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_get_channels_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_get_channels_args args = {};
 	stasis_http_get_channels(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_list(response->message,
+		ari_validate_channel);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /channels\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /channels.
@@ -67,9 +80,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_originate_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_originate_args args = {};
 	struct ast_variable *i;
 
@@ -98,6 +112,14 @@
 		{}
 	}
 	stasis_http_originate(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_void(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /channels\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}.
@@ -107,9 +129,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_get_channel_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_get_channel_args args = {};
 	struct ast_variable *i;
 
@@ -120,6 +143,14 @@
 		{}
 	}
 	stasis_http_get_channel(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_channel(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}.
@@ -129,9 +160,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_delete_channel_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_delete_channel_args args = {};
 	struct ast_variable *i;
 
@@ -142,6 +174,14 @@
 		{}
 	}
 	stasis_http_delete_channel(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_void(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/dial.
@@ -151,9 +191,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_dial_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_dial_args args = {};
 	struct ast_variable *i;
 
@@ -176,6 +217,14 @@
 		{}
 	}
 	stasis_http_dial(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_dialed(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/dial\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/continue.
@@ -185,9 +234,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_continue_in_dialplan_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_continue_in_dialplan_args args = {};
 	struct ast_variable *i;
 
@@ -198,6 +248,14 @@
 		{}
 	}
 	stasis_http_continue_in_dialplan(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_void(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/continue\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/answer.
@@ -207,9 +265,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_answer_channel_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_answer_channel_args args = {};
 	struct ast_variable *i;
 
@@ -220,6 +279,14 @@
 		{}
 	}
 	stasis_http_answer_channel(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_void(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/answer\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/mute.
@@ -229,9 +296,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_mute_channel_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_mute_channel_args args = {};
 	struct ast_variable *i;
 
@@ -248,6 +316,14 @@
 		{}
 	}
 	stasis_http_mute_channel(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_void(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/mute\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/unmute.
@@ -257,9 +333,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_unmute_channel_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_unmute_channel_args args = {};
 	struct ast_variable *i;
 
@@ -276,6 +353,14 @@
 		{}
 	}
 	stasis_http_unmute_channel(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_void(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/unmute\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/hold.
@@ -285,9 +370,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_hold_channel_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_hold_channel_args args = {};
 	struct ast_variable *i;
 
@@ -298,6 +384,14 @@
 		{}
 	}
 	stasis_http_hold_channel(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_void(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/hold\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/unhold.
@@ -307,9 +401,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_unhold_channel_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_unhold_channel_args args = {};
 	struct ast_variable *i;
 
@@ -320,6 +415,14 @@
 		{}
 	}
 	stasis_http_unhold_channel(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_void(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/unhold\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/play.
@@ -329,9 +432,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_play_on_channel_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_play_on_channel_args args = {};
 	struct ast_variable *i;
 
@@ -357,6 +461,14 @@
 		{}
 	}
 	stasis_http_play_on_channel(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_playback(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/play\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/record.
@@ -366,9 +478,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_record_channel_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_record_channel_args args = {};
 	struct ast_variable *i;
 
@@ -403,6 +516,14 @@
 		{}
 	}
 	stasis_http_record_channel(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_void(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/record\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 
 /*! \brief REST handler for /api-docs/channels.{format} */

Modified: team/dlee/ari-event-remodel2/res/res_stasis_http_endpoints.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/res/res_stasis_http_endpoints.c?view=diff&rev=392115&r1=392114&r2=392115
==============================================================================
--- team/dlee/ari-event-remodel2/res/res_stasis_http_endpoints.c (original)
+++ team/dlee/ari-event-remodel2/res/res_stasis_http_endpoints.c Mon Jun 17 17:19:58 2013
@@ -44,6 +44,9 @@
 #include "asterisk/module.h"
 #include "asterisk/stasis_app.h"
 #include "stasis_http/resource_endpoints.h"
+#if defined(AST_DEVMODE)
+#include "stasis_http/ari_model.h"
+#endif
 
 /*!
  * \brief Parameter parsing callback for /endpoints.
@@ -53,11 +56,21 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_get_endpoints_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
 {
+	int is_valid;
 	struct ast_get_endpoints_args args = {};
 	stasis_http_get_endpoints(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_list(response->message,
+		ari_validate_endpoint);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /endpoints\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /endpoints/{tech}.
@@ -67,9 +80,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_get_endpoints_by_tech_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
 {
+	int is_valid;
 	struct ast_get_endpoints_by_tech_args args = {};
 	struct ast_variable *i;
 
@@ -80,6 +94,15 @@
 		{}
 	}
 	stasis_http_get_endpoints_by_tech(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_list(response->message,
+		ari_validate_endpoint);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /endpoints/{tech}\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /endpoints/{tech}/{resource}.
@@ -89,9 +112,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_get_endpoint_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
 {
+	int is_valid;
 	struct ast_get_endpoint_args args = {};
 	struct ast_variable *i;
 
@@ -105,6 +129,14 @@
 		{}
 	}
 	stasis_http_get_endpoint(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_endpoint(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /endpoints/{tech}/{resource}\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 
 /*! \brief REST handler for /api-docs/endpoints.{format} */

Modified: team/dlee/ari-event-remodel2/res/res_stasis_http_events.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/res/res_stasis_http_events.c?view=diff&rev=392115&r1=392114&r2=392115
==============================================================================
--- team/dlee/ari-event-remodel2/res/res_stasis_http_events.c (original)
+++ team/dlee/ari-event-remodel2/res/res_stasis_http_events.c Mon Jun 17 17:19:58 2013
@@ -44,6 +44,9 @@
 #include "asterisk/module.h"
 #include "asterisk/stasis_app.h"
 #include "stasis_http/resource_events.h"
+#if defined(AST_DEVMODE)
+#include "stasis_http/ari_model.h"
+#endif
 
 static void stasis_http_event_websocket_ws_cb(struct ast_websocket *ws_session,
 	struct ast_variable *get_params, struct ast_variable *headers)

Modified: team/dlee/ari-event-remodel2/res/res_stasis_http_playback.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/res/res_stasis_http_playback.c?view=diff&rev=392115&r1=392114&r2=392115
==============================================================================
--- team/dlee/ari-event-remodel2/res/res_stasis_http_playback.c (original)
+++ team/dlee/ari-event-remodel2/res/res_stasis_http_playback.c Mon Jun 17 17:19:58 2013
@@ -44,6 +44,9 @@
 #include "asterisk/module.h"
 #include "asterisk/stasis_app.h"
 #include "stasis_http/resource_playback.h"
+#if defined(AST_DEVMODE)
+#include "stasis_http/ari_model.h"
+#endif
 
 /*!
  * \brief Parameter parsing callback for /playback/{playbackId}.
@@ -53,9 +56,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_get_playback_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_get_playback_args args = {};
 	struct ast_variable *i;
 
@@ -66,6 +70,14 @@
 		{}
 	}
 	stasis_http_get_playback(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_playback(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /playback/{playbackId}\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /playback/{playbackId}.
@@ -75,9 +87,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_stop_playback_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_stop_playback_args args = {};
 	struct ast_variable *i;
 
@@ -88,6 +101,14 @@
 		{}
 	}
 	stasis_http_stop_playback(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_playback(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /playback/{playbackId}\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /playback/{playbackId}/control.
@@ -97,9 +118,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_control_playback_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_control_playback_args args = {};
 	struct ast_variable *i;
 
@@ -116,6 +138,14 @@
 		{}
 	}
 	stasis_http_control_playback(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_playback(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /playback/{playbackId}/control\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 
 /*! \brief REST handler for /api-docs/playback.{format} */

Modified: team/dlee/ari-event-remodel2/res/res_stasis_http_recordings.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/res/res_stasis_http_recordings.c?view=diff&rev=392115&r1=392114&r2=392115
==============================================================================
--- team/dlee/ari-event-remodel2/res/res_stasis_http_recordings.c (original)
+++ team/dlee/ari-event-remodel2/res/res_stasis_http_recordings.c Mon Jun 17 17:19:58 2013
@@ -44,21 +44,10 @@
 #include "asterisk/module.h"
 #include "asterisk/stasis_app.h"
 #include "stasis_http/resource_recordings.h"
-
-/*!
- * \brief Parameter parsing callback for /recordings.
- * \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_recordings_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
-	struct ast_get_recordings_args args = {};
-	stasis_http_get_recordings(headers, &args, response);
-}
+#if defined(AST_DEVMODE)
+#include "stasis_http/ari_model.h"
+#endif
+
 /*!
  * \brief Parameter parsing callback for /recordings/stored.
  * \param get_params GET parameters in the HTTP request.
@@ -67,11 +56,21 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_get_stored_recordings_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_get_stored_recordings_args args = {};
 	stasis_http_get_stored_recordings(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_list(response->message,
+		ari_validate_stored_recording);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /recordings/stored\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /recordings/stored/{recordingId}.
@@ -81,9 +80,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_get_stored_recording_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_get_stored_recording_args args = {};
 	struct ast_variable *i;
 
@@ -94,6 +94,14 @@
 		{}
 	}
 	stasis_http_get_stored_recording(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_stored_recording(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /recordings/stored/{recordingId}\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /recordings/stored/{recordingId}.
@@ -103,9 +111,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_delete_stored_recording_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_delete_stored_recording_args args = {};
 	struct ast_variable *i;
 
@@ -116,6 +125,14 @@
 		{}
 	}
 	stasis_http_delete_stored_recording(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_void(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /recordings/stored/{recordingId}\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /recordings/live.
@@ -125,11 +142,21 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_get_live_recordings_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_get_live_recordings_args args = {};
 	stasis_http_get_live_recordings(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_list(response->message,
+		ari_validate_live_recording);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /recordings/live\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /recordings/live/{recordingId}.
@@ -139,9 +166,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_get_live_recording_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_get_live_recording_args args = {};
 	struct ast_variable *i;
 
@@ -152,6 +180,14 @@
 		{}
 	}
 	stasis_http_get_live_recording(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_live_recording(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /recordings/live/{recordingId}\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /recordings/live/{recordingId}.
@@ -161,9 +197,10 @@
  * \param[out] response Response to the HTTP request.
  */
 static void stasis_http_cancel_recording_cb(
-    struct ast_variable *get_params, struct ast_variable *path_vars,
-    struct ast_variable *headers, struct stasis_http_response *response)
-{
+	struct ast_variable *get_params, struct ast_variable *path_vars,
+	struct ast_variable *headers, struct stasis_http_response *response)
+{
+	int is_valid;
 	struct ast_cancel_recording_args args = {};
 	struct ast_variable *i;
 
@@ -174,6 +211,14 @@
 		{}
 	}
 	stasis_http_cancel_recording(headers, &args, response);
+#if defined(AST_DEVMODE)
+	is_valid = ari_validate_void(response->message);
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /recordings/live/{recordingId}\n");
+		stasis_http_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
 }
 /*!
  * \brief Parameter parsing callback for /recordings/live/{recordingId}/stop.
@@ -183,9 +228,10 @@
  * \param[out] response Response to the HTTP request.
  */

[... 445 lines stripped ...]



More information about the asterisk-commits mailing list