[svn-commits] kmoore: trunk r395603 - in /trunk: configs/ include/asterisk/ main/ res/ res/...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sat Jul 27 18:11:06 CDT 2013


Author: kmoore
Date: Sat Jul 27 18:11:02 2013
New Revision: 395603

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=395603
Log:
Rename everything Stasis-HTTP to ARI

This renames all files and API calls from several variants of
Stasis-HTTP to ARI including:
* Stasis-HTTP -> ARI
* STASIS_HTTP -> ARI
* stasis_http -> ari (ast_ari for global symbols, file names as well)
* stasis http -> ARI

Review: https://reviewboard.asterisk.org/r/2706/
(closes issue ASTERISK-22136)

Added:
    trunk/include/asterisk/ari.h   (with props)
    trunk/res/ari/
    trunk/res/ari.make   (with props)
    trunk/res/ari/ari_model_validators.c   (with props)
    trunk/res/ari/ari_model_validators.h   (with props)
    trunk/res/ari/ari_websockets.c   (with props)
    trunk/res/ari/cli.c   (with props)
    trunk/res/ari/config.c   (with props)
    trunk/res/ari/internal.h   (with props)
    trunk/res/ari/resource_asterisk.c   (with props)
    trunk/res/ari/resource_asterisk.h   (with props)
    trunk/res/ari/resource_bridges.c   (with props)
    trunk/res/ari/resource_bridges.h   (with props)
    trunk/res/ari/resource_channels.c   (with props)
    trunk/res/ari/resource_channels.h   (with props)
    trunk/res/ari/resource_endpoints.c   (with props)
    trunk/res/ari/resource_endpoints.h   (with props)
    trunk/res/ari/resource_events.c   (with props)
    trunk/res/ari/resource_events.h   (with props)
    trunk/res/ari/resource_playback.c   (with props)
    trunk/res/ari/resource_playback.h   (with props)
    trunk/res/ari/resource_recordings.c   (with props)
    trunk/res/ari/resource_recordings.h   (with props)
    trunk/res/ari/resource_sounds.c   (with props)
    trunk/res/ari/resource_sounds.h   (with props)
    trunk/res/res_ari.c   (with props)
    trunk/res/res_ari.exports.in   (with props)
    trunk/res/res_ari_asterisk.c   (with props)
    trunk/res/res_ari_bridges.c   (with props)
    trunk/res/res_ari_channels.c   (with props)
    trunk/res/res_ari_endpoints.c   (with props)
    trunk/res/res_ari_events.c   (with props)
    trunk/res/res_ari_playback.c   (with props)
    trunk/res/res_ari_recordings.c   (with props)
    trunk/res/res_ari_sounds.c   (with props)
    trunk/rest-api-templates/ari.make.mustache   (with props)
    trunk/rest-api-templates/ari_resource.c.mustache   (with props)
    trunk/rest-api-templates/ari_resource.h.mustache   (with props)
    trunk/rest-api-templates/res_ari_resource.c.mustache   (with props)
    trunk/tests/test_ari.c   (with props)
Removed:
    trunk/include/asterisk/stasis_http.h
    trunk/res/res_stasis_http.c
    trunk/res/res_stasis_http.exports.in
    trunk/res/res_stasis_http_asterisk.c
    trunk/res/res_stasis_http_bridges.c
    trunk/res/res_stasis_http_channels.c
    trunk/res/res_stasis_http_endpoints.c
    trunk/res/res_stasis_http_events.c
    trunk/res/res_stasis_http_playback.c
    trunk/res/res_stasis_http_recordings.c
    trunk/res/res_stasis_http_sounds.c
    trunk/res/stasis_http/
    trunk/res/stasis_http.make
    trunk/rest-api-templates/res_stasis_http_resource.c.mustache
    trunk/rest-api-templates/stasis_http.make.mustache
    trunk/rest-api-templates/stasis_http_resource.c.mustache
    trunk/rest-api-templates/stasis_http_resource.h.mustache
    trunk/tests/test_stasis_http.c
Modified:
    trunk/configs/ari.conf.sample
    trunk/main/stasis_config.c
    trunk/res/Makefile
    trunk/res/res_ari_model.c
    trunk/res/res_ari_model.exports.in
    trunk/res/res_statsd.c
    trunk/rest-api-templates/ari_model_validators.c.mustache
    trunk/rest-api-templates/ari_model_validators.h.mustache
    trunk/rest-api-templates/make_ari_stubs.py
    trunk/rest-api-templates/rest_handler.mustache
    trunk/tests/test_ari_model.c

Modified: trunk/configs/ari.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/ari.conf.sample?view=diff&rev=395603&r1=395602&r2=395603
==============================================================================
--- trunk/configs/ari.conf.sample (original)
+++ trunk/configs/ari.conf.sample Sat Jul 27 18:11:02 2013
@@ -1,6 +1,6 @@
 [general]
-enabled = yes		; When set to no, stasis-http support is disabled.
-;pretty = no		; When set to yes, responses from stasis-http are
+enabled = yes		; When set to no, ARI support is disabled.
+;pretty = no		; When set to yes, responses from ARI are
 ;			; formatted to be human readable.
 ;allowed_origins =	; Comma separated list of allowed origins, for
 ;			; Cross-Origin Resource Sharing. May be set to * to

Added: trunk/include/asterisk/ari.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/ari.h?view=auto&rev=395603
==============================================================================
--- trunk/include/asterisk/ari.h (added)
+++ trunk/include/asterisk/ari.h Sat Jul 27 18:11:02 2013
@@ -1,0 +1,231 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2012 - 2013, Digium, Inc.
+ *
+ * David M. Lee, II <dlee at digium.com>
+ *
+ * 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.
+ */
+
+#ifndef _ASTERISK_ARI_H
+#define _ASTERISK_ARI_H
+
+/*! \file
+ *
+ * \brief Stasis RESTful API hooks.
+ *
+ * This header file is used mostly as glue code between generated declarations
+ * and res_ari.c.
+ *
+ * \author David M. Lee, II <dlee at digium.com>
+ */
+
+#include "asterisk/http.h"
+#include "asterisk/json.h"
+#include "asterisk/http_websocket.h"
+
+/*!
+ * \brief Configured encoding format for JSON output.
+ * \return JSON output encoding (compact, pretty, etc.)
+ */
+enum ast_json_encoding_format ast_ari_json_format(void);
+
+struct ast_ari_response;
+
+/*!
+ * \brief Callback type for RESTful method handlers.
+ * \param get_params GET parameters from the HTTP request.
+ * \param path_vars Path variables from any wildcard path segments.
+ * \param headers HTTP headers from the HTTP requiest.
+ * \param[out] response The RESTful response.
+ */
+typedef void (*stasis_rest_callback)(struct ast_variable *get_params,
+				     struct ast_variable *path_vars,
+				     struct ast_variable *headers,
+				     struct ast_ari_response *response);
+
+/*!
+ * \brief Handler for a single RESTful path segment.
+ */
+struct stasis_rest_handlers {
+	/*! Path segement to handle */
+	const char *path_segment;
+	/*! If true (non-zero), path_segment is a wildcard, and will match all
+	 * values.
+	 *
+	 * Value of the segement will be passed into the \a path_vars parameter
+	 * of the callback.
+	 */
+	int is_wildcard;
+	/*! Callbacks for all handled HTTP methods. */
+	stasis_rest_callback callbacks[AST_HTTP_MAX_METHOD];
+	/*! WebSocket server for handling WebSocket upgrades. */
+	struct ast_websocket_server *ws_server;
+	/*! Number of children in the children array */
+	size_t num_children;
+	/*! Handlers for sub-paths */
+	struct stasis_rest_handlers *children[];
+};
+
+/*!
+ * Response type for RESTful requests
+ */
+struct ast_ari_response {
+	/*! Response message */
+	struct ast_json *message;
+	/*! \r\n seperated response headers */
+	struct ast_str *headers;
+	/*! HTTP response code.
+	 * See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html */
+	int response_code;
+	/*! Corresponding text for the response code */
+	const char *response_text; /* Shouldn't http.c handle this? */
+	/*! Flag to indicate that no further response is needed */
+	int no_response:1;
+};
+
+/*!
+ * Add a resource for REST handling.
+ * \param handler Handler to add.
+ * \return 0 on success.
+ * \return non-zero on failure.
+ */
+int ast_ari_add_handler(struct stasis_rest_handlers *handler);
+
+/*!
+ * Remove a resource for REST handling.
+ * \param handler Handler to add.
+ * \return 0 on success.
+ * \return non-zero on failure.
+ */
+int ast_ari_remove_handler(struct stasis_rest_handlers *handler);
+
+/*!
+ * \internal
+ * \brief Stasis RESTful invocation handler.
+ *
+ * Only call from res_ari and test_ari. Only public to allow
+ * for unit testing.
+ *
+ * \param ser TCP/TLS connection.
+ * \param uri HTTP URI, relative to the API path.
+ * \param method HTTP method.
+ * \param get_params HTTP \c GET parameters.
+ * \param headers HTTP headers.
+ * \param[out] response RESTful HTTP response.
+ */
+void ast_ari_invoke(struct ast_tcptls_session_instance *ser,
+	const char *uri, enum ast_http_method method,
+	struct ast_variable *get_params, struct ast_variable *headers,
+	struct ast_ari_response *response);
+
+/*!
+ * \internal
+ * \brief Service function for API declarations.
+ *
+ * Only call from res_ari and test_ari. Only public to allow
+ * for unit testing.
+ *
+ * \param uri Requested URI, relative to the docs path.
+ * \param headers HTTP headers.
+ * \param[out] response RESTful HTTP response.
+ */
+void ast_ari_get_docs(const char *uri, struct ast_variable *headers, struct ast_ari_response *response);
+
+/*! \brief Abstraction for reading/writing JSON to a WebSocket */
+struct ast_ari_websocket_session;
+
+/*!
+ * \brief Create an ARI WebSocket session.
+ *
+ * If \c NULL is given for the validator function, no validation will be
+ * performed.
+ *
+ * \param ws_session Underlying WebSocket session.
+ * \param validator Function to validate outgoing messages.
+ * \return New ARI WebSocket session.
+ * \return \c NULL on error.
+ */
+struct ast_ari_websocket_session *ast_ari_websocket_session_create(
+	struct ast_websocket *ws_session, int (*validator)(struct ast_json *));
+
+/*!
+ * \brief Read a message from an ARI WebSocket.
+ *
+ * \param session Session to read from.
+ * \return Message received.
+ * \return \c NULL if WebSocket could not be read.
+ */
+struct ast_json *ast_ari_websocket_session_read(
+	struct ast_ari_websocket_session *session);
+
+/*!
+ * \brief Send a message to an ARI WebSocket.
+ *
+ * \param session Session to write to.
+ * \param message Message to send.
+ * \return 0 on success.
+ * \return Non-zero on error.
+ */
+int ast_ari_websocket_session_write(struct ast_ari_websocket_session *session,
+	struct ast_json *message);
+
+/*!
+ * \brief The stock message to return when out of memory.
+ *
+ * The refcount is NOT bumped on this object, so ast_json_ref() if you want to
+ * keep the reference.
+ *
+ * \return JSON message specifying an out-of-memory error.
+ */
+struct ast_json *ast_ari_oom_json(void);
+
+/*!
+ * \brief Fill in an error \a ast_ari_response.
+ * \param response Response to fill in.
+ * \param response_code HTTP response code.
+ * \param response_text Text corresponding to the HTTP response code.
+ * \param message_fmt Error message format string.
+ */
+void ast_ari_response_error(struct ast_ari_response *response,
+				int response_code,
+				const char *response_text,
+				const char *message_fmt, ...)
+__attribute__((format(printf, 4, 5)));
+
+/*!
+ * \brief Fill in an \c OK (200) \a ast_ari_response.
+ * \param response Response to fill in.
+ * \param message JSON response.  This reference is stolen, so just \ref
+ *                ast_json_incref if you need to keep a reference to it.
+ */
+void ast_ari_response_ok(struct ast_ari_response *response,
+			     struct ast_json *message);
+
+/*!
+ * \brief Fill in a <tt>No Content</tt> (204) \a ast_ari_response.
+ */
+void ast_ari_response_no_content(struct ast_ari_response *response);
+
+/*!
+ * \brief Fill in a <tt>Created</tt> (201) \a ast_ari_response.
+ */
+void ast_ari_response_created(struct ast_ari_response *response,
+	const char *url, struct ast_json *message);
+
+/*!
+ * \brief Fill in \a response with a 500 message for allocation failures.
+ * \param response Response to fill in.
+ */
+void ast_ari_response_alloc_failed(struct ast_ari_response *response);
+
+#endif /* _ASTERISK_ARI_H */

Propchange: trunk/include/asterisk/ari.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/include/asterisk/ari.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: trunk/include/asterisk/ari.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: trunk/main/stasis_config.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/stasis_config.c?view=diff&rev=395603&r1=395602&r2=395603
==============================================================================
--- trunk/main/stasis_config.c (original)
+++ trunk/main/stasis_config.c Sat Jul 27 18:11:02 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: trunk/res/Makefile
URL: http://svnview.digium.com/svn/asterisk/trunk/res/Makefile?view=diff&rev=395603&r1=395602&r2=395603
==============================================================================
--- trunk/res/Makefile (original)
+++ trunk/res/Makefile Sat Jul 27 18:11:02 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

Added: trunk/res/ari.make
URL: http://svnview.digium.com/svn/asterisk/trunk/res/ari.make?view=auto&rev=395603
==============================================================================
--- trunk/res/ari.make (added)
+++ trunk/res/ari.make Sat Jul 27 18:11:02 2013
@@ -1,0 +1,51 @@
+#
+# Asterisk -- A telephony toolkit for Linux.
+#
+# Generated Makefile for res_ari dependencies.
+#
+# Copyright (C) 2013, Digium, Inc.
+#
+# This program is free software, distributed under the terms of
+# the GNU General Public License
+#
+
+#
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# !!!!!                               DO NOT EDIT                        !!!!!
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# This file is generated by a template. Please see the original template at
+# rest-api-templates/ari.make.mustache
+#
+
+res_ari_asterisk.so: ari/resource_asterisk.o
+
+ari/resource_asterisk.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_asterisk)
+
+res_ari_endpoints.so: ari/resource_endpoints.o
+
+ari/resource_endpoints.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_endpoints)
+
+res_ari_channels.so: ari/resource_channels.o
+
+ari/resource_channels.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_channels)
+
+res_ari_bridges.so: ari/resource_bridges.o
+
+ari/resource_bridges.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_bridges)
+
+res_ari_recordings.so: ari/resource_recordings.o
+
+ari/resource_recordings.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_recordings)
+
+res_ari_sounds.so: ari/resource_sounds.o
+
+ari/resource_sounds.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_sounds)
+
+res_ari_playback.so: ari/resource_playback.o
+
+ari/resource_playback.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_playback)
+
+res_ari_events.so: ari/resource_events.o
+
+ari/resource_events.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_events)
+

Propchange: trunk/res/ari.make
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/res/ari.make
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: trunk/res/ari.make
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: trunk/res/ari/ari_model_validators.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/ari/ari_model_validators.c?view=auto&rev=395603
==============================================================================
--- trunk/res/ari/ari_model_validators.c (added)
+++ trunk/res/ari/ari_model_validators.c Sat Jul 27 18:11:02 2013
@@ -1,0 +1,2969 @@
+/*
+ * 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_validators.h.mustache
+ */
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "asterisk/logger.h"
+#include "asterisk/module.h"
+#include "ari_model_validators.h"
+
+int ast_ari_validate_asterisk_info(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json_iter *iter;
+
+	for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+		{
+			ast_log(LOG_ERROR,
+				"ARI AsteriskInfo has undocumented field %s\n",
+				ast_json_object_iter_key(iter));
+			res = 0;
+		}
+	}
+
+	return res;
+}
+
+ari_validator ast_ari_validate_asterisk_info_fn(void)
+{
+	return ast_ari_validate_asterisk_info;
+}
+
+int ast_ari_validate_variable(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json_iter *iter;
+	int has_value = 0;
+
+	for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+		if (strcmp("value", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_value = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Variable field value failed validation\n");
+				res = 0;
+			}
+		} else
+		{
+			ast_log(LOG_ERROR,
+				"ARI Variable has undocumented field %s\n",
+				ast_json_object_iter_key(iter));
+			res = 0;
+		}
+	}
+
+	if (!has_value) {
+		ast_log(LOG_ERROR, "ARI Variable missing required field value\n");
+		res = 0;
+	}
+
+	return res;
+}
+
+ari_validator ast_ari_validate_variable_fn(void)
+{
+	return ast_ari_validate_variable;
+}
+
+int ast_ari_validate_endpoint(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json_iter *iter;
+	int has_channel_ids = 0;
+	int has_resource = 0;
+	int has_technology = 0;
+
+	for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+		if (strcmp("channel_ids", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_channel_ids = 1;
+			prop_is_valid = ast_ari_validate_list(
+				ast_json_object_iter_value(iter),
+				ast_ari_validate_string);
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Endpoint field channel_ids failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("resource", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_resource = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Endpoint field resource failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Endpoint field state failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("technology", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_technology = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Endpoint field technology failed validation\n");
+				res = 0;
+			}
+		} else
+		{
+			ast_log(LOG_ERROR,
+				"ARI Endpoint has undocumented field %s\n",
+				ast_json_object_iter_key(iter));
+			res = 0;
+		}
+	}
+
+	if (!has_channel_ids) {
+		ast_log(LOG_ERROR, "ARI Endpoint missing required field channel_ids\n");
+		res = 0;
+	}
+
+	if (!has_resource) {
+		ast_log(LOG_ERROR, "ARI Endpoint missing required field resource\n");
+		res = 0;
+	}
+
+	if (!has_technology) {
+		ast_log(LOG_ERROR, "ARI Endpoint missing required field technology\n");
+		res = 0;
+	}
+
+	return res;
+}
+
+ari_validator ast_ari_validate_endpoint_fn(void)
+{
+	return ast_ari_validate_endpoint;
+}
+
+int ast_ari_validate_caller_id(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json_iter *iter;
+	int has_name = 0;
+	int has_number = 0;
+
+	for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+		if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_name = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI CallerID field name failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("number", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_number = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI CallerID field number failed validation\n");
+				res = 0;
+			}
+		} else
+		{
+			ast_log(LOG_ERROR,
+				"ARI CallerID has undocumented field %s\n",
+				ast_json_object_iter_key(iter));
+			res = 0;
+		}
+	}
+
+	if (!has_name) {
+		ast_log(LOG_ERROR, "ARI CallerID missing required field name\n");
+		res = 0;
+	}
+
+	if (!has_number) {
+		ast_log(LOG_ERROR, "ARI CallerID missing required field number\n");
+		res = 0;
+	}
+
+	return res;
+}
+
+ari_validator ast_ari_validate_caller_id_fn(void)
+{
+	return ast_ari_validate_caller_id;
+}
+
+int ast_ari_validate_channel(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json_iter *iter;
+	int has_accountcode = 0;
+	int has_caller = 0;
+	int has_connected = 0;
+	int has_creationtime = 0;
+	int has_dialplan = 0;
+	int has_id = 0;
+	int has_name = 0;
+	int has_state = 0;
+
+	for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+		if (strcmp("accountcode", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_accountcode = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Channel field accountcode failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("caller", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_caller = 1;
+			prop_is_valid = ast_ari_validate_caller_id(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Channel field caller failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("connected", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_connected = 1;
+			prop_is_valid = ast_ari_validate_caller_id(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Channel field connected failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("creationtime", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_creationtime = 1;
+			prop_is_valid = ast_ari_validate_date(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Channel field creationtime failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("dialplan", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_dialplan = 1;
+			prop_is_valid = ast_ari_validate_dialplan_cep(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Channel field dialplan failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("id", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_id = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Channel field id failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_name = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Channel field name failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_state = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Channel field state failed validation\n");
+				res = 0;
+			}
+		} else
+		{
+			ast_log(LOG_ERROR,
+				"ARI Channel has undocumented field %s\n",
+				ast_json_object_iter_key(iter));
+			res = 0;
+		}
+	}
+
+	if (!has_accountcode) {
+		ast_log(LOG_ERROR, "ARI Channel missing required field accountcode\n");
+		res = 0;
+	}
+
+	if (!has_caller) {
+		ast_log(LOG_ERROR, "ARI Channel missing required field caller\n");
+		res = 0;
+	}
+
+	if (!has_connected) {
+		ast_log(LOG_ERROR, "ARI Channel missing required field connected\n");
+		res = 0;
+	}
+
+	if (!has_creationtime) {
+		ast_log(LOG_ERROR, "ARI Channel missing required field creationtime\n");
+		res = 0;
+	}
+
+	if (!has_dialplan) {
+		ast_log(LOG_ERROR, "ARI Channel missing required field dialplan\n");
+		res = 0;
+	}
+
+	if (!has_id) {
+		ast_log(LOG_ERROR, "ARI Channel missing required field id\n");
+		res = 0;
+	}
+
+	if (!has_name) {
+		ast_log(LOG_ERROR, "ARI Channel missing required field name\n");
+		res = 0;
+	}
+
+	if (!has_state) {
+		ast_log(LOG_ERROR, "ARI Channel missing required field state\n");
+		res = 0;
+	}
+
+	return res;
+}
+
+ari_validator ast_ari_validate_channel_fn(void)
+{
+	return ast_ari_validate_channel;
+}
+
+int ast_ari_validate_dialed(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json_iter *iter;
+
+	for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+		{
+			ast_log(LOG_ERROR,
+				"ARI Dialed has undocumented field %s\n",
+				ast_json_object_iter_key(iter));
+			res = 0;
+		}
+	}
+
+	return res;
+}
+
+ari_validator ast_ari_validate_dialed_fn(void)
+{
+	return ast_ari_validate_dialed;
+}
+
+int ast_ari_validate_dialplan_cep(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json_iter *iter;
+	int has_context = 0;
+	int has_exten = 0;
+	int has_priority = 0;
+
+	for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+		if (strcmp("context", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_context = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI DialplanCEP field context failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("exten", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_exten = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI DialplanCEP field exten failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("priority", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_priority = 1;
+			prop_is_valid = ast_ari_validate_long(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI DialplanCEP field priority failed validation\n");
+				res = 0;
+			}
+		} else
+		{
+			ast_log(LOG_ERROR,
+				"ARI DialplanCEP has undocumented field %s\n",
+				ast_json_object_iter_key(iter));
+			res = 0;
+		}
+	}
+
+	if (!has_context) {
+		ast_log(LOG_ERROR, "ARI DialplanCEP missing required field context\n");
+		res = 0;
+	}
+
+	if (!has_exten) {
+		ast_log(LOG_ERROR, "ARI DialplanCEP missing required field exten\n");
+		res = 0;
+	}
+
+	if (!has_priority) {
+		ast_log(LOG_ERROR, "ARI DialplanCEP missing required field priority\n");
+		res = 0;
+	}
+
+	return res;
+}
+
+ari_validator ast_ari_validate_dialplan_cep_fn(void)
+{
+	return ast_ari_validate_dialplan_cep;
+}
+
+int ast_ari_validate_bridge(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json_iter *iter;
+	int has_bridge_class = 0;
+	int has_bridge_type = 0;
+	int has_channels = 0;
+	int has_id = 0;
+	int has_technology = 0;
+
+	for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+		if (strcmp("bridge_class", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_bridge_class = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Bridge field bridge_class failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("bridge_type", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_bridge_type = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Bridge field bridge_type failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("channels", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_channels = 1;
+			prop_is_valid = ast_ari_validate_list(
+				ast_json_object_iter_value(iter),
+				ast_ari_validate_string);
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Bridge field channels failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("id", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_id = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Bridge field id failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("technology", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_technology = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Bridge field technology failed validation\n");
+				res = 0;
+			}
+		} else
+		{
+			ast_log(LOG_ERROR,
+				"ARI Bridge has undocumented field %s\n",
+				ast_json_object_iter_key(iter));
+			res = 0;
+		}
+	}
+
+	if (!has_bridge_class) {
+		ast_log(LOG_ERROR, "ARI Bridge missing required field bridge_class\n");
+		res = 0;
+	}
+
+	if (!has_bridge_type) {
+		ast_log(LOG_ERROR, "ARI Bridge missing required field bridge_type\n");
+		res = 0;
+	}
+
+	if (!has_channels) {
+		ast_log(LOG_ERROR, "ARI Bridge missing required field channels\n");
+		res = 0;
+	}
+
+	if (!has_id) {
+		ast_log(LOG_ERROR, "ARI Bridge missing required field id\n");
+		res = 0;
+	}
+
+	if (!has_technology) {
+		ast_log(LOG_ERROR, "ARI Bridge missing required field technology\n");
+		res = 0;
+	}
+
+	return res;
+}
+
+ari_validator ast_ari_validate_bridge_fn(void)
+{
+	return ast_ari_validate_bridge;
+}
+
+int ast_ari_validate_live_recording(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json_iter *iter;
+	int has_format = 0;
+	int has_name = 0;
+	int has_state = 0;
+
+	for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+		if (strcmp("format", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_format = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI LiveRecording field format failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_name = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI LiveRecording field name failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_state = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI LiveRecording field state failed validation\n");
+				res = 0;
+			}
+		} else
+		{
+			ast_log(LOG_ERROR,
+				"ARI LiveRecording has undocumented field %s\n",
+				ast_json_object_iter_key(iter));
+			res = 0;
+		}
+	}
+
+	if (!has_format) {
+		ast_log(LOG_ERROR, "ARI LiveRecording missing required field format\n");
+		res = 0;
+	}
+
+	if (!has_name) {
+		ast_log(LOG_ERROR, "ARI LiveRecording missing required field name\n");
+		res = 0;
+	}
+
+	if (!has_state) {
+		ast_log(LOG_ERROR, "ARI LiveRecording missing required field state\n");
+		res = 0;
+	}
+
+	return res;
+}
+
+ari_validator ast_ari_validate_live_recording_fn(void)
+{
+	return ast_ari_validate_live_recording;
+}
+
+int ast_ari_validate_stored_recording(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json_iter *iter;
+	int has_formats = 0;
+	int has_id = 0;
+
+	for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+		if (strcmp("duration_seconds", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			prop_is_valid = ast_ari_validate_int(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI StoredRecording field duration_seconds failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("formats", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_formats = 1;
+			prop_is_valid = ast_ari_validate_list(
+				ast_json_object_iter_value(iter),
+				ast_ari_validate_string);
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI StoredRecording field formats failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("id", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_id = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI StoredRecording field id failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("time", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			prop_is_valid = ast_ari_validate_date(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI StoredRecording field time failed validation\n");
+				res = 0;
+			}
+		} else
+		{
+			ast_log(LOG_ERROR,
+				"ARI StoredRecording has undocumented field %s\n",
+				ast_json_object_iter_key(iter));
+			res = 0;
+		}
+	}
+
+	if (!has_formats) {
+		ast_log(LOG_ERROR, "ARI StoredRecording missing required field formats\n");
+		res = 0;
+	}
+
+	if (!has_id) {
+		ast_log(LOG_ERROR, "ARI StoredRecording missing required field id\n");
+		res = 0;
+	}
+
+	return res;
+}
+
+ari_validator ast_ari_validate_stored_recording_fn(void)
+{
+	return ast_ari_validate_stored_recording;
+}
+
+int ast_ari_validate_format_lang_pair(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json_iter *iter;
+	int has_format = 0;
+	int has_language = 0;
+
+	for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+		if (strcmp("format", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_format = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI FormatLangPair field format failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("language", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_language = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI FormatLangPair field language failed validation\n");
+				res = 0;
+			}
+		} else
+		{
+			ast_log(LOG_ERROR,
+				"ARI FormatLangPair has undocumented field %s\n",
+				ast_json_object_iter_key(iter));
+			res = 0;
+		}
+	}
+
+	if (!has_format) {
+		ast_log(LOG_ERROR, "ARI FormatLangPair missing required field format\n");
+		res = 0;
+	}
+
+	if (!has_language) {
+		ast_log(LOG_ERROR, "ARI FormatLangPair missing required field language\n");
+		res = 0;
+	}
+
+	return res;
+}
+
+ari_validator ast_ari_validate_format_lang_pair_fn(void)
+{
+	return ast_ari_validate_format_lang_pair;
+}
+
+int ast_ari_validate_sound(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json_iter *iter;
+	int has_formats = 0;
+	int has_id = 0;
+
+	for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+		if (strcmp("formats", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_formats = 1;
+			prop_is_valid = ast_ari_validate_list(
+				ast_json_object_iter_value(iter),
+				ast_ari_validate_format_lang_pair);
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Sound field formats failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("id", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_id = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Sound field id failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("text", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Sound field text failed validation\n");
+				res = 0;
+			}
+		} else
+		{
+			ast_log(LOG_ERROR,
+				"ARI Sound has undocumented field %s\n",
+				ast_json_object_iter_key(iter));
+			res = 0;
+		}
+	}
+
+	if (!has_formats) {
+		ast_log(LOG_ERROR, "ARI Sound missing required field formats\n");
+		res = 0;
+	}
+
+	if (!has_id) {
+		ast_log(LOG_ERROR, "ARI Sound missing required field id\n");
+		res = 0;
+	}
+
+	return res;
+}
+
+ari_validator ast_ari_validate_sound_fn(void)
+{
+	return ast_ari_validate_sound;
+}
+
+int ast_ari_validate_playback(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json_iter *iter;
+	int has_id = 0;
+	int has_media_uri = 0;
+	int has_state = 0;
+	int has_target_uri = 0;
+

[... 14205 lines stripped ...]



More information about the svn-commits mailing list