[svn-commits] kmoore: branch kmoore/stasis_http_rename r395530 - in /team/kmoore/stasis_htt...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jul 26 13:15:35 CDT 2013


Author: kmoore
Date: Fri Jul 26 13:15:33 2013
New Revision: 395530

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=395530
Log:
Finish internal changes

Added:
    team/kmoore/stasis_http_rename/include/asterisk/ari.h
      - copied unchanged from r395528, team/kmoore/stasis_http_rename/include/asterisk/stasis_http.h
Removed:
    team/kmoore/stasis_http_rename/include/asterisk/stasis_http.h
Modified:
    team/kmoore/stasis_http_rename/main/stasis_config.c
    team/kmoore/stasis_http_rename/res/Makefile
    team/kmoore/stasis_http_rename/res/ari/ari_websockets.c
    team/kmoore/stasis_http_rename/res/ari/config.c
    team/kmoore/stasis_http_rename/res/ari/internal.h
    team/kmoore/stasis_http_rename/res/ari/resource_asterisk.c
    team/kmoore/stasis_http_rename/res/ari/resource_bridges.c
    team/kmoore/stasis_http_rename/res/ari/resource_channels.c
    team/kmoore/stasis_http_rename/res/ari/resource_endpoints.c
    team/kmoore/stasis_http_rename/res/ari/resource_playback.c
    team/kmoore/stasis_http_rename/res/ari/resource_recordings.c
    team/kmoore/stasis_http_rename/res/ari/resource_sounds.c
    team/kmoore/stasis_http_rename/res/res_ari.c
    team/kmoore/stasis_http_rename/res/res_ari_model.c
    team/kmoore/stasis_http_rename/res/res_statsd.c
    team/kmoore/stasis_http_rename/tests/test_stasis_http.c

Modified: team/kmoore/stasis_http_rename/main/stasis_config.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis_http_rename/main/stasis_config.c?view=diff&rev=395530&r1=395529&r2=395530
==============================================================================
--- team/kmoore/stasis_http_rename/main/stasis_config.c (original)
+++ team/kmoore/stasis_http_rename/main/stasis_config.c Fri Jul 26 13:15:33 2013
@@ -70,7 +70,7 @@
 	struct stasis_threadpool_conf *threadpool;
 };
 
-/*! \brief Mapping of the stasis http conf struct's globals to the
+/*! \brief Mapping of the stasis conf struct's globals to the
  *         threadpool context in the config file. */
 static struct aco_type threadpool_option = {
         .type = ACO_GLOBAL,

Modified: team/kmoore/stasis_http_rename/res/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis_http_rename/res/Makefile?view=diff&rev=395530&r1=395529&r2=395530
==============================================================================
--- team/kmoore/stasis_http_rename/res/Makefile (original)
+++ team/kmoore/stasis_http_rename/res/Makefile Fri Jul 26 13:15:33 2013
@@ -73,18 +73,18 @@
 ael/pval.o: ael/pval.c
 
 clean::
-	rm -f snmp/*.[oi] ael/*.[oi] ais/*.[oi] stasis_http/*.[oi]
+	rm -f snmp/*.[oi] ael/*.[oi] ais/*.[oi] ari/*.[oi]
 	rm -f res_sip/*.[oi] stasis/*.[oi]
 	rm -f parking/*.o parking/*.i
 
 $(if $(filter res_parking,$(EMBEDDED_MODS)),modules.link,res_parking.so): $(subst .c,.o,$(wildcard parking/*.c))
 $(subst .c,.o,$(wildcard parking/*.c)): _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_parking)
 
-res_stasis_http.so: stasis_http/cli.o stasis_http/config.o stasis_http/ari_websockets.o
-stasis_http/cli.o stasis_http/config.o stasis_http/ari_websockets.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_stasis_http)
+res_ari.so: ari/cli.o ari/config.o ari/ari_websockets.o
+ari/cli.o ari/config.o ari/ari_websockets.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari)
 
-res_ari_model.so: stasis_http/ari_model_validators.o
-stasis_http/ari_model_validators.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_model)
+res_ari_model.so: ari/ari_model_validators.o
+ari/ari_model_validators.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_model)
 
-# Dependencies for res_stasis_http_*.so are generated, so they're in this file
-include stasis_http.make
+# Dependencies for res_ari_*.so are generated, so they're in this file
+include ari.make

Modified: team/kmoore/stasis_http_rename/res/ari/ari_websockets.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis_http_rename/res/ari/ari_websockets.c?view=diff&rev=395530&r1=395529&r2=395530
==============================================================================
--- team/kmoore/stasis_http_rename/res/ari/ari_websockets.c (original)
+++ team/kmoore/stasis_http_rename/res/ari/ari_websockets.c Fri Jul 26 13:15:33 2013
@@ -21,7 +21,7 @@
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 #include "asterisk/astobj2.h"
-#include "asterisk/stasis_http.h"
+#include "asterisk/ari.h"
 
 /*! \file
  *
@@ -153,7 +153,7 @@
 	}
 #endif
 
-	str = ast_json_dump_string_format(message, stasis_http_json_format());
+	str = ast_json_dump_string_format(message, ari_json_format());
 
 	if (str == NULL) {
 		ast_log(LOG_ERROR, "Failed to encode JSON object\n");

Modified: team/kmoore/stasis_http_rename/res/ari/config.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis_http_rename/res/ari/config.c?view=diff&rev=395530&r1=395529&r2=395530
==============================================================================
--- team/kmoore/stasis_http_rename/res/ari/config.c (original)
+++ team/kmoore/stasis_http_rename/res/ari/config.c Fri Jul 26 13:15:33 2013
@@ -32,7 +32,7 @@
 /*! \brief Locking container for safe configuration access. */
 static AO2_GLOBAL_OBJ_STATIC(confs);
 
-/*! \brief Mapping of the stasis http conf struct's globals to the
+/*! \brief Mapping of the ARI conf struct's globals to the
  *         general context in the config file. */
 static struct aco_type general_option = {
 	.type = ACO_GLOBAL,

Modified: team/kmoore/stasis_http_rename/res/ari/internal.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis_http_rename/res/ari/internal.h?view=diff&rev=395530&r1=395529&r2=395530
==============================================================================
--- team/kmoore/stasis_http_rename/res/ari/internal.h (original)
+++ team/kmoore/stasis_http_rename/res/ari/internal.h Fri Jul 26 13:15:33 2013
@@ -16,12 +16,12 @@
  * at the top of the source tree.
  */
 
-#ifndef STASIS_HTTP_INTERNAL_H_
-#define STASIS_HTTP_INTERNAL_H_
+#ifndef ARI_INTERNAL_H_
+#define ARI_INTERNAL_H_
 
 /*! \file
  *
- * \brief Internal API's for res_stasis_http.
+ * \brief Internal API's for res_ari.
  * \author David M. Lee, II <dlee at digium.com>
  */
 
@@ -48,7 +48,7 @@
 
 struct ari_conf_general;
 
-/*! \brief All configuration options for stasis http. */
+/*! \brief All configuration options for ARI. */
 struct ari_conf {
 	/*! The general section configuration options. */
 	struct ari_conf_general *general;
@@ -59,7 +59,7 @@
 /*! Max length for auth_realm field */
 #define ARI_AUTH_REALM_LEN 80
 
-/*! \brief Global configuration options for stasis http. */
+/*! \brief Global configuration options for ARI. */
 struct ari_conf_general {
 	/*! Enabled by default, disabled if false. */
 	int enabled;
@@ -140,4 +140,4 @@
 /*! @} */
 
 
-#endif /* STASIS_HTTP_INTERNAL_H_ */
+#endif /* ARI_INTERNAL_H_ */

Modified: team/kmoore/stasis_http_rename/res/ari/resource_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis_http_rename/res/ari/resource_asterisk.c?view=diff&rev=395530&r1=395529&r2=395530
==============================================================================
--- team/kmoore/stasis_http_rename/res/ari/resource_asterisk.c (original)
+++ team/kmoore/stasis_http_rename/res/ari/resource_asterisk.c Fri Jul 26 13:15:33 2013
@@ -34,12 +34,12 @@
 #include "resource_asterisk.h"
 #include "asterisk/pbx.h"
 
-void stasis_http_get_asterisk_info(struct ast_variable *headers, struct ast_get_asterisk_info_args *args, struct stasis_http_response *response)
+void ari_get_asterisk_info(struct ast_variable *headers, struct ast_get_asterisk_info_args *args, struct ari_response *response)
 {
-	ast_log(LOG_ERROR, "TODO: stasis_http_get_asterisk_info\n");
+	ast_log(LOG_ERROR, "TODO: ari_get_asterisk_info\n");
 }
 
-void stasis_http_get_global_var(struct ast_variable *headers, struct ast_get_global_var_args *args, struct stasis_http_response *response)
+void ari_get_global_var(struct ast_variable *headers, struct ast_get_global_var_args *args, struct ari_response *response)
 {
 	RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
 	RAII_VAR(struct ast_str *, tmp, ast_str_create(32), ast_free);
@@ -49,26 +49,26 @@
 	ast_assert(response != NULL);
 
 	if (!tmp) {
-		stasis_http_response_alloc_failed(response);
+		ari_response_alloc_failed(response);
 		return;
 	}
 
 	value = ast_str_retrieve_variable(&tmp, 0, NULL, NULL, args->variable);
 
 	if (!(json = ast_json_pack("{s: s}", "value", S_OR(value, "")))) {
-		stasis_http_response_alloc_failed(response);
+		ari_response_alloc_failed(response);
 		return;
 	}
 
-	stasis_http_response_ok(response, ast_json_ref(json));
+	ari_response_ok(response, ast_json_ref(json));
 }
 
-void stasis_http_set_global_var(struct ast_variable *headers, struct ast_set_global_var_args *args, struct stasis_http_response *response)
+void ari_set_global_var(struct ast_variable *headers, struct ast_set_global_var_args *args, struct ari_response *response)
 {
 	ast_assert(response != NULL);
 
 	if (ast_strlen_zero(args->variable)) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 400, "Bad Request",
 			"Variable name is required");
 		return;
@@ -76,5 +76,5 @@
 
 	pbx_builtin_setvar_helper(NULL, args->variable, args->value);
 
-	stasis_http_response_no_content(response);
+	ari_response_no_content(response);
 }

Modified: team/kmoore/stasis_http_rename/res/ari/resource_bridges.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis_http_rename/res/ari/resource_bridges.c?view=diff&rev=395530&r1=395529&r2=395530
==============================================================================
--- team/kmoore/stasis_http_rename/res/ari/resource_bridges.c (original)
+++ team/kmoore/stasis_http_rename/res/ari/resource_bridges.c Fri Jul 26 13:15:33 2013
@@ -54,7 +54,7 @@
  * \return \c NULL if bridge does not exist.
  */
 static struct ast_bridge *find_bridge(
-	struct stasis_http_response *response,
+	struct ari_response *response,
 	const char *bridge_id)
 {
 	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
@@ -66,12 +66,12 @@
 		RAII_VAR(struct ast_bridge_snapshot *, snapshot,
 			ast_bridge_snapshot_get_latest(bridge_id), ao2_cleanup);
 		if (!snapshot) {
-			stasis_http_response_error(response, 404, "Not found",
+			ari_response_error(response, 404, "Not found",
 				"Bridge not found");
 			return NULL;
 		}
 
-		stasis_http_response_error(response, 409, "Conflict",
+		ari_response_error(response, 409, "Conflict",
 			"Bridge not in Stasis application");
 		return NULL;
 	}
@@ -89,7 +89,7 @@
  * \return \c NULL if control object does not exist.
  */
 static struct stasis_app_control *find_channel_control(
-	struct stasis_http_response *response,
+	struct ari_response *response,
 	const char *channel_id)
 {
 	RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
@@ -98,7 +98,7 @@
 
 	control = stasis_app_control_find_by_channel_id(channel_id);
 	if (control == NULL) {
-		stasis_http_response_error(response, 422, "Unprocessable Entity",
+		ari_response_error(response, 422, "Unprocessable Entity",
 			"Channel not in Stasis application");
 		return NULL;
 	}
@@ -107,7 +107,7 @@
 	return control;
 }
 
-void stasis_http_add_channel_to_bridge(struct ast_variable *headers, struct ast_add_channel_to_bridge_args *args, struct stasis_http_response *response)
+void ari_add_channel_to_bridge(struct ast_variable *headers, struct ast_add_channel_to_bridge_args *args, struct ari_response *response)
 {
 	RAII_VAR(struct ast_bridge *, bridge, find_bridge(response, args->bridge_id), ao2_cleanup);
 	RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
@@ -121,10 +121,10 @@
 	}
 
 	stasis_app_control_add_channel_to_bridge(control, bridge);
-	stasis_http_response_no_content(response);
-}
-
-void stasis_http_remove_channel_from_bridge(struct ast_variable *headers, struct ast_remove_channel_from_bridge_args *args, struct stasis_http_response *response)
+	ari_response_no_content(response);
+}
+
+void ari_remove_channel_from_bridge(struct ast_variable *headers, struct ast_remove_channel_from_bridge_args *args, struct ari_response *response)
 {
 	RAII_VAR(struct ast_bridge *, bridge, find_bridge(response, args->bridge_id), ao2_cleanup);
 	RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
@@ -142,12 +142,12 @@
 	 * is added to the channel snapshot. A 409 response should be issued if the bridge
 	 * uniqueids don't match */
 	if (stasis_app_control_remove_channel_from_bridge(control, bridge)) {
-		stasis_http_response_error(response, 500, "Internal Error",
+		ari_response_error(response, 500, "Internal Error",
 			"Could not remove channel from bridge");
 		return;
 	}
 
-	stasis_http_response_no_content(response);
+	ari_response_no_content(response);
 }
 
 struct bridge_channel_control_thread_data {
@@ -196,7 +196,7 @@
 	return ast_request(type, cap, NULL, "ARI", NULL);
 }
 
-void stasis_http_play_on_bridge(struct ast_variable *headers, struct ast_play_on_bridge_args *args, struct stasis_http_response *response)
+void ari_play_on_bridge(struct ast_variable *headers, struct ast_play_on_bridge_args *args, struct ari_response *response)
 {
 	RAII_VAR(struct ast_bridge *, bridge, find_bridge(response, args->bridge_id), ao2_cleanup);
 	RAII_VAR(struct ast_channel *, play_channel, NULL, ast_hangup);
@@ -217,27 +217,27 @@
 	}
 
 	if (!(play_channel = prepare_bridge_media_channel("Announcer"))) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 500, "Internal Error", "Could not create playback channel");
 		return;
 	}
 	ast_debug(1, "Created announcer channel '%s'\n", ast_channel_name(play_channel));
 
 	if (ast_unreal_channel_push_to_bridge(play_channel, bridge)) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 500, "Internal Error", "Failed to put playback channel into the bridge");
 		return;
 	}
 
 	control = stasis_app_control_create(play_channel);
 	if (control == NULL) {
-		stasis_http_response_alloc_failed(response);
+		ari_response_alloc_failed(response);
 		return;
 	}
 
 	snapshot = stasis_app_control_get_snapshot(control);
 	if (!snapshot) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 500, "Internal Error", "Failed to get control snapshot");
 		return;
 	}
@@ -249,7 +249,7 @@
 		args->offsetms);
 
 	if (!playback) {
-		stasis_http_response_alloc_failed(response);
+		ari_response_alloc_failed(response);
 		return;
 	}
 
@@ -257,20 +257,20 @@
 		stasis_app_playback_get_id(playback));
 
 	if (!playback_url) {
-		stasis_http_response_alloc_failed(response);
+		ari_response_alloc_failed(response);
 		return;
 	}
 
 	json = stasis_app_playback_to_json(playback);
 	if (!json) {
-		stasis_http_response_alloc_failed(response);
+		ari_response_alloc_failed(response);
 		return;
 	}
 
 	/* Give play_channel and control reference to the thread data */
 	thread_data = ast_calloc(1, sizeof(*thread_data));
 	if (!thread_data) {
-		stasis_http_response_alloc_failed(response);
+		ari_response_alloc_failed(response);
 		return;
 	}
 
@@ -278,7 +278,7 @@
 	thread_data->control = control;
 
 	if (ast_pthread_create_detached(&threadid, NULL, bridge_channel_control_thread, thread_data)) {
-		stasis_http_response_alloc_failed(response);
+		ari_response_alloc_failed(response);
 		ast_free(thread_data);
 		return;
 	}
@@ -287,10 +287,10 @@
 	play_channel = NULL;
 	control = NULL;
 
-	stasis_http_response_created(response, playback_url, json);
-}
-
-void stasis_http_record_bridge(struct ast_variable *headers, struct ast_record_bridge_args *args, struct stasis_http_response *response)
+	ari_response_created(response, playback_url, json);
+}
+
+void ari_record_bridge(struct ast_variable *headers, struct ast_record_bridge_args *args, struct ari_response *response)
 {
 	RAII_VAR(struct ast_bridge *, bridge, find_bridge(response, args->bridge_id), ao2_cleanup);
 	RAII_VAR(struct ast_channel *, record_channel, NULL, ast_hangup);
@@ -312,26 +312,26 @@
 	}
 
 	if (!(record_channel = prepare_bridge_media_channel("Recorder"))) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 500, "Internal Server Error", "Failed to create recording channel");
 		return;
 	}
 
 	if (ast_unreal_channel_push_to_bridge(record_channel, bridge)) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 500, "Internal Error", "Failed to put recording channel into the bridge");
 		return;
 	}
 
 	control = stasis_app_control_create(record_channel);
 	if (control == NULL) {
-		stasis_http_response_alloc_failed(response);
+		ari_response_alloc_failed(response);
 		return;
 	}
 
 	options = stasis_app_recording_options_create(args->name, args->format);
 	if (options == NULL) {
-		stasis_http_response_alloc_failed(response);
+		ari_response_alloc_failed(response);
 		return;
 	}
 
@@ -350,20 +350,20 @@
 			/* While the arguments are invalid, we should have
 			 * caught them prior to calling record.
 			 */
-			stasis_http_response_error(
+			ari_response_error(
 				response, 500, "Internal Server Error",
 				"Error parsing request");
 			break;
 		case EEXIST:
-			stasis_http_response_error(response, 409, "Conflict",
+			ari_response_error(response, 409, "Conflict",
 				"Recording '%s' already in progress",
 				args->name);
 			break;
 		case ENOMEM:
-			stasis_http_response_alloc_failed(response);
+			ari_response_alloc_failed(response);
 			break;
 		case EPERM:
-			stasis_http_response_error(
+			ari_response_error(
 				response, 400, "Bad Request",
 				"Recording name invalid");
 			break;
@@ -371,7 +371,7 @@
 			ast_log(LOG_WARNING,
 				"Unrecognized recording error: %s\n",
 				strerror(errno));
-			stasis_http_response_error(
+			ari_response_error(
 				response, 500, "Internal Server Error",
 				"Internal Server Error");
 			break;
@@ -382,26 +382,26 @@
 	uri_name_maxlen = strlen(args->name) * 3;
 	uri_encoded_name = ast_malloc(uri_name_maxlen);
 	if (!uri_encoded_name) {
-		stasis_http_response_alloc_failed(response);
+		ari_response_alloc_failed(response);
 		return;
 	}
 	ast_uri_encode(args->name, uri_encoded_name, uri_name_maxlen, ast_uri_http);
 
 	ast_asprintf(&recording_url, "/recordings/live/%s", uri_encoded_name);
 	if (!recording_url) {
-		stasis_http_response_alloc_failed(response);
+		ari_response_alloc_failed(response);
 		return;
 	}
 
 	json = stasis_app_recording_to_json(recording);
 	if (!json) {
-		stasis_http_response_alloc_failed(response);
+		ari_response_alloc_failed(response);
 		return;
 	}
 
 	thread_data = ast_calloc(1, sizeof(*thread_data));
 	if (!thread_data) {
-		stasis_http_response_alloc_failed(response);
+		ari_response_alloc_failed(response);
 		return;
 	}
 
@@ -409,7 +409,7 @@
 	thread_data->control = control;
 
 	if (ast_pthread_create_detached(&threadid, NULL, bridge_channel_control_thread, thread_data)) {
-		stasis_http_response_alloc_failed(response);
+		ari_response_alloc_failed(response);
 		ast_free(thread_data);
 		return;
 	}
@@ -418,24 +418,24 @@
 	record_channel = NULL;
 	control = NULL;
 
-	stasis_http_response_created(response, recording_url, json);
-}
-
-void stasis_http_get_bridge(struct ast_variable *headers, struct ast_get_bridge_args *args, struct stasis_http_response *response)
+	ari_response_created(response, recording_url, json);
+}
+
+void ari_get_bridge(struct ast_variable *headers, struct ast_get_bridge_args *args, struct ari_response *response)
 {
 	RAII_VAR(struct ast_bridge_snapshot *, snapshot, ast_bridge_snapshot_get_latest(args->bridge_id), ao2_cleanup);
 	if (!snapshot) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 404, "Not Found",
 			"Bridge not found");
 		return;
 	}
 
-	stasis_http_response_ok(response,
+	ari_response_ok(response,
 		ast_bridge_snapshot_to_json(snapshot));
 }
 
-void stasis_http_delete_bridge(struct ast_variable *headers, struct ast_delete_bridge_args *args, struct stasis_http_response *response)
+void ari_delete_bridge(struct ast_variable *headers, struct ast_delete_bridge_args *args, struct ari_response *response)
 {
 	RAII_VAR(struct ast_bridge *, bridge, find_bridge(response, args->bridge_id), ao2_cleanup);
 	if (!bridge) {
@@ -443,10 +443,10 @@
 	}
 
 	stasis_app_bridge_destroy(args->bridge_id);
-	stasis_http_response_no_content(response);
-}
-
-void stasis_http_get_bridges(struct ast_variable *headers, struct ast_get_bridges_args *args, struct stasis_http_response *response)
+	ari_response_no_content(response);
+}
+
+void ari_get_bridges(struct ast_variable *headers, struct ast_get_bridges_args *args, struct ari_response *response)
 {
 	RAII_VAR(struct stasis_caching_topic *, caching_topic, NULL, ao2_cleanup);
 	RAII_VAR(struct ao2_container *, snapshots, NULL, ao2_cleanup);
@@ -456,7 +456,7 @@
 
 	caching_topic = ast_bridge_topic_all_cached();
 	if (!caching_topic) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 500, "Internal Server Error",
 			"Message bus not initialized");
 		return;
@@ -465,13 +465,13 @@
 
 	snapshots = stasis_cache_dump(caching_topic, ast_bridge_snapshot_type());
 	if (!snapshots) {
-		stasis_http_response_alloc_failed(response);
+		ari_response_alloc_failed(response);
 		return;
 	}
 
 	json = ast_json_array_create();
 	if (!json) {
-		stasis_http_response_alloc_failed(response);
+		ari_response_alloc_failed(response);
 		return;
 	}
 
@@ -480,22 +480,22 @@
 		RAII_VAR(struct stasis_message *, msg, obj, ao2_cleanup);
 		struct ast_bridge_snapshot *snapshot = stasis_message_data(msg);
 		if (ast_json_array_append(json, ast_bridge_snapshot_to_json(snapshot))) {
-			stasis_http_response_alloc_failed(response);
+			ari_response_alloc_failed(response);
 			return;
 		}
 	}
 	ao2_iterator_destroy(&i);
 
-	stasis_http_response_ok(response, ast_json_ref(json));
-}
-
-void stasis_http_new_bridge(struct ast_variable *headers, struct ast_new_bridge_args *args, struct stasis_http_response *response)
+	ari_response_ok(response, ast_json_ref(json));
+}
+
+void ari_new_bridge(struct ast_variable *headers, struct ast_new_bridge_args *args, struct ari_response *response)
 {
 	RAII_VAR(struct ast_bridge *, bridge, stasis_app_bridge_create(args->type), ao2_cleanup);
 	RAII_VAR(struct ast_bridge_snapshot *, snapshot, NULL, ao2_cleanup);
 
 	if (!bridge) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 500, "Internal Error",
 			"Unable to create bridge");
 		return;
@@ -503,12 +503,12 @@
 
 	snapshot = ast_bridge_snapshot_create(bridge);
 	if (!snapshot) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 500, "Internal Error",
 			"Unable to create snapshot for new bridge");
 		return;
 	}
 
-	stasis_http_response_ok(response,
+	ari_response_ok(response,
 		ast_bridge_snapshot_to_json(snapshot));
 }

Modified: team/kmoore/stasis_http_rename/res/ari/resource_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis_http_rename/res/ari/resource_channels.c?view=diff&rev=395530&r1=395529&r2=395530
==============================================================================
--- team/kmoore/stasis_http_rename/res/ari/resource_channels.c (original)
+++ team/kmoore/stasis_http_rename/res/ari/resource_channels.c Fri Jul 26 13:15:33 2013
@@ -54,7 +54,7 @@
  * \return \c NULL if control object does not exist.
  */
 static struct stasis_app_control *find_control(
-	struct stasis_http_response *response,
+	struct ari_response *response,
 	const char *channel_id)
 {
 	RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
@@ -67,12 +67,12 @@
 		RAII_VAR(struct ast_channel *, chan, NULL, ao2_cleanup);
 		chan = ast_channel_get_by_name(channel_id);
 		if (chan == NULL) {
-			stasis_http_response_error(response, 404, "Not Found",
+			ari_response_error(response, 404, "Not Found",
 				   "Channel not found");
 			return NULL;
 		}
 
-		stasis_http_response_error(response, 409, "Conflict",
+		ari_response_error(response, 409, "Conflict",
 			   "Channel not in Stasis application");
 		return NULL;
 	}
@@ -81,7 +81,7 @@
 	return control;
 }
 
-void stasis_http_dial(struct ast_variable *headers, struct ast_dial_args *args, struct stasis_http_response *response)
+void ari_dial(struct ast_variable *headers, struct ast_dial_args *args, struct ari_response *response)
 {
 	struct stasis_app_control *control;
 
@@ -91,17 +91,17 @@
 	}
 
 	if (stasis_app_control_dial(control, args->endpoint, args->timeout)) {
-		stasis_http_response_alloc_failed(response);
-		return;
-	}
-
-	stasis_http_response_no_content(response);
-}
-
-void stasis_http_continue_in_dialplan(
+		ari_response_alloc_failed(response);
+		return;
+	}
+
+	ari_response_no_content(response);
+}
+
+void ari_continue_in_dialplan(
 	struct ast_variable *headers,
 	struct ast_continue_in_dialplan_args *args,
-	struct stasis_http_response *response)
+	struct ari_response *response)
 {
 	RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
 
@@ -113,16 +113,16 @@
 	}
 
 	if (stasis_app_control_continue(control, args->context, args->extension, args->priority)) {
-		stasis_http_response_alloc_failed(response);
-		return;
-	}
-
-	stasis_http_response_no_content(response);
-}
-
-void stasis_http_answer_channel(struct ast_variable *headers,
+		ari_response_alloc_failed(response);
+		return;
+	}
+
+	ari_response_no_content(response);
+}
+
+void ari_answer_channel(struct ast_variable *headers,
 				struct ast_answer_channel_args *args,
-				struct stasis_http_response *response)
+				struct ari_response *response)
 {
 	RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
 
@@ -132,16 +132,16 @@
 	}
 
 	if (stasis_app_control_answer(control) != 0) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 500, "Internal Server Error",
 			"Failed to answer channel");
 		return;
 	}
 
-	stasis_http_response_no_content(response);
-}
-
-void stasis_http_mute_channel(struct ast_variable *headers, struct ast_mute_channel_args *args, struct stasis_http_response *response)
+	ari_response_no_content(response);
+}
+
+void ari_mute_channel(struct ast_variable *headers, struct ast_mute_channel_args *args, struct ari_response *response)
 {
 	RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
 	unsigned int direction = 0;
@@ -159,7 +159,7 @@
 	} else if (!strcmp(args->direction, "both")) {
 		direction = AST_MUTE_DIRECTION_READ | AST_MUTE_DIRECTION_WRITE;
 	} else {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 400, "Bad Request",
 			"Invalid direction specified");
 		return;
@@ -167,10 +167,10 @@
 
 	stasis_app_control_mute(control, direction, frametype);
 
-	stasis_http_response_no_content(response);
-}
-
-void stasis_http_unmute_channel(struct ast_variable *headers, struct ast_unmute_channel_args *args, struct stasis_http_response *response)
+	ari_response_no_content(response);
+}
+
+void ari_unmute_channel(struct ast_variable *headers, struct ast_unmute_channel_args *args, struct ari_response *response)
 {
 	RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
 	unsigned int direction = 0;
@@ -188,7 +188,7 @@
 	} else if (!strcmp(args->direction, "both")) {
 		direction = AST_MUTE_DIRECTION_READ | AST_MUTE_DIRECTION_WRITE;
 	} else {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 400, "Bad Request",
 			"Invalid direction specified");
 		return;
@@ -196,10 +196,10 @@
 
 	stasis_app_control_unmute(control, direction, frametype);
 
-	stasis_http_response_no_content(response);
-}
-
-void stasis_http_hold_channel(struct ast_variable *headers, struct ast_hold_channel_args *args, struct stasis_http_response *response)
+	ari_response_no_content(response);
+}
+
+void ari_hold_channel(struct ast_variable *headers, struct ast_hold_channel_args *args, struct ari_response *response)
 {
 	RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
 
@@ -211,10 +211,10 @@
 
 	stasis_app_control_hold(control);
 
-	stasis_http_response_no_content(response);
-}
-
-void stasis_http_unhold_channel(struct ast_variable *headers, struct ast_unhold_channel_args *args, struct stasis_http_response *response)
+	ari_response_no_content(response);
+}
+
+void ari_unhold_channel(struct ast_variable *headers, struct ast_unhold_channel_args *args, struct ari_response *response)
 {
 	RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
 
@@ -226,10 +226,10 @@
 
 	stasis_app_control_unhold(control);
 
-	stasis_http_response_no_content(response);
-}
-
-void stasis_http_moh_start_channel(struct ast_variable *headers, struct ast_moh_start_channel_args *args, struct stasis_http_response *response)
+	ari_response_no_content(response);
+}
+
+void ari_moh_start_channel(struct ast_variable *headers, struct ast_moh_start_channel_args *args, struct ari_response *response)
 {
 	RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
 
@@ -240,10 +240,10 @@
 	}
 
 	stasis_app_control_moh_start(control, args->moh_class);
-	stasis_http_response_no_content(response);
-}
-
-void stasis_http_moh_stop_channel(struct ast_variable *headers, struct ast_moh_stop_channel_args *args, struct stasis_http_response *response)
+	ari_response_no_content(response);
+}
+
+void ari_moh_stop_channel(struct ast_variable *headers, struct ast_moh_stop_channel_args *args, struct ari_response *response)
 {
 	RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
 
@@ -254,12 +254,12 @@
 	}
 
 	stasis_app_control_moh_stop(control);
-	stasis_http_response_no_content(response);
-}
-
-void stasis_http_play_on_channel(struct ast_variable *headers,
+	ari_response_no_content(response);
+}
+
+void ari_play_on_channel(struct ast_variable *headers,
 	struct ast_play_on_channel_args *args,
-	struct stasis_http_response *response)
+	struct ari_response *response)
 {
 	RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
@@ -278,21 +278,21 @@
 
 	snapshot = stasis_app_control_get_snapshot(control);
 	if (!snapshot) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 404, "Not Found",
 			"Channel not found");
 		return;
 	}
 
 	if (args->skipms < 0) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 400, "Bad Request",
 			"skipms cannot be negative");
 		return;
 	}
 
 	if (args->offsetms < 0) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 400, "Bad Request",
 			"offsetms cannot be negative");
 		return;
@@ -303,7 +303,7 @@
 	playback = stasis_app_control_play_uri(control, args->media, language,
 		args->channel_id, STASIS_PLAYBACK_TARGET_CHANNEL, args->skipms, args->offsetms);
 	if (!playback) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 500, "Internal Server Error",
 			"Failed to queue media for playback");
 		return;
@@ -312,7 +312,7 @@
 	ast_asprintf(&playback_url, "/playback/%s",
 		stasis_app_playback_get_id(playback));
 	if (!playback_url) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 500, "Internal Server Error",
 			"Out of memory");
 		return;
@@ -320,18 +320,18 @@
 
 	json = stasis_app_playback_to_json(playback);
 	if (!json) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 500, "Internal Server Error",
 			"Out of memory");
 		return;
 	}
 
-	stasis_http_response_created(response, playback_url, json);
-}
-
-void stasis_http_record_channel(struct ast_variable *headers,
+	ari_response_created(response, playback_url, json);
+}
+
+void ari_record_channel(struct ast_variable *headers,
 	struct ast_record_channel_args *args,
-	struct stasis_http_response *response)
+	struct ari_response *response)
 {
 	RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
@@ -346,14 +346,14 @@
 	ast_assert(response != NULL);
 
 	if (args->max_duration_seconds < 0) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 400, "Bad Request",
 			"max_duration_seconds cannot be negative");
 		return;
 	}
 
 	if (args->max_silence_seconds < 0) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 400, "Bad Request",
 			"max_silence_seconds cannot be negative");
 		return;
@@ -367,7 +367,7 @@
 
 	options = stasis_app_recording_options_create(args->name, args->format);
 	if (options == NULL) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 500, "Internal Server Error",
 			"Out of memory");
 	}
@@ -380,14 +380,14 @@
 	options->beep = args->beep;
 
 	if (options->terminate_on == STASIS_APP_RECORDING_TERMINATE_INVALID) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 400, "Bad Request",
 			"terminateOn invalid");
 		return;
 	}
 
 	if (options->if_exists == -1) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 400, "Bad Request",
 			"ifExists invalid");
 		return;
@@ -400,22 +400,22 @@
 			/* While the arguments are invalid, we should have
 			 * caught them prior to calling record.
 			 */
-			stasis_http_response_error(
+			ari_response_error(
 				response, 500, "Internal Server Error",
 				"Error parsing request");
 			break;
 		case EEXIST:
-			stasis_http_response_error(response, 409, "Conflict",
+			ari_response_error(response, 409, "Conflict",
 				"Recording '%s' already in progress",
 				args->name);
 			break;
 		case ENOMEM:
-			stasis_http_response_error(
+			ari_response_error(
 				response, 500, "Internal Server Error",
 				"Out of memory");
 			break;
 		case EPERM:
-			stasis_http_response_error(
+			ari_response_error(
 				response, 400, "Bad Request",
 				"Recording name invalid");
 			break;
@@ -423,7 +423,7 @@
 			ast_log(LOG_WARNING,
 				"Unrecognized recording error: %s\n",
 				strerror(errno));
-			stasis_http_response_error(
+			ari_response_error(
 				response, 500, "Internal Server Error",
 				"Internal Server Error");
 			break;
@@ -434,7 +434,7 @@
 	uri_name_maxlen = strlen(args->name) * 3;
 	uri_encoded_name = ast_malloc(uri_name_maxlen);
 	if (!uri_encoded_name) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 500, "Internal Server Error",
 			"Out of memory");
 		return;
@@ -444,7 +444,7 @@
 
 	ast_asprintf(&recording_url, "/recordings/live/%s", uri_encoded_name);
 	if (!recording_url) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 500, "Internal Server Error",
 			"Out of memory");
 		return;
@@ -452,18 +452,18 @@
 
 	json = stasis_app_recording_to_json(recording);
 	if (!json) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 500, "Internal Server Error",
 			"Out of memory");
 		return;
 	}
 
-	stasis_http_response_created(response, recording_url, json);
-}
-
-void stasis_http_get_channel(struct ast_variable *headers,
+	ari_response_created(response, recording_url, json);
+}
+
+void ari_get_channel(struct ast_variable *headers,
 			     struct ast_get_channel_args *args,
-			     struct stasis_http_response *response)
+			     struct ari_response *response)
 {
 	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
 	struct stasis_caching_topic *caching_topic;
@@ -471,7 +471,7 @@
 
 	caching_topic = ast_channel_topic_all_cached();
 	if (!caching_topic) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 500, "Internal Server Error",
 			"Message bus not initialized");
 		return;
@@ -480,7 +480,7 @@
 	msg = stasis_cache_get(caching_topic, ast_channel_snapshot_type(),
 			       args->channel_id);
 	if (!msg) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 404, "Not Found",
 			"Channel not found");
 		return;
@@ -489,19 +489,19 @@
 	snapshot = stasis_message_data(msg);
 	ast_assert(snapshot != NULL);
 
-	stasis_http_response_ok(response,
+	ari_response_ok(response,
 				ast_channel_snapshot_to_json(snapshot));
 }
 
-void stasis_http_delete_channel(struct ast_variable *headers,
+void ari_delete_channel(struct ast_variable *headers,
 				struct ast_delete_channel_args *args,
-				struct stasis_http_response *response)
+				struct ari_response *response)
 {
 	RAII_VAR(struct ast_channel *, chan, NULL, ao2_cleanup);
 
 	chan = ast_channel_get_by_name(args->channel_id);
 	if (chan == NULL) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 404, "Not Found",
 			"Channel not found");
 		return;
@@ -509,12 +509,12 @@
 
 	ast_softhangup(chan, AST_SOFTHANGUP_EXPLICIT);
 
-	stasis_http_response_no_content(response);
-}
-
-void stasis_http_get_channels(struct ast_variable *headers,
+	ari_response_no_content(response);
+}
+
+void ari_get_channels(struct ast_variable *headers,
 			      struct ast_get_channels_args *args,
-			      struct stasis_http_response *response)
+			      struct ari_response *response)
 {
 	RAII_VAR(struct stasis_caching_topic *, caching_topic, NULL, ao2_cleanup);
 	RAII_VAR(struct ao2_container *, snapshots, NULL, ao2_cleanup);
@@ -524,7 +524,7 @@
 
 	caching_topic = ast_channel_topic_all_cached();
 	if (!caching_topic) {
-		stasis_http_response_error(
+		ari_response_error(
 			response, 500, "Internal Server Error",
 			"Message bus not initialized");
 		return;
@@ -533,13 +533,13 @@
 
 	snapshots = stasis_cache_dump(caching_topic, ast_channel_snapshot_type());
 	if (!snapshots) {
-		stasis_http_response_alloc_failed(response);
+		ari_response_alloc_failed(response);
 		return;
 	}
 
 	json = ast_json_array_create();
 	if (!json) {
-		stasis_http_response_alloc_failed(response);
+		ari_response_alloc_failed(response);
 		return;
 	}
 
@@ -550,18 +550,18 @@
 		int r = ast_json_array_append(
 			json, ast_channel_snapshot_to_json(snapshot));
 		if (r != 0) {
-			stasis_http_response_alloc_failed(response);
+			ari_response_alloc_failed(response);
 			return;
 		}
 	}
 	ao2_iterator_destroy(&i);
 
-	stasis_http_response_ok(response, ast_json_ref(json));
-}
-
-void stasis_http_originate(struct ast_variable *headers,
+	ari_response_ok(response, ast_json_ref(json));
+}
+
+void ari_originate(struct ast_variable *headers,
 			   struct ast_originate_args *args,
-			   struct stasis_http_response *response)
+			   struct ari_response *response)
 {
 	char *dialtech;
 	char dialdevice[AST_CHANNEL_NAME];
@@ -573,7 +573,7 @@
 	char *stuff;
 
 	if (ast_strlen_zero(args->endpoint)) {
-		stasis_http_response_error(response, 400, "Bad Request",
+		ari_response_error(response, 400, "Bad Request",
 			"Endpoint must be specified");
 		return;
 	}
@@ -585,7 +585,7 @@
 	}
 
 	if (ast_strlen_zero(dialtech) || ast_strlen_zero(dialdevice)) {
-		stasis_http_response_error(response, 400, "Bad Request",
+		ari_response_error(response, 400, "Bad Request",
 			"Invalid endpoint specified");
 		return;
 	}
@@ -611,7 +611,7 @@
 		RAII_VAR(struct ast_str *, appdata, ast_str_create(64), ast_free);
 
 		if (!appdata) {
-			stasis_http_response_alloc_failed(response);
+			ari_response_alloc_failed(response);
 			return;
 		}
 
@@ -622,25 +622,25 @@
 
 		/* originate a channel, putting it into an application */
 		if (ast_pbx_outgoing_app(dialtech, NULL, dialdevice, timeout, app, ast_str_buffer(appdata), NULL, 0, cid_num, cid_name, NULL, NULL, NULL)) {
-			stasis_http_response_alloc_failed(response);
+			ari_response_alloc_failed(response);
 			return;
 		}
 	} else if (!ast_strlen_zero(args->extension)) {
 		/* originate a channel, sending it to an extension */
 		if (ast_pbx_outgoing_exten(dialtech, NULL, dialdevice, timeout, S_OR(args->context, "default"), args->extension, args->priority ? args->priority : 1, NULL, 0, cid_num, cid_name, NULL, NULL, NULL, 0)) {
-			stasis_http_response_alloc_failed(response);
+			ari_response_alloc_failed(response);
 			return;
 		}
 	} else {
-		stasis_http_response_error(response, 400, "Bad Request",
+		ari_response_error(response, 400, "Bad Request",
 			"Application or extension must be specified");
 		return;
 	}
 
-	stasis_http_response_no_content(response);
-}
-

[... 1023 lines stripped ...]



More information about the svn-commits mailing list