<commit_before>var rest = require('restler');
var promise = require('promise');
var config = null;

// default options for restler
var options = {
	rejectUnauthorized: false,
	headers: {
		'Content-Type': 'application/json',
		'Accept': 'application/json',
		'User-Agent': 'Restler for node.js'
	}
};



module.exports = {
	/**
	 * override default options
	 *
	 * @param opt
	 */
	setOptions: function(opt){
		options = opt;
	},

	/**
	 * set configuration in the format shown in ./conf.sample.js
	 * @param cnf
	 */
	configure: function(cnf){
		config = cnf;
		// create url to use in calls
		if(config.ORION.user && config.ORION.pass){
			brokerUrl = config.ORION.protocol + '://' + config.ORION.user + ':' + config.ORION.pass + '@' + config.ORION.url;
		}else{
			brokerUrl = config.ORION.protocol + '://' + config.ORION.url;
		}
	},

	/**
	 * request all registered entities
	 * @returns {*}
	 */
	requestEntities: function(){
		var url = brokerUrl + 'contextEntities';
		return new promise(function(resolve, reject){
			rest.get(url, options)
					.on('success', function(data, response) {
						resolve(data);
					})
					.on('fail', function(data, response) {
						reject(data);
					});
		});
	},

	/**
	 * register a new entity - pass in the attribute json
	 *
	 *
	 * {
	 *	"attributes" : [
	 *		{
	 *			"name" : "temperature",
	 *			"type" : "float",
	 *			"value" : "23"<commit_msg>fixed broken configuration options<commit_after>var rest = require('restler');
var promise = require('promise');
var config = null;

// default options for restler
var options = {
	rejectUnauthorized: false,
	headers: {
		'Content-Type': 'application/json',
		'Accept': 'application/json',
		'User-Agent': 'Restler for node.js'
	}
};



module.exports = {
	/**
	 * override default options
	 *
	 * @param opt
	 */
	setOptions: function(opt){
		options = opt;
	},

	/**
	 * set configuration in the format shown in ./conf.sample.js
	 * @param cnf
	 */
	configure: function(cnf){
		config = cnf;
		// create url to use in calls
		if(config.user && config.pass){
			brokerUrl = config.protocol + '://' + config.user + ':' + config.pass + '@' + config.url;
		}else{
			brokerUrl = config.protocol + '://' + config.url;
		}
	},

	/**
	 * request all registered entities
	 * @returns {*}
	 */
	requestEntities: function(){
		var url = brokerUrl + 'contextEntities';
		return new promise(function(resolve, reject){
			rest.get(url, options)
					.on('success', function(data, response) {
						resolve(data);
					})
					.on('fail', function(data, response) {
						reject(data);
					});
		});
	},

	/**
	 * register a new entity - pass in the attribute json
	 *
	 *
	 * {
	 *	"attributes" : [
	 *		{
	 *			"name" : "temperature",
	 *			"type" : "float",
	 *			"value" : "23"
{'fraction_non_alphanumeric': 0.17275027105168053, 'fraction_numerical': 0.0014456089627755693, 'mean_word_length': 2.9318181818181817, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5662514', 'n_tokens_mistral': 1060, 'n_tokens_neox': 917, 'n_words': 218}