[svn-commits] dlee: branch dlee/ari-event-remodel r391897 - in /team/dlee/ari-event-remodel...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jun 14 16:21:02 CDT 2013


Author: dlee
Date: Fri Jun 14 16:21:00 2013
New Revision: 391897

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=391897
Log:
Switched ari_model native and generated code around.

Added:
    team/dlee/ari-event-remodel/res/res_ari_model.c
      - copied, changed from r391893, team/dlee/ari-event-remodel/res/stasis_http/ari_model_native.c
    team/dlee/ari-event-remodel/res/stasis_http/ari_model.c   (with props)
    team/dlee/ari-event-remodel/res/stasis_http/ari_model.h   (with props)
    team/dlee/ari-event-remodel/rest-api-templates/ari_model.c.mustache
      - copied, changed from r391893, team/dlee/ari-event-remodel/rest-api-templates/res_ari_model.c.mustache
Removed:
    team/dlee/ari-event-remodel/res/stasis_http/ari_model_native.c
    team/dlee/ari-event-remodel/rest-api-templates/res_ari_model.c.mustache
Modified:
    team/dlee/ari-event-remodel/res/Makefile
    team/dlee/ari-event-remodel/rest-api-templates/ari_model.h.mustache
    team/dlee/ari-event-remodel/rest-api-templates/make_stasis_http_stubs.py

Modified: team/dlee/ari-event-remodel/res/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel/res/Makefile?view=diff&rev=391897&r1=391896&r2=391897
==============================================================================
--- team/dlee/ari-event-remodel/res/Makefile (original)
+++ team/dlee/ari-event-remodel/res/Makefile Fri Jun 14 16:21:00 2013
@@ -80,8 +80,8 @@
 $(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_ari_model.so: stasis_http/ari_model_native.o
-stasis_http/ari_model_native.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_model)
+res_ari_model.so: stasis_http/ari_model.o
+stasis_http/ari_model.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

Copied: team/dlee/ari-event-remodel/res/res_ari_model.c (from r391893, team/dlee/ari-event-remodel/res/stasis_http/ari_model_native.c)
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel/res/res_ari_model.c?view=diff&rev=391897&p1=team/dlee/ari-event-remodel/res/stasis_http/ari_model_native.c&r1=391893&p2=team/dlee/ari-event-remodel/res/res_ari_model.c&r2=391897
==============================================================================
--- team/dlee/ari-event-remodel/res/stasis_http/ari_model_native.c (original)
+++ team/dlee/ari-event-remodel/res/res_ari_model.c Fri Jun 14 16:21:00 2013
@@ -18,7 +18,7 @@
 
 /*! \file
  *
- * \brief Implementation native Swagger validators.
+ * \brief Implementation Swagger validators.
  *
  * \author David M. Lee, II <dlee at digium.com>
  */
@@ -33,6 +33,7 @@
 
 #include "asterisk/ari_model.h"
 #include "asterisk/logger.h"
+#include "asterisk/module.h"
 #include "asterisk/utils.h"
 
 #include <regex.h>
@@ -135,19 +136,27 @@
 	return res;
 }
 
-int ari_native_init(void)
+static int load_module(void)
 {
 	int res;
 	res = regcomp(&date_regex, DATE_PATTERN,
 		REG_EXTENDED | REG_ICASE | REG_NOSUB);
 
 	if (res != 0) {
-		return -1;
+		return AST_MODULE_LOAD_FAILURE;
 	}
+	return AST_MODULE_LOAD_SUCCESS;
+}
+
+static int unload_module(void)
+{
+	regfree(&date_regex);
 	return 0;
 }
 
-void ari_native_cleanup(void)
-{
-	regfree(&date_regex);
-}
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER,
+	"ARI Model validators",
+	.load = load_module,
+	.unload = unload_module,
+	.load_pri = AST_MODPRI_APP_DEPEND,
+        );

Added: team/dlee/ari-event-remodel/res/stasis_http/ari_model.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel/res/stasis_http/ari_model.c?view=auto&rev=391897
==============================================================================
--- team/dlee/ari-event-remodel/res/stasis_http/ari_model.c (added)
+++ team/dlee/ari-event-remodel/res/stasis_http/ari_model.c Fri Jun 14 16:21:00 2013
@@ -1,0 +1,1223 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2013, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ *
+ * \brief Generated file - Build validators for ARI model objects.
+ */
+
+ /*
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * !!!!!                               DO NOT EDIT                        !!!!!
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * This file is generated by a mustache template. Please see the original
+ * template in rest-api-templates/ari_model.h.mustache
+ */
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "asterisk/logger.h"
+#include "asterisk/module.h"
+#include "asterisk/ari_model.h"
+
+int ari_validate_asterisk_info(struct ast_json *json)
+{
+	int res = 1;
+	return res;
+}
+
+int ari_validate_endpoint(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "resource");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Endpoint field resource failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Endpoint missing required field resource\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "technology");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Endpoint field technology failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Endpoint missing required field technology\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_caller_id(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "name");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI CallerID field name failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI CallerID missing required field name\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "number");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI CallerID field number failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI CallerID missing required field number\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_channel(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "accountcode");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Channel field accountcode failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Channel missing required field accountcode\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "appl");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Channel field appl failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Channel missing required field appl\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "caller");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_caller_id(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Channel field caller failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Channel missing required field caller\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "connected");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_caller_id(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Channel field connected failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Channel missing required field connected\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "creationtime");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_date(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Channel field creationtime failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Channel missing required field creationtime\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "data");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Channel field data failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Channel missing required field data\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "dialplan");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_dialplan_cep(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Channel field dialplan failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Channel missing required field dialplan\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "hangupsource");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Channel field hangupsource failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Channel missing required field hangupsource\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "linkedid");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Channel field linkedid failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Channel missing required field linkedid\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "name");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Channel field name failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Channel missing required field name\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "parkinglot");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Channel field parkinglot failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Channel missing required field parkinglot\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "peeraccount");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Channel field peeraccount failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Channel missing required field peeraccount\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "state");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Channel field state failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Channel missing required field state\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "uniqueid");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Channel field uniqueid failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Channel missing required field uniqueid\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "userfield");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Channel field userfield failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Channel missing required field userfield\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_dialed(struct ast_json *json)
+{
+	int res = 1;
+	return res;
+}
+
+int ari_validate_dialplan_cep(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "context");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI DialplanCEP field context failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI DialplanCEP missing required field context\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "exten");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI DialplanCEP field exten failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI DialplanCEP missing required field exten\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "priority");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_long(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI DialplanCEP field priority failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI DialplanCEP missing required field priority\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_bridge(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "bridge_type");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Bridge field bridge_type failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Bridge missing required field bridge_type\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "channels");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_list(prop, ari_validate_string);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Bridge field channels failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Bridge missing required field channels\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_live_recording(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "id");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI LiveRecording field id failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI LiveRecording missing required field id\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_stored_recording(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "duration_seconds");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_int(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI StoredRecording field duration_seconds failed validation\n");
+			res = 0;
+		}
+	}
+	prop = ast_json_object_get(json, "formats");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_list(prop, ari_validate_string);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI StoredRecording field formats failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI StoredRecording missing required field formats\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "id");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI StoredRecording field id failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI StoredRecording missing required field id\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "time");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_date(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI StoredRecording field time failed validation\n");
+			res = 0;
+		}
+	}
+	return res;
+}
+
+int ari_validate_sound(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "formats");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_list(prop, ari_validate_string);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Sound field formats failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Sound missing required field formats\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "id");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Sound field id failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Sound missing required field id\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "lang");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Sound field lang failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Sound missing required field lang\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "text");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Sound field text failed validation\n");
+			res = 0;
+		}
+	}
+	return res;
+}
+
+int ari_validate_playback(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "id");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Playback field id failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Playback missing required field id\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "language");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Playback field language failed validation\n");
+			res = 0;
+		}
+	}
+	prop = ast_json_object_get(json, "media_uri");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Playback field media_uri failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Playback missing required field media_uri\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "state");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Playback field state failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Playback missing required field state\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "target_uri");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Playback field target_uri failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Playback missing required field target_uri\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_application_replaced(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "application");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ApplicationReplaced field application failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ApplicationReplaced missing required field application\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_bridge_created(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "bridge");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_bridge(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI BridgeCreated field bridge failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI BridgeCreated missing required field bridge\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_bridge_destroyed(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "bridge");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_bridge(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI BridgeDestroyed field bridge failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI BridgeDestroyed missing required field bridge\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_bridge_merged(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "bridge");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_bridge(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI BridgeMerged field bridge failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI BridgeMerged missing required field bridge\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "bridge_from");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_bridge(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI BridgeMerged field bridge_from failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI BridgeMerged missing required field bridge_from\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_channel_caller_id(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "caller_presentation");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_int(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelCallerId field caller_presentation failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field caller_presentation\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "caller_presentation_txt");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelCallerId field caller_presentation_txt failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field caller_presentation_txt\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "channel");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_channel(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelCallerId field channel failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field channel\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_channel_created(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "channel");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_channel(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelCreated field channel failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelCreated missing required field channel\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_channel_destroyed(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "cause");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_int(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelDestroyed field cause failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field cause\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "cause_txt");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelDestroyed field cause_txt failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field cause_txt\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "channel");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_channel(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelDestroyed field channel failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field channel\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_channel_dialplan(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "application");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelDialplan field application failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field application\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "application_data");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelDialplan field application_data failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field application_data\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "channel");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_channel(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelDialplan field channel failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field channel\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_channel_dtmf_received(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "channel");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_channel(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field channel failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelDtmfReceived missing required field channel\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "digit");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field digit failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelDtmfReceived missing required field digit\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_channel_entered_bridge(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "bridge");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_bridge(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelEnteredBridge field bridge failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelEnteredBridge missing required field bridge\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "channel");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_channel(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelEnteredBridge field channel failed validation\n");
+			res = 0;
+		}
+	}
+	return res;
+}
+
+int ari_validate_channel_hangup_request(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "cause");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_int(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelHangupRequest field cause failed validation\n");
+			res = 0;
+		}
+	}
+	prop = ast_json_object_get(json, "channel");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_channel(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelHangupRequest field channel failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelHangupRequest missing required field channel\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "soft");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_boolean(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelHangupRequest field soft failed validation\n");
+			res = 0;
+		}
+	}
+	return res;
+}
+
+int ari_validate_channel_left_bridge(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "bridge");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_bridge(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelLeftBridge field bridge failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelLeftBridge missing required field bridge\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "channel");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_channel(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelLeftBridge field channel failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelLeftBridge missing required field channel\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_channel_snapshot(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "channel");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_channel(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelSnapshot field channel failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelSnapshot missing required field channel\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_channel_state_change(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "channel");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_channel(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelStateChange field channel failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelStateChange missing required field channel\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_channel_userevent(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "channel");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_channel(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelUserevent field channel failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelUserevent missing required field channel\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "eventname");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelUserevent field eventname failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelUserevent missing required field eventname\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_channel_varset(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "channel");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_channel(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelVarset field channel failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelVarset missing required field channel\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "value");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelVarset field value failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelVarset missing required field value\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "variable");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI ChannelVarset field variable failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI ChannelVarset missing required field variable\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_event(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "application");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Event field application failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI Event missing required field application\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "timestamp");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_date(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Event field timestamp failed validation\n");
+			res = 0;
+		}
+	}
+	prop = ast_json_object_get(json, "type");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_string(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI Event field type failed validation\n");
+			res = 0;
+		}
+	}
+	return res;
+}
+
+int ari_validate_playback_finished(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "playback");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_playback(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI PlaybackFinished field playback failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI PlaybackFinished missing required field playback\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_playback_started(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "playback");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_playback(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI PlaybackStarted field playback failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI PlaybackStarted missing required field playback\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_stasis_end(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "channel");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_channel(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI StasisEnd field channel failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI StasisEnd missing required field channel\n");
+		res = 0;
+	}
+	return res;
+}
+
+int ari_validate_stasis_start(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json *prop;
+	prop = ast_json_object_get(json, "args");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_list(prop, ari_validate_string);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI StasisStart field args failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI StasisStart missing required field args\n");
+		res = 0;
+	}
+	prop = ast_json_object_get(json, "channel");
+	if (prop) {
+		int prop_res;
+		prop_res = ari_validate_channel(prop);
+		if (!prop_res) {
+			ast_log(LOG_ERROR, "ARI StasisStart field channel failed validation\n");
+			res = 0;
+		}
+	}
+	else {
+		ast_log(LOG_ERROR, "ARI StasisStart missing required field channel\n");
+		res = 0;
+	}
+	return res;
+}

Propchange: team/dlee/ari-event-remodel/res/stasis_http/ari_model.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/dlee/ari-event-remodel/res/stasis_http/ari_model.c
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/dlee/ari-event-remodel/res/stasis_http/ari_model.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: team/dlee/ari-event-remodel/res/stasis_http/ari_model.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel/res/stasis_http/ari_model.h?view=auto&rev=391897
==============================================================================
--- team/dlee/ari-event-remodel/res/stasis_http/ari_model.h (added)
+++ team/dlee/ari-event-remodel/res/stasis_http/ari_model.h Fri Jun 14 16:21:00 2013
@@ -1,0 +1,1501 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2013, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ *
+ * \brief Generated file - Build validators for ARI model objects.
+ */
+
+ /*
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * !!!!!                               DO NOT EDIT                        !!!!!
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * This file is generated by a mustache template. Please see the original
+ * template in rest-api-templates/ari_model.h.mustache
+ */
+
+#ifndef _ASTERISK_ARI_MODEL_H
+#define _ASTERISK_ARI_MODEL_H
+
+#include "asterisk/json.h"
+
+/*! @} */
+
+/*! @{
+ * \brief Validator for native Swagger type.
+ *
+ * \param json JSON object to validate.
+ * \returns True (non-zero) if valid.
+ * \returns False (zero) if invalid.
+ */
+
+int ari_validate_byte(struct ast_json *json);
+int ari_validate_boolean(struct ast_json *json);
+int ari_validate_int(struct ast_json *json);
+int ari_validate_long(struct ast_json *json);
+int ari_validate_float(struct ast_json *json);
+int ari_validate_double(struct ast_json *json);
+int ari_validate_string(struct ast_json *json);
+int ari_validate_date(struct ast_json *json);
+
+/*! @} */
+
+/*!
+ * \brief Validator for a Swagger List[]/JSON array.
+ *
+ * \param json JSON object to validate.
+ * \param fn Validator to call on every element in the array.
+ * \returns True (non-zero) if valid.
+ * \returns False (zero) if invalid.
+ */
+int ari_validate_list(struct ast_json *json, int (*fn)(struct ast_json *));
+
+/*!
+ * \brief Validator for AsteriskInfo.
+ *
+ * Asterisk system information
+ *
+ * \param json JSON object to validate.
+ * \returns True (non-zero) if valid.
+ * \returns False (zero) if invalid.
+ */
+int ari_validate_asterisk_info(struct ast_json *json);
+
+/*! @} */
+
+/*! @{
+ * \brief Validator for native Swagger type.
+ *
+ * \param json JSON object to validate.
+ * \returns True (non-zero) if valid.
+ * \returns False (zero) if invalid.
+ */
+
+int ari_validate_byte(struct ast_json *json);
+int ari_validate_boolean(struct ast_json *json);
+int ari_validate_int(struct ast_json *json);
+int ari_validate_long(struct ast_json *json);
+int ari_validate_float(struct ast_json *json);
+int ari_validate_double(struct ast_json *json);
+int ari_validate_string(struct ast_json *json);
+int ari_validate_date(struct ast_json *json);
+
+/*! @} */
+
+/*!
+ * \brief Validator for a Swagger List[]/JSON array.
+ *
+ * \param json JSON object to validate.
+ * \param fn Validator to call on every element in the array.
+ * \returns True (non-zero) if valid.
+ * \returns False (zero) if invalid.
+ */
+int ari_validate_list(struct ast_json *json, int (*fn)(struct ast_json *));
+
+/*!
+ * \brief Validator for Endpoint.
+ *
+ * An external device that may offer/accept calls to/from Asterisk.
+ *
+ * Unlike most resources, which have a single unique identifier, an endpoint is uniquely identified by the technology/resource pair.
+ *
+ * \param json JSON object to validate.
+ * \returns True (non-zero) if valid.
+ * \returns False (zero) if invalid.
+ */
+int ari_validate_endpoint(struct ast_json *json);
+
+/*! @} */
+
+/*! @{
+ * \brief Validator for native Swagger type.
+ *
+ * \param json JSON object to validate.
+ * \returns True (non-zero) if valid.
+ * \returns False (zero) if invalid.
+ */
+
+int ari_validate_byte(struct ast_json *json);
+int ari_validate_boolean(struct ast_json *json);
+int ari_validate_int(struct ast_json *json);
+int ari_validate_long(struct ast_json *json);
+int ari_validate_float(struct ast_json *json);
+int ari_validate_double(struct ast_json *json);
+int ari_validate_string(struct ast_json *json);
+int ari_validate_date(struct ast_json *json);
+
+/*! @} */
+
+/*!
+ * \brief Validator for a Swagger List[]/JSON array.
+ *
+ * \param json JSON object to validate.
+ * \param fn Validator to call on every element in the array.
+ * \returns True (non-zero) if valid.
+ * \returns False (zero) if invalid.
+ */
+int ari_validate_list(struct ast_json *json, int (*fn)(struct ast_json *));
+
+/*!
+ * \brief Validator for CallerID.
+ *
+ * Caller identification
+ *

[... 1445 lines stripped ...]



More information about the svn-commits mailing list