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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jun 20 15:50:47 CDT 2013


Author: dlee
Date: Thu Jun 20 15:50:45 2013
New Revision: 392363

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392363
Log:
Validate response codes

Modified:
    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_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/rest-api-templates/res_stasis_http_resource.c.mustache
    team/dlee/ari-event-remodel2/rest-api/api-docs/channels.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=392363&r1=392362&r2=392363
==============================================================================
--- team/dlee/ari-event-remodel2/res/res_stasis_http_asterisk.c (original)
+++ team/dlee/ari-event-remodel2/res/res_stasis_http_asterisk.c Thu Jun 20 15:50:45 2013
@@ -59,7 +59,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+#if defined(AST_DEVMODE)
 	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_get_asterisk_info_args args = {};
 	struct ast_variable *i;
 
@@ -71,7 +75,22 @@
 	}
 	stasis_http_get_asterisk_info(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_asterisk_info(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_asterisk_info(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /asterisk/info\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /asterisk/info\n");
 		stasis_http_response_error(response, 500,

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=392363&r1=392362&r2=392363
==============================================================================
--- team/dlee/ari-event-remodel2/res/res_stasis_http_bridges.c (original)
+++ team/dlee/ari-event-remodel2/res/res_stasis_http_bridges.c Thu Jun 20 15:50:45 2013
@@ -59,12 +59,30 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	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);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_list(response->message,
+				ari_validate_bridge);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /bridges\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /bridges\n");
 		stasis_http_response_error(response, 500,
@@ -83,7 +101,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_new_bridge_args args = {};
 	struct ast_variable *i;
 
@@ -95,7 +117,22 @@
 	}
 	stasis_http_new_bridge(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_bridge(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_bridge(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /bridges\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /bridges\n");
 		stasis_http_response_error(response, 500,
@@ -114,7 +151,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_get_bridge_args args = {};
 	struct ast_variable *i;
 
@@ -126,7 +167,22 @@
 	}
 	stasis_http_get_bridge(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_bridge(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_bridge(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}\n");
 		stasis_http_response_error(response, 500,
@@ -145,7 +201,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_delete_bridge_args args = {};
 	struct ast_variable *i;
 
@@ -157,7 +217,22 @@
 	}
 	stasis_http_delete_bridge(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_void(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_void(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}\n");
 		stasis_http_response_error(response, 500,
@@ -176,7 +251,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_add_channel_to_bridge_args args = {};
 	struct ast_variable *i;
 
@@ -194,7 +273,22 @@
 	}
 	stasis_http_add_channel_to_bridge(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_void(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_void(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/addChannel\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/addChannel\n");
 		stasis_http_response_error(response, 500,
@@ -213,7 +307,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_remove_channel_from_bridge_args args = {};
 	struct ast_variable *i;
 
@@ -231,7 +329,22 @@
 	}
 	stasis_http_remove_channel_from_bridge(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_void(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_void(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/removeChannel\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/removeChannel\n");
 		stasis_http_response_error(response, 500,
@@ -250,7 +363,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_record_bridge_args args = {};
 	struct ast_variable *i;
 
@@ -283,7 +400,22 @@
 	}
 	stasis_http_record_bridge(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_live_recording(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_live_recording(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/record\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/record\n");
 		stasis_http_response_error(response, 500,

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=392363&r1=392362&r2=392363
==============================================================================
--- team/dlee/ari-event-remodel2/res/res_stasis_http_channels.c (original)
+++ team/dlee/ari-event-remodel2/res/res_stasis_http_channels.c Thu Jun 20 15:50:45 2013
@@ -59,12 +59,30 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	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);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_list(response->message,
+				ari_validate_channel);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /channels\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /channels\n");
 		stasis_http_response_error(response, 500,
@@ -83,7 +101,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_originate_args args = {};
 	struct ast_variable *i;
 
@@ -113,7 +135,22 @@
 	}
 	stasis_http_originate(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_void(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_void(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /channels\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /channels\n");
 		stasis_http_response_error(response, 500,
@@ -132,7 +169,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_get_channel_args args = {};
 	struct ast_variable *i;
 
@@ -144,7 +185,23 @@
 	}
 	stasis_http_get_channel(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_channel(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+	case 404: /* Channel not found */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_channel(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}\n");
 		stasis_http_response_error(response, 500,
@@ -163,7 +220,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_delete_channel_args args = {};
 	struct ast_variable *i;
 
@@ -175,7 +236,23 @@
 	}
 	stasis_http_delete_channel(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_void(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+	case 404: /* Channel not found */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_void(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}\n");
 		stasis_http_response_error(response, 500,
@@ -194,7 +271,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_dial_args args = {};
 	struct ast_variable *i;
 
@@ -218,7 +299,24 @@
 	}
 	stasis_http_dial(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_dialed(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+	case 404: /* Channel not found */
+	case 409: /* Channel not in a Stasis application */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_dialed(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/dial\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/dial\n");
 		stasis_http_response_error(response, 500,
@@ -237,7 +335,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_continue_in_dialplan_args args = {};
 	struct ast_variable *i;
 
@@ -249,7 +351,24 @@
 	}
 	stasis_http_continue_in_dialplan(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_void(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+	case 404: /* Channel not found */
+	case 409: /* Channel not in a Stasis application */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_void(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/continue\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/continue\n");
 		stasis_http_response_error(response, 500,
@@ -268,7 +387,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_answer_channel_args args = {};
 	struct ast_variable *i;
 
@@ -280,7 +403,24 @@
 	}
 	stasis_http_answer_channel(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_void(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+	case 404: /* Channel not found */
+	case 409: /* Channel not in a Stasis application */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_void(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/answer\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/answer\n");
 		stasis_http_response_error(response, 500,
@@ -299,7 +439,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_mute_channel_args args = {};
 	struct ast_variable *i;
 
@@ -317,7 +461,24 @@
 	}
 	stasis_http_mute_channel(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_void(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+	case 404: /* Channel not found */
+	case 409: /* Channel not in a Stasis application */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_void(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/mute\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/mute\n");
 		stasis_http_response_error(response, 500,
@@ -336,7 +497,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_unmute_channel_args args = {};
 	struct ast_variable *i;
 
@@ -354,7 +519,24 @@
 	}
 	stasis_http_unmute_channel(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_void(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+	case 404: /* Channel not found */
+	case 409: /* Channel not in a Stasis application */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_void(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/unmute\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/unmute\n");
 		stasis_http_response_error(response, 500,
@@ -373,7 +555,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_hold_channel_args args = {};
 	struct ast_variable *i;
 
@@ -385,7 +571,24 @@
 	}
 	stasis_http_hold_channel(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_void(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+	case 404: /* Channel not found */
+	case 409: /* Channel not in a Stasis application */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_void(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/hold\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/hold\n");
 		stasis_http_response_error(response, 500,
@@ -404,7 +607,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_unhold_channel_args args = {};
 	struct ast_variable *i;
 
@@ -416,7 +623,24 @@
 	}
 	stasis_http_unhold_channel(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_void(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+	case 404: /* Channel not found */
+	case 409: /* Channel not in a Stasis application */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_void(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/unhold\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/unhold\n");
 		stasis_http_response_error(response, 500,
@@ -435,7 +659,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_play_on_channel_args args = {};
 	struct ast_variable *i;
 
@@ -462,7 +690,24 @@
 	}
 	stasis_http_play_on_channel(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_playback(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+	case 404: /* Channel not found */
+	case 409: /* Channel not in a Stasis application */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_playback(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/play\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/play\n");
 		stasis_http_response_error(response, 500,
@@ -481,7 +726,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_record_channel_args args = {};
 	struct ast_variable *i;
 
@@ -517,7 +766,24 @@
 	}
 	stasis_http_record_channel(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_void(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+	case 404: /* Channel not found */
+	case 409: /* Channel is not in a Stasis application, or The channel is currently bridged with other channels. */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_void(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/record\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/record\n");
 		stasis_http_response_error(response, 500,

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=392363&r1=392362&r2=392363
==============================================================================
--- team/dlee/ari-event-remodel2/res/res_stasis_http_endpoints.c (original)
+++ team/dlee/ari-event-remodel2/res/res_stasis_http_endpoints.c Thu Jun 20 15:50:45 2013
@@ -59,12 +59,30 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+#if defined(AST_DEVMODE)
 	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	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);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_list(response->message,
+				ari_validate_endpoint);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /endpoints\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /endpoints\n");
 		stasis_http_response_error(response, 500,
@@ -83,7 +101,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+#if defined(AST_DEVMODE)
 	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_get_endpoints_by_tech_args args = {};
 	struct ast_variable *i;
 
@@ -95,8 +117,22 @@
 	}
 	stasis_http_get_endpoints_by_tech(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_list(response->message,
-		ari_validate_endpoint);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_list(response->message,
+				ari_validate_endpoint);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /endpoints/{tech}\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /endpoints/{tech}\n");
 		stasis_http_response_error(response, 500,
@@ -115,7 +151,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+#if defined(AST_DEVMODE)
 	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_get_endpoint_args args = {};
 	struct ast_variable *i;
 
@@ -130,7 +170,22 @@
 	}
 	stasis_http_get_endpoint(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_endpoint(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_endpoint(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /endpoints/{tech}/{resource}\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /endpoints/{tech}/{resource}\n");
 		stasis_http_response_error(response, 500,

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=392363&r1=392362&r2=392363
==============================================================================
--- team/dlee/ari-event-remodel2/res/res_stasis_http_playback.c (original)
+++ team/dlee/ari-event-remodel2/res/res_stasis_http_playback.c Thu Jun 20 15:50:45 2013
@@ -59,7 +59,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+#if defined(AST_DEVMODE)
 	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_get_playback_args args = {};
 	struct ast_variable *i;
 
@@ -71,7 +75,22 @@
 	}
 	stasis_http_get_playback(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_playback(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_playback(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /playback/{playbackId}\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /playback/{playbackId}\n");
 		stasis_http_response_error(response, 500,
@@ -90,7 +109,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+#if defined(AST_DEVMODE)
 	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_stop_playback_args args = {};
 	struct ast_variable *i;
 
@@ -102,7 +125,22 @@
 	}
 	stasis_http_stop_playback(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_playback(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_playback(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /playback/{playbackId}\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /playback/{playbackId}\n");
 		stasis_http_response_error(response, 500,
@@ -121,7 +159,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
+#if defined(AST_DEVMODE)
 	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_control_playback_args args = {};
 	struct ast_variable *i;
 
@@ -139,7 +181,25 @@
 	}
 	stasis_http_control_playback(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_playback(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+	case 400: /* The provided operation parameter was invalid */
+	case 404: /* The playback cannot be found */
+	case 409: /* The operation cannot be performed in the playback's current state */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_playback(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /playback/{playbackId}/control\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /playback/{playbackId}/control\n");
 		stasis_http_response_error(response, 500,

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=392363&r1=392362&r2=392363
==============================================================================
--- team/dlee/ari-event-remodel2/res/res_stasis_http_recordings.c (original)
+++ team/dlee/ari-event-remodel2/res/res_stasis_http_recordings.c Thu Jun 20 15:50:45 2013
@@ -59,12 +59,30 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	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);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_list(response->message,
+				ari_validate_stored_recording);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /recordings/stored\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /recordings/stored\n");
 		stasis_http_response_error(response, 500,
@@ -83,7 +101,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_get_stored_recording_args args = {};
 	struct ast_variable *i;
 
@@ -95,7 +117,22 @@
 	}
 	stasis_http_get_stored_recording(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_stored_recording(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_stored_recording(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /recordings/stored/{recordingId}\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /recordings/stored/{recordingId}\n");
 		stasis_http_response_error(response, 500,
@@ -114,7 +151,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_delete_stored_recording_args args = {};
 	struct ast_variable *i;
 
@@ -126,7 +167,22 @@
 	}
 	stasis_http_delete_stored_recording(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_void(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_void(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /recordings/stored/{recordingId}\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /recordings/stored/{recordingId}\n");
 		stasis_http_response_error(response, 500,
@@ -145,12 +201,30 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	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);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_list(response->message,
+				ari_validate_live_recording);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /recordings/live\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /recordings/live\n");
 		stasis_http_response_error(response, 500,
@@ -169,7 +243,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_get_live_recording_args args = {};
 	struct ast_variable *i;
 
@@ -181,7 +259,22 @@
 	}
 	stasis_http_get_live_recording(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_live_recording(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_live_recording(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /recordings/live/{recordingId}\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /recordings/live/{recordingId}\n");
 		stasis_http_response_error(response, 500,
@@ -200,7 +293,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_cancel_recording_args args = {};
 	struct ast_variable *i;
 
@@ -212,7 +309,22 @@
 	}
 	stasis_http_cancel_recording(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_void(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_void(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /recordings/live/{recordingId}\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /recordings/live/{recordingId}\n");
 		stasis_http_response_error(response, 500,
@@ -231,7 +343,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_stop_recording_args args = {};
 	struct ast_variable *i;
 
@@ -243,7 +359,22 @@
 	}
 	stasis_http_stop_recording(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_void(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_void(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /recordings/live/{recordingId}/stop\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /recordings/live/{recordingId}/stop\n");
 		stasis_http_response_error(response, 500,
@@ -262,7 +393,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_pause_recording_args args = {};
 	struct ast_variable *i;
 
@@ -274,7 +409,22 @@
 	}
 	stasis_http_pause_recording(headers, &args, response);
 #if defined(AST_DEVMODE)
-	is_valid = ari_validate_void(response->message);
+	code = response->response_code;
+
+	switch (code) {
+	case 500: /* Internal server error */
+		is_valid = 1;
+		break;
+	default:
+		if (200 <= code && code <= 299) {
+			is_valid = ari_validate_void(
+				response->message);
+		} else {
+			ast_log(LOG_ERROR, "Invalid error response %d for /recordings/live/{recordingId}/pause\n", code);
+			is_valid = 0;
+		}
+	}
+
 	if (!is_valid) {
 		ast_log(LOG_ERROR, "Response validation failed for /recordings/live/{recordingId}/pause\n");
 		stasis_http_response_error(response, 500,
@@ -293,7 +443,11 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct stasis_http_response *response)
 {
-	int is_valid;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	struct ast_unpause_recording_args args = {};
 	struct ast_variable *i;
 
@@ -305,7 +459,22 @@
 	}

[... 255 lines stripped ...]



More information about the asterisk-commits mailing list