lib/utils.js
/**
 * This is a convenience function for posting packet schemas to the
 * Heimdallr server. The top-level keys for packetSchemas should be
 * one or more of 'event', 'sensor', and 'control'. The value of
 * these fields should be an object whose keys are the names of the
 * packet subtypes and whose values are valid JSON schema.
 *
 * @func postSchemas
 * @arg {string} token - Authentication token.
 * @arg {string|array} uuids - A single UUID or a list of UUIDs of the
 *    provider(s) that the packet schemas are for.
 * @arg {object} packetSchemas - The packet schemas.
 * @arg {function} [fn] - Callback to run once all the POSTS have
 *    completed. It will be passed an object with keys that are the
 *    provider UUIDs and values that are the response from the POST.
 */
This is a convenience function for posting packet schemas to the
Heimdallr server.

@func postSchemas
@arg {string} token - Authentication token.
@arg {string|array} uuids - A single UUID or a list of UUIDs of the
provider(s) that the packet schemas are for.
@arg {object} packetSchemas - The packet schemas.
@arg {function} [fn] - Callback to run once all the POSTS have
completed. It will be passed an object with keys that are the
provider UUIDs and values that are the response from the POST.
This is a convenience function for posting packet schemas to the Heimdallr server . @func postSchemas @arg { string } token - Authentication token . @arg { string|array } uuids - A single UUID or a list of UUIDs of the provider ( s ) that the packet schemas are for . @arg { object } packetSchemas - The packet schemas . @arg { function } [ fn ] - Callback to run once all the POSTS have completed . It will be passed an object with keys that are the provider UUIDs and values that are the response from the POST .
function postSchemas(token, uuids, packetSchemas, fn) {
    var i,
        packetType;
    options.headers.authorization += token;
    if (!(uuids instanceof Array)) {
        uuids = [uuids];
    }
    packetSchemas = packetSchemas || {};
    if (_.isFunction(fn)) {
        finishedFn = fn;
    }
    numCallbacks = uuids.length * Object.keys(packetSchemas).length;
    options.qs = {authSource: privateOptions.authSource};
    for (i = 0; i < uuids.length; i++) {
        options.url = privateOptions.url + '/api/v1/provider/' +
            uuids[i] + '/subtype-schemas';
        for (packetType in packetSchemas) {
            if (packetSchemas.hasOwnProperty(packetType)) {
                options.body = {
                    packetType: packetType,
                    subtypeSchemas: packetSchemas[packetType]
                };
                request.post(options, processResults.bind(uuids[i]));
            }
        }
    }
}
function postSchemas ( token , uuids , packetSchemas , fn ) { var i , packetType ; options . headers . authorization += token ; if ( ! ( uuids instanceof Array ) ) { uuids = [ uuids ] ; } packetSchemas = packetSchemas || { } ; if ( _ . isFunction ( fn ) ) { finishedFn = fn ; } numCallbacks = uuids . length * Object . keys ( packetSchemas ) . length ; options . qs = { authSource : privateOptions . authSource } ; for ( i = 0 ; i < uuids . length ; i ++ ) { options . url = privateOptions . url + '/api/v1/provider/' + uuids [ i ] + '/subtype-schemas' ; for ( packetType in packetSchemas ) { if ( packetSchemas . hasOwnProperty ( packetType ) ) { options . body = { packetType : packetType , subtypeSchemas : packetSchemas [ packetType ] } ; request . post ( options , processResults . bind ( uuids [ i ] ) ) ; } } } }
This is a convenience function for posting packet schemas to the
 Heimdallr server.
This is a convenience function for posting packet schemas to the Heimdallr server .
// Calculate the number of times the processResults should be called