[svn-commits] dlee: branch dlee/ASTERISK-22685-json-body r402384 - in /team/dlee/ASTERISK-2...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Nov 1 15:58:01 CDT 2013


Author: dlee
Date: Fri Nov  1 15:58:00 2013
New Revision: 402384

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=402384
Log:
Compiles!

Modified:
    team/dlee/ASTERISK-22685-json-body/res/res_ari_applications.c
    team/dlee/ASTERISK-22685-json-body/res/res_ari_asterisk.c
    team/dlee/ASTERISK-22685-json-body/res/res_ari_bridges.c
    team/dlee/ASTERISK-22685-json-body/res/res_ari_channels.c
    team/dlee/ASTERISK-22685-json-body/res/res_ari_endpoints.c
    team/dlee/ASTERISK-22685-json-body/res/res_ari_events.c
    team/dlee/ASTERISK-22685-json-body/res/res_ari_playback.c
    team/dlee/ASTERISK-22685-json-body/res/res_ari_recordings.c
    team/dlee/ASTERISK-22685-json-body/res/res_ari_sounds.c
    team/dlee/ASTERISK-22685-json-body/rest-api-templates/asterisk_processor.py
    team/dlee/ASTERISK-22685-json-body/rest-api-templates/param_parsing.mustache
    team/dlee/ASTERISK-22685-json-body/rest-api-templates/res_ari_resource.c.mustache

Modified: team/dlee/ASTERISK-22685-json-body/res/res_ari_applications.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22685-json-body/res/res_ari_applications.c?view=diff&rev=402384&r1=402383&r2=402384
==============================================================================
--- team/dlee/ASTERISK-22685-json-body/res/res_ari_applications.c (original)
+++ team/dlee/ASTERISK-22685-json-body/res/res_ari_applications.c Fri Nov  1 15:58:00 2013
@@ -64,10 +64,12 @@
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
 	struct ast_get_applications_args args = {};
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
+
 
 	ast_ari_get_applications(headers, &args, response);
 #if defined(AST_DEVMODE)
@@ -115,6 +117,7 @@
 {
 	struct ast_get_application_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -126,6 +129,7 @@
 		} else
 		{}
 	}
+
 	ast_ari_get_application(headers, &args, response);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
@@ -173,6 +177,8 @@
 {
 	struct ast_application_subscribe_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -229,6 +235,47 @@
 			args.application_name = (i->value);
 		} else
 		{}
+	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "eventSource");
+	if (field && ast_json_typeof(field) == AST_JSON_ARRAY) {
+		size_t i;
+		args.event_source_count = ast_json_array_size(field);
+		ast_free(args.event_source); /* In case it was set above */
+		args.event_source = ast_malloc(sizeof(*args.event_source) * args.event_source_count);
+
+		if (!args.event_source) {
+			ast_ari_response_alloc_failed(response);
+			goto fin;
+		}
+
+		for (i = 0; i < args.event_source_count; ++i) {
+			args.event_source[i] = ast_json_string_get(ast_json_array_get(field, i));
+		}
+	} else {
+		args.event_source_count = 1;
+		args.event_source = ast_malloc(sizeof(*args.event_source) * args.event_source_count);
+		if (!args.event_source) {
+			ast_ari_response_alloc_failed(response);
+			goto fin;
+		}
+		args.event_source[0] = ast_json_string_get(field);
 	}
 	ast_ari_application_subscribe(headers, &args, response);
 #if defined(AST_DEVMODE)
@@ -281,6 +328,8 @@
 {
 	struct ast_application_unsubscribe_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -337,6 +386,47 @@
 			args.application_name = (i->value);
 		} else
 		{}
+	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "eventSource");
+	if (field && ast_json_typeof(field) == AST_JSON_ARRAY) {
+		size_t i;
+		args.event_source_count = ast_json_array_size(field);
+		ast_free(args.event_source); /* In case it was set above */
+		args.event_source = ast_malloc(sizeof(*args.event_source) * args.event_source_count);
+
+		if (!args.event_source) {
+			ast_ari_response_alloc_failed(response);
+			goto fin;
+		}
+
+		for (i = 0; i < args.event_source_count; ++i) {
+			args.event_source[i] = ast_json_string_get(ast_json_array_get(field, i));
+		}
+	} else {
+		args.event_source_count = 1;
+		args.event_source = ast_malloc(sizeof(*args.event_source) * args.event_source_count);
+		if (!args.event_source) {
+			ast_ari_response_alloc_failed(response);
+			goto fin;
+		}
+		args.event_source[0] = ast_json_string_get(field);
 	}
 	ast_ari_application_unsubscribe(headers, &args, response);
 #if defined(AST_DEVMODE)

Modified: team/dlee/ASTERISK-22685-json-body/res/res_ari_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22685-json-body/res/res_ari_asterisk.c?view=diff&rev=402384&r1=402383&r2=402384
==============================================================================
--- team/dlee/ASTERISK-22685-json-body/res/res_ari_asterisk.c (original)
+++ team/dlee/ASTERISK-22685-json-body/res/res_ari_asterisk.c Fri Nov  1 15:58:00 2013
@@ -64,13 +64,16 @@
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
 	struct ast_asterisk_echo_args args = {};
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
 
-	args.anything = ast_http_get_json(ser, headers);
-	if (!args.anything) {
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
 		switch (errno) {
 		case EFBIG:
 			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
@@ -83,6 +86,7 @@
 			goto fin;
 		}
 	}
+	args.anything = ast_json_ref(body);
 	ast_ari_asterisk_echo(headers, &args, response);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
@@ -130,6 +134,8 @@
 {
 	struct ast_get_asterisk_info_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -181,6 +187,47 @@
 		} else
 		{}
 	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "only");
+	if (field && ast_json_typeof(field) == AST_JSON_ARRAY) {
+		size_t i;
+		args.only_count = ast_json_array_size(field);
+		ast_free(args.only); /* In case it was set above */
+		args.only = ast_malloc(sizeof(*args.only) * args.only_count);
+
+		if (!args.only) {
+			ast_ari_response_alloc_failed(response);
+			goto fin;
+		}
+
+		for (i = 0; i < args.only_count; ++i) {
+			args.only[i] = ast_json_string_get(ast_json_array_get(field, i));
+		}
+	} else {
+		args.only_count = 1;
+		args.only = ast_malloc(sizeof(*args.only) * args.only_count);
+		if (!args.only) {
+			ast_ari_response_alloc_failed(response);
+			goto fin;
+		}
+		args.only[0] = ast_json_string_get(field);
+	}
 	ast_ari_get_asterisk_info(headers, &args, response);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
@@ -229,6 +276,8 @@
 {
 	struct ast_get_global_var_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -239,6 +288,27 @@
 			args.variable = (i->value);
 		} else
 		{}
+	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "variable");
+	if (field) {
+		args.variable = ast_json_string_get(field);
 	}
 	ast_ari_get_global_var(headers, &args, response);
 #if defined(AST_DEVMODE)
@@ -287,6 +357,8 @@
 {
 	struct ast_set_global_var_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -300,6 +372,31 @@
 			args.value = (i->value);
 		} else
 		{}
+	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "variable");
+	if (field) {
+		args.variable = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "value");
+	if (field) {
+		args.value = ast_json_string_get(field);
 	}
 	ast_ari_set_global_var(headers, &args, response);
 #if defined(AST_DEVMODE)

Modified: team/dlee/ASTERISK-22685-json-body/res/res_ari_bridges.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22685-json-body/res/res_ari_bridges.c?view=diff&rev=402384&r1=402383&r2=402384
==============================================================================
--- team/dlee/ASTERISK-22685-json-body/res/res_ari_bridges.c (original)
+++ team/dlee/ASTERISK-22685-json-body/res/res_ari_bridges.c Fri Nov  1 15:58:00 2013
@@ -64,10 +64,12 @@
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
 	struct ast_get_bridges_args args = {};
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
+
 
 	ast_ari_get_bridges(headers, &args, response);
 #if defined(AST_DEVMODE)
@@ -115,6 +117,8 @@
 {
 	struct ast_new_bridge_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -125,6 +129,27 @@
 			args.type = (i->value);
 		} else
 		{}
+	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "type");
+	if (field) {
+		args.type = ast_json_string_get(field);
 	}
 	ast_ari_new_bridge(headers, &args, response);
 #if defined(AST_DEVMODE)
@@ -172,6 +197,7 @@
 {
 	struct ast_get_bridge_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -183,6 +209,7 @@
 		} else
 		{}
 	}
+
 	ast_ari_get_bridge(headers, &args, response);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
@@ -230,6 +257,7 @@
 {
 	struct ast_delete_bridge_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -241,6 +269,7 @@
 		} else
 		{}
 	}
+
 	ast_ari_delete_bridge(headers, &args, response);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
@@ -288,6 +317,8 @@
 {
 	struct ast_add_channel_to_bridge_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -348,6 +379,51 @@
 		} else
 		{}
 	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "channel");
+	if (field && ast_json_typeof(field) == AST_JSON_ARRAY) {
+		size_t i;
+		args.channel_count = ast_json_array_size(field);
+		ast_free(args.channel); /* In case it was set above */
+		args.channel = ast_malloc(sizeof(*args.channel) * args.channel_count);
+
+		if (!args.channel) {
+			ast_ari_response_alloc_failed(response);
+			goto fin;
+		}
+
+		for (i = 0; i < args.channel_count; ++i) {
+			args.channel[i] = ast_json_string_get(ast_json_array_get(field, i));
+		}
+	} else {
+		args.channel_count = 1;
+		args.channel = ast_malloc(sizeof(*args.channel) * args.channel_count);
+		if (!args.channel) {
+			ast_ari_response_alloc_failed(response);
+			goto fin;
+		}
+		args.channel[0] = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "role");
+	if (field) {
+		args.role = ast_json_string_get(field);
+	}
 	ast_ari_add_channel_to_bridge(headers, &args, response);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
@@ -400,6 +476,8 @@
 {
 	struct ast_remove_channel_from_bridge_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -457,6 +535,47 @@
 		} else
 		{}
 	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "channel");
+	if (field && ast_json_typeof(field) == AST_JSON_ARRAY) {
+		size_t i;
+		args.channel_count = ast_json_array_size(field);
+		ast_free(args.channel); /* In case it was set above */
+		args.channel = ast_malloc(sizeof(*args.channel) * args.channel_count);
+
+		if (!args.channel) {
+			ast_ari_response_alloc_failed(response);
+			goto fin;
+		}
+
+		for (i = 0; i < args.channel_count; ++i) {
+			args.channel[i] = ast_json_string_get(ast_json_array_get(field, i));
+		}
+	} else {
+		args.channel_count = 1;
+		args.channel = ast_malloc(sizeof(*args.channel) * args.channel_count);
+		if (!args.channel) {
+			ast_ari_response_alloc_failed(response);
+			goto fin;
+		}
+		args.channel[0] = ast_json_string_get(field);
+	}
 	ast_ari_remove_channel_from_bridge(headers, &args, response);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
@@ -509,6 +628,8 @@
 {
 	struct ast_moh_start_bridge_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -525,6 +646,27 @@
 			args.bridge_id = (i->value);
 		} else
 		{}
+	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "mohClass");
+	if (field) {
+		args.moh_class = ast_json_string_get(field);
 	}
 	ast_ari_moh_start_bridge(headers, &args, response);
 #if defined(AST_DEVMODE)
@@ -574,6 +716,7 @@
 {
 	struct ast_moh_stop_bridge_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -585,6 +728,7 @@
 		} else
 		{}
 	}
+
 	ast_ari_moh_stop_bridge(headers, &args, response);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
@@ -633,6 +777,8 @@
 {
 	struct ast_play_on_bridge_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -658,6 +804,39 @@
 			args.bridge_id = (i->value);
 		} else
 		{}
+	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "media");
+	if (field) {
+		args.media = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "lang");
+	if (field) {
+		args.lang = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "offsetms");
+	if (field) {
+		args.offsetms = ast_json_integer_get(field);
+	}
+	field = ast_json_object_get(body, "skipms");
+	if (field) {
+		args.skipms = ast_json_integer_get(field);
 	}
 	ast_ari_play_on_bridge(headers, &args, response);
 #if defined(AST_DEVMODE)
@@ -707,6 +886,8 @@
 {
 	struct ast_record_bridge_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -741,6 +922,51 @@
 			args.bridge_id = (i->value);
 		} else
 		{}
+	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "name");
+	if (field) {
+		args.name = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "format");
+	if (field) {
+		args.format = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "maxDurationSeconds");
+	if (field) {
+		args.max_duration_seconds = ast_json_integer_get(field);
+	}
+	field = ast_json_object_get(body, "maxSilenceSeconds");
+	if (field) {
+		args.max_silence_seconds = ast_json_integer_get(field);
+	}
+	field = ast_json_object_get(body, "ifExists");
+	if (field) {
+		args.if_exists = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "beep");
+	if (field) {
+		args.beep = ast_json_is_true(field);
+	}
+	field = ast_json_object_get(body, "terminateOn");
+	if (field) {
+		args.terminate_on = ast_json_string_get(field);
 	}
 	ast_ari_record_bridge(headers, &args, response);
 #if defined(AST_DEVMODE)

Modified: team/dlee/ASTERISK-22685-json-body/res/res_ari_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22685-json-body/res/res_ari_channels.c?view=diff&rev=402384&r1=402383&r2=402384
==============================================================================
--- team/dlee/ASTERISK-22685-json-body/res/res_ari_channels.c (original)
+++ team/dlee/ASTERISK-22685-json-body/res/res_ari_channels.c Fri Nov  1 15:58:00 2013
@@ -64,10 +64,12 @@
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
 	struct ast_get_channels_args args = {};
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
+
 
 	ast_ari_get_channels(headers, &args, response);
 #if defined(AST_DEVMODE)
@@ -115,6 +117,8 @@
 {
 	struct ast_originate_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -146,6 +150,55 @@
 			args.timeout = atoi(i->value);
 		} else
 		{}
+	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "endpoint");
+	if (field) {
+		args.endpoint = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "extension");
+	if (field) {
+		args.extension = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "context");
+	if (field) {
+		args.context = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "priority");
+	if (field) {
+		args.priority = ast_json_integer_get(field);
+	}
+	field = ast_json_object_get(body, "app");
+	if (field) {
+		args.app = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "appArgs");
+	if (field) {
+		args.app_args = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "callerId");
+	if (field) {
+		args.caller_id = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "timeout");
+	if (field) {
+		args.timeout = ast_json_integer_get(field);
 	}
 	ast_ari_originate(headers, &args, response);
 #if defined(AST_DEVMODE)
@@ -194,6 +247,7 @@
 {
 	struct ast_get_channel_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -205,6 +259,7 @@
 		} else
 		{}
 	}
+
 	ast_ari_get_channel(headers, &args, response);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
@@ -252,6 +307,8 @@
 {
 	struct ast_delete_channel_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -268,6 +325,27 @@
 			args.channel_id = (i->value);
 		} else
 		{}
+	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "reason");
+	if (field) {
+		args.reason = ast_json_string_get(field);
 	}
 	ast_ari_delete_channel(headers, &args, response);
 #if defined(AST_DEVMODE)
@@ -317,6 +395,8 @@
 {
 	struct ast_continue_in_dialplan_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -339,6 +419,35 @@
 			args.channel_id = (i->value);
 		} else
 		{}
+	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "context");
+	if (field) {
+		args.context = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "extension");
+	if (field) {
+		args.extension = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "priority");
+	if (field) {
+		args.priority = ast_json_integer_get(field);
 	}
 	ast_ari_continue_in_dialplan(headers, &args, response);
 #if defined(AST_DEVMODE)
@@ -388,6 +497,7 @@
 {
 	struct ast_answer_channel_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -399,6 +509,7 @@
 		} else
 		{}
 	}
+
 	ast_ari_answer_channel(headers, &args, response);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
@@ -447,6 +558,7 @@
 {
 	struct ast_ring_channel_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -458,6 +570,7 @@
 		} else
 		{}
 	}
+
 	ast_ari_ring_channel(headers, &args, response);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
@@ -506,6 +619,8 @@
 {
 	struct ast_send_dtmfchannel_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -534,6 +649,43 @@
 			args.channel_id = (i->value);
 		} else
 		{}
+	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "dtmf");
+	if (field) {
+		args.dtmf = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "before");
+	if (field) {
+		args.before = ast_json_integer_get(field);
+	}
+	field = ast_json_object_get(body, "between");
+	if (field) {
+		args.between = ast_json_integer_get(field);
+	}
+	field = ast_json_object_get(body, "duration");
+	if (field) {
+		args.duration = ast_json_integer_get(field);
+	}
+	field = ast_json_object_get(body, "after");
+	if (field) {
+		args.after = ast_json_integer_get(field);
 	}
 	ast_ari_send_dtmfchannel(headers, &args, response);
 #if defined(AST_DEVMODE)
@@ -584,6 +736,8 @@
 {
 	struct ast_mute_channel_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -600,6 +754,27 @@
 			args.channel_id = (i->value);
 		} else
 		{}
+	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "direction");
+	if (field) {
+		args.direction = ast_json_string_get(field);
 	}
 	ast_ari_mute_channel(headers, &args, response);
 #if defined(AST_DEVMODE)
@@ -649,6 +824,8 @@
 {
 	struct ast_unmute_channel_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -665,6 +842,27 @@
 			args.channel_id = (i->value);
 		} else
 		{}
+	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "direction");
+	if (field) {
+		args.direction = ast_json_string_get(field);
 	}
 	ast_ari_unmute_channel(headers, &args, response);
 #if defined(AST_DEVMODE)
@@ -714,6 +912,7 @@
 {
 	struct ast_hold_channel_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -725,6 +924,7 @@
 		} else
 		{}
 	}
+
 	ast_ari_hold_channel(headers, &args, response);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
@@ -773,6 +973,7 @@
 {
 	struct ast_unhold_channel_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -784,6 +985,7 @@
 		} else
 		{}
 	}
+
 	ast_ari_unhold_channel(headers, &args, response);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
@@ -832,6 +1034,8 @@
 {
 	struct ast_moh_start_channel_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -848,6 +1052,27 @@
 			args.channel_id = (i->value);
 		} else
 		{}
+	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "mohClass");
+	if (field) {
+		args.moh_class = ast_json_string_get(field);
 	}
 	ast_ari_moh_start_channel(headers, &args, response);
 #if defined(AST_DEVMODE)
@@ -897,6 +1122,7 @@
 {
 	struct ast_moh_stop_channel_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -908,6 +1134,7 @@
 		} else
 		{}
 	}
+
 	ast_ari_moh_stop_channel(headers, &args, response);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
@@ -956,6 +1183,8 @@
 {
 	struct ast_play_on_channel_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -981,6 +1210,39 @@
 			args.channel_id = (i->value);
 		} else
 		{}
+	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "media");
+	if (field) {
+		args.media = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "lang");
+	if (field) {
+		args.lang = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "offsetms");
+	if (field) {
+		args.offsetms = ast_json_integer_get(field);
+	}
+	field = ast_json_object_get(body, "skipms");
+	if (field) {
+		args.skipms = ast_json_integer_get(field);
 	}
 	ast_ari_play_on_channel(headers, &args, response);
 #if defined(AST_DEVMODE)
@@ -1030,6 +1292,8 @@
 {
 	struct ast_record_channel_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -1064,6 +1328,51 @@
 			args.channel_id = (i->value);
 		} else
 		{}
+	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "name");
+	if (field) {
+		args.name = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "format");
+	if (field) {
+		args.format = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "maxDurationSeconds");
+	if (field) {
+		args.max_duration_seconds = ast_json_integer_get(field);
+	}
+	field = ast_json_object_get(body, "maxSilenceSeconds");
+	if (field) {
+		args.max_silence_seconds = ast_json_integer_get(field);
+	}
+	field = ast_json_object_get(body, "ifExists");
+	if (field) {
+		args.if_exists = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "beep");
+	if (field) {
+		args.beep = ast_json_is_true(field);
+	}
+	field = ast_json_object_get(body, "terminateOn");
+	if (field) {
+		args.terminate_on = ast_json_string_get(field);
 	}
 	ast_ari_record_channel(headers, &args, response);
 #if defined(AST_DEVMODE)
@@ -1115,6 +1424,8 @@
 {
 	struct ast_get_channel_var_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -1131,6 +1442,27 @@
 			args.channel_id = (i->value);
 		} else
 		{}
+	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "variable");
+	if (field) {
+		args.variable = ast_json_string_get(field);
 	}
 	ast_ari_get_channel_var(headers, &args, response);
 #if defined(AST_DEVMODE)
@@ -1181,6 +1513,8 @@
 {
 	struct ast_set_channel_var_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -1200,6 +1534,31 @@
 			args.channel_id = (i->value);
 		} else
 		{}
+	}
+
+	/* Look for a JSON request entity */
+	body = ast_http_get_json(ser, headers);
+	if (!body) {
+		switch (errno) {
+		case EFBIG:
+			ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
+			goto fin;
+		case ENOMEM:
+			ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
+			goto fin;
+		case EIO:
+			ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
+			goto fin;
+		}
+	}
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "variable");
+	if (field) {
+		args.variable = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "value");
+	if (field) {
+		args.value = ast_json_string_get(field);
 	}
 	ast_ari_set_channel_var(headers, &args, response);
 #if defined(AST_DEVMODE)

Modified: team/dlee/ASTERISK-22685-json-body/res/res_ari_endpoints.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22685-json-body/res/res_ari_endpoints.c?view=diff&rev=402384&r1=402383&r2=402384
==============================================================================
--- team/dlee/ASTERISK-22685-json-body/res/res_ari_endpoints.c (original)
+++ team/dlee/ASTERISK-22685-json-body/res/res_ari_endpoints.c Fri Nov  1 15:58:00 2013
@@ -64,10 +64,12 @@
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
 	struct ast_get_endpoints_args args = {};
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
+
 
 	ast_ari_get_endpoints(headers, &args, response);
 #if defined(AST_DEVMODE)
@@ -115,6 +117,7 @@
 {
 	struct ast_get_endpoints_by_tech_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -126,6 +129,7 @@
 		} else
 		{}
 	}
+
 	ast_ari_get_endpoints_by_tech(headers, &args, response);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
@@ -172,6 +176,7 @@
 {
 	struct ast_get_endpoint_args args = {};
 	struct ast_variable *i;
+	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -186,6 +191,7 @@
 		} else
 		{}
 	}
+
 	ast_ari_get_endpoint(headers, &args, response);
 #if defined(AST_DEVMODE)
 	code = response->response_code;

Modified: team/dlee/ASTERISK-22685-json-body/res/res_ari_events.c

[... 577 lines stripped ...]



More information about the svn-commits mailing list